Search in sources :

Example 16 with Address

use of org.hl7.fhir.dstu2016may.model.Address in project summary-care-record-api by NHSDigital.

the class OrganisationMapper method mapOrganization.

public Organization mapOrganization(Node organisation) {
    var org = new Organization();
    org.setId(randomUUID());
    xmlUtils.getOptionalValueByXPath(organisation, ORG_CODE_XPATH).ifPresent(it -> org.addType(new CodeableConcept(new Coding().setCode(it))));
    xmlUtils.detachOptionalNodeByXPath(organisation, ORG_NAME_XPATH).ifPresent(name -> org.setName(name.getTextContent()));
    xmlUtils.detachOptionalNodeByXPath(organisation, ADDRESS_XPATH).ifPresent(node -> org.addAddress(new Address().setText(node.getTextContent())));
    xmlUtils.detachOptionalNodeByXPath(organisation, TELECOM_XPATH).ifPresent(telecom -> org.addTelecom(telecomMapper.mapTelecom(telecom)));
    return org;
}
Also used : Organization(org.hl7.fhir.r4.model.Organization) Address(org.hl7.fhir.r4.model.Address) Coding(org.hl7.fhir.r4.model.Coding) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 17 with Address

use of org.hl7.fhir.dstu2016may.model.Address in project openmrs-module-fhir2 by openmrs.

the class FhirPatientServiceImplTest method setUp.

@Before
public void setUp() {
    patientService = new FhirPatientServiceImpl() {

        @Override
        protected void validateObject(Patient object) {
        }
    };
    patientService.setDao(dao);
    patientService.setTranslator(patientTranslator);
    patientService.setSearchQuery(searchQuery);
    patientService.setSearchQueryInclude(searchQueryInclude);
    PersonName name = new PersonName();
    name.setFamilyName(PATIENT_FAMILY_NAME);
    name.setGivenName(PATIENT_GIVEN_NAME);
    patient = new Patient();
    patient.setUuid(PATIENT_UUID);
    patient.setGender("M");
    patient.addName(name);
    PersonAddress address = new PersonAddress();
    address.setCityVillage(CITY);
    address.setStateProvince(STATE);
    address.setPostalCode(POSTAL_CODE);
    address.setCountry(COUNTRY);
    HumanName humanName = new HumanName();
    humanName.addGiven(PATIENT_GIVEN_NAME);
    humanName.setFamily(PATIENT_FAMILY_NAME);
    fhirPatient = new org.hl7.fhir.r4.model.Patient();
    fhirPatient.setId(PATIENT_UUID);
    fhirPatient.addName(humanName);
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) PersonName(org.openmrs.PersonName) PersonAddress(org.openmrs.PersonAddress) Patient(org.openmrs.Patient) Before(org.junit.Before)

Example 18 with Address

use of org.hl7.fhir.dstu2016may.model.Address in project openmrs-module-fhir2 by openmrs.

the class LocationSearchQueryTest method searchForLocations_shouldSortLocationsByStateAsRequested.

@Test
public void searchForLocations_shouldSortLocationsByStateAsRequested() {
    SortSpec sort = new SortSpec();
    sort.setParamName("address-state");
    sort.setOrder(SortOrderEnum.ASC);
    List<Location> resultsList = getLocationListWithoutNulls(sort);
    // check if the sorting is indeed correct by ascending order
    for (int i = 1; i < resultsList.size(); i++) {
        assertThat(resultsList.get(i - 1).getAddress().getState(), lessThanOrEqualTo(resultsList.get(i).getAddress().getState()));
    }
    sort.setOrder(SortOrderEnum.DESC);
    resultsList = getLocationListWithoutNulls(sort);
    // check if the sorting is indeed correct by descending order
    for (int i = 1; i < resultsList.size(); i++) {
        assertThat(resultsList.get(i - 1).getAddress().getState(), greaterThanOrEqualTo(resultsList.get(i).getAddress().getState()));
    }
}
Also used : SortSpec(ca.uhn.fhir.rest.api.SortSpec) Location(org.hl7.fhir.r4.model.Location) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 19 with Address

use of org.hl7.fhir.dstu2016may.model.Address in project openmrs-module-fhir2 by openmrs.

the class LocationSearchQueryTest method getLocationListWithoutNulls.

private List<Location> getLocationListWithoutNulls(SortSpec sort) {
    SearchParameterMap theParams = new SearchParameterMap().setSortSpec(sort);
    IBundleProvider locations = search(theParams);
    assertThat(locations, notNullValue());
    List<Location> locationList = get(locations);
    assertThat(locationList, not(empty()));
    assertThat(locationList, hasSize(greaterThan(1)));
    // Remove locations with sort parameter value null, to allow comparison while asserting.
    switch(sort.getParamName()) {
        case "name":
            locationList.removeIf(p -> p.getName() == null);
            break;
        case "address-city":
            locationList.removeIf(p -> p.getAddress().getCity() == null);
            break;
        case "address-state":
            locationList.removeIf(p -> p.getAddress().getState() == null);
            break;
        case "address-postalCode":
            locationList.removeIf(p -> p.getAddress().getPostalCode() == null);
            break;
        case "address-country":
            locationList.removeIf(p -> p.getAddress().getCountry() == null);
            break;
    }
    return locationList;
}
Also used : IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Location(org.hl7.fhir.r4.model.Location)

Example 20 with Address

use of org.hl7.fhir.dstu2016may.model.Address in project openmrs-module-fhir2 by openmrs.

the class LocationSearchQueryTest method searchForLocations_shouldReturnCorrectLocationByParentPostalCode.

@Test
public void searchForLocations_shouldReturnCorrectLocationByParentPostalCode() {
    ReferenceAndListParam parentLocation = new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(LOCATION_PARENT_POSTAL_CODE).setChain("address-postalcode")));
    SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.LOCATION_REFERENCE_SEARCH_HANDLER, parentLocation);
    IBundleProvider locations = search(theParams);
    List<Location> resultList = get(locations);
    assertThat(locations, notNullValue());
    assertThat(resultList, hasSize(equalTo(1)));
    assertThat(resultList.get(0).getIdElement().getIdPart(), equalTo(LOCATION_UUID));
}
Also used : ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Location(org.hl7.fhir.r4.model.Location) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Aggregations

Address (org.hl7.fhir.r4.model.Address)75 Test (org.junit.Test)47 Patient (org.hl7.fhir.r4.model.Patient)30 Test (org.junit.jupiter.api.Test)30 PersonAddress (org.openmrs.PersonAddress)27 HumanName (org.hl7.fhir.r4.model.HumanName)24 Identifier (org.hl7.fhir.r4.model.Identifier)23 ArrayList (java.util.ArrayList)22 Address (org.hl7.fhir.dstu3.model.Address)22 Path (javax.ws.rs.Path)20 Produces (javax.ws.rs.Produces)20 NotImplementedException (org.apache.commons.lang3.NotImplementedException)19 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)19 Location (org.hl7.fhir.r4.model.Location)13 Organization (org.hl7.fhir.r4.model.Organization)13 InputStream (java.io.InputStream)12 IdType (org.hl7.fhir.dstu3.model.IdType)12 Patient (org.hl7.fhir.dstu3.model.Patient)12 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)12 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)12