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