use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project openmrs-module-fhir2 by openmrs.
the class ObservationFhirResourceProviderIntegrationTest method shouldReturnLastnEncountersObservationsAsJson.
@Test
public void shouldReturnLastnEncountersObservationsAsJson() throws Exception {
MockHttpServletResponse response = get("Observation/$lastn-encounters?max=2&subject=" + OBS_PATIENT_UUID + "&category=laboratory&code=5089").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("Weight"))))))));
assertThat(entries, everyItem(hasResource(hasProperty("category", everyItem(hasProperty("coding", everyItem(hasProperty("code", equalTo("laboratory")))))))));
assertThat(getDistinctEncounterDatetime(entries), lessThanOrEqualTo(2));
}
use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project openmrs-module-fhir2 by openmrs.
the class ObservationFhirResourceProviderIntegrationTest method shouldReturnLastnObservationsWhenPatientReferenceIsPassedInPatientParameterAsXml.
@Test
public void shouldReturnLastnObservationsWhenPatientReferenceIsPassedInPatientParameterAsXml() throws Exception {
MockHttpServletResponse response = get("Observation/$lastn?max=2&patient=" + OBS_PATIENT_UUID + "&category=laboratory&code=5242").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(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, everyItem(hasResource(hasProperty("category", everyItem(hasProperty("coding", everyItem(hasProperty("code", equalTo("laboratory")))))))));
assertThat(entries, isSortedAndWithinMax(2));
}
use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project openmrs-module-fhir2 by openmrs.
the class ObservationFhirResourceProviderIntegrationTest method shouldReturnLastnObservationsWhenMaxIsMissingAsXml.
@Test
public void shouldReturnLastnObservationsWhenMaxIsMissingAsXml() throws Exception {
MockHttpServletResponse response = get("Observation/$lastn?subject=" + OBS_PATIENT_UUID + "&category=laboratory&code=5242").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("Respiratory rate"))))))));
assertThat(entries, everyItem(hasResource(hasProperty("category", everyItem(hasProperty("coding", everyItem(hasProperty("code", equalTo("laboratory")))))))));
assertThat(entries, isSortedAndWithinMax(1));
}
use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project openmrs-module-fhir2 by openmrs.
the class ObservationFhirResourceProviderIntegrationTest method shouldReturnLastnObservationsAsJson.
@Test
public void shouldReturnLastnObservationsAsJson() throws Exception {
MockHttpServletResponse response = get("Observation/$lastn?max=2&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(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, everyItem(hasResource(hasProperty("category", everyItem(hasProperty("coding", everyItem(hasProperty("code", equalTo("laboratory")))))))));
assertThat(entries, isSortedAndWithinMax(2));
}
use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportResourceProviderIntegrationTest method shouldReturnSortedAndFilteredSearchResultsForPatientsAsJson.
@Test
public void shouldReturnSortedAndFilteredSearchResultsForPatientsAsJson() throws Exception {
MockHttpServletResponse response = get("/DiagnosticReport?patient.given=Collet&_sort=-_lastUpdated").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));
List<Bundle.BundleEntryComponent> entries = results.getEntry();
assertThat(entries, everyItem(hasResource(hasProperty("subject", hasProperty("reference", equalTo("Patient/5946f880-b197-400b-9caa-a3c661d23041"))))));
assertThat(entries, containsInRelativeOrder(hasResource(hasProperty("meta", hasProperty("lastUpdated", equalTo(Date.from(LocalDateTime.of(2018, 8, 18, 14, 9, 35).atZone(ZoneId.systemDefault()).toInstant()))))), hasResource(hasProperty("meta", hasProperty("lastUpdated", equalTo(Date.from(LocalDateTime.of(2008, 8, 18, 14, 9, 35).atZone(ZoneId.systemDefault()).toInstant())))))));
assertThat(entries, everyItem(hasResource(validResource())));
}
Aggregations