Search in sources :

Example 11 with ContactPoint

use of org.hl7.fhir.dstu2.model.ContactPoint in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7TelecomFHIRConversionTest method patient_telcom_test.

// Suppress warnings about too many assertions in a test.  Justification: creating a FHIR message is very costly; we need to check many asserts per creation for efficiency.
@java.lang.SuppressWarnings("squid:S5961")
@Test
void patient_telcom_test() {
    String patientPhone = "MSH|^~\\&|MIICEHRApplication|MIIC|MIIC|MIIC|201705130822||VXU^V04^VXU_V04|test1100|P|2.5.1|||AL|AL|||||Z22^CDCPHINVS|^^^^^MIIC^SR^^^MIIC|MIIC\n" + // Home has 2 phones and an email, work has one phone and two emails
    "PID|1||12345678^^^^MR|ALTID|Moose^Mickey^J^III^^^||20060504|M|||||^PRN^PH^^22^555^1111313^^^^^^^^^^^3~^PRN^CP^^22^555^2221313^^^^^^^^^^^1~^NET^X.400^email.test@gmail.com^^^^^^^^^^^^^^2|^PRN^PH^^^555^1111414^889~^^^professional@buisness.com~^^^moose.mickey@buisness.com^^^^^^^^^^^^^^4||||||||||||||||\n";
    Patient patient = PatientUtils.createPatientFromHl7Segment(ftv, patientPhone);
    assertThat(patient.hasTelecom()).isTrue();
    List<ContactPoint> contacts = patient.getTelecom();
    assertThat(contacts.size()).isEqualTo(6);
    // First home contact
    ContactPoint contact = contacts.get(0);
    assertThat(contact.getUse()).isEqualTo(ContactPoint.ContactPointUse.HOME);
    assertThat(contact.getValue()).hasToString("+22 555 111 1313");
    assertThat(contact.hasRank()).isTrue();
    assertThat(contact.getRank()).hasToString("3");
    assertThat(contact.getSystem()).isEqualTo(ContactPoint.ContactPointSystem.PHONE);
    // Second home contact is mobile
    contact = contacts.get(1);
    assertThat(contact.getUse()).isEqualTo(ContactPoint.ContactPointUse.MOBILE);
    assertThat(contact.getValue()).hasToString("+22 555 222 1313");
    assertThat(contact.hasRank()).isTrue();
    assertThat(contact.getRank()).hasToString("1");
    assertThat(contact.getSystem()).isEqualTo(ContactPoint.ContactPointSystem.PHONE);
    // Third home contact is an email
    contact = contacts.get(2);
    assertThat(contact.getUse()).isEqualTo(ContactPoint.ContactPointUse.HOME);
    assertThat(contact.getValue()).hasToString("email.test@gmail.com");
    assertThat(contact.hasRank()).isTrue();
    assertThat(contact.getRank()).hasToString("2");
    assertThat(contact.getSystem()).isEqualTo(ContactPoint.ContactPointSystem.EMAIL);
    // First work contact is work phone
    contact = contacts.get(3);
    assertThat(contact.getUse()).isEqualTo(ContactPoint.ContactPointUse.WORK);
    assertThat(contact.getValue()).hasToString("(555) 111 1414 ext. 889");
    assertThat(contact.hasRank()).isFalse();
    assertThat(contact.getSystem()).isEqualTo(ContactPoint.ContactPointSystem.PHONE);
    // Second work contact is external work email
    contact = contacts.get(4);
    assertThat(contact.getUse()).isEqualTo(ContactPoint.ContactPointUse.WORK);
    assertThat(contact.getValue()).hasToString("professional@buisness.com");
    assertThat(contact.hasRank()).isFalse();
    assertThat(contact.getSystem()).isEqualTo(ContactPoint.ContactPointSystem.EMAIL);
    // Third work contact is internal work email and is ranked for contact
    contact = contacts.get(5);
    assertThat(contact.getUse()).isEqualTo(ContactPoint.ContactPointUse.WORK);
    assertThat(contact.getValue()).hasToString("moose.mickey@buisness.com");
    assertThat(contact.hasRank()).isTrue();
    assertThat(contact.getRank()).hasToString("4");
    assertThat(contact.getSystem()).isEqualTo(ContactPoint.ContactPointSystem.EMAIL);
}
Also used : ContactPoint(org.hl7.fhir.r4.model.ContactPoint) Patient(org.hl7.fhir.r4.model.Patient) Test(org.junit.jupiter.api.Test)

Example 12 with ContactPoint

use of org.hl7.fhir.dstu2.model.ContactPoint in project BridgeServer2 by Sage-Bionetworks.

the class CRCController method createPatient.

