Skip to content

Commit

Permalink
(chore) replace the existing name instead of creating a new name
Browse files Browse the repository at this point in the history
  • Loading branch information
icrc-jofrancisco committed Jul 25, 2024
1 parent ac091a0 commit e36af45
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public class PatientTranslatorImplTest {

private static final String PATIENT_IDENTIFIER_UUID = "654321-fedcba-654321";

private static final String PATIENT_NAME_UUID = "1fdb5469-57c7-435f-b009-3dcceb23b0a2";

private static final String PATIENT_GIVEN_NAME = "Jean Claude";

private static final String PATIENT_FAMILY_NAME = "van Damme";
Expand Down Expand Up @@ -317,6 +319,27 @@ public void shouldTranslateFhirPatientNameToOpenmrsPatientName() {
assertThat(result.getFamilyName(), equalTo(PATIENT_FAMILY_NAME));
}

@Test
public void shouldTranslateFhirPatientNameToExistingOpenmrsPatientName() {
PersonName personName = new PersonName();
personName.setUuid(PATIENT_NAME_UUID);
personName.setGivenName(PATIENT_GIVEN_NAME);
personName.setFamilyName(PATIENT_FAMILY_NAME);
when(nameTranslator.toOpenmrsType(any(), any())).thenReturn(personName);

Patient patient = new Patient();
HumanName name = new HumanName();
name.setId(PATIENT_NAME_UUID);
name.addGiven(PATIENT_GIVEN_NAME);
name.setFamily(PATIENT_FAMILY_NAME);
patient.addName(name);

org.openmrs.Patient result = patientTranslator.toOpenmrsType(patient);
assertThat(result.getGivenName(), equalTo(PATIENT_GIVEN_NAME));
assertThat(result.getFamilyName(), equalTo(PATIENT_FAMILY_NAME));
assertThat(result.getPersonName().getUuid(), equalTo(PATIENT_NAME_UUID));
}

@Test
public void shouldTranslateFhirPatientGenderToOpenmrsGender() {
when(genderTranslator.toOpenmrsType(Enumerations.AdministrativeGender.FEMALE)).thenReturn("F");
Expand Down

0 comments on commit e36af45

Please sign in to comment.