Search in sources :

Example 56 with Attachment

use of org.hl7.fhir.r4.model.Attachment in project synthea by synthetichealth.

the class FhirStu3 method media.

/**
 * Map the given Media element to a FHIR Media resource, and add it to the given Bundle.
 *
 * @param rand Source of randomness to use when generating ids etc
 * @param personEntry    The Entry for the Person
 * @param bundle         Bundle to add the Media to
 * @param encounterEntry Current Encounter entry
 * @param obs   The Observation to map to FHIR and add to the bundle
 * @return The added Entry
 */
private static BundleEntryComponent media(RandomNumberGenerator rand, BundleEntryComponent personEntry, Bundle bundle, BundleEntryComponent encounterEntry, Observation obs) {
    org.hl7.fhir.dstu3.model.Media mediaResource = new org.hl7.fhir.dstu3.model.Media();
    if (obs.codes != null && obs.codes.size() > 0) {
        List<CodeableConcept> reasonList = obs.codes.stream().map(code -> mapCodeToCodeableConcept(code, SNOMED_URI)).collect(Collectors.toList());
        mediaResource.setReasonCode(reasonList);
    }
    // Hard code as an image
    mediaResource.setType(DigitalMediaType.PHOTO);
    mediaResource.setSubject(new Reference(personEntry.getFullUrl()));
    Attachment content = (Attachment) obs.value;
    org.hl7.fhir.dstu3.model.Attachment contentResource = new org.hl7.fhir.dstu3.model.Attachment();
    contentResource.setContentType(content.contentType);
    contentResource.setLanguage(content.language);
    if (content.data != null) {
        contentResource.setDataElement(new org.hl7.fhir.dstu3.model.Base64BinaryType(content.data));
    }
    contentResource.setUrl(content.url);
    contentResource.setSize(content.size);
    contentResource.setTitle(content.title);
    if (content.hash != null) {
        contentResource.setHashElement(new org.hl7.fhir.dstu3.model.Base64BinaryType(content.hash));
    }
    mediaResource.setWidth(content.width);
    mediaResource.setHeight(content.height);
    mediaResource.setContent(contentResource);
    return newEntry(rand, bundle, mediaResource);
}
Also used : MedicationAdministrationDosageComponent(org.hl7.fhir.dstu3.model.MedicationAdministration.MedicationAdministrationDosageComponent) Type(org.hl7.fhir.dstu3.model.Type) MedicationAdministration(org.hl7.fhir.dstu3.model.MedicationAdministration) Identifier(org.hl7.fhir.dstu3.model.Identifier) Coding(org.hl7.fhir.dstu3.model.Coding) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) HashBasedTable(com.google.common.collect.HashBasedTable) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) GoalStatus(org.hl7.fhir.dstu3.model.Goal.GoalStatus) MedicationAdministrationStatus(org.hl7.fhir.dstu3.model.MedicationAdministration.MedicationAdministrationStatus) Medication(org.mitre.synthea.world.concepts.HealthRecord.Medication) BigDecimal(java.math.BigDecimal) FhirContext(ca.uhn.fhir.context.FhirContext) DiagnosticReport(org.hl7.fhir.dstu3.model.DiagnosticReport) InstanceAvailability(org.hl7.fhir.dstu3.model.ImagingStudy.InstanceAvailability) Person(org.mitre.synthea.world.agents.Person) DigitalMediaType(org.hl7.fhir.dstu3.model.Media.DigitalMediaType) Map(java.util.Map) PatientCommunicationComponent(org.hl7.fhir.dstu3.model.Patient.PatientCommunicationComponent) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) TimingRepeatComponent(org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent) Coverage(org.hl7.fhir.dstu3.model.Coverage) RandomNumberGenerator(org.mitre.synthea.helpers.RandomNumberGenerator) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) Reference(org.hl7.fhir.dstu3.model.Reference) HTTPVerb(org.hl7.fhir.dstu3.model.Bundle.HTTPVerb) HealthRecord(org.mitre.synthea.world.concepts.HealthRecord) Utilities(org.mitre.synthea.helpers.Utilities) ImagingStudySeriesInstanceComponent(org.hl7.fhir.dstu3.model.ImagingStudy.ImagingStudySeriesInstanceComponent) ContactPointSystem(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem) EncounterType(org.mitre.synthea.world.concepts.HealthRecord.EncounterType) ConditionClinicalStatus(org.hl7.fhir.dstu3.model.Condition.ConditionClinicalStatus) Device(org.hl7.fhir.dstu3.model.Device) CodeType(org.hl7.fhir.dstu3.model.CodeType) Money(org.hl7.fhir.dstu3.model.Money) ReferralRequest(org.hl7.fhir.dstu3.model.ReferralRequest) IntegerType(org.hl7.fhir.dstu3.model.IntegerType) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) SupplyDeliveryStatus(org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliveryStatus) Calendar(java.util.Calendar) Period(org.hl7.fhir.dstu3.model.Period) PositiveIntType(org.hl7.fhir.dstu3.model.PositiveIntType) EncounterHospitalizationComponent(org.hl7.fhir.dstu3.model.Encounter.EncounterHospitalizationComponent) SupplyDelivery(org.hl7.fhir.dstu3.model.SupplyDelivery) Procedure(org.mitre.synthea.world.concepts.HealthRecord.Procedure) Practitioner(org.hl7.fhir.dstu3.model.Practitioner) SimpleQuantity(org.hl7.fhir.dstu3.model.SimpleQuantity) ImagingStudy(org.mitre.synthea.world.concepts.HealthRecord.ImagingStudy) IOException(java.io.IOException) Dosage(org.hl7.fhir.dstu3.model.Dosage) Claim(org.mitre.synthea.world.concepts.Claim) SpecialConditionComponent(org.hl7.fhir.dstu3.model.Claim.SpecialConditionComponent) Basic(org.hl7.fhir.dstu3.model.Basic) Patient(org.hl7.fhir.dstu3.model.Patient) MedicationRequestIntent(org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestIntent) UnitsOfTime(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime) JsonObject(com.google.gson.JsonObject) Attachment(org.mitre.synthea.engine.Components.Attachment) NodeType(org.hl7.fhir.utilities.xhtml.NodeType) Point2D(java.awt.geom.Point2D) Bundle(org.hl7.fhir.dstu3.model.Bundle) Date(java.util.Date) BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) Costs(org.mitre.synthea.world.concepts.Costs) Extension(org.hl7.fhir.dstu3.model.Extension) DiagnosticReportStatus(org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus) Organization(org.hl7.fhir.dstu3.model.Organization) ImagingStudySeriesComponent(org.hl7.fhir.dstu3.model.ImagingStudy.ImagingStudySeriesComponent) Gson(com.google.gson.Gson) Components(org.mitre.synthea.engine.Components) ObservationComponentComponent(org.hl7.fhir.dstu3.model.Observation.ObservationComponentComponent) StringType(org.hl7.fhir.dstu3.model.StringType) MedicationRequestRequesterComponent(org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestRequesterComponent) Address(org.hl7.fhir.dstu3.model.Address) ImmunizationStatus(org.hl7.fhir.dstu3.model.Immunization.ImmunizationStatus) Report(org.mitre.synthea.world.concepts.HealthRecord.Report) CarePlanActivityDetailComponent(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityDetailComponent) Collectors(java.util.stream.Collectors) CarePlanStatus(org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus) Quantity(org.hl7.fhir.dstu3.model.Quantity) ConditionVerificationStatus(org.hl7.fhir.dstu3.model.Condition.ConditionVerificationStatus) AdministrativeGender(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender) List(java.util.List) CarePlanActivityStatus(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus) ProcedureStatus(org.hl7.fhir.dstu3.model.Procedure.ProcedureStatus) EncounterStatus(org.hl7.fhir.dstu3.model.Encounter.EncounterStatus) AllergyIntoleranceCategory(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCategory) BooleanType(org.hl7.fhir.dstu3.model.BooleanType) ContactPoint(org.hl7.fhir.dstu3.model.ContactPoint) DateType(org.hl7.fhir.dstu3.model.DateType) CarePlanActivityComponent(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityComponent) SimpleCSV(org.mitre.synthea.helpers.SimpleCSV) MedicationRequestStatus(org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestStatus) MedicationRequest(org.hl7.fhir.dstu3.model.MedicationRequest) Clinician(org.mitre.synthea.world.agents.Clinician) HashMap(java.util.HashMap) ItemComponent(org.hl7.fhir.dstu3.model.Claim.ItemComponent) JsonElement(com.google.gson.JsonElement) Immunization(org.hl7.fhir.dstu3.model.Immunization) Meta(org.hl7.fhir.dstu3.model.Meta) ObservationStatus(org.hl7.fhir.dstu3.model.Observation.ObservationStatus) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) CarePlan(org.mitre.synthea.world.concepts.HealthRecord.CarePlan) SupplyDeliverySuppliedItemComponent(org.hl7.fhir.dstu3.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent) AllergyIntoleranceCriticality(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceCriticality) CarePlanIntent(org.hl7.fhir.dstu3.model.CarePlan.CarePlanIntent) ProcedureComponent(org.hl7.fhir.dstu3.model.Claim.ProcedureComponent) FHIRDeviceStatus(org.hl7.fhir.dstu3.model.Device.FHIRDeviceStatus) Config(org.mitre.synthea.helpers.Config) DateTimeType(org.hl7.fhir.dstu3.model.DateTimeType) AllergyIntolerance(org.hl7.fhir.dstu3.model.AllergyIntolerance) Resource(org.hl7.fhir.dstu3.model.Resource) BundleType(org.hl7.fhir.dstu3.model.Bundle.BundleType) BundleEntryRequestComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryRequestComponent) Condition(org.hl7.fhir.dstu3.model.Condition) DecimalType(org.hl7.fhir.dstu3.model.DecimalType) Payer(org.mitre.synthea.world.agents.Payer) NarrativeStatus(org.hl7.fhir.dstu3.model.Narrative.NarrativeStatus) ContactComponent(org.hl7.fhir.dstu3.model.Patient.ContactComponent) ClaimStatus(org.hl7.fhir.dstu3.model.Claim.ClaimStatus) Provider(org.mitre.synthea.world.agents.Provider) AllergyIntoleranceVerificationStatus(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceVerificationStatus) AllergyIntoleranceClinicalStatus(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceClinicalStatus) Observation(org.mitre.synthea.world.concepts.HealthRecord.Observation) Narrative(org.hl7.fhir.dstu3.model.Narrative) AllergyIntoleranceType(org.hl7.fhir.dstu3.model.AllergyIntolerance.AllergyIntoleranceType) ContactPointUse(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse) Timing(org.hl7.fhir.dstu3.model.Timing) Table(com.google.common.collect.Table) HumanName(org.hl7.fhir.dstu3.model.HumanName) Property(org.hl7.fhir.dstu3.model.Property) Reference(org.hl7.fhir.dstu3.model.Reference) Attachment(org.mitre.synthea.engine.Components.Attachment) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 57 with Attachment

