Search in sources :

Example 81 with Address

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

the class Hl7AddressFHIRConversionTest method patient_address_district_and_multiple_address_conversion_test.

@Test
// See Hl7RelatedGeneralUtils.getAddressDistrict for details on when district and county apply.
void patient_address_district_and_multiple_address_conversion_test() {
    // When there is no county XAD.9 in the address, and there is only one address, use the PID county.
    String patientSingleAddressYesAddressCountyNoPatientCounty = "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^^^20011120&20081120^^^^Y^Z^V^c/o Pluto19||^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 patientSingleAddressNoAddressCountyNoPatientCounty = "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^^^^^20011120&20081120^^^^Y^Z^V^c/o Pluto19||^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 patientSingleAddressYesAddressCountyYesPatientCounty = "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^^^20011120&20081120^^^^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 patientSingleAddressNoAddressCountyYesPatientCounty = "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^^^^^20011120&20081120^^^^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 patientMultipleAddressOneAddressCountyYesPatientCounty = "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^^^20011120&20081120^^^^Y^Z^V^c/o Pluto19~222 2nd Ave^Suite #2^Salt Lake City^Utah^22222|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, patientSingleAddressYesAddressCountyNoPatientCounty);
    assertThat(patient.hasAddress()).isTrue();
    List<Address> addresses = patient.getAddress();
    assertThat(addresses.size()).isEqualTo(1);
    Address address = addresses.get(0);
    assertThat(address.getDistrict()).isEqualTo("AdrC");
    // If no address county, and no patient county, = no county
    patient = PatientUtils.createPatientFromHl7Segment(ftv, patientSingleAddressNoAddressCountyNoPatientCounty);
    assertThat(patient.hasAddress()).isTrue();
    addresses = patient.getAddress();
    assertThat(addresses.size()).isEqualTo(1);
    address = addresses.get(0);
    assertThat(address.getDistrict()).isNull();
    // If address county, ignore patient county
    patient = PatientUtils.createPatientFromHl7Segment(ftv, patientSingleAddressYesAddressCountyYesPatientCounty);
    assertThat(patient.hasAddress()).isTrue();
    addresses = patient.getAddress();
    assertThat(addresses.size()).isEqualTo(1);
    address = addresses.get(0);
    assertThat(address.getDistrict()).isEqualTo("AdrC");
    // If no address county, a patient county is present, and EXACTLY one (repeatable) address then Patient County
    patient = PatientUtils.createPatientFromHl7Segment(ftv, patientSingleAddressNoAddressCountyYesPatientCounty);
    assertThat(patient.hasAddress()).isTrue();
    addresses = patient.getAddress();
    assertThat(addresses.size()).isEqualTo(1);
    address = addresses.get(0);
    assertThat(address.getDistrict()).isEqualTo("PatC");
    // If more than one address, ignore the patient county and use only the address county, if it is present
    patient = PatientUtils.createPatientFromHl7Segment(ftv, patientMultipleAddressOneAddressCountyYesPatientCounty);
    assertThat(patient.hasAddress()).isTrue();
    addresses = patient.getAddress();
    assertThat(addresses.size()).isEqualTo(2);
    address = addresses.get(0);
    // Address 1 has a county
    assertThat(address.getDistrict()).isEqualTo("AdrC");
    address = addresses.get(1);
    // Address 2 has no county; result is correctly NOT "PatC"
    assertThat(address.getDistrict()).isNull();
    // Check a few other things about the addresses to confirm they are different and correct
    address = addresses.get(0);
    assertThat(address.getCity()).isEqualTo("Minneapolis");
    assertThat(address.getState()).isEqualTo("MN");
    assertThat(address.getCountry()).isEqualTo("USA");
    assertThat(address.getPostalCode()).isEqualTo("11111");
    address = addresses.get(1);
    assertThat(address.getCity()).isEqualTo("Salt Lake City");
    assertThat(address.getState()).isEqualTo("Utah");
    assertThat(address.getCountry()).isNull();
    assertThat(address.getPostalCode()).isEqualTo("22222");
}
Also used : Address(org.hl7.fhir.r4.model.Address) Patient(org.hl7.fhir.r4.model.Patient) Test(org.junit.jupiter.api.Test)

Example 82 with Address

use of com.adobe.target.delivery.v1.model.Address in project openmrs-module-fhir2 by openmrs.

the class FhirRelatedPersonServiceImplTest method setup.