Patient createPatient(Account account) {
    Patient patient = new Patient();
    patient.setActive(true);
    patient.setId(account.getId());
    Identifier identifier = new Identifier();
    identifier.setValue(account.getId());
    identifier.setSystem(USER_ID_VALUE_NS);
    patient.addIdentifier(identifier);
    Coding coding = new Coding();
    coding.setSystem("source");
    coding.setCode("sage");
    Meta meta = new Meta();
    meta.setTag(ImmutableList.of(coding));
    patient.setMeta(meta);
    HumanName name = new HumanName();
    if (isNotBlank(account.getFirstName())) {
        name.addGiven(account.getFirstName());
    }
    if (isNotBlank(account.getLastName())) {
        name.setFamily(account.getLastName());
    }
    patient.addName(name);
    Map<String, String> atts = account.getAttributes();
    if (isNotBlank(atts.get("gender"))) {
        if ("female".equalsIgnoreCase(atts.get("gender"))) {
            patient.setGender(AdministrativeGender.FEMALE);
        } else if ("male".equalsIgnoreCase(atts.get("gender"))) {
            patient.setGender(AdministrativeGender.MALE);
        } else {
            patient.setGender(AdministrativeGender.OTHER);
        }
    } else {
        patient.setGender(AdministrativeGender.UNKNOWN);
    }
    if (isNotBlank(atts.get("dob"))) {
        LocalDate localDate = LocalDate.parse(atts.get("dob"));
        patient.setBirthDate(localDate.toDate());
    }
    Address address = new Address();
    if (isNotBlank(atts.get("address1"))) {
        address.addLine(atts.get("address1"));
    }
    if (isNotBlank(atts.get("address2"))) {
        address.addLine(atts.get("address2"));
    }
    if (isNotBlank(atts.get("city"))) {
        address.setCity(atts.get("city"));
    }
    if (isNotBlank(atts.get("state"))) {
        address.setState(atts.get("state"));
    } else {
        address.setState("NY");
    }
    if (isNotBlank(atts.get("zip_code"))) {
        address.setPostalCode(atts.get("zip_code"));
    }
    patient.addAddress(address);
    if (isNotBlank(atts.get("home_phone"))) {
        ContactPoint contact = new ContactPoint();
        contact.setSystem(ContactPointSystem.PHONE);
        contact.setValue(atts.get("home_phone"));
        patient.addTelecom(contact);
    }
    if (account.getPhone() != null && TRUE.equals(account.getPhoneVerified())) {
        ContactPoint contact = new ContactPoint();
        contact.setSystem(ContactPointSystem.SMS);
        contact.setValue(account.getPhone().getNumber());
        patient.addTelecom(contact);
    }
    if (account.getEmail() != null && TRUE.equals(account.getEmailVerified())) {
        ContactPoint contact = new ContactPoint();
        contact.setSystem(ContactPointSystem.EMAIL);
        contact.setValue(account.getEmail());
        patient.addTelecom(contact);
    }
    Reference ref = new Reference("CUZUCK");
    ref.setDisplay("COVID Recovery Corps");
    ContactComponent contact = new ContactComponent();
    contact.setOrganization(ref);
    patient.addContact(contact);
    return patient;
}
Also used : Meta(org.hl7.fhir.dstu3.model.Meta) HumanName(org.hl7.fhir.dstu3.model.HumanName) ContactPoint(org.hl7.fhir.dstu3.model.ContactPoint) Identifier(org.hl7.fhir.dstu3.model.Identifier) Address(org.hl7.fhir.dstu3.model.Address) Coding(org.hl7.fhir.dstu3.model.Coding) Reference(org.hl7.fhir.dstu3.model.Reference) ContactComponent(org.hl7.fhir.dstu3.model.Patient.ContactComponent) Patient(org.hl7.fhir.dstu3.model.Patient) LocalDate(org.joda.time.LocalDate)

Example 13 with ContactPoint

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

the class LocationTranslatorImplTest method shouldTranslateLocationAttributeToFhirContactPoint.

@Test
public void shouldTranslateLocationAttributeToFhirContactPoint() {
    ContactPoint contactPoint = new ContactPoint();
    contactPoint.setId(CONTACT_POINT_ID);
    contactPoint.setValue(CONTACT_POINT_VALUE);
    LocationAttribute locationAttribute = new LocationAttribute();
    locationAttribute.setUuid(LOCATION_ATTRIBUTE_UUID);
    locationAttribute.setValue(LOCATION_ATTRIBUTE_VALUE);
    LocationAttributeType attributeType = new LocationAttributeType();
    attributeType.setName(LOCATION_ATTRIBUTE_TYPE_NAME);
    attributeType.setUuid(LOCATION_ATTRIBUTE_TYPE_UUID);
    locationAttribute.setAttributeType(attributeType);
    org.hl7.fhir.r4.model.Location location = locationTranslator.toFhirResource(new Location());
    assertThat(location, notNullValue());
    assertThat(location.getTelecom(), notNullValue());
}
Also used : ContactPoint(org.hl7.fhir.r4.model.ContactPoint) LocationAttribute(org.openmrs.LocationAttribute) LocationAttributeType(org.openmrs.LocationAttributeType) Location(org.openmrs.Location) Test(org.junit.Test)

Example 14 with ContactPoint

use of org.hl7.fhir.dstu2.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 15 with ContactPoint

use of org.hl7.fhir.dstu2.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)

Aggregations

ContactPoint (org.hl7.fhir.r4.model.ContactPoint)53 Test (org.junit.Test)28 Address (org.hl7.fhir.r4.model.Address)15 PersonAttribute (org.openmrs.PersonAttribute)15 NotImplementedException (org.apache.commons.lang3.NotImplementedException)14 Identifier (org.hl7.fhir.r4.model.Identifier)14 Test (org.junit.jupiter.api.Test)14 HumanName (org.hl7.fhir.r4.model.HumanName)13 ContactPoint (org.hl7.fhir.dstu3.model.ContactPoint)12 ProviderAttribute (org.openmrs.ProviderAttribute)11 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)10 ArrayList (java.util.ArrayList)9 IdType (org.hl7.fhir.dstu3.model.IdType)9 Organization (org.hl7.fhir.r4.model.Organization)9 Patient (org.hl7.fhir.r4.model.Patient)9 HashSet (java.util.HashSet)8 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)8 ContactDetail (org.hl7.fhir.r5.model.ContactDetail)6 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)6 HashMap (java.util.HashMap)5