Search in sources :

Example 81 with Observation

use of org.hl7.fhir.r4b.model.Observation in project openmrs-module-fhir2 by openmrs.

the class ObservationFhirResourceProviderTest method getLastnObservations_shouldReturnRecentNObservationsWhenPatientReferenceIsPassedInPatientParameter.

@Test
public void getLastnObservations_shouldReturnRecentNObservationsWhenPatientReferenceIsPassedInPatientParameter() {
    NumberParam max = new NumberParam(2);
    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(max, referenceParam, categories, code)).thenReturn(new MockIBundleProvider<>(Collections.singletonList(observation), 10, 1));
    IBundleProvider results = resourceProvider.getLastnObservations(max, null, referenceParam, 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));
}
Also used : TokenParam(ca.uhn.fhir.rest.param.TokenParam) ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) NumberParam(ca.uhn.fhir.rest.param.NumberParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 82 with Observation

use of org.hl7.fhir.r4b.model.Observation in project openmrs-module-fhir2 by openmrs.

the class ObservationFhirResourceProviderTest method getLastnEncountersObservations_shouldReturnRecentNEncountersObservationsWhenPatientReferenceIsPassedInPatientParameter.

@Test
public void getLastnEncountersObservations_shouldReturnRecentNEncountersObservationsWhenPatientReferenceIsPassedInPatientParameter() {
    NumberParam max = new NumberParam(2);
    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.getLastnEncountersObservations(max, referenceParam, categories, code)).thenReturn(new MockIBundleProvider<>(Collections.singletonList(observation), 10, 1));
    IBundleProvider results = resourceProvider.getLastnEncountersObservations(max, null, referenceParam, 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));
}
Also used : TokenParam(ca.uhn.fhir.rest.param.TokenParam) ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) NumberParam(ca.uhn.fhir.rest.param.NumberParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 83 with Observation

use of org.hl7.fhir.r4b.model.Observation in project openmrs-module-fhir2 by openmrs.

the class ObservationFhirResourceProviderTest method getLastnEncounters_shouldReturnFirstRecentEncountersObservationsWhenMaxIsMissing.

@Test
public void getLastnEncounters_shouldReturnFirstRecentEncountersObservationsWhenMaxIsMissing() {
    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.getLastnEncountersObservations(null, referenceParam, categories, code)).thenReturn(new MockIBundleProvider<>(Collections.singletonList(observation), 10, 1));
    IBundleProvider results = resourceProvider.getLastnEncountersObservations(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));
}
Also used : TokenParam(ca.uhn.fhir.rest.param.TokenParam) ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 84 with Observation

use of org.hl7.fhir.r4b.model.Observation in project openmrs-module-fhir2 by openmrs.

the class ObservationFhirResourceProviderTest method getLastnEncountersObservations_shouldReturnRecentNEncountersObservationsWhenPatientReferenceIsNotGiven.

@Test
public void getLastnEncountersObservations_shouldReturnRecentNEncountersObservationsWhenPatientReferenceIsNotGiven() {
    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.getLastnEncountersObservations(max, null, categories, code)).thenReturn(new MockIBundleProvider<>(Collections.singletonList(observation), 10, 1));
    IBundleProvider results = resourceProvider.getLastnEncountersObservations(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));
}
Also used : TokenParam(ca.uhn.fhir.rest.param.TokenParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) NumberParam(ca.uhn.fhir.rest.param.NumberParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Example 85 with Observation

use of org.hl7.fhir.r4b.model.Observation in project openmrs-module-fhir2 by openmrs.

the class ObservationFhirResourceProviderTest method getLastnObservations_shouldReturnRecentNObservationsWhenNoCodeIsSpecified.

@Test
public void getLastnObservations_shouldReturnRecentNObservationsWhenNoCodeIsSpecified() {
    NumberParam max = new NumberParam(2);
    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"));
    when(observationService.getLastnObservations(max, referenceParam, categories, null)).thenReturn(new MockIBundleProvider<>(Collections.singletonList(observation), 10, 1));
    IBundleProvider results = resourceProvider.getLastnObservations(max, referenceParam, null, categories, 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));
}
Also used : TokenParam(ca.uhn.fhir.rest.param.TokenParam) ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) ReferenceAndListParam(ca.uhn.fhir.rest.param.ReferenceAndListParam) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) NumberParam(ca.uhn.fhir.rest.param.NumberParam) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ReferenceOrListParam(ca.uhn.fhir.rest.param.ReferenceOrListParam) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) BaseFhirProvenanceResourceTest(org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest) Test(org.junit.Test)

Aggregations

Observation (org.hl7.fhir.r4.model.Observation)237 Test (org.junit.Test)235 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)114 Test (org.junit.jupiter.api.Test)107 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)106 Observation (org.hl7.fhir.dstu3.model.Observation)94 Bundle (org.hl7.fhir.r4.model.Bundle)88 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)64 ArrayList (java.util.ArrayList)62 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)59 Resource (org.hl7.fhir.r4.model.Resource)55 Bundle (org.hl7.fhir.dstu3.model.Bundle)53 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)47 Coding (org.hl7.fhir.r4.model.Coding)46 Reference (org.hl7.fhir.r4.model.Reference)41 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)37 TokenParam (ca.uhn.fhir.rest.param.TokenParam)37 Date (java.util.Date)34 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)32 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)32