public static String readStringExtension(Element c, String uri) { Extension ex = ExtensionHelper.getExtension(c, uri); if (ex == null) return null; if (ex.getValue() instanceof UriType) return ((UriType) ex.getValue()).getValue(); if (ex.getValue() instanceof CanonicalType) return ((CanonicalType) ex.getValue()).getValue(); if (ex.getValue() instanceof CodeType) return ((CodeType) ex.getValue()).getValue(); if (ex.getValue() instanceof IntegerType) return ((IntegerType) ex.getValue()).asStringValue(); if ((ex.getValue() instanceof MarkdownType)) return ((MarkdownType) ex.getValue()).getValue(); if (!(ex.getValue() instanceof StringType)) return null; return ((StringType) ex.getValue()).getValue(); }
public static String readStringExtension(DomainResource c, String uri) { Extension ex = getExtension(c, uri); if (ex == null) return null; if ((ex.getValue() instanceof StringType)) return ((StringType) ex.getValue()).getValue(); if ((ex.getValue() instanceof UriType)) return ((UriType) ex.getValue()).getValue(); if (ex.getValue() instanceof CodeType) return ((CodeType) ex.getValue()).getValue(); if (ex.getValue() instanceof IntegerType) return ((IntegerType) ex.getValue()).asStringValue(); if ((ex.getValue() instanceof MarkdownType)) return ((MarkdownType) ex.getValue()).getValue(); return null; }
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; }
@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 boolean findBooleanExtension(DomainResource 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 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 Type getAllowedUnits(ElementDefinition eld) { for (Extension e : eld.getExtension()) if (e.getUrl().equals(EXT_ALLOWABLE_UNITS)) return e.getValue(); return null; }
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 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(); }
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 org.hl7.fhir.instance.model.Extension convertExtension(org.hl7.fhir.r4.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()); if (src.hasValue()) if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.r4.model.CanonicalType) tgt.setValue(convertCanonicalToReference((CanonicalType)src.getValue())); else tgt.setValue(convertType(src.getValue())); tgt.setValue(convertType(src.getValue())); return tgt; }
public static org.hl7.fhir.dstu2016may.model.Extension convertExtension(org.hl7.fhir.r4.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()); if (src.hasValue()) if (CANONICAL_URLS.contains(src.getUrl()) && src.getValue() instanceof org.hl7.fhir.r4.model.CanonicalType) tgt.setValue(convertCanonicalToReference((CanonicalType)src.getValue())); else tgt.setValue(convertType(src.getValue())); return tgt; }
private boolean hasAnyExampleValues(StructureDefinition sd, String index) { for (ElementDefinition ed : sd.getSnapshot().getElement()) for (Extension ex : ed.getExtension()) { String ndx = ToolingExtensions.readStringExtension(ex, "index"); Extension exv = ToolingExtensions.getExtension(ex, "exValue"); if (exv != null) { Type value = exv.getValue(); if (index.equals(ndx) && value != null) return true; } } return false; }
@Override public Type getExampleValue(ElementDefinition ed) { if (ed.hasFixed()) return ed.getFixed(); for (Extension ex : ed.getExtension()) { String ndx = ToolingExtensions.readStringExtension(ex, "index"); Type value = ToolingExtensions.getExtension(ex, "exValue").getValue(); if (index.equals(ndx) && value != null) return value; } return null; } @Override
public org.hl7.fhir.instance.model.Patient.AnimalComponent convertAnimalComponent(org.hl7.fhir.r4.model.Extension src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.instance.model.Patient.AnimalComponent tgt = new org.hl7.fhir.instance.model.Patient.AnimalComponent(); copyElement(src, tgt); if (src.hasExtension("species")) tgt.setSpecies(convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) src.getExtensionByUrl("species").getValue())); if (src.hasExtension("breed")) tgt.setBreed(convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) src.getExtensionByUrl("breed").getValue())); if (src.hasExtension("genderStatus")) tgt.setGenderStatus(convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) src.getExtensionByUrl("genderStatus").getValue())); return tgt; }