Search in sources :

Example 6 with Address

use of com.adobe.target.delivery.v1.model.Address in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7AddressFHIRConversionTest method patient_address_date_ranges_test.

@Test
void patient_address_date_ranges_test() {
    String patientAddress = "MSH|^~\\&|MIICEHRApplication|MIIC|MIIC|MIIC|201705130822||VXU^V04^VXU_V04|test1100|P|2.5.1|||AL|AL|||||Z22^CDCPHINVS|^^^^^MIIC^SR^^^MIIC|MIIC\n" + "PID|1||12345678^^^^MR|ALTID|Moose^Mickey^J^III^^^|Mother^Micky|20060504|M|Alias^Alias|2106-3^White^ HL70005|111 1st Street^Suite #1^Minneapolis^MN^11111^USA^H^^AdrC^^^20010101&20081231^^^^Y^Z^V^c/o Pluto19|PatC|^PRN^^^PH^555^5555555|^PRN^^^PH^555^666666|english|married|bhuddist|1234567_account|111-22-3333|||2186-5^not Hispanic or Latino^CDCREC|Born in USA|||USA||||\n";
    String patientAddressExplicitEffectiveExpirationDates = "MSH|^~\\&|MIICEHRApplication|MIIC|MIIC|MIIC|201705130822||VXU^V04^VXU_V04|test1100|P|2.5.1|||AL|AL|||||Z22^CDCPHINVS|^^^^^MIIC^SR^^^MIIC|MIIC\n" + "PID|1||12345678^^^^MR|ALTID|Moose^Mickey^J^III^^^|Mother^Micky|20060504|M|Alias^Alias|2106-3^White^ HL70005|111 1st Street^Suite #1^Minneapolis^MN^11111^USA^H^^AdrC^^^20010101&20081231^19920101^19981231^^Y^Z^V^c/o Pluto19|PatC|^PRN^^^PH^555^5555555|^PRN^^^PH^555^666666|english|married|bhuddist|1234567_account|111-22-3333|||2186-5^not Hispanic or Latino^CDCREC|Born in USA|||USA||||\n";
    // If address county, ignore patient county
    Patient patient = PatientUtils.createPatientFromHl7Segment(ftv, patientAddress);
    assertThat(patient.hasAddress()).isTrue();
    List<Address> addresses = patient.getAddress();
    assertThat(addresses.size()).isEqualTo(1);
    Address address = addresses.get(0);
    // Test date range
    Period period = address.getPeriod();
    assertThat(period.hasStart()).isTrue();
    assertThat(period.hasEnd()).isTrue();
    Date startDate = period.getStart();
    Calendar startCalendar = Calendar.getInstance();
    startCalendar.setTime(startDate);
    assertThat(startCalendar.get(Calendar.YEAR)).isEqualTo(2001);
    // Zero based; January is 0
    assertThat(startCalendar.get(Calendar.MONTH)).isZero();
    assertThat(startCalendar.get(Calendar.DAY_OF_MONTH)).isEqualTo(1);
    Date endDate = period.getEnd();
    Calendar endCalendar = Calendar.getInstance();
    endCalendar.setTime(endDate);
    assertThat(endCalendar.get(Calendar.YEAR)).isEqualTo(2008);
    // Zero based; December is 11
    assertThat(endCalendar.get(Calendar.MONTH)).isEqualTo(11);
    assertThat(endCalendar.get(Calendar.DAY_OF_MONTH)).isEqualTo(31);
    // Test explicit date start (effective) and end (expiration)
    patient = PatientUtils.createPatientFromHl7Segment(ftv, patientAddressExplicitEffectiveExpirationDates);
    assertThat(patient.hasAddress()).isTrue();
    addresses = patient.getAddress();
    assertThat(addresses.size()).isEqualTo(1);
    address = addresses.get(0);
    period = address.getPeriod();
    assertThat(period.hasStart()).isTrue();
    assertThat(period.hasEnd()).isTrue();
    startDate = period.getStart();
    startCalendar = Calendar.getInstance();
    startCalendar.setTime(startDate);
    assertThat(startCalendar.get(Calendar.YEAR)).isEqualTo(1992);
    // Zero based; January is 0
    assertThat(startCalendar.get(Calendar.MONTH)).isZero();
    assertThat(startCalendar.get(Calendar.DAY_OF_MONTH)).isEqualTo(1);
    endDate = period.getEnd();
    endCalendar = Calendar.getInstance();
    endCalendar.setTime(endDate);
    assertThat(endCalendar.get(Calendar.YEAR)).isEqualTo(1998);
    // Zero based; December is 11
    assertThat(endCalendar.get(Calendar.MONTH)).isEqualTo(11);
    assertThat(endCalendar.get(Calendar.DAY_OF_MONTH)).isEqualTo(31);
}
Also used : Address(org.hl7.fhir.r4.model.Address) Calendar(java.util.Calendar) Patient(org.hl7.fhir.r4.model.Patient) Period(org.hl7.fhir.r4.model.Period) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 7 with Address

