use of org.hl7.fhir.r4.model.Bundle.BundleEntryComponent in project cqf-ruler by DBCG.
the class CacheValueSetsProviderIT method testCacheValueSetsAlreadyExpanded.
// Get help with this....
// @Test
// public void testCacheValueSetsExpandAndAddConcepts() throws Exception {
// Endpoint endpoint = uploadLocalServerEndpoint();
// RequestDetails details = Mockito.mock(RequestDetails.class);
// ValueSet vs =
// uploadValueSet("valueset/valueset-buprenorphine-and-methadone-medications.json");
// vs.getCompose().getInclude().forEach(include -> {
// assertTrue(!include.hasConcept());
// });
// StringAndListParam stringAndListParam =
// getStringAndListParamFromValueSet(vs);
// IGenericClient localClient = createClient(ourCtx, endpoint);
// //
// localClient.operation().onServer().named("updateCodeSystems").withNoParameters(Parameters.class).execute();
// Resource outcomeResource = cacheValueSetsProvider.cacheValuesets(details,
// endpoint.getIdElement(), stringAndListParam, null, null);
// assertTrue(outcomeResource instanceof Bundle);
// Bundle resultBundle = (Bundle) outcomeResource;
// assertTrue(resultBundle.getEntry().size() == 1);
// BundleEntryComponent entry = resultBundle.getEntry().get(0);
// assertTrue(entry.getResponse().getLocation().startsWith("ValueSet/" +
// vs.getIdElement().getIdPart()));
// assertTrue(entry.getResponse().getStatus().equals("200 OK"));
// ValueSet resultingValueSet =
// localClient.read().resource(ValueSet.class).withId(vs.getIdElement()).execute();
// resultingValueSet.getCompose().getInclude().forEach(include -> {
// assertTrue(include.hasConcept());
// });
// }
@Test
public void testCacheValueSetsAlreadyExpanded() throws Exception {
Endpoint endpoint = uploadLocalServerEndpoint();
RequestDetails details = Mockito.mock(RequestDetails.class);
ValueSet vs = uploadValueSet("valueset/valueset-benzodiazepine-medications.json");
StringAndListParam stringAndListParam = getStringAndListParamFromValueSet(vs);
Resource outcomeResource = cacheValueSetsProvider.cacheValuesets(details, endpoint.getIdElement(), stringAndListParam, null, null);
assertTrue(outcomeResource instanceof Bundle);
Bundle resultBundle = (Bundle) outcomeResource;
assertEquals(1, resultBundle.getEntry().size());
BundleEntryComponent entry = resultBundle.getEntry().get(0);
assertTrue(entry.getResponse().getLocation().startsWith("ValueSet/" + vs.getIdElement().getIdPart()));
assertEquals("200 OK", entry.getResponse().getStatus());
}
use of org.hl7.fhir.r4.model.Bundle.BundleEntryComponent in project cqf-ruler by DBCG.
the class CacheValueSetsProviderIT method testCacheValueSetsNoCompose.
@Test
public void testCacheValueSetsNoCompose() throws Exception {
Endpoint endpoint = uploadLocalServerEndpoint();
RequestDetails details = Mockito.mock(RequestDetails.class);
ValueSet vs = uploadValueSet("valueset/valueset-benzodiazepine-medications.json");
assertTrue(vs.getCompose().getInclude().isEmpty());
StringAndListParam stringAndListParam = getStringAndListParamFromValueSet(vs);
Resource outcomeResource = cacheValueSetsProvider.cacheValuesets(details, endpoint.getIdElement(), stringAndListParam, null, null);
assertTrue(outcomeResource instanceof Bundle);
Bundle resultBundle = (Bundle) outcomeResource;
assertEquals(1, resultBundle.getEntry().size());
BundleEntryComponent entry = resultBundle.getEntry().get(0);
assertTrue(entry.getResponse().getLocation().startsWith("ValueSet/" + vs.getIdElement().getIdPart()));
assertEquals("200 OK", entry.getResponse().getStatus());
// ValueSet resultingValueSet = createClient(ourCtx,
// endpoint).read().resource(ValueSet.class).withId(vs.getIdElement()).execute();
// resultingValueSet not returning with a version
// assertTrue(resultingValueSet.getVersion().endsWith("-cached"));
}
use of org.hl7.fhir.r4.model.Bundle.BundleEntryComponent in project cqf-ruler by DBCG.
the class CacheValueSetsProviderIT method testCacheValueSetsAlreadyExpanded.
// Get help with this....
// @Test
// public void testCacheValueSetsExpandAndAddConcepts() throws Exception {
// Endpoint endpoint = uploadLocalServerEndpoint();
// RequestDetails details = Mockito.mock(RequestDetails.class);
// ValueSet vs = uploadValueSet("valueset/valueset-buprenorphine-and-methadone-medications.json");
// vs.getCompose().getInclude().forEach(include -> {
// assertTrue(!include.hasConcept());
// });
// StringAndListParam stringAndListParam = getStringAndListParamFromValueSet(vs);
// IGenericClient localClient = createClient(ourCtx, endpoint);
// // localClient.operation().onServer().named("updateCodeSystems").withNoParameters(Parameters.class).execute();
// Resource outcomeResource = cacheValueSetsProvider.cacheValuesets(details, endpoint.getIdElement(), stringAndListParam, null, null);
// assertTrue(outcomeResource instanceof Bundle);
// Bundle resultBundle = (Bundle) outcomeResource;
// assertTrue(resultBundle.getEntry().size() == 1);
// BundleEntryComponent entry = resultBundle.getEntry().get(0);
// assertTrue(entry.getResponse().getLocation().startsWith("ValueSet/" + vs.getIdElement().getIdPart()));
// assertTrue(entry.getResponse().getStatus().equals("200 OK"));
// ValueSet resultingValueSet = localClient.read().resource(ValueSet.class).withId(vs.getIdElement()).execute();
// resultingValueSet.getCompose().getInclude().forEach(include -> {
// assertTrue(include.hasConcept());
// });
// }
@Test
public void testCacheValueSetsAlreadyExpanded() throws Exception {
Endpoint endpoint = uploadLocalServerEndpoint();
RequestDetails details = Mockito.mock(RequestDetails.class);
ValueSet vs = uploadValueSet("valueset/valueset-benzodiazepine-medications.json");
StringAndListParam stringAndListParam = getStringAndListParamFromValueSet(vs);
Resource outcomeResource = cacheValueSetsProvider.cacheValuesets(details, endpoint.getIdElement(), stringAndListParam, null, null);
assertTrue(outcomeResource instanceof Bundle);
Bundle resultBundle = (Bundle) outcomeResource;
assertEquals(1, resultBundle.getEntry().size());
BundleEntryComponent entry = resultBundle.getEntry().get(0);
assertTrue(entry.getResponse().getLocation().startsWith("ValueSet/" + vs.getIdElement().getIdPart()));
assertEquals("200 OK", entry.getResponse().getStatus());
}
use of org.hl7.fhir.r4.model.Bundle.BundleEntryComponent in project bunsen by cerner.
the class Stu3FhirConversionSupport method extractEntryFromBundle.
@Override
public List<IBaseResource> extractEntryFromBundle(IBaseBundle bundle, String resourceName) {
Bundle stu3Bundle = (Bundle) bundle;
List<IBaseResource> items = stu3Bundle.getEntry().stream().map(BundleEntryComponent::getResource).filter(resource -> resource != null && resourceName.equalsIgnoreCase(resource.getResourceType().name())).collect(Collectors.toList());
return items;
}
use of org.hl7.fhir.r4.model.Bundle.BundleEntryComponent 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);
}
Aggregations