use of org.hl7.fhir.r4.model.Attachment in project synthea by synthetichealth.

the class FhirStu3 method convertToFHIR.

/**
 * Convert the given Person into a FHIR Bundle, containing the Patient and the
 * associated entries from their health record.
 *
 * @param person Person to generate the FHIR from
 * @param stopTime Time the simulation ended
 * @return FHIR Bundle containing the Person's health record.
 */
public static Bundle convertToFHIR(Person person, long stopTime) {
    Bundle bundle = new Bundle();
    if (TRANSACTION_BUNDLE) {
        bundle.setType(BundleType.TRANSACTION);
    } else {
        bundle.setType(BundleType.COLLECTION);
    }
    BundleEntryComponent personEntry = basicInfo(person, bundle, stopTime);
    for (Encounter encounter : person.record.encounters) {
        BundleEntryComponent encounterEntry = encounter(person, personEntry, bundle, encounter);
        for (HealthRecord.Entry condition : encounter.conditions) {
            condition(person, personEntry, bundle, encounterEntry, condition);
        }
        for (HealthRecord.Entry allergy : encounter.allergies) {
            allergy(person, personEntry, bundle, encounterEntry, allergy);
        }
        for (Observation observation : encounter.observations) {
            // Observation resources in stu3 don't support Attachments
            if (observation.value instanceof Attachment) {
                media(person, personEntry, bundle, encounterEntry, observation);
            } else {
                observation(person, personEntry, bundle, encounterEntry, observation);
            }
        }
        for (Procedure procedure : encounter.procedures) {
            procedure(person, personEntry, bundle, encounterEntry, procedure);
        }
        for (Medication medication : encounter.medications) {
            medication(person, personEntry, bundle, encounterEntry, medication);
        }
        for (HealthRecord.Entry immunization : encounter.immunizations) {
            immunization(person, personEntry, bundle, encounterEntry, immunization);
        }
        for (Report report : encounter.reports) {
            report(person, personEntry, bundle, encounterEntry, report);
        }
        for (CarePlan careplan : encounter.careplans) {
            careplan(person, personEntry, bundle, encounterEntry, careplan);
        }
        for (ImagingStudy imagingStudy : encounter.imagingStudies) {
            imagingStudy(person, personEntry, bundle, encounterEntry, imagingStudy);
        }
        for (HealthRecord.Device device : encounter.devices) {
            device(person, personEntry, bundle, device);
        }
        for (HealthRecord.Supply supply : encounter.supplies) {
            supplyDelivery(person, personEntry, bundle, supply, encounter);
        }
        // one claim per encounter
        BundleEntryComponent encounterClaim = encounterClaim(person, personEntry, bundle, encounterEntry, encounter.claim);
        explanationOfBenefit(personEntry, bundle, encounterEntry, person, encounterClaim, encounter);
    }
    return bundle;
}
Also used : DiagnosticReport(org.hl7.fhir.dstu3.model.DiagnosticReport) Report(org.mitre.synthea.world.concepts.HealthRecord.Report) Bundle(org.hl7.fhir.dstu3.model.Bundle) ImagingStudy(org.mitre.synthea.world.concepts.HealthRecord.ImagingStudy) Attachment(org.mitre.synthea.engine.Components.Attachment) HealthRecord(org.mitre.synthea.world.concepts.HealthRecord) CarePlan(org.mitre.synthea.world.concepts.HealthRecord.CarePlan) BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) Observation(org.mitre.synthea.world.concepts.HealthRecord.Observation) Medication(org.mitre.synthea.world.concepts.HealthRecord.Medication) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Procedure(org.mitre.synthea.world.concepts.HealthRecord.Procedure)

