Search in sources :

Example 31 with Property

use of com.adobe.target.delivery.v1.model.Property in project himss_2021_sepsis_detection by redhat-na-ssa.

the class FhirServerTest method riskAssessmentPredictionTest.

@Test
public void riskAssessmentPredictionTest() throws IOException {
    String filePath = "/fhir/RiskAssessment.json";
    InputStream fStream = null;
    String oJson = null;
    try {
        fStream = this.getClass().getResourceAsStream(filePath);
        if (fStream != null) {
            oJson = IOUtils.toString(fStream, "UTF-8");
            RiskAssessment rAssessment = (RiskAssessment) fhirCtx.newJsonParser().parseResource(oJson);
            RiskAssessmentPredictionComponent raPredictionComponent = rAssessment.getPredictionFirstRep();
            Property cProp = raPredictionComponent.getOutcome().getChildByName("coding");
            Coding coding = (Coding) cProp.getValues().get(0);
            String code = coding.getCode();
            log.info("riskAssessmentPredictionTest() code = " + code);
        } else {
            log.error("riskAssessmentTest() resource not found: " + filePath);
            return;
        }
    } finally {
        if (fStream != null)
            fStream.close();
    }
}
Also used : RiskAssessment(org.hl7.fhir.r4.model.RiskAssessment) RiskAssessmentPredictionComponent(org.hl7.fhir.r4.model.RiskAssessment.RiskAssessmentPredictionComponent) Coding(org.hl7.fhir.r4.model.Coding) InputStream(java.io.InputStream) Property(org.hl7.fhir.r4.model.Property) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 32 with Property

use of com.adobe.target.delivery.v1.model.Property in project org.hl7.fhir.core by hapifhir.

the class NarrativeGenerator method splitExtensions.

private List<PropertyWrapper> splitExtensions(StructureDefinition profile, List<PropertyWrapper> children) throws UnsupportedEncodingException, IOException, FHIRException {
    List<PropertyWrapper> results = new ArrayList<PropertyWrapper>();
    Map<String, PropertyWrapper> map = new HashMap<String, PropertyWrapper>();
    for (PropertyWrapper p : children) if (p.getName().equals("extension") || p.getName().equals("modifierExtension")) {
        // we're going to split these up, and create a property for each url
        if (p.hasValues()) {
            for (BaseWrapper v : p.getValues()) {
                Extension ex = (Extension) v.getBase();
                String url = ex.getUrl();
                StructureDefinition ed = context.fetchResource(StructureDefinition.class, url);
                if (p.getName().equals("modifierExtension") && ed == null)
                    throw new DefinitionException("Unknown modifier extension " + url);
                PropertyWrapper pe = map.get(p.getName() + "[" + url + "]");
                if (pe == null) {
                    if (ed == null) {
                        if (url.startsWith("http://hl7.org/fhir"))
                            throw new DefinitionException("unknown extension " + url);
                        System.out.println("unknown extension " + url);
                        pe = new PropertyWrapperDirect(new Property(p.getName() + "[" + url + "]", p.getTypeCode(), p.getDefinition(), p.getMinCardinality(), p.getMaxCardinality(), ex));
                    } else {
                        ElementDefinition def = ed.getSnapshot().getElement().get(0);
                        pe = new PropertyWrapperDirect(new Property(p.getName() + "[" + url + "]", "Extension", def.getDefinition(), def.getMin(), def.getMax().equals("*") ? Integer.MAX_VALUE : Integer.parseInt(def.getMax()), ex));
                        ((PropertyWrapperDirect) pe).wrapped.setStructure(ed);
                    }
                    results.add(pe);
                } else
                    pe.getValues().add(v);
            }
        }
    } else
        results.add(p);
    return results;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Extension(org.hl7.fhir.dstu2.model.Extension) StructureDefinition(org.hl7.fhir.dstu2.model.StructureDefinition) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) ElementDefinition(org.hl7.fhir.dstu2.model.ElementDefinition) Property(org.hl7.fhir.dstu2.model.Property)

Example 33 with Property

use of com.adobe.target.delivery.v1.model.Property in project org.hl7.fhir.core by hapifhir.

the class ProfileDrivenRenderer method splitExtensions.

