Search in sources :

Example 91 with Subject

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

Example 92 with Subject

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

Example 93 with Subject

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))))));
}
Also used : Bundle(org.hl7.fhir.dstu3.model.Bundle) Encounter(org.hl7.fhir.dstu3.model.Encounter) Matchers.containsString(org.hamcrest.Matchers.containsString) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Example 94 with Subject

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())));
}
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 95 with Subject

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())));
}
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)

Aggregations

Test (org.junit.Test)124 Test (org.junit.jupiter.api.Test)68 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)64 Bundle (org.hl7.fhir.r4.model.Bundle)56 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)54 Parameters (org.hl7.fhir.r4.model.Parameters)46 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)43 RestIntegrationTest (org.opencds.cqf.ruler.test.RestIntegrationTest)42 StringType (org.hl7.fhir.r4.model.StringType)41 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)39 Observation (org.hl7.fhir.r4.model.Observation)38 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)37 Bundle (org.hl7.fhir.dstu3.model.Bundle)35 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)32 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)32 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)31 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)31 Patient (org.hl7.fhir.r4.model.Patient)30 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)30 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)29