Example 58 with Attachment

use of org.hl7.fhir.r4.model.Attachment in project synthea by synthetichealth.

the class ExportHelper method getObservationValue.

/**
 * Helper to get a readable string representation of an Observation's value.
 * Units are not included.
 *
 * @param observation The observation to get the value from
 * @return A human-readable string representation of observation.value
 */
public static String getObservationValue(Observation observation) {
    String value = null;
    if (observation.value instanceof Condition) {
        Code conditionCode = ((HealthRecord.Entry) observation.value).codes.get(0);
        value = conditionCode.display;
    } else if (observation.value instanceof Code) {
        value = ((Code) observation.value).display;
    } else if (observation.value instanceof String) {
        value = (String) observation.value;
    } else if (observation.value instanceof Double) {
        // round to 1 decimal place for display
        value = String.format(Locale.US, "%.1f", observation.value);
    } else if (observation.value instanceof SampledData) {
        value = sampledDataToValueString((SampledData) observation.value);
    } else if (observation.value instanceof Attachment) {
        value = attachmentToValueString((Attachment) observation.value);
    } else if (observation.value != null) {
        value = observation.value.toString();
    }
    return value;
}
Also used : Condition(org.hl7.fhir.dstu3.model.Condition) HealthRecord(org.mitre.synthea.world.concepts.HealthRecord) SampledData(org.mitre.synthea.engine.Components.SampledData) Attachment(org.mitre.synthea.engine.Components.Attachment) Code(org.mitre.synthea.world.concepts.HealthRecord.Code)

Example 59 with Attachment

use of org.hl7.fhir.r4.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 60 with Attachment

use of org.hl7.fhir.r4.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)

Aggregations

Attachment (org.hl7.fhir.r4.model.Attachment)33 ArrayList (java.util.ArrayList)32 Attachment (com.ibm.cloud.cloudant.v1.model.Attachment)17 Reference (org.hl7.fhir.r4.model.Reference)17 Test (org.testng.annotations.Test)17 DocumentRevisionStatus (com.ibm.cloud.cloudant.v1.model.DocumentRevisionStatus)16 Revisions (com.ibm.cloud.cloudant.v1.model.Revisions)16 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)16 NotImplementedException (org.apache.commons.lang3.NotImplementedException)14 HashMap (java.util.HashMap)12 Coding (org.hl7.fhir.r4.model.Coding)11 Document (com.ibm.cloud.cloudant.v1.model.Document)10 List (java.util.List)10 DiagnosticReport (org.hl7.fhir.r4.model.DiagnosticReport)10 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 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)8 Resource (org.hl7.fhir.r4.model.Resource)8 DesignDocument (com.ibm.cloud.cloudant.v1.model.DesignDocument)7