UPDATE medical_notes SET clinic_contact_id=(SELECT organization_id FROM directory_contacts WHERE id=medical_notes.vet_contact_id)
WHERE vet_contact_id IS NOT NULL AND EXISTS(SELECT 1 FROM directory_contacts WHERE id=medical_notes.vet_contact_id AND organization_id IS NOT NULL);
UPDATE treatments SET clinic_contact_id=(SELECT organization_id FROM directory_contacts WHERE id=treatments.vet_contact_id)
WHERE vet_contact_id IS NOT NULL AND EXISTS(SELECT 1 FROM directory_contacts WHERE id=treatments.vet_contact_id AND organization_id IS NOT NULL);
UPDATE vaccinations SET clinic_contact_id=(SELECT organization_id FROM directory_contacts WHERE id=vaccinations.vet_contact_id)
WHERE vet_contact_id IS NOT NULL AND EXISTS(SELECT 1 FROM directory_contacts WHERE id=vaccinations.vet_contact_id AND organization_id IS NOT NULL);
