use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestFhirResourceProviderWebTest method getMedicationRequestByUuid_shouldReturnMedication.
@Test
public void getMedicationRequestByUuid_shouldReturnMedication() throws Exception {
MedicationRequest medicationRequest = new MedicationRequest();
medicationRequest.setId(MEDICATION_REQUEST_UUID);
when(fhirMedicationRequestService.get(MEDICATION_REQUEST_UUID)).thenReturn(medicationRequest);
MockHttpServletResponse response = get("/MedicationRequest/" + MEDICATION_REQUEST_UUID).accept(FhirMediaTypes.JSON).go();
assertThat(response, isOk());
assertThat(response.getContentType(), equalTo(FhirMediaTypes.JSON.toString()));
assertThat(readResponse(response).getIdElement().getIdPart(), equalTo(MEDICATION_REQUEST_UUID));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestNarrativeTest method shouldGenerateMedicationRequestNarrative.
/**
* Check that the expected narrative is generated for some example MedicationRequest resource
*
* @throws IOException
*/
@Test
public void shouldGenerateMedicationRequestNarrative() throws IOException {
MedicationRequest given = parser.parseResource(MedicationRequest.class, getClass().getClassLoader().getResourceAsStream(EXAMPLE_RESOURCE_PATH));
MedicationRequest result = parser.parseResource(MedicationRequest.class, parser.encodeResourceToString(given));
assertThat(result, notNullValue());
assertThat(result.getText(), notNullValue());
assertThat(result.getText().getStatusAsString(), equalTo("generated"));
assertThat(result.getText().getDivAsString(), equalTo(readNarrativeFile(EXPECTED_NARRATIVE_PATH)));
}
use of org.hl7.fhir.r4.model.MedicationRequest in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestFhirResourceProviderIntegrationTest method shouldReturnCountForMedicationRequestAsXml.
@Test
public void shouldReturnCountForMedicationRequestAsXml() throws Exception {
MockHttpServletResponse response = get("/MedicationRequest?_summary=count").accept(FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(FhirMediaTypes.XML.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 shouldSearchForExistingMedicationRequestsAsXML.
@Test
public void shouldSearchForExistingMedicationRequestsAsXML() throws Exception {
MockHttpServletResponse response = get("/MedicationRequest").accept(BaseFhirIntegrationTest.FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(BaseFhirIntegrationTest.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/R3/MedicationRequest/"))));
assertThat(entries, everyItem(hasResource(instanceOf(MedicationRequest.class))));
assertThat(entries, everyItem(hasResource(validResource())));
response = get("/MedicationRequest?patient.identifier=MO-2").accept(BaseFhirIntegrationTest.FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(BaseFhirIntegrationTest.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(BaseFhirIntegrationTest.FhirMediaTypes.XML).go();
assertThat(response, isOk());
assertThat(response.getContentType(), is(BaseFhirIntegrationTest.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