Search in sources :

Example 6 with RelatedArtifact

use of org.hl7.fhir.r4.model.RelatedArtifact in project cqf-ruler by DBCG.

the class ActivityDefinitionApplyProvider method resolveDiagnosticReport.

private DiagnosticReport resolveDiagnosticReport(ActivityDefinition activityDefinition, String patientId) {
    DiagnosticReport diagnosticReport = new DiagnosticReport();
    diagnosticReport.setStatus(DiagnosticReport.DiagnosticReportStatus.UNKNOWN);
    diagnosticReport.setSubject(new Reference(patientId));
    if (activityDefinition.hasCode()) {
        diagnosticReport.setCode(activityDefinition.getCode());
    } else {
        throw new ActivityDefinitionApplyException("Missing required ActivityDefinition.code property for DiagnosticReport");
    }
    if (activityDefinition.hasRelatedArtifact()) {
        List<Attachment> presentedFormAttachments = new ArrayList<>();
        for (RelatedArtifact artifact : activityDefinition.getRelatedArtifact()) {
            Attachment attachment = new Attachment();
            if (artifact.hasUrl()) {
                attachment.setUrl(artifact.getUrl());
            }
            if (artifact.hasDisplay()) {
                attachment.setTitle(artifact.getDisplay());
            }
            presentedFormAttachments.add(attachment);
        }
        diagnosticReport.setPresentedForm(presentedFormAttachments);
    }
    return diagnosticReport;
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) ArrayList(java.util.ArrayList) DiagnosticReport(org.hl7.fhir.dstu3.model.DiagnosticReport) Attachment(org.hl7.fhir.dstu3.model.Attachment) RelatedArtifact(org.hl7.fhir.dstu3.model.RelatedArtifact)

Example 7 with RelatedArtifact

use of org.hl7.fhir.r4.model.RelatedArtifact in project cqf-ruler by DBCG.

the class ActivityDefinitionApplyProvider method resolveCommunication.

private Communication resolveCommunication(ActivityDefinition activityDefinition, String patientId) {
    Communication communication = new Communication();
    communication.setStatus(Communication.CommunicationStatus.UNKNOWN);
    communication.setSubject(new Reference(patientId));
    if (activityDefinition.hasCode()) {
        communication.setReasonCode(Collections.singletonList(activityDefinition.getCode()));
    }
    if (activityDefinition.hasRelatedArtifact()) {
        for (RelatedArtifact artifact : activityDefinition.getRelatedArtifact()) {
            if (artifact.hasUrl()) {
                Attachment attachment = new Attachment().setUrl(artifact.getUrl());
                if (artifact.hasDisplay()) {
                    attachment.setTitle(artifact.getDisplay());
                }
                Communication.CommunicationPayloadComponent payload = new Communication.CommunicationPayloadComponent();
                payload.setContent(artifact.hasDisplay() ? attachment.setTitle(artifact.getDisplay()) : attachment);
                communication.setPayload(Collections.singletonList(payload));
            }
        // TODO - other relatedArtifact types
        }
    }
    return communication;
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) Attachment(org.hl7.fhir.dstu3.model.Attachment) RelatedArtifact(org.hl7.fhir.dstu3.model.RelatedArtifact) Communication(org.hl7.fhir.dstu3.model.Communication)

Example 8 with RelatedArtifact

use of org.hl7.fhir.r4.model.RelatedArtifact in project cqf-ruler by DBCG.

the class ActivityDefinitionApplyProvider method resolveCommunication.

private Communication resolveCommunication(ActivityDefinition activityDefinition, String patientId) {
    Communication communication = new Communication();
    communication.setStatus(Communication.CommunicationStatus.UNKNOWN);
    communication.setSubject(new Reference(patientId));
    if (activityDefinition.hasCode()) {
        communication.setReasonCode(Collections.singletonList(activityDefinition.getCode()));
    }
    if (activityDefinition.hasRelatedArtifact()) {
        for (RelatedArtifact artifact : activityDefinition.getRelatedArtifact()) {
            if (artifact.hasUrl()) {
                Attachment attachment = new Attachment().setUrl(artifact.getUrl());
                if (artifact.hasDisplay()) {
                    attachment.setTitle(artifact.getDisplay());
                }
                Communication.CommunicationPayloadComponent payload = new Communication.CommunicationPayloadComponent();
                payload.setContent(artifact.hasDisplay() ? attachment.setTitle(artifact.getDisplay()) : attachment);
                communication.setPayload(Collections.singletonList(payload));
            }
        // TODO - other relatedArtifact types
        }
    }
    return communication;
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) Attachment(org.hl7.fhir.r4.model.Attachment) RelatedArtifact(org.hl7.fhir.r4.model.RelatedArtifact) Communication(org.hl7.fhir.r4.model.Communication)

Example 9 with RelatedArtifact

