Search in sources :

Example 46 with Attachment

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

the class FhirR4 method convertToFHIR.

/**
 * Convert the given Person into a FHIR Bundle of the Patient and the
 * associated entries from their health record.
 *
 * @param person   Person to generate the FHIR JSON for
 * @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.Allergy allergy : encounter.allergies) {
            allergy(person, personEntry, bundle, encounterEntry, allergy);
        }
        for (Observation observation : encounter.observations) {
            // Observation resources in v4 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 (HealthRecord.Device device : encounter.devices) {
            device(person, personEntry, bundle, device);
        }
        for (HealthRecord.Supply supply : encounter.supplies) {
            supplyDelivery(person, personEntry, bundle, supply, encounter);
        }
        for (Medication medication : encounter.medications) {
            medicationRequest(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) {
            BundleEntryComponent careTeamEntry = careTeam(person, personEntry, bundle, encounterEntry, careplan);
            carePlan(person, personEntry, bundle, encounterEntry, encounter.provider, careTeamEntry, careplan);
        }
        for (ImagingStudy imagingStudy : encounter.imagingStudies) {
            imagingStudy(person, personEntry, bundle, encounterEntry, imagingStudy);
        }
        if (USE_US_CORE_IG) {
            String clinicalNoteText = ClinicalNoteExporter.export(person, encounter);
            boolean lastNote = (encounter == person.record.encounters.get(person.record.encounters.size() - 1));
            clinicalNote(person, personEntry, bundle, encounterEntry, clinicalNoteText, lastNote);
        }
        // one claim per encounter
        BundleEntryComponent encounterClaim = encounterClaim(person, personEntry, bundle, encounterEntry, encounter.claim);
        explanationOfBenefit(personEntry, bundle, encounterEntry, person, encounterClaim, encounter);
    }
    if (USE_US_CORE_IG) {
        // Add Provenance to the Bundle
        provenance(bundle, person, stopTime);
    }
    return bundle;
}
Also used : DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) Report(org.mitre.synthea.world.concepts.HealthRecord.Report) Bundle(org.hl7.fhir.r4.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.r4.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 47 with Attachment

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

the class FhirR4 method media.

/**
 * Map the given Observation with attachment 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.r4.model.Media mediaResource = new org.hl7.fhir.r4.model.Media();
    // Hard code as Image since we don't anticipate using video or audio any time soon
    Code mediaType = new Code("http://terminology.hl7.org/CodeSystem/media-type", "image", "Image");
    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);
    }
    mediaResource.setType(mapCodeToCodeableConcept(mediaType, MEDIA_TYPE_URI));
    mediaResource.setStatus(MediaStatus.COMPLETED);
    mediaResource.setSubject(new Reference(personEntry.getFullUrl()));
    mediaResource.setEncounter(new Reference(encounterEntry.getFullUrl()));
    Attachment content = (Attachment) obs.value;
    org.hl7.fhir.r4.model.Attachment contentResource = new org.hl7.fhir.r4.model.Attachment();
    contentResource.setContentType(content.contentType);
    contentResource.setLanguage(content.language);
    if (content.data != null) {
        contentResource.setDataElement(new org.hl7.fhir.r4.model.Base64BinaryType(content.data));
    } else {
        contentResource.setSize(content.size);
    }
    contentResource.setUrl(content.url);
    contentResource.setTitle(content.title);
    if (content.hash != null) {
        contentResource.setHashElement(new org.hl7.fhir.r4.model.Base64BinaryType(content.hash));
    }
    mediaResource.setWidth(content.width);
    mediaResource.setHeight(content.height);
    mediaResource.setContent(contentResource);
    return newEntry(rand, bundle, mediaResource);
}
Also used : Location(org.mitre.synthea.world.geography.Location) SimpleQuantity(org.hl7.fhir.r4.model.SimpleQuantity) SupplyDeliveryStatus(org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliveryStatus) Identifier(org.hl7.fhir.r4.model.Identifier) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) HashBasedTable(com.google.common.collect.HashBasedTable) Condition(org.hl7.fhir.r4.model.Condition) CarePlanActivityComponent(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityComponent) Reference(org.hl7.fhir.r4.model.Reference) SupplyDeliverySuppliedItemComponent(org.hl7.fhir.r4.model.SupplyDelivery.SupplyDeliverySuppliedItemComponent) HTTPVerb(org.hl7.fhir.r4.model.Bundle.HTTPVerb) Medication(org.mitre.synthea.world.concepts.HealthRecord.Medication) FhirContext(ca.uhn.fhir.context.FhirContext) Device(org.hl7.fhir.r4.model.Device) Person(org.mitre.synthea.world.agents.Person) ImmunizationStatus(org.hl7.fhir.r4.model.Immunization.ImmunizationStatus) Map(java.util.Map) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) Coverage(org.hl7.fhir.r4.model.Coverage) IntegerType(org.hl7.fhir.r4.model.IntegerType) Meta(org.hl7.fhir.r4.model.Meta) Practitioner(org.hl7.fhir.r4.model.Practitioner) RandomNumberGenerator(org.mitre.synthea.helpers.RandomNumberGenerator) ProcedureStatus(org.hl7.fhir.r4.model.Procedure.ProcedureStatus) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) CarePlanActivityStatus(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus) Goal(org.hl7.fhir.r4.model.Goal) EncounterHospitalizationComponent(org.hl7.fhir.r4.model.Encounter.EncounterHospitalizationComponent) Period(org.hl7.fhir.r4.model.Period) HealthRecord(org.mitre.synthea.world.concepts.HealthRecord) Provenance(org.hl7.fhir.r4.model.Provenance) ContactPoint(org.hl7.fhir.r4.model.ContactPoint) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) Utilities(org.mitre.synthea.helpers.Utilities) BundleEntryRequestComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent) BooleanType(org.hl7.fhir.r4.model.BooleanType) ObservationComponentComponent(org.hl7.fhir.r4.model.Observation.ObservationComponentComponent) Coding(org.hl7.fhir.r4.model.Coding) EncounterStatus(org.hl7.fhir.r4.model.Encounter.EncounterStatus) ImagingStudySeriesInstanceComponent(org.hl7.fhir.r4.model.ImagingStudy.ImagingStudySeriesInstanceComponent) BundleType(org.hl7.fhir.r4.model.Bundle.BundleType) EncounterType(org.mitre.synthea.world.concepts.HealthRecord.EncounterType) DeviceNameType(org.hl7.fhir.r4.model.Device.DeviceNameType) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) AllergyIntoleranceType(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceType) DocumentReferenceContextComponent(org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceContextComponent) Use(org.hl7.fhir.r4.model.ExplanationOfBenefit.Use) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) DosageDoseAndRateComponent(org.hl7.fhir.r4.model.Dosage.DosageDoseAndRateComponent) ProvenanceAgentComponent(org.hl7.fhir.r4.model.Provenance.ProvenanceAgentComponent) Money(org.hl7.fhir.r4.model.Money) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Calendar(java.util.Calendar) ContactPointUse(org.hl7.fhir.r4.model.ContactPoint.ContactPointUse) LocationPhysicalType(org.hl7.fhir.r4.model.codesystems.LocationPhysicalType) DiagnosisComponent(org.hl7.fhir.r4.model.Claim.DiagnosisComponent) Quantity(org.hl7.fhir.r4.model.Quantity) DecimalType(org.hl7.fhir.r4.model.DecimalType) Procedure(org.mitre.synthea.world.concepts.HealthRecord.Procedure) ImagingStudySeriesComponent(org.hl7.fhir.r4.model.ImagingStudy.ImagingStudySeriesComponent) ImagingStudy(org.mitre.synthea.world.concepts.HealthRecord.ImagingStudy) IOException(java.io.IOException) NarrativeStatus(org.hl7.fhir.r4.model.Narrative.NarrativeStatus) FHIRDeviceStatus(org.hl7.fhir.r4.model.Device.FHIRDeviceStatus) Claim(org.mitre.synthea.world.concepts.Claim) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit) Bundle(org.hl7.fhir.r4.model.Bundle) CodeType(org.hl7.fhir.r4.model.CodeType) CarePlanIntent(org.hl7.fhir.r4.model.CarePlan.CarePlanIntent) DocumentReferenceStatus(org.hl7.fhir.r4.model.Enumerations.DocumentReferenceStatus) LocationStatus(org.hl7.fhir.r4.model.Location.LocationStatus) TotalComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.TotalComponent) ContactComponent(org.hl7.fhir.r4.model.Patient.ContactComponent) JsonObject(com.google.gson.JsonObject) Attachment(org.mitre.synthea.engine.Components.Attachment) NodeType(org.hl7.fhir.utilities.xhtml.NodeType) Point2D(java.awt.geom.Point2D) Date(java.util.Date) CoverageStatus(org.hl7.fhir.r4.model.Coverage.CoverageStatus) Costs(org.mitre.synthea.world.concepts.Costs) AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) LocationPositionComponent(org.hl7.fhir.r4.model.Location.LocationPositionComponent) ContactPointSystem(org.hl7.fhir.r4.model.ContactPoint.ContactPointSystem) HumanName(org.hl7.fhir.r4.model.HumanName) Gson(com.google.gson.Gson) StringType(org.hl7.fhir.r4.model.StringType) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Components(org.mitre.synthea.engine.Components) Patient(org.hl7.fhir.r4.model.Patient) Timing(org.hl7.fhir.r4.model.Timing) GoalLifecycleStatus(org.hl7.fhir.r4.model.Goal.GoalLifecycleStatus) DateType(org.hl7.fhir.r4.model.DateType) CarePlanStatus(org.hl7.fhir.r4.model.CarePlan.CarePlanStatus) SupplyDelivery(org.hl7.fhir.r4.model.SupplyDelivery) Report(org.mitre.synthea.world.concepts.HealthRecord.Report) CareTeamStatus(org.hl7.fhir.r4.model.CareTeam.CareTeamStatus) MedicationAdministration(org.hl7.fhir.r4.model.MedicationAdministration) Resource(org.hl7.fhir.r4.model.Resource) MedicationRequestStatus(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestStatus) Collectors(java.util.stream.Collectors) SupportingInformationComponent(org.hl7.fhir.r4.model.Claim.SupportingInformationComponent) CarePlanActivityDetailComponent(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityDetailComponent) InsuranceComponent(org.hl7.fhir.r4.model.Claim.InsuranceComponent) ProcedureComponent(org.hl7.fhir.r4.model.Claim.ProcedureComponent) Narrative(org.hl7.fhir.r4.model.Narrative) List(java.util.List) Immunization(org.hl7.fhir.r4.model.Immunization) Extension(org.hl7.fhir.r4.model.Extension) PositiveIntType(org.hl7.fhir.r4.model.PositiveIntType) ClaimStatus(org.hl7.fhir.r4.model.Claim.ClaimStatus) MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) SimpleCSV(org.mitre.synthea.helpers.SimpleCSV) Property(org.hl7.fhir.r4.model.Property) TimingRepeatComponent(org.hl7.fhir.r4.model.Timing.TimingRepeatComponent) Type(org.hl7.fhir.r4.model.Type) Clinician(org.mitre.synthea.world.agents.Clinician) AllergyIntoleranceCategory(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCategory) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) HashMap(java.util.HashMap) AllergyIntoleranceCriticality(org.hl7.fhir.r4.model.AllergyIntolerance.AllergyIntoleranceCriticality) Dosage(org.hl7.fhir.r4.model.Dosage) CareTeam(org.hl7.fhir.r4.model.CareTeam) JsonElement(com.google.gson.JsonElement) Address(org.hl7.fhir.r4.model.Address) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) CarePlan(org.mitre.synthea.world.concepts.HealthRecord.CarePlan) ItemComponent(org.hl7.fhir.r4.model.Claim.ItemComponent) PatientCommunicationComponent(org.hl7.fhir.r4.model.Patient.PatientCommunicationComponent) ImagingStudyStatus(org.hl7.fhir.r4.model.ImagingStudy.ImagingStudyStatus) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) UnitsOfTime(org.hl7.fhir.r4.model.Timing.UnitsOfTime) ObservationStatus(org.hl7.fhir.r4.model.Observation.ObservationStatus) Config(org.mitre.synthea.helpers.Config) DoseRateType(org.hl7.fhir.r4.model.codesystems.DoseRateType) MedicationRequestIntent(org.hl7.fhir.r4.model.MedicationRequest.MedicationRequestIntent) MedicationStatus(org.hl7.fhir.r4.model.Medication.MedicationStatus) MedicationAdministrationDosageComponent(org.hl7.fhir.r4.model.MedicationAdministration.MedicationAdministrationDosageComponent) Payer(org.mitre.synthea.world.agents.Payer) MediaStatus(org.hl7.fhir.r4.model.Media.MediaStatus) Provider(org.mitre.synthea.world.agents.Provider) CareTeamParticipantComponent(org.hl7.fhir.r4.model.CareTeam.CareTeamParticipantComponent) Organization(org.hl7.fhir.r4.model.Organization) AdministrativeGender(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender) RemittanceOutcome(org.hl7.fhir.r4.model.ExplanationOfBenefit.RemittanceOutcome) Observation(org.mitre.synthea.world.concepts.HealthRecord.Observation) IdentifierUse(org.hl7.fhir.r4.model.Identifier.IdentifierUse) DiagnosticReportStatus(org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus) Table(com.google.common.collect.Table) Reference(org.hl7.fhir.r4.model.Reference) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) Attachment(org.mitre.synthea.engine.Components.Attachment) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 48 with Attachment

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

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

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

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