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