Search in sources :

Example 96 with BundleEntryComponent

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());
}
Also used : BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) Endpoint(org.hl7.fhir.dstu3.model.Endpoint) StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) Bundle(org.hl7.fhir.dstu3.model.Bundle) Resource(org.hl7.fhir.dstu3.model.Resource) ValueSet(org.hl7.fhir.dstu3.model.ValueSet) RequestDetails(ca.uhn.fhir.rest.api.server.RequestDetails) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 97 with BundleEntryComponent

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"));
}
Also used : BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) Endpoint(org.hl7.fhir.dstu3.model.Endpoint) StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) Bundle(org.hl7.fhir.dstu3.model.Bundle) Resource(org.hl7.fhir.dstu3.model.Resource) ValueSet(org.hl7.fhir.dstu3.model.ValueSet) RequestDetails(ca.uhn.fhir.rest.api.server.RequestDetails) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 98 with BundleEntryComponent

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());
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Endpoint(org.hl7.fhir.r4.model.Endpoint) StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) Bundle(org.hl7.fhir.r4.model.Bundle) Resource(org.hl7.fhir.r4.model.Resource) ValueSet(org.hl7.fhir.r4.model.ValueSet) RequestDetails(ca.uhn.fhir.rest.api.server.RequestDetails) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 99 with BundleEntryComponent

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;
}
Also used : FhirConversionSupport(com.cerner.bunsen.definitions.FhirConversionSupport) List(java.util.List) Bundle(org.hl7.fhir.dstu3.model.Bundle) IBase(org.hl7.fhir.instance.model.api.IBase) BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Map(java.util.Map) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) Collectors(java.util.stream.Collectors) Base(org.hl7.fhir.dstu3.model.Base) Property(org.hl7.fhir.dstu3.model.Property) BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) Bundle(org.hl7.fhir.dstu3.model.Bundle) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource)

Example 100 with BundleEntryComponent

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

Aggregations

BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)214 Resource (org.hl7.fhir.r4.model.Resource)153 Test (org.junit.jupiter.api.Test)126 Bundle (org.hl7.fhir.r4.model.Bundle)96 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)88 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)87 Reference (org.hl7.fhir.r4.model.Reference)46 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)42 Date (java.util.Date)40 Observation (org.hl7.fhir.r4.model.Observation)34 MedicationRequest (org.hl7.fhir.r4.model.MedicationRequest)33 Patient (org.hl7.fhir.r4.model.Patient)33 BundleEntryComponent (org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent)32 Condition (org.hl7.fhir.r4.model.Condition)30 Test (org.junit.Test)30 ArrayList (java.util.ArrayList)29 Coding (org.hl7.fhir.r4.model.Coding)29 Code (org.mitre.synthea.world.concepts.HealthRecord.Code)29 DocumentReference (org.hl7.fhir.r4.model.DocumentReference)28 Identifier (org.hl7.fhir.r4.model.Identifier)26