Search in sources :

Example 96 with MedicationRequest

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())));
}
Also used : MedicationRequest(org.hl7.fhir.dstu3.model.MedicationRequest) Bundle(org.hl7.fhir.dstu3.model.Bundle) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test) BaseFhirIntegrationTest(org.openmrs.module.fhir2.BaseFhirIntegrationTest)

Example 97 with MedicationRequest

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)));
}
Also used : Bundle(org.hl7.fhir.dstu3.model.Bundle) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test) BaseFhirIntegrationTest(org.openmrs.module.fhir2.BaseFhirIntegrationTest)

Example 98 with MedicationRequest

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())));
}
Also used : MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) Bundle(org.hl7.fhir.r4.model.Bundle) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 99 with MedicationRequest

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())));
}
Also used : MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) Bundle(org.hl7.fhir.r4.model.Bundle) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 100 with MedicationRequest

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());
}
Also used : MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Aggregations

MedicationRequest (org.hl7.fhir.r4.model.MedicationRequest)128 Test (org.junit.Test)128 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)78 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)58 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)48 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)44 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)44 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)44 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)36 Test (org.junit.jupiter.api.Test)35 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)33 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)33 Resource (org.hl7.fhir.r4.model.Resource)31 MedicationRequest (org.hl7.fhir.dstu3.model.MedicationRequest)26 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)23 TokenParam (ca.uhn.fhir.rest.param.TokenParam)23 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)23 ArrayList (java.util.ArrayList)19 Include (ca.uhn.fhir.model.api.Include)15 HashSet (java.util.HashSet)15