Search in sources :

Example 1 with ImagingStudy

use of org.mitre.synthea.world.concepts.HealthRecord.ImagingStudy in project synthea by synthetichealth.

the class FhirR4 method imagingStudy.

/**
 * Map the given ImagingStudy to a FHIR ImagingStudy 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 ImagingStudy to
 * @param encounterEntry Current Encounter entry
 * @param imagingStudy   The ImagingStudy to map to FHIR and add to the bundle
 * @return The added Entry
 */
private static BundleEntryComponent imagingStudy(RandomNumberGenerator rand, BundleEntryComponent personEntry, Bundle bundle, BundleEntryComponent encounterEntry, ImagingStudy imagingStudy) {
    org.hl7.fhir.r4.model.ImagingStudy imagingStudyResource = new org.hl7.fhir.r4.model.ImagingStudy();
    imagingStudyResource.addIdentifier(generateIdentifier(imagingStudy.dicomUid));
    imagingStudyResource.setStatus(ImagingStudyStatus.AVAILABLE);
    imagingStudyResource.setSubject(new Reference(personEntry.getFullUrl()));
    imagingStudyResource.setEncounter(new Reference(encounterEntry.getFullUrl()));
    if (USE_US_CORE_IG) {
        org.hl7.fhir.r4.model.Encounter encounterResource = (org.hl7.fhir.r4.model.Encounter) encounterEntry.getResource();
        imagingStudyResource.setLocation(encounterResource.getLocationFirstRep().getLocation());
    }
    if (!imagingStudy.codes.isEmpty()) {
        imagingStudyResource.addProcedureCode(mapCodeToCodeableConcept(imagingStudy.codes.get(0), SNOMED_URI));
    }
    Date startDate = new Date(imagingStudy.start);
    imagingStudyResource.setStarted(startDate);
    // Convert the series into their FHIR equivalents
    int numberOfSeries = imagingStudy.series.size();
    imagingStudyResource.setNumberOfSeries(numberOfSeries);
    List<ImagingStudySeriesComponent> seriesResourceList = new ArrayList<ImagingStudySeriesComponent>();
    int totalNumberOfInstances = 0;
    int seriesNo = 1;
    for (ImagingStudy.Series series : imagingStudy.series) {
        ImagingStudySeriesComponent seriesResource = new ImagingStudySeriesComponent();
        seriesResource.setUid(series.dicomUid);
        seriesResource.setNumber(seriesNo);
        seriesResource.setStarted(startDate);
        CodeableConcept modalityConcept = mapCodeToCodeableConcept(series.modality, DICOM_DCM_URI);
        seriesResource.setModality(modalityConcept.getCoding().get(0));
        CodeableConcept bodySiteConcept = mapCodeToCodeableConcept(series.bodySite, SNOMED_URI);
        seriesResource.setBodySite(bodySiteConcept.getCoding().get(0));
        // Convert the images in each series into their FHIR equivalents
        int numberOfInstances = series.instances.size();
        seriesResource.setNumberOfInstances(numberOfInstances);
        totalNumberOfInstances += numberOfInstances;
        List<ImagingStudySeriesInstanceComponent> instanceResourceList = new ArrayList<ImagingStudySeriesInstanceComponent>();
        int instanceNo = 1;
        for (ImagingStudy.Instance instance : series.instances) {
            ImagingStudySeriesInstanceComponent instanceResource = new ImagingStudySeriesInstanceComponent();
            instanceResource.setUid(instance.dicomUid);
            instanceResource.setTitle(instance.title);
            instanceResource.setSopClass(new Coding().setCode(instance.sopClass.code).setSystem("urn:ietf:rfc:3986"));
            instanceResource.setNumber(instanceNo);
            instanceResourceList.add(instanceResource);
            instanceNo += 1;
        }
        seriesResource.setInstance(instanceResourceList);
        seriesResourceList.add(seriesResource);
        seriesNo += 1;
    }
    imagingStudyResource.setSeries(seriesResourceList);
    imagingStudyResource.setNumberOfInstances(totalNumberOfInstances);
    return newEntry(rand, bundle, imagingStudyResource);
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) ImagingStudySeriesInstanceComponent(org.hl7.fhir.r4.model.ImagingStudy.ImagingStudySeriesInstanceComponent) ArrayList(java.util.ArrayList) ImagingStudy(org.mitre.synthea.world.concepts.HealthRecord.ImagingStudy) Date(java.util.Date) ContactPoint(org.hl7.fhir.r4.model.ContactPoint) ImagingStudySeriesComponent(org.hl7.fhir.r4.model.ImagingStudy.ImagingStudySeriesComponent) Coding(org.hl7.fhir.r4.model.Coding) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 2 with ImagingStudy

