Search in sources :

Example 16 with HumanName

use of org.hl7.fhir.r4.model.HumanName in project elexis-server by elexis.

the class PractitionerRoleTest method getPractitionerProperties.

/**
 * Test all properties set by {@link TestDatabaseInitializer#initializeMandant()}.
 */
@Test
public void getPractitionerProperties() {
    List<IUser> user = UserServiceHolder.get().getUsersByAssociatedContact(TestDatabaseInitializer.getMandant());
    assertFalse(user.isEmpty());
    PractitionerRole readPractitionerRole = client.read().resource(PractitionerRole.class).withId(user.get(0).getId()).execute();
    assertNotNull(readPractitionerRole);
    assertNotNull(readPractitionerRole.getPractitioner());
    Practitioner readPractitioner = client.read().resource(Practitioner.class).withId(readPractitionerRole.getPractitioner().getReferenceElement().getIdPart()).execute();
    assertNotNull(readPractitioner);
    List<HumanName> names = readPractitioner.getName();
    assertNotNull(names);
    assertFalse(names.isEmpty());
    assertEquals(2, names.size());
    HumanName name = names.get(0);
    assertNotNull(name);
    assertEquals(NameUse.OFFICIAL, name.getUse());
    assertEquals("Mandant", name.getFamily());
    assertEquals("Test", name.getGivenAsSingleString());
    HumanName sysName = names.get(1);
    assertNotNull(sysName);
    assertEquals(NameUse.ANONYMOUS, sysName.getUse());
    assertEquals("tst", sysName.getText());
    Date dob = readPractitioner.getBirthDate();
    assertNotNull(dob);
    assertEquals(LocalDate.of(1970, Month.JANUARY, 1), AllTests.getLocalDateTime(dob).toLocalDate());
    assertEquals(AdministrativeGender.MALE, readPractitioner.getGender());
    List<ContactPoint> telcoms = readPractitioner.getTelecom();
    assertNotNull(telcoms);
    assertEquals(2, telcoms.size());
    assertEquals(1, telcoms.get(0).getRank());
    assertEquals("+01555234", telcoms.get(0).getValue());
    assertEquals(ContactPointUse.MOBILE, telcoms.get(1).getUse());
    assertEquals("+01444234", telcoms.get(1).getValue());
    List<Address> addresses = readPractitioner.getAddress();
    assertNotNull(addresses);
    assertEquals(1, addresses.size());
    assertEquals("City", addresses.get(0).getCity());
    assertEquals("123", addresses.get(0).getPostalCode());
    assertEquals("Street 100", addresses.get(0).getLine().get(0).asStringValue());
    List<Identifier> identifiers = readPractitioner.getIdentifier();
    boolean eanFound = false;
    boolean kskFound = false;
    for (Identifier identifier : identifiers) {
        if (identifier.getSystem().equals(XidConstants.DOMAIN_EAN)) {
            assertEquals("2000000000002", identifier.getValue());
            eanFound = true;
        }
        if (identifier.getSystem().equals("www.xid.ch/id/ksk")) {
            assertEquals("C000002", identifier.getValue());
            kskFound = true;
        }
    }
    assertTrue(eanFound);
    assertTrue(kskFound);
    assertTrue(readPractitioner.getActive());
}
Also used : Address(org.hl7.fhir.r4.model.Address) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) Date(java.util.Date) LocalDate(java.time.LocalDate) Practitioner(org.hl7.fhir.r4.model.Practitioner) HumanName(org.hl7.fhir.r4.model.HumanName) ContactPoint(org.hl7.fhir.r4.model.ContactPoint) Identifier(org.hl7.fhir.r4.model.Identifier) IUser(ch.elexis.core.model.IUser) Test(org.junit.Test)

Example 17 with HumanName

use of org.hl7.fhir.r4.model.HumanName in project openmrs-module-fhir2 by openmrs.

the class PersonFhirResourceProviderTest method initPerson.

