use of org.hl7.fhir.r5.model.Observation in project openmrs-module-fhir2 by openmrs.
the class ObservationFhirResourceProviderTest method getLastnObservations_shouldReturnRecentNObservationsWhenPatientReferenceIsNotGiven.
@Test
public void getLastnObservations_shouldReturnRecentNObservationsWhenPatientReferenceIsNotGiven() {
NumberParam max = new NumberParam(2);
TokenAndListParam categories = new TokenAndListParam().addAnd(new TokenParam().setValue("laboratory"));
TokenAndListParam code = new TokenAndListParam().addAnd(new TokenParam().setSystem(FhirTestConstants.LOINC_SYSTEM_URL).setValue(LOINC_SYSTOLIC_BP), new TokenParam().setSystem(FhirTestConstants.CIEL_SYSTEM_URN).setValue(CIEL_DIASTOLIC_BP));
when(observationService.getLastnObservations(max, null, categories, code)).thenReturn(new MockIBundleProvider<>(Collections.singletonList(observation), 10, 1));
IBundleProvider results = resourceProvider.getLastnObservations(max, null, null, categories, code);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, hasSize(equalTo(1)));
assertThat(resultList.get(0), notNullValue());
assertThat(resultList.get(0).fhirType(), equalTo(FhirConstants.OBSERVATION));
assertThat(resultList.get(0).getIdElement().getIdPart(), equalTo(OBSERVATION_UUID));
}
use of org.hl7.fhir.r5.model.Observation in project openmrs-module-fhir2 by openmrs.
the class ObservationFhirResourceProviderTest method searchObservations_shouldNotAddRelatedResourcesForEmptyInclude.
@Test
public void searchObservations_shouldNotAddRelatedResourcesForEmptyInclude() {
HashSet<Include> includes = new HashSet<>();
when(observationService.searchForObservations(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), isNull(), any())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(observation), 10, 1));
IBundleProvider results = resourceProvider.searchObservations(null, null, null, null, null, null, null, null, null, null, null, null, null, null, includes, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, hasSize(equalTo(1)));
assertThat(resultList.get(0), notNullValue());
assertThat(resultList.get(0).fhirType(), equalTo(FhirConstants.OBSERVATION));
assertThat(resultList.get(0).getIdElement().getIdPart(), equalTo(OBSERVATION_UUID));
}
use of org.hl7.fhir.r5.model.Observation in project openmrs-module-fhir2 by openmrs.
the class ObservationFhirResourceProviderTest method getLastn_shouldReturnFirstRecentObservationsWhenMaxIsMissing.
@Test
public void getLastn_shouldReturnFirstRecentObservationsWhenMaxIsMissing() {
ReferenceAndListParam referenceParam = new ReferenceAndListParam();
ReferenceParam patient = new ReferenceParam();
patient.setValue(PATIENT_UUID);
referenceParam.addValue(new ReferenceOrListParam().add(patient));
TokenAndListParam categories = new TokenAndListParam().addAnd(new TokenParam().setValue("laboratory"));
TokenAndListParam code = new TokenAndListParam().addAnd(new TokenParam().setSystem(FhirTestConstants.LOINC_SYSTEM_URL).setValue(LOINC_SYSTOLIC_BP), new TokenParam().setSystem(FhirTestConstants.CIEL_SYSTEM_URN).setValue(CIEL_DIASTOLIC_BP));
when(observationService.getLastnObservations(null, referenceParam, categories, code)).thenReturn(new MockIBundleProvider<>(Collections.singletonList(observation), 10, 1));
IBundleProvider results = resourceProvider.getLastnObservations(null, referenceParam, null, categories, code);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, hasSize(equalTo(1)));
assertThat(resultList.get(0), notNullValue());
assertThat(resultList.get(0).fhirType(), equalTo(FhirConstants.OBSERVATION));
assertThat(resultList.get(0).getIdElement().getIdPart(), equalTo(OBSERVATION_UUID));
}
use of org.hl7.fhir.r5.model.Observation in project openmrs-module-fhir2 by openmrs.
the class ObservationFhirResourceProviderTest method searchObservations_shouldReturnMatchingObservationsWhenPatientParamIsSpecified.
@Test
public void searchObservations_shouldReturnMatchingObservationsWhenPatientParamIsSpecified() {
when(observationService.searchForObservations(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(observation), 10, 1));
ReferenceAndListParam patientParam = new ReferenceAndListParam();
patientParam.addValue(new ReferenceOrListParam().add(new ReferenceParam().setChain(Patient.SP_NAME)));
IBundleProvider results = resourceProvider.searchObservations(null, null, null, null, null, null, null, null, null, null, null, null, null, patientParam, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, hasSize(equalTo(1)));
assertThat(resultList.get(0), notNullValue());
assertThat(resultList.get(0).fhirType(), equalTo(FhirConstants.OBSERVATION));
assertThat(resultList.get(0).getIdElement().getIdPart(), equalTo(OBSERVATION_UUID));
}
use of org.hl7.fhir.r5.model.Observation in project openmrs-module-fhir2 by openmrs.
the class ObservationFhirResourceProviderTest method getLastnObservations_shouldReturnRecentNObservationsWhenBothCodeAndCategoryIsNotSpecified.
@Test
public void getLastnObservations_shouldReturnRecentNObservationsWhenBothCodeAndCategoryIsNotSpecified() {
NumberParam max = new NumberParam(2);
ReferenceAndListParam referenceParam = new ReferenceAndListParam();
ReferenceParam patient = new ReferenceParam();
patient.setValue(PATIENT_UUID);
referenceParam.addValue(new ReferenceOrListParam().add(patient));
when(observationService.getLastnObservations(max, referenceParam, null, null)).thenReturn(new MockIBundleProvider<>(Collections.singletonList(observation), 10, 1));
IBundleProvider results = resourceProvider.getLastnObservations(max, referenceParam, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, hasSize(equalTo(1)));
assertThat(resultList.get(0), notNullValue());
assertThat(resultList.get(0).fhirType(), equalTo(FhirConstants.OBSERVATION));
assertThat(resultList.get(0).getIdElement().getIdPart(), equalTo(OBSERVATION_UUID));
}
Aggregations