/** * Override parent because we're using FHIRPath here */ @Override protected List<Object> extractValues(String thePaths, IBaseResource theResource) { FHIRPathEngine fp = new FHIRPathEngine(myWorkerContext); List<Object> values = new ArrayList<>(); String[] nextPathsSplit = SPLIT.split(thePaths); for (String nextPath : nextPathsSplit) { List<Base> allValues; try { allValues = fp.evaluate((Base) theResource, trim(nextPath)); } catch (FHIRException e) { String msg = getContext().getLocalizer().getMessage(BaseSearchParamExtractor.class, "failedToExtractPaths", nextPath, e.toString()); throw new InternalErrorException(msg, e); } if (allValues.isEmpty() == false) { values.addAll(allValues); } } for (int i = 0; i < values.size(); i++) { Object nextObject = values.get(i); if (nextObject instanceof Extension) { Extension nextExtension = (Extension) nextObject; nextObject = nextExtension.getValue(); values.set(i, nextObject); } } return values; }
public static org.hl7.fhir.dstu2016may.model.Extension convertExtension(org.hl7.fhir.dstu3.model.Extension src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2016may.model.Extension tgt = new org.hl7.fhir.dstu2016may.model.Extension(); copyElement(src, tgt); tgt.setUrl(src.getUrl()); tgt.setValue(convertType(src.getValue())); return tgt; }
public org.hl7.fhir.instance.model.Extension convertExtension(org.hl7.fhir.dstu3.model.Extension src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.instance.model.Extension tgt = new org.hl7.fhir.instance.model.Extension(); copyElement(src, tgt); tgt.setUrl(src.getUrl()); tgt.setValue(convertType(src.getValue())); return tgt; }
else if (binding.getStrength() == BindingStrength.EXTENSIBLE) { if (binding.hasExtension("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet")) checkMaxValueSet(errors, path, element, profile, (Reference) binding.getExtensionsByUrl("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet").get(0).getValue(), value); else warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "The value provided ('"+value+"') is not in the value set " + describeReference(binding.getValueSet()) + " (" + vs.getUrl() + ", and a code should come from this value set unless it has no suitable code)"+(vr.getMessage() != null ? " (error message = "+vr.getMessage()+")" : ""));
@SuppressWarnings("unchecked") public static PrimitiveType<Type> readPrimitiveExtension(DomainResource c, String uri) { Extension ex = getExtension(c, uri); if (ex == null) return null; return (PrimitiveType<Type>) ex.getValue(); }
public static int readIntegerExtension(DomainResource dr, String uri, int defaultValue) { Extension ex = ExtensionHelper.getExtension(dr, uri); if (ex == null) return defaultValue; if (ex.getValue() instanceof IntegerType) return ((IntegerType) ex.getValue()).getValue(); throw new Error("Unable to read extension "+uri+" as an integer"); }
public static boolean findBooleanExtension(Element c, String uri) { Extension ex = ExtensionHelper.getExtension(c, uri); if (ex == null) return false; if (!(ex.getValue() instanceof BooleanType)) return false; return true; }
public static List<CodeType> getSubsumes(ConceptDefinitionComponent c) { List<CodeType> res = new ArrayList<CodeType>(); for (Extension e : c.getExtension()) { if (EXT_SUBSUMES.equals(e.getUrl())) res.add((CodeType) e.getValue()); } return res; }
public static boolean hasLanguageTranslation(Element element, String lang) { for (Extension e : element.getExtension()) { if (e.getUrl().equals(EXT_TRANSLATION)) { Extension e1 = ExtensionHelper.getExtension(e, "lang"); if (e1 != null && e1.getValue() instanceof CodeType && ((CodeType) e.getValue()).getValue().equals(lang)) return true; } } return false; }
public static Type getAllowedUnits(ElementDefinition eld) { for (Extension e : eld.getExtension()) if (e.getUrl().equals(EXT_ALLOWABLE_UNITS)) return e.getValue(); return null; }
public static String getLanguageTranslation(Element element, String lang) { for (Extension e : element.getExtension()) { if (e.getUrl().equals(EXT_TRANSLATION)) { Extension e1 = ExtensionHelper.getExtension(e, "lang"); if (e1 != null && e1.getValue() instanceof CodeType && ((CodeType) e.getValue()).getValue().equals(lang)) { e1 = ExtensionHelper.getExtension(e, "content"); return ((StringType) e.getValue()).getValue(); } } } return null; }
public String getExtensionString(String theUrl) throws FHIRException { List<Extension> ext = getExtensionsByUrl(theUrl); if (ext.isEmpty()) return null; if (ext.size() > 1) throw new FHIRException("Multiple matching extensions found"); if (!ext.get(0).getValue().isPrimitive()) throw new FHIRException("Extension could not be converted to a string"); return ext.get(0).getValue().primitiveValue(); }
Element ex = getExtensionByUrl(extensions, e.getUrl()); if (rule(errors, IssueType.VALUE, focus.line(), focus.col(), path, ex != null, "Extension count mismatch: unable to find extension: " + e.getUrl())) { checkFixedValue(errors, path, ex.getNamedChild("extension").getNamedChild("value"), e.getValue(), "extension.value", ex.getNamedChild("extension"));
else if (binding.getStrength() == BindingStrength.EXTENSIBLE) { if (binding.hasExtension("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet")) checkMaxValueSet(errors, path, element, profile, (Reference) binding.getExtensionsByUrl("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet").get(0).getValue(), c); else warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "Could not confirm that the codes provided are in the value set " + describeReference(binding.getValueSet()) + " (" + valueset.getUrl() + ", and a code should come from this value set unless it has no suitable code)"); else if (binding.getStrength() == BindingStrength.EXTENSIBLE) { if (binding.hasExtension("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet")) checkMaxValueSet(errors, path, element, profile, (Reference) binding.getExtensionsByUrl("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet").get(0).getValue(), c); else warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "The Coding provided is not in the value set " + describeReference(binding.getValueSet()) + " (" + valueset.getUrl() + ", and a code should come from this value set unless it has no suitable code)"+(vr.getMessage() != null ? " (error message = "+vr.getMessage()+")" : ""));
else if (binding.getStrength() == BindingStrength.EXTENSIBLE) { if (binding.hasExtension("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet")) checkMaxValueSet(errors, path, element, profile, (Reference) binding.getExtensionsByUrl("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet").get(0).getValue(), cc); else warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "Could not confirm that the codes provided are in the value set " + describeReference(binding.getValueSet()) + " and a code should come from this value set unless it has no suitable code (class = "+vr.getErrorClass().toString()+")"); else if (binding.getStrength() == BindingStrength.EXTENSIBLE) { if (binding.hasExtension("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet")) checkMaxValueSet(errors, path, element, profile, (Reference) binding.getExtensionsByUrl("http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet").get(0).getValue(), cc); else warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "None of the codes provided are in the value set " + describeReference(binding.getValueSet()) + " (" + valueset.getUrl() + ", and a code should come from this value set unless it has no suitable code) (codes = "+ccSummary(cc)+")");
public static org.hl7.fhir.dstu2016may.model.Extension convertExtension(org.hl7.fhir.dstu3.model.Extension src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu2016may.model.Extension tgt = new org.hl7.fhir.dstu2016may.model.Extension(); copyElement(src, tgt); tgt.setUrl(src.getUrl()); tgt.setValue(convertType(src.getValue())); return tgt; }
public org.hl7.fhir.instance.model.Extension convertExtension(org.hl7.fhir.dstu3.model.Extension src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.instance.model.Extension tgt = new org.hl7.fhir.instance.model.Extension(); copyElement(src, tgt); tgt.setUrl(src.getUrl()); tgt.setValue(convertType(src.getValue())); return tgt; }