Search in sources :

Example 1 with ImagingStudySeriesComponent

use of org.hl7.fhir.dstu3.model.ImagingStudy.ImagingStudySeriesComponent 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 ImagingStudySeriesComponent

use of org.hl7.fhir.dstu3.model.ImagingStudy.ImagingStudySeriesComponent 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)

Aggregations

ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 ImagingStudy (org.mitre.synthea.world.concepts.HealthRecord.ImagingStudy)2 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)1 ContactPoint (org.hl7.fhir.dstu3.model.ContactPoint)1 ImagingStudySeriesComponent (org.hl7.fhir.dstu3.model.ImagingStudy.ImagingStudySeriesComponent)1 ImagingStudySeriesInstanceComponent (org.hl7.fhir.dstu3.model.ImagingStudy.ImagingStudySeriesInstanceComponent)1 Reference (org.hl7.fhir.dstu3.model.Reference)1 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)1 Coding (org.hl7.fhir.r4.model.Coding)1 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)1 DocumentReference (org.hl7.fhir.r4.model.DocumentReference)1 ImagingStudySeriesComponent (org.hl7.fhir.r4.model.ImagingStudy.ImagingStudySeriesComponent)1 ImagingStudySeriesInstanceComponent (org.hl7.fhir.r4.model.ImagingStudy.ImagingStudySeriesInstanceComponent)1 Reference (org.hl7.fhir.r4.model.Reference)1 Encounter (org.mitre.synthea.world.concepts.HealthRecord.Encounter)1