Search in sources :

Example 51 with Attachment

use of org.hl7.fhir.r4b.model.Attachment 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.r4.model.Reference) ArrayList(java.util.ArrayList) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) Attachment(org.hl7.fhir.r4.model.Attachment) RelatedArtifact(org.hl7.fhir.r4.model.RelatedArtifact)

Example 52 with Attachment

use of org.hl7.fhir.r4b.model.Attachment in project cqf-ruler by DBCG.

the class ActivityDefinitionApplyProvider method resolveCommunicationRequest.

private CommunicationRequest resolveCommunicationRequest(ActivityDefinition activityDefinition, String patientId) {
    CommunicationRequest communicationRequest = new CommunicationRequest();
    communicationRequest.setStatus(CommunicationRequest.CommunicationRequestStatus.UNKNOWN);
    communicationRequest.setSubject(new Reference(patientId));
    // Unsure if this is correct - this is the way Motive is doing it...
    if (activityDefinition.hasCode()) {
        if (activityDefinition.getCode().hasText()) {
            communicationRequest.addPayload().setContent(new StringType(activityDefinition.getCode().getText()));
        }
    }
    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());
                }
                CommunicationRequest.CommunicationRequestPayloadComponent payload = new CommunicationRequest.CommunicationRequestPayloadComponent();
                payload.setContent(artifact.hasDisplay() ? attachment.setTitle(artifact.getDisplay()) : attachment);
                communicationRequest.setPayload(Collections.singletonList(payload));
            }
        // TODO - other relatedArtifact types
        }
    }
    return communicationRequest;
}
Also used : StringType(org.hl7.fhir.r4.model.StringType) Reference(org.hl7.fhir.r4.model.Reference) Attachment(org.hl7.fhir.r4.model.Attachment) RelatedArtifact(org.hl7.fhir.r4.model.RelatedArtifact) CommunicationRequest(org.hl7.fhir.r4.model.CommunicationRequest)

Example 53 with Attachment

use of org.hl7.fhir.r4b.model.Attachment in project cqf-ruler by DBCG.

the class ActivityDefinitionApplyProvider method resolveTask.

private Task resolveTask(ActivityDefinition activityDefinition, String patientId) {
    Task task = new Task();
    task.setStatus(Task.TaskStatus.DRAFT);
    task.setIntent(Task.TaskIntent.PROPOSAL);
    task.setFor(new Reference(patientId));
    Task.ParameterComponent input = new Task.ParameterComponent();
    if (activityDefinition.hasCode()) {
        task.setCode(activityDefinition.getCode());
        input.setType(activityDefinition.getCode());
    }
    // Extension defined by CPG-on-FHIR for Questionnaire canonical URI
    Extension collectsWith = activityDefinition.getExtensionByUrl("http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-collectWith");
    if (collectsWith != null && collectsWith.getValueAsPrimitive().toString() != null) {
        CanonicalType uri = new CanonicalType(collectsWith.getValueAsPrimitive().toString());
        input.setValue(uri);
    }
    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());
                }
                input.setValue(artifact.hasDisplay() ? attachment.setTitle(artifact.getDisplay()) : attachment);
            }
        // TODO - other relatedArtifact types
        }
    }
    // If input has been populated, then add it to the Task.
    if (input.getType() != null || input.getValue() != null) {
        task.addInput(input);
    }
    return task;
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) Task(org.hl7.fhir.r4.model.Task) Reference(org.hl7.fhir.r4.model.Reference) Attachment(org.hl7.fhir.r4.model.Attachment) RelatedArtifact(org.hl7.fhir.r4.model.RelatedArtifact) CanonicalType(org.hl7.fhir.r4.model.CanonicalType)

Example 54 with Attachment

use of org.hl7.fhir.r4b.model.Attachment in project cqf-ruler by DBCG.

the class STU3CarePlanToCdsCard method convert.