use of com.adobe.target.delivery.v1.model.Address 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 8 with Address

use of com.adobe.target.delivery.v1.model.Address in project BridgeServer2 by Sage-Bionetworks.

the class CRCControllerTest method createPatient.

@Test
public void createPatient() {
    account.setId("userId");
    account.setFirstName("Test");
    account.setLastName("User");
    account.setEmail(EMAIL);
    account.setEmailVerified(true);
    account.setPhone(PHONE);
    account.setPhoneVerified(true);
    account.setAttributes(new ImmutableMap.Builder<String, String>().put("address1", "123 Sesame Street").put("address2", "Apt. 6").put("city", "Seattle").put("dob", "1980-08-10").put("gender", "female").put("state", "WA").put("zip_code", "10001").put("home_phone", PHONE.getNumber()).build());
    Patient patient = controller.createPatient(account);
    assertTrue(patient.getActive());
    assertEquals(patient.getIdentifier().get(0).getValue(), TEST_USER_ID);
    assertEquals(patient.getIdentifier().get(0).getSystem(), USER_ID_VALUE_NS);
    assertEquals(patient.getName().get(0).getGivenAsSingleString(), "Test");
    assertEquals(patient.getName().get(0).getFamily(), "User");
    assertEquals(patient.getMeta().getTag().get(0).getSystem(), "source");
    assertEquals(patient.getMeta().getTag().get(0).getCode(), "sage");
    assertEquals(patient.getGender().name(), "FEMALE");
    assertEquals(LocalDate.fromDateFields(patient.getBirthDate()).toString(), "1980-08-10");
    assertEquals(patient.getTelecom().get(0).getValue(), PHONE.getNumber());
    assertEquals(patient.getTelecom().get(0).getSystem().name(), "PHONE");
    assertEquals(patient.getTelecom().get(1).getValue(), PHONE.getNumber());
    assertEquals(patient.getTelecom().get(1).getSystem().name(), "SMS");
    assertEquals(patient.getTelecom().get(2).getValue(), EMAIL);
    assertEquals(patient.getTelecom().get(2).getSystem().name(), "EMAIL");
    Address address = patient.getAddress().get(0);
    assertEquals(address.getLine().get(0).getValue(), "123 Sesame Street");
    assertEquals(address.getLine().get(1).getValue(), "Apt. 6");
    assertEquals(address.getCity(), "Seattle");
    assertEquals(address.getState(), "WA");
    assertEquals(address.getPostalCode(), "10001");
}
Also used : Address(org.hl7.fhir.dstu3.model.Address) Patient(org.hl7.fhir.dstu3.model.Patient) Test(org.testng.annotations.Test)

Example 9 with Address

use of com.adobe.target.delivery.v1.model.Address in project quality-measure-and-cohort-service by Alvearie.

the class MeasureEvaluatorTest method measure_default_unsupported_type.