@Before
public void setup() {
    relatedPersonService = new FhirRelatedPersonServiceImpl() {

        @Override
        protected void validateObject(Relationship object) {
        }
    };
    relatedPersonService.setDao(dao);
    relatedPersonService.setTranslator(translator);
    relatedPersonService.setSearchQuery(searchQuery);
    relatedPersonService.setSearchQueryInclude(searchQueryInclude);
    PersonName name = new PersonName();
    name.setUuid(PERSON_NAME_UUID);
    name.setGivenName(GIVEN_NAME);
    name.setFamilyName(FAMILY_NAME);
    PersonAddress address = new PersonAddress();
    address.setCityVillage(CITY);
    address.setStateProvince(STATE);
    address.setPostalCode(POSTAL_CODE);
    address.setCountry(COUNTRY);
    person = new org.openmrs.Person();
    person.setUuid(PERSON_UUID);
    person.setGender("M");
    person.addName(name);
    relationship = new org.openmrs.Relationship();
    relationship.setRelationshipId(1000);
    relationship.setPersonA(person);
    HumanName humanName = new HumanName();
    humanName.addGiven(GIVEN_NAME);
    humanName.setFamily(FAMILY_NAME);
    humanName.setId(PERSON_NAME_UUID);
    Address relatedPersonAddress = new Address();
    relatedPersonAddress.setCity(CITY);
    relatedPersonAddress.setState(STATE);
    relatedPersonAddress.setPostalCode(POSTAL_CODE);
    relatedPersonAddress.setCountry(COUNTRY);
    relatedPerson = new RelatedPerson();
    relatedPerson.addName(humanName);
    relatedPerson.addAddress(relatedPersonAddress);
    relatedPerson.setGender(Enumerations.AdministrativeGender.MALE);
}
Also used : Relationship(org.openmrs.Relationship) HumanName(org.hl7.fhir.r4.model.HumanName) PersonName(org.openmrs.PersonName) PersonAddress(org.openmrs.PersonAddress) Address(org.hl7.fhir.r4.model.Address) PersonAddress(org.openmrs.PersonAddress) Relationship(org.openmrs.Relationship) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) Before(org.junit.Before)

Example 83 with Address

use of com.adobe.target.delivery.v1.model.Address in project openmrs-module-fhir2 by openmrs.

the class FhirLocationServiceImplTest method setUp.

@Before
public void setUp() {
    fhirLocationService = new FhirLocationServiceImpl() {

        @Override
        protected void validateObject(org.openmrs.Location object) {
        }
    };
    fhirLocationService.setDao(locationDao);
    fhirLocationService.setTranslator(locationTranslator);
    fhirLocationService.setSearchQuery(searchQuery);
    fhirLocationService.setSearchQueryInclude(searchQueryInclude);
    location = new org.openmrs.Location();
    location.setUuid(LOCATION_UUID);
    location.setName(LOCATION_NAME);
    location.setDescription(LOCATION_DESCRIPTION);
    location.setDateCreated(new Date());
    location.setRetired(false);
    Set<LocationTag> locationTags = new HashSet<>();
    locationTags.add(new LocationTag(LOGIN_LOCATION_TAG_NAME, LOGIN_LOCATION_TAG_DESCRIPTION));
    location.setTags(locationTags);
    fhirLocation = new Location();
    fhirLocation.setId(LOCATION_UUID);
    fhirLocation.setName(LOCATION_NAME);
    fhirLocation.setDescription(LOCATION_DESCRIPTION);
    Address address = new Address();
    address.setCity(LOCATION_CITY);
    address.setPostalCode(POSTAL_CODE);
    address.setCountry(LOCATION_COUNTRY);
    address.setState(LOCATION_STATE);
    fhirLocation.setAddress(address);
}
Also used : LocationTag(org.openmrs.LocationTag) Address(org.hl7.fhir.r4.model.Address) Date(java.util.Date) HashSet(java.util.HashSet) Location(org.hl7.fhir.r4.model.Location) Before(org.junit.Before)

Example 84 with Address

use of com.adobe.target.delivery.v1.model.Address in project openmrs-module-fhir2 by openmrs.

the class LocationFhirResourceProviderTest method initLocation.

@Before
public void initLocation() {
    Address address = new Address();
    address.setCity(CITY);
    address.setCountry(COUNTRY);
    address.setState(STATE);
    address.setPostalCode(POSTAL_CODE);
    location = new Location();
    location.setId(LOCATION_UUID);
    location.setName(LOCATION_NAME);
    location.setAddress(address);
    location.getMeta().addTag(new Coding(FhirConstants.OPENMRS_FHIR_EXT_LOCATION_TAG, LOGIN_LOCATION_TAG_NAME, LOGIN_LOCATION_TAG_DESCRIPTION));
    setProvenanceResources(location);
}
Also used : Address(org.hl7.fhir.r4.model.Address) Coding(org.hl7.fhir.r4.model.Coding) Location(org.hl7.fhir.r4.model.Location) Before(org.junit.Before)

Example 85 with Address

use of com.adobe.target.delivery.v1.model.Address in project openmrs-module-fhir2 by openmrs.

the class PersonAddressTranslatorImplTest method shouldConvertFhirCountryToCountry.

@Test
public void shouldConvertFhirCountryToCountry() {
    Address address = new Address();
    address.setCountry(COUNTRY);
    assertThat(addressTranslator.toOpenmrsType(address).getCountry(), equalTo(COUNTRY));
}
Also used : Address(org.hl7.fhir.r4.model.Address) PersonAddress(org.openmrs.PersonAddress) Test(org.junit.Test)

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