Search in sources :

Example 81 with Subject

use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project openmrs-module-fhir2 by openmrs.

the class ObservationFhirResourceProviderIntegrationTest method shouldReturnLastnEncountersObservationsWhenCodeIsMissingAsJson.

@Test
public void shouldReturnLastnEncountersObservationsWhenCodeIsMissingAsJson() throws Exception {
    MockHttpServletResponse response = get("Observation/$lastn-encounters?max=2&subject=" + OBS_PATIENT_UUID + "&category=laboratory").accept(FhirMediaTypes.JSON).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
    assertThat(response.getContentAsString(), notNullValue());
    Bundle results = readBundleResponse(response);
    assertThat(results, notNullValue());
    assertThat(results.getType(), equalTo(Bundle.BundleType.SEARCHSET));
    assertThat(results.hasEntry(), is(true));
    assertThat(results, hasProperty("total", equalTo(3)));
    List<Bundle.BundleEntryComponent> entries = results.getEntry();
    assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R3/Observation/"))));
    assertThat(entries, everyItem(hasResource(instanceOf(Observation.class))));
    assertThat(entries, everyItem(hasResource(validResource())));
    assertThat(entries, everyItem(hasResource(hasProperty("subject", hasProperty("reference", endsWith(OBS_PATIENT_UUID))))));
    assertThat(entries, everyItem(hasResource(hasProperty("category", everyItem(hasProperty("coding", everyItem(hasProperty("code", equalTo("laboratory")))))))));
    assertThat(getDistinctEncounterDatetime(entries), lessThanOrEqualTo(2));
}
Also used : Bundle(org.hl7.fhir.dstu3.model.Bundle) Observation(org.hl7.fhir.dstu3.model.Observation) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 82 with Subject

use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project openmrs-module-fhir2 by openmrs.

the class ObservationFhirResourceProviderIntegrationTest method shouldReturnLastnEncountersObservationsWhenCodeIsMissingAsXml.

@Test
public void shouldReturnLastnEncountersObservationsWhenCodeIsMissingAsXml() throws Exception {
    MockHttpServletResponse response = get("Observation/$lastn-encounters?max=2&subject=" + OBS_PATIENT_UUID + "&category=laboratory").accept(FhirMediaTypes.XML).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
    assertThat(response.getContentAsString(), notNullValue());
    Bundle results = readBundleResponse(response);
    assertThat(results, notNullValue());
    assertThat(results.getType(), equalTo(Bundle.BundleType.SEARCHSET));
    assertThat(results.hasEntry(), is(true));
    assertThat(results, hasProperty("total", equalTo(3)));
    List<Bundle.BundleEntryComponent> entries = results.getEntry();
    assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R3/Observation/"))));
    assertThat(entries, everyItem(hasResource(instanceOf(Observation.class))));
    assertThat(entries, everyItem(hasResource(validResource())));
    assertThat(entries, everyItem(hasResource(hasProperty("subject", hasProperty("reference", endsWith(OBS_PATIENT_UUID))))));
    assertThat(entries, everyItem(hasResource(hasProperty("category", everyItem(hasProperty("coding", everyItem(hasProperty("code", equalTo("laboratory")))))))));
    assertThat(getDistinctEncounterDatetime(entries), lessThanOrEqualTo(2));
}
Also used : Bundle(org.hl7.fhir.dstu3.model.Bundle) Observation(org.hl7.fhir.dstu3.model.Observation) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 83 with Subject

use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project openmrs-module-fhir2 by openmrs.

the class ObservationFhirResourceProviderIntegrationTest method shouldReturnLastnObservationsWhenMaxIsMissingAsJson.

@Test
public void shouldReturnLastnObservationsWhenMaxIsMissingAsJson() throws Exception {
    MockHttpServletResponse response = get("Observation/$lastn?subject=" + OBS_PATIENT_UUID + "&category=laboratory&code=5242").accept(FhirMediaTypes.JSON).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
    assertThat(response.getContentAsString(), notNullValue());
    Bundle results = readBundleResponse(response);
    assertThat(results, notNullValue());
    assertThat(results.getType(), equalTo(Bundle.BundleType.SEARCHSET));
    assertThat(results.hasEntry(), is(true));
    assertThat(results, hasProperty("total", equalTo(2)));
    List<Bundle.BundleEntryComponent> entries = results.getEntry();
    assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R3/Observation/"))));
    assertThat(entries, everyItem(hasResource(instanceOf(Observation.class))));
    assertThat(entries, everyItem(hasResource(validResource())));
    assertThat(entries, everyItem(hasResource(hasProperty("subject", hasProperty("reference", endsWith(OBS_PATIENT_UUID))))));
    assertThat(entries, everyItem(hasResource(hasProperty("code", hasProperty("coding", everyItem(hasProperty("display", equalTo("Respiratory rate"))))))));
    assertThat(entries, everyItem(hasResource(hasProperty("category", everyItem(hasProperty("coding", everyItem(hasProperty("code", equalTo("laboratory")))))))));
    assertThat(entries, isSortedAndWithinMax(1));
}
Also used : Bundle(org.hl7.fhir.dstu3.model.Bundle) Observation(org.hl7.fhir.dstu3.model.Observation) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 84 with Subject