private List<PropertyWrapper> splitExtensions(StructureDefinition profile, List<PropertyWrapper> children) throws UnsupportedEncodingException, IOException, FHIRException {
    List<PropertyWrapper> results = new ArrayList<PropertyWrapper>();
    Map<String, PropertyWrapper> map = new HashMap<String, PropertyWrapper>();
    for (PropertyWrapper p : children) if (p.getName().equals("extension") || p.getName().equals("modifierExtension")) {
        // we're going to split these up, and create a property for each url
        if (p.hasValues()) {
            for (BaseWrapper v : p.getValues()) {
                Extension ex = (Extension) v.getBase();
                String url = ex.getUrl();
                StructureDefinition ed = getContext().getWorker().fetchResource(StructureDefinition.class, url);
                if (ed == null) {
                    if (xverManager == null) {
                        xverManager = new XVerExtensionManager(context.getWorker());
                    }
                    if (xverManager.matchingUrl(url) && xverManager.status(url) == XVerExtensionStatus.Valid) {
                        ed = xverManager.makeDefinition(url);
                        getContext().getWorker().generateSnapshot(ed);
                        getContext().getWorker().cacheResource(ed);
                    }
                }
                if (p.getName().equals("modifierExtension") && ed == null) {
                    throw new DefinitionException("Unknown modifier extension " + url);
                }
                PropertyWrapper pe = map.get(p.getName() + "[" + url + "]");
                if (pe == null) {
                    if (ed == null) {
                        if (url.startsWith("http://hl7.org/fhir") && !url.startsWith("http://hl7.org/fhir/us")) {
                            throw new DefinitionException("unknown extension " + url);
                        }
                        // System.out.println("unknown extension "+url);
                        pe = new PropertyWrapperDirect(this.context, new Property(p.getName() + "[" + url + "]", p.getTypeCode(), p.getDefinition(), p.getMinCardinality(), p.getMaxCardinality(), ex), null);
                    } else {
                        ElementDefinition def = ed.getSnapshot().getElement().get(0);
                        pe = new PropertyWrapperDirect(this.context, new Property(p.getName() + "[" + url + "]", "Extension", def.getDefinition(), def.getMin(), def.getMax().equals("*") ? Integer.MAX_VALUE : Integer.parseInt(def.getMax()), ex), ed.getSnapshot().getElementFirstRep());
                        ((PropertyWrapperDirect) pe).getWrapped().setStructure(ed);
                    }
                    results.add(pe);
                } else
                    pe.getValues().add(v);
            }
        }
    } else
        results.add(p);
    return results;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PropertyWrapperDirect(org.hl7.fhir.r5.renderers.utils.DirectWrappers.PropertyWrapperDirect) PropertyWrapper(org.hl7.fhir.r5.renderers.utils.BaseWrappers.PropertyWrapper) Extension(org.hl7.fhir.r5.model.Extension) BaseWrapper(org.hl7.fhir.r5.renderers.utils.BaseWrappers.BaseWrapper) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) XVerExtensionManager(org.hl7.fhir.r5.utils.XVerExtensionManager) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition) Property(org.hl7.fhir.r5.model.Property)

Example 34 with Property

use of com.adobe.target.delivery.v1.model.Property in project nia-patient-switching-standard-adaptor by NHSDigital.

the class SDSService method parsePersistDuration.

private Duration parsePersistDuration(String sdsResponse) throws SdsRetrievalException {
    Bundle bundle;
    try {
        bundle = fhirParser.parseResource(sdsResponse, Bundle.class);
    } catch (FhirValidationException e) {
        throw new SdsRetrievalException(e.getMessage());
    }
    List<Bundle.BundleEntryComponent> entries = bundle.getEntry();
    if (entries.isEmpty()) {
        throw new SdsRetrievalException("sds response doesn't contain any results");
    }
    Resource resource = entries.get(0).getResource();
    Property matchingChildren = resource.getChildByName(EXTENSION_KEY_VALUE);
    Optional<Extension> extensions = matchingChildren.getValues().stream().map(child -> (Extension) child).findFirst();
    Optional<Extension> persistDuration = extensions.orElseThrow(() -> new SdsRetrievalException("Error parsing persist duration extension")).getExtensionsByUrl(PERSIST_DURATION_URL).stream().findFirst();
    String isoDuration = persistDuration.orElseThrow(() -> new SdsRetrievalException("Error parsing persist duration value")).getValue().toString();
    return Duration.parse(isoDuration);
}
Also used : Extension(org.hl7.fhir.dstu3.model.Extension) Bundle(org.hl7.fhir.dstu3.model.Bundle) Resource(org.hl7.fhir.dstu3.model.Resource) Autowired(org.springframework.beans.factory.annotation.Autowired) Extension(org.hl7.fhir.dstu3.model.Extension) FhirParser(uk.nhs.adaptors.common.util.fhir.FhirParser) SdsRequestBuilder(uk.nhs.adaptors.pss.translator.sds.SdsRequestBuilder) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) Service(org.springframework.stereotype.Service) Duration(java.time.Duration) FhirValidationException(uk.nhs.adaptors.common.exception.FhirValidationException) Optional(java.util.Optional) WebClientResponseException(org.springframework.web.reactive.function.client.WebClientResponseException) AllArgsConstructor(lombok.AllArgsConstructor) Property(org.hl7.fhir.dstu3.model.Property) SdsRetrievalException(uk.nhs.adaptors.pss.translator.exception.SdsRetrievalException) Bundle(org.hl7.fhir.dstu3.model.Bundle) Resource(org.hl7.fhir.dstu3.model.Resource) SdsRetrievalException(uk.nhs.adaptors.pss.translator.exception.SdsRetrievalException) FhirValidationException(uk.nhs.adaptors.common.exception.FhirValidationException) Property(org.hl7.fhir.dstu3.model.Property)

Aggregations

TargetDeliveryRequest (com.adobe.target.edge.client.model.TargetDeliveryRequest)10 Property (com.adobe.target.delivery.v1.model.Property)9 Test (org.junit.jupiter.api.Test)9 Context (com.adobe.target.delivery.v1.model.Context)8 ExecuteRequest (com.adobe.target.delivery.v1.model.ExecuteRequest)8 TargetDeliveryResponse (com.adobe.target.edge.client.model.TargetDeliveryResponse)8 TargetTestDeliveryRequestUtils.getContext (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext)8 TargetTestDeliveryRequestUtils.getMboxExecuteRequest (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getMboxExecuteRequest)8 TimingTool (com.adobe.target.edge.client.utils.TimingTool)8 PrefetchRequest (com.adobe.target.delivery.v1.model.PrefetchRequest)7 Property (io.adminshell.aas.v3.model.Property)7 DeliveryResponse (com.adobe.target.delivery.v1.model.DeliveryResponse)5 TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse)5 TargetTestDeliveryRequestUtils.getTestDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getTestDeliveryResponse)5 ArrayList (java.util.ArrayList)5 TelemetryEntry (com.adobe.target.delivery.v1.model.TelemetryEntry)4 SubmodelElement (io.adminshell.aas.v3.model.SubmodelElement)4 HashMap (java.util.HashMap)4 Property (model.Property)4 Type (model.Type)3