@Before
public void initPerson() {
    HumanName name = new HumanName();
    name.addGiven(GIVEN_NAME);
    name.setFamily(FAMILY_NAME);
    person = new org.hl7.fhir.r4.model.Person();
    person.setId(PERSON_UUID);
    person.setGender(Enumerations.AdministrativeGender.MALE);
    person.addName(name);
    setProvenanceResources(person);
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) Before(org.junit.Before)

Example 18 with HumanName

use of org.hl7.fhir.r4.model.HumanName in project openmrs-module-fhir2 by openmrs.

the class RelatedPersonFhirResourceProviderTest method initRelatedPerson.

@Before
public void initRelatedPerson() {
    HumanName name = new HumanName();
    name.addGiven(GIVEN_NAME);
    name.setFamily(FAMILY_NAME);
    relatedPerson = new org.hl7.fhir.r4.model.RelatedPerson();
    relatedPerson.setId(RELATED_PERSON_UUID);
    relatedPerson.setGender(Enumerations.AdministrativeGender.MALE);
    relatedPerson.addName(name);
    setProvenanceResources(relatedPerson);
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) Before(org.junit.Before)

Example 19 with HumanName

use of org.hl7.fhir.r4.model.HumanName in project openmrs-module-fhir2 by openmrs.

the class PatientFhirResourceProviderTest method initPatient.

@Before
public void initPatient() {
    HumanName name = new HumanName();
    name.addGiven(GIVEN_NAME);
    name.setFamily(FAMILY_NAME);
    patient = new Patient();
    patient.setId(PATIENT_UUID);
    patient.addName(name);
    patient.setActive(true);
    patient.setBirthDate(new Date());
    patient.setGender(Enumerations.AdministrativeGender.MALE);
    setProvenanceResources(patient);
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) Patient(org.hl7.fhir.r4.model.Patient) Date(java.util.Date) Before(org.junit.Before)

Example 20 with HumanName

use of org.hl7.fhir.r4.model.HumanName in project openmrs-module-fhir2 by openmrs.

the class PractitionerTranslatorProviderImplTest method shouldTranslateProviderGenderToFhirPractitionerType.

@Test
public void shouldTranslateProviderGenderToFhirPractitionerType() {
    Person person = new Person();
    PersonName name = new PersonName();
    name.setGivenName(GIVEN_NAME);
    name.setFamilyName(FAMILY_NAME);
    person.addName(name);
    provider.setPerson(person);
    HumanName humanName = new HumanName();
    humanName.setFamily(FAMILY_NAME);
    humanName.addGiven(GIVEN_NAME);
    when(nameTranslator.toFhirResource(name)).thenReturn(humanName);
    Practitioner practitioner = practitionerTranslator.toFhirResource(provider);
    assertThat(practitioner, notNullValue());
    assertThat(practitioner.getName(), notNullValue());
    assertThat(practitioner.getName(), not(empty()));
    assertThat(practitioner.getName().get(0).getGiven().get(0).getValue(), equalTo(GIVEN_NAME));
    assertThat(practitioner.getName().get(0).getFamily(), equalTo(FAMILY_NAME));
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) HumanName(org.hl7.fhir.r4.model.HumanName) PersonName(org.openmrs.PersonName) Person(org.openmrs.Person) Test(org.junit.Test)

Aggregations

HumanName (org.hl7.fhir.r4.model.HumanName)84 HumanName (org.hl7.fhir.dstu3.model.HumanName)37 Patient (org.hl7.fhir.r4.model.Patient)37 Test (org.junit.jupiter.api.Test)29 ArrayList (java.util.ArrayList)27 Patient (org.hl7.fhir.dstu3.model.Patient)27 Test (org.junit.Test)26 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)23 Address (org.hl7.fhir.r4.model.Address)20 Identifier (org.hl7.fhir.r4.model.Identifier)20 PersonName (org.openmrs.PersonName)17 CamelSpringBootTest (org.apache.camel.test.spring.junit5.CamelSpringBootTest)16 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)16 GET (javax.ws.rs.GET)15 Path (javax.ws.rs.Path)15 Produces (javax.ws.rs.Produces)15 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)15 NotImplementedException (org.apache.commons.lang3.NotImplementedException)14 StringType (org.hl7.fhir.r4.model.StringType)14 Date (java.util.Date)13