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);
}
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);
}
Aggregations