use of org.mitre.synthea.world.concepts.HealthRecord.ImagingStudy 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 3 with ImagingStudy

use of org.mitre.synthea.world.concepts.HealthRecord.ImagingStudy in project synthea by synthetichealth.

the class FhirDstu2 method convertToFHIR.

/**
 * Convert the given Person into a FHIR Bundle with the Patient and the
 * associated entries from their health record.
 *
 * @param person Person to generate the FHIR Bundle
 * @param stopTime Time the simulation ended
 * @return String containing a 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(BundleTypeEnum.TRANSACTION);
    } else {
        bundle.setType(BundleTypeEnum.COLLECTION);
    }
    Entry personEntry = basicInfo(person, bundle, stopTime);
    for (Encounter encounter : person.record.encounters) {
        Entry 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
        encounterClaim(person, personEntry, bundle, encounterEntry, encounter.claim);
    }
    return bundle;
}
Also used : Report(org.mitre.synthea.world.concepts.HealthRecord.Report) DiagnosticReport(ca.uhn.fhir.model.dstu2.resource.DiagnosticReport) Bundle(ca.uhn.fhir.model.dstu2.resource.Bundle) ImagingStudy(org.mitre.synthea.world.concepts.HealthRecord.ImagingStudy) Attachment(org.mitre.synthea.engine.Components.Attachment) Entry(ca.uhn.fhir.model.dstu2.resource.Bundle.Entry) HealthRecord(org.mitre.synthea.world.concepts.HealthRecord) CarePlan(org.mitre.synthea.world.concepts.HealthRecord.CarePlan) 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 4 with ImagingStudy

use of org.mitre.synthea.world.concepts.HealthRecord.ImagingStudy in project synthea by synthetichealth.

the class FhirStu3 method imagingStudy.

/**
 * Map the given ImagingStudy to a FHIR ImagingStudy 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 ImagingStudy to
 * @param encounterEntry Current Encounter entry
 * @param imagingStudy The ImagingStudy to map to FHIR and add to the bundle
 * @return The added Entry
 */
