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