use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestFhirResourceProviderIntegrationTest method shouldSearchForExistingMedicationRequestsAsJson.
@Test
public void shouldSearchForExistingMedicationRequestsAsJson() throws Exception {
MockHttpServletResponse response = get("/MedicationRequest").accept(BaseFhirIntegrationTest.FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(BaseFhirIntegrationTest.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/R3/MedicationRequest/"))));
assertThat(entries, everyItem(hasResource(instanceOf(MedicationRequest.class))));
assertThat(entries, everyItem(hasResource(validResource())));
response = get("/MedicationRequest?patient.identifier=MO-2").accept(BaseFhirIntegrationTest.FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(BaseFhirIntegrationTest.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.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestFhirResourceProviderIntegrationTest method shouldReturnCountForMedicationRequestAsJson.
@Test
public void shouldReturnCountForMedicationRequestAsJson() throws Exception {
MockHttpServletResponse response = get("/MedicationRequest?_summary=count").accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.JSON.toString()));
assertThat(response.getContentAsString(), notNullValue());
Bundle result = readBundleResponse(response);
assertThat(result, notNullValue());
assertThat(result.getType(), equalTo(Bundle.BundleType.SEARCHSET));
assertThat(result, hasProperty("total", equalTo(13)));
}
use of org.hl7.fhir.r4.model.MedicationRequest 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.r4.model.MedicationRequest 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())));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestFhirResourceProviderIntegrationTest method shouldReturnExistingMedicationRequestAsXML.
@Test
public void shouldReturnExistingMedicationRequestAsXML() throws Exception {
MockHttpServletResponse response = get("/MedicationRequest/" + MEDICATION_REQUEST_UUID).accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.toString()));
assertThat(response.getContentAsString(), notNullValue());
MedicationRequest medicationRequest = readResponse(response);
assertThat(medicationRequest, notNullValue());
assertThat(medicationRequest.getIdElement().getIdPart(), equalTo(MEDICATION_REQUEST_UUID));
assertThat(medicationRequest, validResource());
}
Aggregations