private static BundleEntryComponent imagingStudy(RandomNumberGenerator rand, BundleEntryComponent personEntry, Bundle bundle, BundleEntryComponent encounterEntry, ImagingStudy imagingStudy) {
    org.hl7.fhir.dstu3.model.ImagingStudy imagingStudyResource = new org.hl7.fhir.dstu3.model.ImagingStudy();
    imagingStudyResource.setUid("urn:oid:" + imagingStudy.dicomUid);
    imagingStudyResource.setPatient(new Reference(personEntry.getFullUrl()));
    imagingStudyResource.setContext(new Reference(encounterEntry.getFullUrl()));
    if (!imagingStudy.codes.isEmpty()) {
        imagingStudyResource.addProcedureCode(mapCodeToCodeableConcept(imagingStudy.codes.get(0), SNOMED_URI));
    }
    Date startDate = new Date(imagingStudy.start);
    imagingStudyResource.setStarted(startDate);
    // Convert the series into their FHIR equivalents
    int numberOfSeries = imagingStudy.series.size();
    imagingStudyResource.setNumberOfSeries(numberOfSeries);
    List<ImagingStudySeriesComponent> seriesResourceList = new ArrayList<ImagingStudySeriesComponent>();
    int totalNumberOfInstances = 0;
    int seriesNo = 1;
    for (ImagingStudy.Series series : imagingStudy.series) {
        ImagingStudySeriesComponent seriesResource = new ImagingStudySeriesComponent();
        seriesResource.setUid("urn:oid:" + series.dicomUid);
        seriesResource.setNumber(seriesNo);
        seriesResource.setStarted(startDate);
        seriesResource.setAvailability(InstanceAvailability.UNAVAILABLE);
        CodeableConcept modalityConcept = mapCodeToCodeableConcept(series.modality, DICOM_DCM_URI);
        seriesResource.setModality(modalityConcept.getCoding().get(0));
        CodeableConcept bodySiteConcept = mapCodeToCodeableConcept(series.bodySite, SNOMED_URI);
        seriesResource.setBodySite(bodySiteConcept.getCoding().get(0));
        // Convert the images in each series into their FHIR equivalents
        int numberOfInstances = series.instances.size();
        seriesResource.setNumberOfInstances(numberOfInstances);
        totalNumberOfInstances += numberOfInstances;
        List<ImagingStudySeriesInstanceComponent> instanceResourceList = new ArrayList<ImagingStudySeriesInstanceComponent>();
        int instanceNo = 1;
        for (ImagingStudy.Instance instance : series.instances) {
            ImagingStudySeriesInstanceComponent instanceResource = new ImagingStudySeriesInstanceComponent();
            instanceResource.setUid("urn:oid:" + instance.dicomUid);
            instanceResource.setTitle(instance.title);
            instanceResource.setSopClass("urn:oid:" + instance.sopClass.code);
            instanceResource.setNumber(instanceNo);
            instanceResourceList.add(instanceResource);
            instanceNo += 1;
        }
        seriesResource.setInstance(instanceResourceList);
        seriesResourceList.add(seriesResource);
        seriesNo += 1;
    }
    imagingStudyResource.setSeries(seriesResourceList);
    imagingStudyResource.setNumberOfInstances(totalNumberOfInstances);
    return newEntry(rand, bundle, imagingStudyResource);
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) ImagingStudySeriesInstanceComponent(org.hl7.fhir.dstu3.model.ImagingStudy.ImagingStudySeriesInstanceComponent) ArrayList(java.util.ArrayList) ImagingStudy(org.mitre.synthea.world.concepts.HealthRecord.ImagingStudy) Date(java.util.Date) ContactPoint(org.hl7.fhir.dstu3.model.ContactPoint) ImagingStudySeriesComponent(org.hl7.fhir.dstu3.model.ImagingStudy.ImagingStudySeriesComponent) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 5 with ImagingStudy

use of org.mitre.synthea.world.concepts.HealthRecord.ImagingStudy in project synthea by synthetichealth.

the class TextExporter method exportAll.

/**
 * Produce and export a person's record in the text format.
 *
 * @param person Person to export
 * @param fileTag Tag to add to the filename
 * @param time Time the simulation ended
 * @throws IOException if any error occurs writing to the standard export location
 */
