Search in sources :

Example 11 with ContactPoint

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

the class PatientTest method getPatientProperties.

/**
 * Test all properties set by
 * {@link TestDatabaseInitializer#initializePatient()}.
 */
@Test
public void getPatientProperties() {
    IReadExecutable<Patient> readPatientE = client.read().resource(Patient.class).withId(AllTests.getTestDatabaseInitializer().getPatient().getId());
    Patient readPatient = readPatientE.execute();
    assertNotNull(readPatient);
    List<HumanName> names = readPatient.getName();
    assertNotNull(names);
    assertFalse(names.isEmpty());
    HumanName name = names.get(0);
    assertNotNull(name);
    assertEquals("Patient", name.getFamily());
    assertEquals("Test", name.getGivenAsSingleString());
    Date dob = readPatient.getBirthDate();
    assertNotNull(dob);
    assertEquals(LocalDate.of(1990, Month.JANUARY, 1), AllTests.getLocalDateTime(dob).toLocalDate());
    assertEquals(AdministrativeGender.FEMALE, readPatient.getGender());
    List<ContactPoint> telcoms = readPatient.getTelecom();
    assertNotNull(telcoms);
    assertEquals(2, telcoms.size());
    assertEquals(1, telcoms.get(0).getRank());
    assertEquals("+01555123", telcoms.get(0).getValue());
    assertEquals(ContactPointUse.MOBILE, telcoms.get(1).getUse());
    assertEquals("+01444123", telcoms.get(1).getValue());
    List<Address> addresses = readPatient.getAddress();
    assertNotNull(addresses);
    assertEquals(1, addresses.size());
    assertEquals(AddressUse.HOME, addresses.get(0).getUse());
    assertEquals("City", addresses.get(0).getCity());
    assertEquals("123", addresses.get(0).getPostalCode());
    assertEquals("Street 1", addresses.get(0).getLine().get(0).asStringValue());
    List<Identifier> identifiers = readPatient.getIdentifier();
    boolean ahvFound = false;
    for (Identifier identifier : identifiers) {
        if (identifier.getSystem().equals(XidConstants.CH_AHV)) {
            assertTrue(identifier.getValue().startsWith("756"));
            ahvFound = true;
        }
    }
    assertTrue(ahvFound);
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) ContactPoint(org.hl7.fhir.r4.model.ContactPoint) Identifier(org.hl7.fhir.r4.model.Identifier) Address(org.hl7.fhir.r4.model.Address) Patient(org.hl7.fhir.r4.model.Patient) IPatient(ch.elexis.core.model.IPatient) Date(java.util.Date) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 12 with ContactPoint

use of org.hl7.fhir.r4.model.ContactPoint 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 13 with ContactPoint

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

the class PatientTranslatorImplTest method shouldReturnPatientContactPointGivenOpenMrsPatient.

@Test
public void shouldReturnPatientContactPointGivenOpenMrsPatient() {
    PersonAttributeType attributeType = new PersonAttributeType();
    attributeType.setName(PERSON_ATTRIBUTE_TYPE_NAME);
    attributeType.setUuid(PERSON_ATTRIBUTE_TYPE_UUID);
    PersonAttribute personAttribute = new PersonAttribute();
    personAttribute.setUuid(PERSON_ATTRIBUTE_UUID);
    personAttribute.setValue(PERSON_ATTRIBUTE_VALUE);
    personAttribute.setAttributeType(attributeType);
    org.openmrs.Patient patient = new org.openmrs.Patient();
    patient.addAttribute(personAttribute);
    List<ContactPoint> contactPoints = patientTranslator.getPatientContactDetails(patient);
    assertThat(contactPoints, notNullValue());
}
Also used : ContactPoint(org.hl7.fhir.r4.model.ContactPoint) PersonAttributeType(org.openmrs.PersonAttributeType) Patient(org.hl7.fhir.r4.model.Patient) PersonAttribute(org.openmrs.PersonAttribute) Test(org.junit.Test)

Example 14 with ContactPoint

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

the class PersonTranslatorImplTest method shouldTranslateOpenmrsGenderToFhirGenderType.

