use of org.hl7.fhir.r5.utils.validation in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForObsConditions_shouldSearchForConditionsByMultiplePatientIdentifierOr.
@Test
public void searchForObsConditions_shouldSearchForConditionsByMultiplePatientIdentifierOr() {
ReferenceAndListParam referenceParam = new ReferenceAndListParam();
ReferenceParam patient = new ReferenceParam();
patient.setValue(PATIENT_IDENTIFIER);
patient.setChain(Patient.SP_IDENTIFIER);
ReferenceParam badPatient = new ReferenceParam();
badPatient.setValue(PATIENT_WRONG_IDENTIFIER);
badPatient.setChain(Patient.SP_IDENTIFIER);
referenceParam.addValue(new ReferenceOrListParam().add(patient).add(badPatient));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, referenceParam);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertEquals(resultList.size(), 2);
assertThat(((org.hl7.fhir.r4.model.Condition) resultList.iterator().next()).getSubject().getReference(), endsWith(PATIENT_UUID));
}
use of org.hl7.fhir.r5.utils.validation in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForConditions_shouldReturnConditionByOnsetAgeEqualHour.
@Test
public void searchForConditions_shouldReturnConditionByOnsetAgeEqualHour() {
QuantityOrListParam orList = new QuantityOrListParam();
orList.addOr(new QuantityParam(ParamPrefixEnum.EQUAL, 2, "", "h"));
QuantityAndListParam onsetAgeParam = new QuantityAndListParam().addAnd(orList);
when(localDateTimeFactory.now()).thenReturn(LocalDateTime.of(2008, Month.JULY, 1, 3, 0, 0));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.QUANTITY_SEARCH_HANDLER, onsetAgeParam);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(((org.hl7.fhir.r4.model.Condition) resultList.iterator().next()).getIdElement().getIdPart(), equalTo(EXISTING_OBS_CONDITION_UUID));
}
use of org.hl7.fhir.r5.utils.validation in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForObsConditions_shouldReturnConditionByPatientGivenName.
@Test
public void searchForObsConditions_shouldReturnConditionByPatientGivenName() {
ReferenceParam patientReference = new ReferenceParam(Patient.SP_GIVEN, PATIENT_GIVEN_NAME);
ReferenceAndListParam patientList = new ReferenceAndListParam();
patientList.addValue(new ReferenceOrListParam().add(patientReference));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, patientList);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertEquals(resultList.size(), 2);
assertThat(((org.hl7.fhir.r4.model.Condition) resultList.iterator().next()).getSubject().getReferenceElement().getIdPart(), equalTo(PATIENT_UUID));
}
use of org.hl7.fhir.r5.utils.validation in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForObsConditions_shouldReturnConditionByPatientUuid.
@Test
public void searchForObsConditions_shouldReturnConditionByPatientUuid() {
ReferenceParam patientReference = new ReferenceParam(null, PATIENT_UUID);
ReferenceAndListParam patientList = new ReferenceAndListParam();
patientList.addAnd(new ReferenceOrListParam().addOr(patientReference));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, patientList);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertEquals(resultList.size(), 2);
assertThat(((org.hl7.fhir.r4.model.Condition) resultList.iterator().next()).getSubject().getReferenceElement().getIdPart(), equalTo(PATIENT_UUID));
}
use of org.hl7.fhir.r5.utils.validation in project openmrs-module-fhir2 by openmrs.
the class ConditionSearchQueryTest method searchForObsConditions_shouldSearchForConditionsByMultiplePatientUuidOr.
@Test
public void searchForObsConditions_shouldSearchForConditionsByMultiplePatientUuidOr() {
ReferenceAndListParam referenceParam = new ReferenceAndListParam();
ReferenceParam patient = new ReferenceParam();
patient.setValue(PATIENT_UUID);
ReferenceParam badPatient = new ReferenceParam();
badPatient.setValue(PATIENT_WRONG_UUID);
referenceParam.addValue(new ReferenceOrListParam().add(patient).add(badPatient));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, referenceParam);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertEquals(resultList.size(), 2);
assertThat(((org.hl7.fhir.r4.model.Condition) resultList.iterator().next()).getSubject().getReferenceElement().getIdPart(), equalTo(PATIENT_UUID));
}
Aggregations