public static void exportAll(Person person, String fileTag, long time) throws IOException {
    List<Encounter> encounters = person.record.encounters;
    List<Entry> conditions = new ArrayList<>();
    List<Entry> allergies = new ArrayList<>();
    List<Report> reports = new ArrayList<>();
    List<Observation> observations = new ArrayList<>();
    List<Procedure> procedures = new ArrayList<>();
    List<Medication> medications = new ArrayList<>();
    List<Entry> immunizations = new ArrayList<>();
    List<CarePlan> careplans = new ArrayList<>();
    List<ImagingStudy> imagingStudies = new ArrayList<>();
    for (Encounter encounter : person.record.encounters) {
        conditions.addAll(encounter.conditions);
        allergies.addAll(encounter.allergies);
        reports.addAll(encounter.reports);
        observations.addAll(encounter.observations);
        procedures.addAll(encounter.procedures);
        medications.addAll(encounter.medications);
        immunizations.addAll(encounter.immunizations);
        careplans.addAll(encounter.careplans);
        imagingStudies.addAll(encounter.imagingStudies);
    }
    // reverse these items so they are displayed in reverse chrono order
    Collections.reverse(encounters);
    Collections.reverse(conditions);
    Collections.reverse(allergies);
    Collections.reverse(reports);
    Collections.reverse(observations);
    Collections.reverse(procedures);
    Collections.reverse(medications);
    Collections.reverse(immunizations);
    Collections.reverse(careplans);
    Collections.reverse(imagingStudies);
    // now we finally start writing things
    List<String> textRecord = new LinkedList<>();
    basicInfo(textRecord, person, time);
    breakline(textRecord);
    textRecord.add("ALLERGIES:");
    if (allergies.isEmpty()) {
        textRecord.add("No Known Allergies");
    } else {
        for (Entry allergy : allergies) {
            condition(textRecord, allergy, true);
        }
    }
    breakline(textRecord);
    textRecord.add("MEDICATIONS:");
    for (Medication medication : medications) {
        medication(textRecord, medication, true);
    }
    breakline(textRecord);
    textRecord.add("CONDITIONS:");
    for (Entry condition : conditions) {
        condition(textRecord, condition, true);
    }
    breakline(textRecord);
    textRecord.add("CARE PLANS:");
    for (CarePlan careplan : careplans) {
        careplan(textRecord, careplan, true);
    }
    breakline(textRecord);
    textRecord.add("REPORTS:");
    for (Report report : reports) {
        diagnosticReport(textRecord, report);
    }
    breakline(textRecord);
    textRecord.add("OBSERVATIONS:");
    for (Observation observation : observations) {
        observation(textRecord, observation);
    }
    breakline(textRecord);
    textRecord.add("PROCEDURES:");
    for (Procedure procedure : procedures) {
        procedure(textRecord, procedure);
    }
    breakline(textRecord);
    textRecord.add("IMMUNIZATIONS:");
    for (Entry immunization : immunizations) {
        immunization(textRecord, immunization);
    }
    breakline(textRecord);
    textRecord.add("ENCOUNTERS:");
    for (Encounter encounter : encounters) {
        encounter(textRecord, encounter);
    }
    breakline(textRecord);
    textRecord.add("IMAGING STUDIES:");
    for (ImagingStudy imagingStudy : imagingStudies) {
        imagingStudy(textRecord, imagingStudy);
    }
    breakline(textRecord);
    // finally write to the file
    File outDirectory = Exporter.getOutputFolder("text", person);
    Path outFilePath = outDirectory.toPath().resolve(Exporter.filename(person, fileTag, "txt"));
    Files.write(outFilePath, textRecord, StandardOpenOption.CREATE_NEW);
}
Also used : Path(java.nio.file.Path) Report(org.mitre.synthea.world.concepts.HealthRecord.Report) ArrayList(java.util.ArrayList) ImagingStudy(org.mitre.synthea.world.concepts.HealthRecord.ImagingStudy) LinkedList(java.util.LinkedList) Entry(org.mitre.synthea.world.concepts.HealthRecord.Entry) CarePlan(org.mitre.synthea.world.concepts.HealthRecord.CarePlan) 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) File(java.io.File)

Aggregations

ImagingStudy (org.mitre.synthea.world.concepts.HealthRecord.ImagingStudy)11 Encounter (org.mitre.synthea.world.concepts.HealthRecord.Encounter)7 CarePlan (org.mitre.synthea.world.concepts.HealthRecord.CarePlan)6 Medication (org.mitre.synthea.world.concepts.HealthRecord.Medication)6 Observation (org.mitre.synthea.world.concepts.HealthRecord.Observation)6 Procedure (org.mitre.synthea.world.concepts.HealthRecord.Procedure)6 ArrayList (java.util.ArrayList)5 Report (org.mitre.synthea.world.concepts.HealthRecord.Report)5 HealthRecord (org.mitre.synthea.world.concepts.HealthRecord)4 Date (java.util.Date)3 Attachment (org.mitre.synthea.engine.Components.Attachment)3 Entry (org.mitre.synthea.world.concepts.HealthRecord.Entry)3 Code (org.mitre.synthea.world.concepts.HealthRecord.Code)2 CodeableConceptDt (ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt)1 ResourceReferenceDt (ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt)1 Bundle (ca.uhn.fhir.model.dstu2.resource.Bundle)1 Entry (ca.uhn.fhir.model.dstu2.resource.Bundle.Entry)1 DiagnosticReport (ca.uhn.fhir.model.dstu2.resource.DiagnosticReport)1 Series (ca.uhn.fhir.model.dstu2.resource.ImagingStudy.Series)1 SeriesInstance (ca.uhn.fhir.model.dstu2.resource.ImagingStudy.SeriesInstance)1