Search in sources :

Example 96 with Subject

use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project openmrs-module-fhir2 by openmrs.

the class ServiceRequestFhirResourceProviderIntegrationTest method shouldSearchForExistingServiceRequestsAsXML.

@Test
public void shouldSearchForExistingServiceRequestsAsXML() throws Exception {
    MockHttpServletResponse response = get("/ServiceRequest").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/ServiceRequest/"))));
    assertThat(entries, everyItem(hasResource(instanceOf(ServiceRequest.class))));
    assertThat(entries, everyItem(hasResource(validResource())));
    response = get("/ServiceRequest?patient.identifier=101-6&encounter=y403fafb-e5e4-42d0-9d11-4f52e89d123r").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(hasProperty("encounter", hasProperty("reference", endsWith(ENCOUNTER_UUID))))));
    assertThat(entries, everyItem(hasResource(validResource())));
}
Also used : Bundle(org.hl7.fhir.r4.model.Bundle) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) Test(org.junit.Test)

Example 97 with Subject

use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project openmrs-module-fhir2 by openmrs.

the class ServiceRequestFhirResourceProviderIntegrationTest method shouldSearchForExistingServiceRequestsAsJson.

@Test
public void shouldSearchForExistingServiceRequestsAsJson() throws Exception {
    MockHttpServletResponse response = get("/ServiceRequest").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/ServiceRequest/"))));
    assertThat(entries, everyItem(hasResource(instanceOf(ServiceRequest.class))));
    assertThat(entries, everyItem(hasResource(validResource())));
    response = get("/ServiceRequest?patient.identifier=101-6&encounter=y403fafb-e5e4-42d0-9d11-4f52e89d123r").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(hasProperty("encounter", hasProperty("reference", endsWith(ENCOUNTER_UUID))))));
    assertThat(entries, everyItem(hasResource(validResource())));
}
Also used : Bundle(org.hl7.fhir.r4.model.Bundle) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) Test(org.junit.Test)

Example 98 with Subject

use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method generateDocumentNarrative.

public XhtmlNode generateDocumentNarrative(Bundle feed) {
    /*
     When the document is presented for human consumption, applications must present the collated narrative portions of the following resources in order:
     * The Composition resource
     * The Subject resource
     * Resources referenced in the section.content
     */
    XhtmlNode root = new XhtmlNode(NodeType.Element, "div");
    Composition comp = (Composition) feed.getEntry().get(0).getResource();
    root.getChildNodes().add(comp.getText().getDiv());
    Resource subject = ResourceUtilities.getById(feed, null, comp.getSubject().getReference());
    if (subject != null && subject instanceof DomainResource) {
        root.addTag("hr");
        root.getChildNodes().add(((DomainResource) subject).getText().getDiv());
    }
    List<SectionComponent> sections = comp.getSection();
    renderSections(feed, root, sections, 1);
    return root;
}
Also used : Composition(org.hl7.fhir.dstu2.model.Composition) DomainResource(org.hl7.fhir.dstu2.model.DomainResource) Resource(org.hl7.fhir.dstu2.model.Resource) DomainResource(org.hl7.fhir.dstu2.model.DomainResource) SectionComponent(org.hl7.fhir.dstu2.model.Composition.SectionComponent) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 99 with Subject

use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeDocumentManifest.

protected void composeDocumentManifest(Complex parent, String parentType, String name, DocumentManifest element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "DocumentManifest", name, element, index);
    if (element.hasMasterIdentifier())
        composeIdentifier(t, "DocumentManifest", "masterIdentifier", element.getMasterIdentifier(), -1);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "DocumentManifest", "identifier", element.getIdentifier().get(i), i);
    if (element.hasSubject())
        composeReference(t, "DocumentManifest", "subject", element.getSubject(), -1);
    for (int i = 0; i < element.getRecipient().size(); i++) composeReference(t, "DocumentManifest", "recipient", element.getRecipient().get(i), i);
    if (element.hasType())
        composeCodeableConcept(t, "DocumentManifest", "type", element.getType(), -1);
    for (int i = 0; i < element.getAuthor().size(); i++) composeReference(t, "DocumentManifest", "author", element.getAuthor().get(i), i);
    if (element.hasCreatedElement())
        composeDateTime(t, "DocumentManifest", "created", element.getCreatedElement(), -1);
    if (element.hasSourceElement())
        composeUri(t, "DocumentManifest", "source", element.getSourceElement(), -1);
    if (element.hasStatusElement())
        composeEnum(t, "DocumentManifest", "status", element.getStatusElement(), -1);
    if (element.hasDescriptionElement())
        composeString(t, "DocumentManifest", "description", element.getDescriptionElement(), -1);
    for (int i = 0; i < element.getContent().size(); i++) composeDocumentManifestDocumentManifestContentComponent(t, "DocumentManifest", "content", element.getContent().get(i), i);
    for (int i = 0; i < element.getRelated().size(); i++) composeDocumentManifestDocumentManifestRelatedComponent(t, "DocumentManifest", "related", element.getRelated().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 100 with Subject

use of org.hl7.fhir.utilities.turtle.Turtle.Subject in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeAccount.

protected void composeAccount(Complex parent, String parentType, String name, Account element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "Account", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "Account", "identifier", element.getIdentifier().get(i), i);
    if (element.hasNameElement())
        composeString(t, "Account", "name", element.getNameElement(), -1);
    if (element.hasType())
        composeCodeableConcept(t, "Account", "type", element.getType(), -1);
    if (element.hasStatusElement())
        composeEnum(t, "Account", "status", element.getStatusElement(), -1);
    if (element.hasActivePeriod())
        composePeriod(t, "Account", "activePeriod", element.getActivePeriod(), -1);
    if (element.hasCurrency())
        composeCoding(t, "Account", "currency", element.getCurrency(), -1);
    if (element.hasBalance())
        composeQuantity(t, "Account", "balance", element.getBalance(), -1);
    if (element.hasCoveragePeriod())
        composePeriod(t, "Account", "coveragePeriod", element.getCoveragePeriod(), -1);
    if (element.hasSubject())
        composeReference(t, "Account", "subject", element.getSubject(), -1);
    if (element.hasOwner())
        composeReference(t, "Account", "owner", element.getOwner(), -1);
    if (element.hasDescriptionElement())
        composeString(t, "Account", "description", element.getDescriptionElement(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

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