@Test
public void shouldTranslateOpenmrsGenderToFhirGenderType() {
    Person person = new Person();
    ContactPoint contactPoint = new ContactPoint();
    contactPoint.setId(CONTACT_ID);
    contactPoint.setValue(CONTACT_VALUE);
    PersonAttributeType attributeType = new PersonAttributeType();
    attributeType.setName(PERSON_ATTRIBUTE_TYPE_NAME);
    attributeType.setUuid(PERSON_ATTRIBUTE_TYPE_UUID);
    PersonAttribute personAttribute = new PersonAttribute();
    personAttribute.setUuid(PERSON_ATTRIBUTE_UUID);
    personAttribute.setValue(PERSON_ATTRIBUTE_VALUE);
    personAttribute.setAttributeType(attributeType);
    when(genderTranslator.toFhirResource(argThat(equalTo("F")))).thenReturn(Enumerations.AdministrativeGender.FEMALE);
    person.setGender("F");
    org.hl7.fhir.r4.model.Person result = personTranslator.toFhirResource(person);
    assertThat(result, notNullValue());
    assertThat(result.getGender(), is(Enumerations.AdministrativeGender.FEMALE));
}
Also used : ContactPoint(org.hl7.fhir.r4.model.ContactPoint) PersonAttributeType(org.openmrs.PersonAttributeType) Person(org.openmrs.Person) PersonAttribute(org.openmrs.PersonAttribute) Test(org.junit.Test)

Example 15 with ContactPoint

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

the class PersonTranslatorImplTest method shouldTranslateFhirContactPointToPersonAttribute.

@Test
public void shouldTranslateFhirContactPointToPersonAttribute() {
    PersonAttributeType attributeType = new PersonAttributeType();
    attributeType.setName(PERSON_ATTRIBUTE_TYPE_NAME);
    attributeType.setUuid(PERSON_ATTRIBUTE_TYPE_UUID);
    PersonAttribute personAttribute = new PersonAttribute();
    personAttribute.setUuid(PERSON_ATTRIBUTE_UUID);
    personAttribute.setValue(PERSON_ATTRIBUTE_VALUE);
    personAttribute.setAttributeType(attributeType);
    Person omrsPerson = new Person();
    omrsPerson.addAttribute(personAttribute);
    org.hl7.fhir.r4.model.Person person = new org.hl7.fhir.r4.model.Person();
    ContactPoint contactPoint = new ContactPoint();
    contactPoint.setId(PERSON_ATTRIBUTE_UUID);
    contactPoint.setValue(PERSON_ATTRIBUTE_VALUE);
    person.addTelecom(contactPoint);
    when(telecomTranslator.toOpenmrsType(any(), any())).thenReturn(personAttribute);
    Person people = personTranslator.toOpenmrsType(person);
    assertThat(people, notNullValue());
    assertThat(people.getAttributes(), notNullValue());
    assertThat(people.getAttributes().isEmpty(), is(false));
    assertThat(people.getAttributes(), hasSize(greaterThanOrEqualTo(1)));
}
Also used : ContactPoint(org.hl7.fhir.r4.model.ContactPoint) PersonAttributeType(org.openmrs.PersonAttributeType) Person(org.openmrs.Person) PersonAttribute(org.openmrs.PersonAttribute) Test(org.junit.Test)

Aggregations

ContactPoint (org.hl7.fhir.r4.model.ContactPoint)56 Test (org.junit.Test)28 Address (org.hl7.fhir.r4.model.Address)18 Identifier (org.hl7.fhir.r4.model.Identifier)17 HumanName (org.hl7.fhir.r4.model.HumanName)16 PersonAttribute (org.openmrs.PersonAttribute)15 NotImplementedException (org.apache.commons.lang3.NotImplementedException)14 ContactPoint (org.hl7.fhir.dstu3.model.ContactPoint)14 Test (org.junit.jupiter.api.Test)14 ArrayList (java.util.ArrayList)12 Organization (org.hl7.fhir.r4.model.Organization)12 ProviderAttribute (org.openmrs.ProviderAttribute)11 HashSet (java.util.HashSet)10 IdType (org.hl7.fhir.dstu3.model.IdType)9 Patient (org.hl7.fhir.r4.model.Patient)9 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)7 ContactDetail (org.hl7.fhir.r5.model.ContactDetail)6 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)6 HashMap (java.util.HashMap)5 Base64 (org.apache.commons.codec.binary.Base64)5