private static List<CdsCard> convert(RequestGroup requestGroup) {
    List<CdsCard> cards = new ArrayList<>();
    // links
    List<CdsCard.Links> links = new ArrayList<>();
    if (requestGroup.hasExtension()) {
        for (Extension extension : requestGroup.getExtension()) {
            CdsCard.Links link = new CdsCard.Links();
            if (extension.getValue() instanceof Attachment) {
                Attachment attachment = (Attachment) extension.getValue();
                if (attachment.hasUrl()) {
                    link.setUrl(attachment.getUrl());
                }
                if (attachment.hasTitle()) {
                    link.setLabel(attachment.getTitle());
                }
                if (attachment.hasExtension()) {
                    link.setType(attachment.getExtensionFirstRep().getValue().primitiveValue());
                }
            } else {
                throw new RuntimeException("Invalid link extension type: " + extension.getValue().fhirType());
            }
            links.add(link);
        }
    }
    if (requestGroup.hasAction()) {
        for (RequestGroup.RequestGroupActionComponent action : requestGroup.getAction()) {
            IParser jsonParser = FhirContext.forCached(FhirVersionEnum.DSTU3).newJsonParser().setPrettyPrint(true);
            CdsCard card = new CdsCard(jsonParser);
            // basic
            if (action.hasTitle()) {
                card.setSummary(action.getTitle());
            }
            if (action.hasDescription()) {
                card.setDetail(action.getDescription());
            }
            if (action.hasExtension()) {
                card.setIndicator(action.getExtensionFirstRep().getValue().toString());
            }
            // source
            if (action.hasDocumentation()) {
                // Assuming first related artifact has everything
                RelatedArtifact documentation = action.getDocumentationFirstRep();
                CdsCard.Source source = new CdsCard.Source();
                if (documentation.hasDisplay()) {
                    source.setLabel(documentation.getDisplay());
                }
                if (documentation.hasUrl()) {
                    source.setUrl(documentation.getUrl());
                }
                if (documentation.hasDocument() && documentation.getDocument().hasUrl()) {
                    source.setIcon(documentation.getDocument().getUrl());
                }
                card.setSource(source);
            }
            if (action.hasSelectionBehavior()) {
                card.setSelectionBehavior(action.getSelectionBehavior().toCode());
            }
            // suggestions
            // TODO - uuid
            boolean hasSuggestions = false;
            CdsCard.Suggestions suggestions = new CdsCard.Suggestions();
            CdsCard.Suggestions.Action actions = new CdsCard.Suggestions.Action();
            if (action.hasLabel()) {
                suggestions.setLabel(action.getLabel());
                hasSuggestions = true;
                if (action.hasDescription()) {
                    actions.setDescription(action.getDescription());
                }
                if (action.hasType() && !action.getType().getCode().equals("fire-event")) {
                    String code = action.getType().getCode();
                    actions.setType(CdsCard.Suggestions.Action.ActionType.valueOf(code.equals("remove") ? "delete" : code));
                }
                if (action.hasResource()) {
                    if (actions.getType().name().equalsIgnoreCase("create")) {
                        action.getResourceTarget().setId((String) null);
                    }
                    actions.setResource(action.getResourceTarget());
                }
            }
            if (hasSuggestions) {
                suggestions.addAction(actions);
                card.addSuggestion(suggestions);
            }
            if (!links.isEmpty()) {
                card.setLinks(links);
            }
            cards.add(card);
        }
    }
    return cards;
}
Also used : ArrayList(java.util.ArrayList) Attachment(org.hl7.fhir.dstu3.model.Attachment) RelatedArtifact(org.hl7.fhir.dstu3.model.RelatedArtifact) Extension(org.hl7.fhir.dstu3.model.Extension) RequestGroup(org.hl7.fhir.dstu3.model.RequestGroup) IParser(ca.uhn.fhir.parser.IParser)

Example 55 with Attachment

use of org.hl7.fhir.r4b.model.Attachment in project beneficiary-fhir-data by CMSgov.

the class PartDEventTransformerV2Test method shouldHaveCtstrphcCvrgCdSupInfo.

@Test
public void shouldHaveCtstrphcCvrgCdSupInfo() {
    SupportingInformationComponent sic = TransformerTestUtilsV2.findSupportingInfoByCode("https://bluebutton.cms.gov/resources/variables/ctstrphc_cvrg_cd", eob.getSupportingInfo());
    SupportingInformationComponent compare = TransformerTestUtilsV2.createSupportingInfo(// We don't care what the sequence number is here
    sic.getSequence(), // Category
    Arrays.asList(new Coding("http://terminology.hl7.org/CodeSystem/claiminformationcategory", "info", "Information"), new Coding("https://bluebutton.cms.gov/resources/codesystem/information", "https://bluebutton.cms.gov/resources/variables/ctstrphc_cvrg_cd", "Catastrophic Coverage Code")), // Code
    new Coding("https://bluebutton.cms.gov/resources/variables/ctstrphc_cvrg_cd", "C", "Above attachment point"));
    assertTrue(compare.equalsDeep(sic));
}
Also used : SupportingInformationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent) Coding(org.hl7.fhir.r4.model.Coding) Test(org.junit.jupiter.api.Test)

Aggregations

Attachment (org.hl7.fhir.r4.model.Attachment)33 Reference (org.hl7.fhir.r4.model.Reference)17 ArrayList (java.util.ArrayList)16 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)16 NotImplementedException (org.apache.commons.lang3.NotImplementedException)14 Coding (org.hl7.fhir.r4.model.Coding)11 DiagnosticReport (org.hl7.fhir.r4.model.DiagnosticReport)10 List (java.util.List)9 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)9 DocumentReference (org.hl7.fhir.r4.model.DocumentReference)9 Observation (org.hl7.fhir.r4.model.Observation)9 Test (org.junit.jupiter.api.Test)9 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)8 Resource (org.hl7.fhir.r4.model.Resource)8 FhirContext (ca.uhn.fhir.context.FhirContext)5 HashMap (java.util.HashMap)5 Base64 (org.apache.commons.codec.binary.Base64)5 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)5 Extension (org.hl7.fhir.r4.model.Extension)5 Library (org.hl7.fhir.r4.model.Library)5