use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project openmrs-module-fhir2 by openmrs.
the class EncounterFhirResourceProviderIntegrationTest method shouldSearchForEncountersByPatientGivenNameAsJson.
@Test
public void shouldSearchForEncountersByPatientGivenNameAsJson() throws Exception {
String uri = String.format("/Encounter/?subject.given=%s", PATIENT_GIVEN_NAME);
MockHttpServletResponse response = get(uri).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.isEmpty(), not(true));
assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R4/Encounter"))));
assertThat(entries, everyItem(hasResource(instanceOf(Encounter.class))));
assertThat(entries, everyItem(hasResource(validResource())));
assertThat(entries, everyItem(hasResource(hasProperty("subject", hasProperty("display", containsString(PATIENT_GIVEN_NAME))))));
}
use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project openmrs-module-fhir2 by openmrs.
the class DiagnosticReportResourceProviderIntegrationTest method shouldReturnSortedAndFilteredSearchResultsForPatientsAsXML.
@Test
public void shouldReturnSortedAndFilteredSearchResultsForPatientsAsXML() throws Exception {
MockHttpServletResponse response = get("/DiagnosticReport?patient.given=Collet&_sort=-_lastUpdated").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));
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())));
}
use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project openmrs-module-fhir2 by openmrs.
the class EncounterFhirResourceProviderIntegrationTest method shouldSearchForEncountersByPatientIdAsXml.
@Test
public void shouldSearchForEncountersByPatientIdAsXml() throws Exception {
String uri = String.format("/Encounter?subject:Patient=%s", PATIENT_UUID);
MockHttpServletResponse response = get(uri).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));
List<Bundle.BundleEntryComponent> entries = results.getEntry();
assertThat(entries.isEmpty(), not(true));
assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R3/Encounter"))));
assertThat(entries, everyItem(hasResource(instanceOf(Encounter.class))));
assertThat(entries, everyItem(hasResource(validResource())));
assertThat(entries, everyItem(hasResource(hasProperty("subject", hasProperty("reference", equalTo("Patient/" + PATIENT_UUID))))));
}
use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestFhirResourceProviderIntegrationTest method shouldSearchForExistingMedicationRequestsAsJson.
@Test
public void shouldSearchForExistingMedicationRequestsAsJson() throws Exception {
MockHttpServletResponse response = get("/MedicationRequest").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(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R4/MedicationRequest/"))));
assertThat(entries, everyItem(hasResource(instanceOf(MedicationRequest.class))));
assertThat(entries, everyItem(hasResource(validResource())));
response = get("/MedicationRequest?patient.identifier=MO-2").accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());
results = readBundleResponse(response);
assertThat(results, notNullValue());
assertThat(results.getType(), equalTo(Bundle.BundleType.SEARCHSET));
assertThat(results.hasEntry(), is(true));
entries = results.getEntry();
assertThat(entries, everyItem(hasResource(hasProperty("subject", hasProperty("reference", endsWith(PATIENT_UUID))))));
assertThat(entries, everyItem(hasResource(validResource())));
}
use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestFhirResourceProviderIntegrationTest method shouldSearchForExistingMedicationRequestsAsXML.
@Test
public void shouldSearchForExistingMedicationRequestsAsXML() throws Exception {
MockHttpServletResponse response = get("/MedicationRequest").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));
List<Bundle.BundleEntryComponent> entries = results.getEntry();
assertThat(entries, everyItem(hasProperty("fullUrl", startsWith("http://localhost/ws/fhir2/R4/MedicationRequest/"))));
assertThat(entries, everyItem(hasResource(instanceOf(MedicationRequest.class))));
assertThat(entries, everyItem(hasResource(validResource())));
response = get("/MedicationRequest?patient.identifier=MO-2").accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
results = readBundleResponse(response);
assertThat(results, notNullValue());
assertThat(results.getType(), equalTo(Bundle.BundleType.SEARCHSET));
assertThat(results.hasEntry(), is(true));
entries = results.getEntry();
assertThat(entries, everyItem(hasResource(hasProperty("subject", hasProperty("reference", endsWith(PATIENT_UUID))))));
assertThat(entries, everyItem(hasResource(validResource())));
}
Aggregations