@Test(expected = UnsupportedFhirTypeException.class)
public void measure_default_unsupported_type() throws Exception {
    CapabilityStatement metadata = getCapabilityStatement();
    mockFhirResourceRetrieval("/metadata?_format=json", metadata);
    Patient patient = getPatient("123", AdministrativeGender.MALE, "1970-10-10");
    mockFhirResourceRetrieval(patient);
    Library library = mockLibraryRetrieval("TestAdultMales", DEFAULT_VERSION, "cql/fhir-measure/test-parameter-defaults.cql");
    expressionsByPopulationType.clear();
    expressionsByPopulationType.put(MeasurePopulationType.INITIALPOPULATION, INITIAL_POPULATION);
    expressionsByPopulationType.put(MeasurePopulationType.DENOMINATOR, DENOMINATOR);
    expressionsByPopulationType.put(MeasurePopulationType.NUMERATOR, NUMERATOR);
    Measure measure = getProportionMeasure("ProportionMeasureName", library, expressionsByPopulationType);
    Address unsupportedType = new Address();
    unsupportedType.setCity("Cleaveland");
    measure.addExtension(createMeasureParameter("SomeAge", unsupportedType));
    mockFhirResourceRetrieval(measure);
    evaluator.evaluatePatientMeasure(measure.getId(), patient.getId(), null, new MeasureEvidenceOptions());
}
Also used : Address(org.hl7.fhir.r4.model.Address) CapabilityStatement(org.hl7.fhir.r4.model.CapabilityStatement) Measure(org.hl7.fhir.r4.model.Measure) Patient(org.hl7.fhir.r4.model.Patient) Library(org.hl7.fhir.r4.model.Library) MeasureEvidenceOptions(com.ibm.cohort.engine.measure.evidence.MeasureEvidenceOptions) Test(org.junit.Test)

Example 10 with Address

use of com.adobe.target.delivery.v1.model.Address in project summary-care-record-api by NHSDigital.

the class AgentPersonMapper method mapOrganization.

private Organization mapOrganization(Node agentPerson) {
    Organization org;
    Optional<Node> orgNode = xmlUtils.detachOptionalNodeByXPath(agentPerson, ORG_XPATH);
    Optional<Node> orgSdsNode = xmlUtils.detachOptionalNodeByXPath(agentPerson, ORG_SDS_XPATH);
    if (orgNode.isPresent()) {
        org = organisationMapper.mapOrganization(orgNode.get());
    } else if (orgSdsNode.isPresent()) {
        org = organisationSdsMapper.mapOrganizationSds(orgSdsNode.get());
    } else {
        org = new Organization();
        org.setId(randomUUID());
    }
    org.setTelecom(mapContactPoints(agentPerson));
    xmlUtils.getOptionalValueByXPath(agentPerson, ADDRESS_XPATH).ifPresent(val -> org.addAddress(new Address().setText(val)));
    return org;
}
Also used : Organization(org.hl7.fhir.r4.model.Organization) Address(org.hl7.fhir.r4.model.Address) Node(org.w3c.dom.Node)

Aggregations

Address (org.hl7.fhir.r4.model.Address)75 Test (org.junit.Test)35 Address (org.hl7.fhir.dstu3.model.Address)22 PersonAddress (org.openmrs.PersonAddress)21 HumanName (org.hl7.fhir.r4.model.HumanName)20 Patient (org.hl7.fhir.r4.model.Patient)18 ArrayList (java.util.ArrayList)17 Identifier (org.hl7.fhir.r4.model.Identifier)17 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)16 Test (org.junit.jupiter.api.Test)13 Organization (org.hl7.fhir.r4.model.Organization)12 Address (com.amazonaws.services.ec2.model.Address)7 HumanName (org.hl7.fhir.dstu3.model.HumanName)7 PatientCommunicationComponent (org.hl7.fhir.r4.model.Patient.PatientCommunicationComponent)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 DescribeAddressesResult (com.amazonaws.services.ec2.model.DescribeAddressesResult)5 HashSet (java.util.HashSet)5 Coding (org.hl7.fhir.r4.model.Coding)5 StringType (org.hl7.fhir.r4.model.StringType)5 Before (org.junit.Before)5