use of org.hl7.fhir.r4.model.RelatedArtifact in project quality-measure-and-cohort-service by Alvearie.

the class CohortCLITest method testCQLTranslationCustomIGWithTargetUrl.

@Test
public void testCQLTranslationCustomIGWithTargetUrl() throws Exception {
    FhirServerConfig fhirConfig = getFhirServerConfig();
    mockFhirResourceRetrieval("/metadata?_format=json", getCapabilityStatement());
    Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, "1978-05-06");
    patient.addExtension(new Extension("http://fakeIg.com/fake-extension", new StringType("fakeValue")));
    mockFhirResourceRetrieval(patient);
    Library root = getLibrary("test", DEFAULT_RESOURCE_VERSION, "cql/ig-test/Test-1.0.0.cql");
    Library helpers = getLibrary("FHIRHelpers", "4.0.0", "cql/fhir-helpers/FHIRHelpers.cql", "text/cql", "cql/fhir-helpers/FHIRHelpers.xml", "application/elm+json");
    RelatedArtifact related = new RelatedArtifact();
    related.setType(RelatedArtifactType.DEPENDSON);
    related.setResource("/Library/" + helpers.getId());
    root.addRelatedArtifact(related);
    mockFhirResourceRetrieval(root);
    mockFhirSingletonBundleRetrieval(helpers);
    File tmpFile = new File("target/fhir-stub.json");
    ObjectMapper om = new ObjectMapper();
    try (Writer w = new FileWriter(tmpFile)) {
        w.write(om.writeValueAsString(fhirConfig));
    }
    try {
        PrintStream originalOut = System.out;
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try (PrintStream captureOut = new PrintStream(baos)) {
            System.setOut(captureOut);
            CohortCLI.main(new String[] { "-d", tmpFile.getAbsolutePath(), "-f", root.getId(), "-l", root.getName(), "-v", root.getVersion(), "-c", patient.getId(), "-s", "CQL", "-i", "src/test/resources/modelinfo/ig-with-target-modelinfo-0.0.1.xml" });
        } finally {
            System.setOut(originalOut);
        }
        String output = new String(baos.toByteArray());
        System.out.println(output);
        verify(1, getRequestedFor(urlEqualTo("/Patient/" + patient.getId() + "?_format=json")));
        verify(1, getRequestedFor(urlEqualTo("/Library/" + root.getId() + "?_format=json")));
        verify(1, getRequestedFor(urlEqualTo("/Library?url=%2FLibrary%2F" + helpers.getId() + "&_format=json")));
    } finally {
        tmpFile.delete();
    }
}
Also used : PrintStream(java.io.PrintStream) StringType(org.hl7.fhir.r4.model.StringType) FileWriter(java.io.FileWriter) Patient(org.hl7.fhir.r4.model.Patient) ByteArrayOutputStream(java.io.ByteArrayOutputStream) RelatedArtifact(org.hl7.fhir.r4.model.RelatedArtifact) Extension(org.hl7.fhir.r4.model.Extension) FhirServerConfig(com.ibm.cohort.fhir.client.config.FhirServerConfig) Library(org.hl7.fhir.r4.model.Library) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) FileWriter(java.io.FileWriter) Writer(java.io.Writer) Test(org.junit.Test)

Example 10 with RelatedArtifact

use of org.hl7.fhir.r4.model.RelatedArtifact in project quality-measure-and-cohort-service by Alvearie.

the class R4LibraryDependencyGathererTest method withRelation.

private void withRelation(Library library, String relatedUrl) {
    RelatedArtifact relation = new RelatedArtifact().setType(RelatedArtifact.RelatedArtifactType.DEPENDSON).setResource(relatedUrl);
    library.addRelatedArtifact(relation);
}
Also used : RelatedArtifact(org.hl7.fhir.r4.model.RelatedArtifact)

Aggregations

RelatedArtifact (org.hl7.fhir.r4.model.RelatedArtifact)13 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)13 ArrayList (java.util.ArrayList)7 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)7 RelatedArtifact (org.hl7.fhir.dstu3.model.RelatedArtifact)6 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)6 Attachment (org.hl7.fhir.r4.model.Attachment)5 IParser (ca.uhn.fhir.parser.IParser)4 Extension (org.hl7.fhir.r4.model.Extension)4 Library (org.hl7.fhir.r4.model.Library)4 RelatedArtifact (org.hl7.fhir.r5.model.RelatedArtifact)4 Attachment (org.hl7.fhir.dstu3.model.Attachment)3 Reference (org.hl7.fhir.r4.model.Reference)3 FhirContext (ca.uhn.fhir.context.FhirContext)2 IdDt (ca.uhn.fhir.model.primitive.IdDt)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 FhirServerConfig (com.ibm.cohort.fhir.client.config.FhirServerConfig)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 File (java.io.File)2 FileWriter (java.io.FileWriter)2