use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project openmrs-module-fhir2 by openmrs.

the class ObservationFhirResourceProviderIntegrationTest method shouldReturnLastnEncountersObservationsWhenPatientReferenceIsPassedInPatientParameterAsXml.

@Test
public void shouldReturnLastnEncountersObservationsWhenPatientReferenceIsPassedInPatientParameterAsXml() throws Exception {
    MockHttpServletResponse response = get("Observation/$lastn-encounters?max=2&patient=" + OBS_PATIENT_UUID + "&category=laboratory&code=5089").accept(FhirMediaTypes.XML).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
    assertThat(response.getContentAsString(), notNullValue());
    Bundle results = readBundleResponse(response);
    assertThat(results, notNullValue());
    assertThat(results.getType(), equalTo(Bundle.BundleType.SEARCHSET));
    assertThat(results.hasEntry(), is(true));
    assertThat(results, hasProperty("total", equalTo(2)));
    List<Bundle.BundleEntryComponent> entries = results.getEntry();
    assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R3/Observation/"))));
    assertThat(entries, everyItem(hasResource(instanceOf(Observation.class))));
    assertThat(entries, everyItem(hasResource(validResource())));
    assertThat(entries, everyItem(hasResource(hasProperty("subject", hasProperty("reference", endsWith(OBS_PATIENT_UUID))))));
    assertThat(entries, everyItem(hasResource(hasProperty("code", hasProperty("coding", everyItem(hasProperty("display", equalTo("Weight"))))))));
    assertThat(entries, everyItem(hasResource(hasProperty("category", everyItem(hasProperty("coding", everyItem(hasProperty("code", equalTo("laboratory")))))))));
    assertThat(getDistinctEncounterDatetime(entries), lessThanOrEqualTo(2));
}
Also used : Bundle(org.hl7.fhir.dstu3.model.Bundle) Observation(org.hl7.fhir.dstu3.model.Observation) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 85 with Subject

use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project openmrs-module-fhir2 by openmrs.

the class ObservationFhirResourceProviderIntegrationTest method shouldReturnLastnObservationsWhenCategoryIsMissingAsJson.

@Test
public void shouldReturnLastnObservationsWhenCategoryIsMissingAsJson() throws Exception {
    MockHttpServletResponse response = get("Observation/$lastn?max=2&patient=" + OBS_PATIENT_UUID + "&code=5242").accept(FhirMediaTypes.JSON).go();
    assertThat(response, isOk());
    assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
    assertThat(response.getContentAsString(), notNullValue());
    Bundle results = readBundleResponse(response);
    assertThat(results, notNullValue());
    assertThat(results.getType(), equalTo(Bundle.BundleType.SEARCHSET));
    assertThat(results.hasEntry(), is(true));
    assertThat(results, hasProperty("total", equalTo(7)));
    List<Bundle.BundleEntryComponent> entries = results.getEntry();
    assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R3/Observation/"))));
    assertThat(entries, everyItem(hasResource(instanceOf(Observation.class))));
    assertThat(entries, everyItem(hasResource(validResource())));
    assertThat(entries, everyItem(hasResource(hasProperty("subject", hasProperty("reference", endsWith(OBS_PATIENT_UUID))))));
    assertThat(entries, everyItem(hasResource(hasProperty("code", hasProperty("coding", everyItem(hasProperty("display", equalTo("Respiratory rate"))))))));
    assertThat(entries, isSortedAndWithinMax(2));
}
Also used : Bundle(org.hl7.fhir.dstu3.model.Bundle) Observation(org.hl7.fhir.dstu3.model.Observation) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)124 Test (org.junit.jupiter.api.Test)68 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)64 Bundle (org.hl7.fhir.r4.model.Bundle)56 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)54 Parameters (org.hl7.fhir.r4.model.Parameters)46 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)43 RestIntegrationTest (org.opencds.cqf.ruler.test.RestIntegrationTest)42 StringType (org.hl7.fhir.r4.model.StringType)41 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)39 Observation (org.hl7.fhir.r4.model.Observation)38 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)37 Bundle (org.hl7.fhir.dstu3.model.Bundle)35 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)32 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)32 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)31 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)31 Patient (org.hl7.fhir.r4.model.Patient)30 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)30 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)29