use of org.hl7.fhir.r4b.model.CodeSystem.ConceptPropertyComponent in project org.hl7.fhir.core by hapifhir.
the class CodeSystemUtilities method setStatus.
public static void setStatus(CodeSystem cs, ConceptDefinitionComponent concept, ConceptStatus status) throws FHIRFormatError {
defineStatusProperty(cs);
ConceptPropertyComponent p = getProperty(concept, "status");
if (p != null)
p.setValue(new CodeType(status.toCode()));
else
concept.addProperty().setCode("status").setValue(new CodeType(status.toCode()));
}
use of org.hl7.fhir.r4b.model.CodeSystem.ConceptPropertyComponent in project org.hl7.fhir.core by hapifhir.
the class CodeSystemRenderer method addDefineRowToTable.
private boolean addDefineRowToTable(XhtmlNode t, ConceptDefinitionComponent c, int level, boolean hasHierarchy, boolean hasDisplay, boolean hasDefinitions, boolean comment, boolean version, boolean deprecated, List<UsedConceptMap> maps, String system, CodeSystem cs, List<PropertyComponent> properties, CodeSystemNavigator csNav, List<String> langs, boolean isSupplement) throws FHIRFormatError, DefinitionException, IOException {
boolean hasExtensions = false;
XhtmlNode tr = t.tr();
XhtmlNode td = tr.td();
if (hasHierarchy) {
td.addText(Integer.toString(level + 1));
td = tr.td();
String s = Utilities.padLeft("", '\u00A0', level * 2);
td.addText(s);
}
String link = isSupplement ? getLinkForCode(cs.getSupplements(), null, c.getCode()) : null;
if (link != null) {
td.ah(link).attribute("style", "white-space:nowrap").addText(c.getCode());
} else {
td.attribute("style", "white-space:nowrap").addText(c.getCode());
}
XhtmlNode a;
if (c.hasCodeElement()) {
td.an(cs.getId() + "-" + Utilities.nmtokenize(c.getCode()));
}
for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) {
if (cd.hasLanguage() && !langs.contains(cd.getLanguage()) && (!cs.hasLanguage() || !cs.getLanguage().equals(cd.getLanguage()))) {
langs.add(cd.getLanguage());
}
}
if (hasDisplay) {
td = tr.td();
renderDisplayName(c, cs, td);
}
if (hasDefinitions) {
td = tr.td();
if (c != null && c.hasDefinitionElement()) {
if (getContext().getLang() == null) {
if (hasMarkdownInDefinitions(cs))
addMarkdown(td, c.getDefinition());
else
td.addText(c.getDefinition());
} else if (getContext().getLang().equals("*")) {
boolean sl = false;
for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "definition") && cd.hasLanguage() && !c.getDefinition().equalsIgnoreCase(cd.getValue()))
sl = true;
td.addText((sl ? cs.getLanguage("en") + ": " : "") + c.getDefinition());
for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) {
if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "definition") && cd.hasLanguage() && !c.getDefinition().equalsIgnoreCase(cd.getValue())) {
td.br();
td.addText(cd.getLanguage() + ": " + cd.getValue());
}
}
} else if (getContext().getLang().equals(cs.getLanguage()) || (getContext().getLang().equals("en") && !cs.hasLanguage())) {
td.addText(c.getDefinition());
} else {
for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) {
if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "definition") && cd.hasLanguage() && cd.getLanguage().equals(getContext().getLang())) {
td.addText(cd.getValue());
}
}
}
}
}
if (deprecated) {
td = tr.td();
Boolean b = CodeSystemUtilities.isDeprecated(cs, c, false);
if (b != null && b) {
smartAddText(td, getContext().getWorker().translator().translate("xhtml-gen-cs", "Deprecated", getContext().getLang()));
hasExtensions = true;
if (ToolingExtensions.hasExtension(c, ToolingExtensions.EXT_REPLACED_BY)) {
Coding cc = (Coding) ToolingExtensions.getExtension(c, ToolingExtensions.EXT_REPLACED_BY).getValue();
td.tx(" (replaced by ");
String url = getCodingReference(cc, system);
if (url != null) {
td.ah(url).addText(cc.getCode());
td.tx(": " + cc.getDisplay() + ")");
} else
td.addText(cc.getCode() + " '" + cc.getDisplay() + "' in " + cc.getSystem() + ")");
}
}
}
if (comment) {
td = tr.td();
Extension ext = c.getExtensionByUrl(ToolingExtensions.EXT_CS_COMMENT);
if (ext != null) {
hasExtensions = true;
String bc = ext.hasValue() ? ext.getValue().primitiveValue() : null;
Map<String, String> translations = ToolingExtensions.getLanguageTranslations(ext.getValue());
if (getContext().getLang() == null) {
if (bc != null)
td.addText(bc);
} else if (getContext().getLang().equals("*")) {
boolean sl = false;
for (String l : translations.keySet()) if (bc == null || !bc.equalsIgnoreCase(translations.get(l)))
sl = true;
if (bc != null) {
td.addText((sl ? cs.getLanguage("en") + ": " : "") + bc);
}
for (String l : translations.keySet()) {
if (bc == null || !bc.equalsIgnoreCase(translations.get(l))) {
if (!td.getChildNodes().isEmpty())
td.br();
td.addText(l + ": " + translations.get(l));
}
}
} else if (getContext().getLang().equals(cs.getLanguage()) || (getContext().getLang().equals("en") && !cs.hasLanguage())) {
if (bc != null)
td.addText(bc);
} else {
if (bc != null)
translations.put(cs.getLanguage("en"), bc);
for (String l : translations.keySet()) {
if (l.equals(getContext().getLang())) {
td.addText(translations.get(l));
}
}
}
}
}
if (version) {
td = tr.td();
if (c.hasUserData("cs.version.notes"))
td.addText(c.getUserString("cs.version.notes"));
}
if (properties != null) {
for (PropertyComponent pc : properties) {
td = tr.td();
boolean first = true;
List<ConceptPropertyComponent> pcvl = CodeSystemUtilities.getPropertyValues(c, pc.getCode());
for (ConceptPropertyComponent pcv : pcvl) {
if (pcv.hasValue()) {
if (first)
first = false;
else
td.addText(", ");
if (pcv.hasValueCoding()) {
td.addText(pcv.getValueCoding().getCode());
} else if (pcv.hasValueStringType() && Utilities.isAbsoluteUrlLinkable(pcv.getValue().primitiveValue())) {
td.ah(pcv.getValue().primitiveValue()).tx(pcv.getValue().primitiveValue());
} else {
td.addText(pcv.getValue().primitiveValue());
}
}
}
}
}
for (UsedConceptMap m : maps) {
td = tr.td();
List<TargetElementComponentWrapper> mappings = findMappingsForCode(c.getCode(), m.getMap());
boolean first = true;
for (TargetElementComponentWrapper mapping : mappings) {
if (!first)
td.br();
first = false;
XhtmlNode span = td.span(null, mapping.comp.hasRelationship() ? mapping.comp.getRelationship().toCode() : "");
span.addText(getCharForRelationship(mapping.comp));
a = td.ah(getContext().getSpecificationLink() + m.getLink() + "#" + makeAnchor(mapping.group.getTarget(), mapping.comp.getCode()));
a.addText(mapping.comp.getCode());
if (!Utilities.noString(mapping.comp.getComment()))
td.i().tx("(" + mapping.comp.getComment() + ")");
}
}
List<ConceptDefinitionComponent> ocl = csNav.getOtherChildren(c);
for (ConceptDefinitionComponent cc : csNav.getConcepts(c)) {
hasExtensions = addDefineRowToTable(t, cc, level + 1, hasHierarchy, hasDisplay, hasDefinitions, comment, version, deprecated, maps, system, cs, properties, csNav, langs, isSupplement) || hasExtensions;
}
for (ConceptDefinitionComponent cc : ocl) {
tr = t.tr();
td = tr.td();
td.addText(Integer.toString(level + 2));
td = tr.td();
String s = Utilities.padLeft("", '\u00A0', (level + 1) * 2);
td.addText(s);
td.attribute("style", "white-space:nowrap");
a = td.ah("#" + cs.getId() + "-" + Utilities.nmtokenize(cc.getCode()));
a.addText(cc.getCode());
if (hasDisplay) {
td = tr.td();
renderDisplayName(cc, cs, td);
}
int w = 1 + (deprecated ? 1 : 0) + (comment ? 1 : 0) + (version ? 1 : 0) + maps.size();
if (properties != null) {
w = w + properties.size();
}
td = tr.td().colspan(Integer.toString(w));
}
return hasExtensions;
}
use of org.hl7.fhir.r4b.model.CodeSystem.ConceptPropertyComponent in project org.hl7.fhir.core by hapifhir.
the class CodeSystemRenderer method addDefineRowToTable.
private boolean addDefineRowToTable(XhtmlNode t, ConceptDefinitionComponent c, int level, boolean hasHierarchy, boolean hasDisplay, boolean hasDefinitions, boolean comment, boolean version, boolean deprecated, List<UsedConceptMap> maps, String system, CodeSystem cs, List<PropertyComponent> properties, CodeSystemNavigator csNav, List<String> langs, boolean isSupplement) throws FHIRFormatError, DefinitionException, IOException {
boolean hasExtensions = false;
XhtmlNode tr = t.tr();
XhtmlNode td = tr.td();
if (hasHierarchy) {
td.addText(Integer.toString(level + 1));
td = tr.td();
String s = Utilities.padLeft("", '\u00A0', level * 2);
td.addText(s);
}
String link = isSupplement ? getLinkForCode(cs.getSupplements(), null, c.getCode()) : null;
if (link != null) {
td.ah(link).attribute("style", "white-space:nowrap").addText(c.getCode());
} else {
td.attribute("style", "white-space:nowrap").addText(c.getCode());
}
XhtmlNode a;
if (c.hasCodeElement()) {
td.an(cs.getId() + "-" + Utilities.nmtokenize(c.getCode()));
}
for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) {
if (cd.hasLanguage() && !langs.contains(cd.getLanguage()) && (!cs.hasLanguage() || !cs.getLanguage().equals(cd.getLanguage()))) {
langs.add(cd.getLanguage());
}
}
if (hasDisplay) {
td = tr.td();
renderDisplayName(c, cs, td);
}
if (hasDefinitions) {
td = tr.td();
if (c != null && c.hasDefinitionElement()) {
if (getContext().getLang() == null) {
if (hasMarkdownInDefinitions(cs))
addMarkdown(td, c.getDefinition());
else
td.addText(c.getDefinition());
} else if (getContext().getLang().equals("*")) {
boolean sl = false;
for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "definition") && cd.hasLanguage() && !c.getDefinition().equalsIgnoreCase(cd.getValue()))
sl = true;
td.addText((sl ? cs.getLanguage("en") + ": " : "") + c.getDefinition());
for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) {
if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "definition") && cd.hasLanguage() && !c.getDefinition().equalsIgnoreCase(cd.getValue())) {
td.br();
td.addText(cd.getLanguage() + ": " + cd.getValue());
}
}
} else if (getContext().getLang().equals(cs.getLanguage()) || (getContext().getLang().equals("en") && !cs.hasLanguage())) {
td.addText(c.getDefinition());
} else {
for (ConceptDefinitionDesignationComponent cd : c.getDesignation()) {
if (cd.getUse().is("http://terminology.hl7.org/CodeSystem/designation-usage", "definition") && cd.hasLanguage() && cd.getLanguage().equals(getContext().getLang())) {
td.addText(cd.getValue());
}
}
}
}
}
if (deprecated) {
td = tr.td();
Boolean b = CodeSystemUtilities.isDeprecated(cs, c, false);
if (b != null && b) {
smartAddText(td, getContext().getWorker().translator().translate("xhtml-gen-cs", "Deprecated", getContext().getLang()));
hasExtensions = true;
if (ToolingExtensions.hasExtension(c, ToolingExtensions.EXT_REPLACED_BY)) {
Coding cc = (Coding) ToolingExtensions.getExtension(c, ToolingExtensions.EXT_REPLACED_BY).getValue();
td.tx(" (replaced by ");
String url = getCodingReference(cc, system);
if (url != null) {
td.ah(url).addText(cc.getCode());
td.tx(": " + cc.getDisplay() + ")");
} else
td.addText(cc.getCode() + " '" + cc.getDisplay() + "' in " + cc.getSystem() + ")");
}
}
}
if (comment) {
td = tr.td();
Extension ext = c.getExtensionByUrl(ToolingExtensions.EXT_CS_COMMENT);
if (ext != null) {
hasExtensions = true;
String bc = ext.hasValue() ? ext.getValue().primitiveValue() : null;
Map<String, String> translations = ToolingExtensions.getLanguageTranslations(ext.getValue());
if (getContext().getLang() == null) {
if (bc != null)
td.addText(bc);
} else if (getContext().getLang().equals("*")) {
boolean sl = false;
for (String l : translations.keySet()) if (bc == null || !bc.equalsIgnoreCase(translations.get(l)))
sl = true;
if (bc != null) {
td.addText((sl ? cs.getLanguage("en") + ": " : "") + bc);
}
for (String l : translations.keySet()) {
if (bc == null || !bc.equalsIgnoreCase(translations.get(l))) {
if (!td.getChildNodes().isEmpty())
td.br();
td.addText(l + ": " + translations.get(l));
}
}
} else if (getContext().getLang().equals(cs.getLanguage()) || (getContext().getLang().equals("en") && !cs.hasLanguage())) {
if (bc != null)
td.addText(bc);
} else {
if (bc != null)
translations.put(cs.getLanguage("en"), bc);
for (String l : translations.keySet()) {
if (l.equals(getContext().getLang())) {
td.addText(translations.get(l));
}
}
}
}
}
if (version) {
td = tr.td();
if (c.hasUserData("cs.version.notes"))
td.addText(c.getUserString("cs.version.notes"));
}
if (properties != null) {
for (PropertyComponent pc : properties) {
td = tr.td();
boolean first = true;
List<ConceptPropertyComponent> pcvl = CodeSystemUtilities.getPropertyValues(c, pc.getCode());
for (ConceptPropertyComponent pcv : pcvl) {
if (pcv.hasValue()) {
if (first)
first = false;
else
td.addText(", ");
if (pcv.hasValueCoding()) {
td.addText(pcv.getValueCoding().getCode());
} else if (pcv.hasValueStringType() && Utilities.isAbsoluteUrlLinkable(pcv.getValue().primitiveValue())) {
td.ah(pcv.getValue().primitiveValue()).tx(pcv.getValue().primitiveValue());
} else {
td.addText(pcv.getValue().primitiveValue());
}
}
}
}
}
for (UsedConceptMap m : maps) {
td = tr.td();
List<TargetElementComponentWrapper> mappings = findMappingsForCode(c.getCode(), m.getMap());
boolean first = true;
for (TargetElementComponentWrapper mapping : mappings) {
if (!first)
td.br();
first = false;
XhtmlNode span = td.span(null, mapping.comp.hasEquivalence() ? mapping.comp.getEquivalence().toCode() : "");
span.addText(getCharForRelationship(mapping.comp));
a = td.ah(getContext().getSpecificationLink() + m.getLink() + "#" + makeAnchor(mapping.group.getTarget(), mapping.comp.getCode()));
a.addText(mapping.comp.getCode());
if (!Utilities.noString(mapping.comp.getComment()))
td.i().tx("(" + mapping.comp.getComment() + ")");
}
}
List<ConceptDefinitionComponent> ocl = csNav.getOtherChildren(c);
for (ConceptDefinitionComponent cc : csNav.getConcepts(c)) {
hasExtensions = addDefineRowToTable(t, cc, level + 1, hasHierarchy, hasDisplay, hasDefinitions, comment, version, deprecated, maps, system, cs, properties, csNav, langs, isSupplement) || hasExtensions;
}
for (ConceptDefinitionComponent cc : ocl) {
tr = t.tr();
td = tr.td();
td.addText(Integer.toString(level + 2));
td = tr.td();
String s = Utilities.padLeft("", '\u00A0', (level + 1) * 2);
td.addText(s);
td.attribute("style", "white-space:nowrap");
a = td.ah("#" + cs.getId() + "-" + Utilities.nmtokenize(cc.getCode()));
a.addText(cc.getCode());
if (hasDisplay) {
td = tr.td();
renderDisplayName(cc, cs, td);
}
int w = 1 + (deprecated ? 1 : 0) + (comment ? 1 : 0) + (version ? 1 : 0) + maps.size();
if (properties != null) {
w = w + properties.size();
}
td = tr.td().colspan(Integer.toString(w));
}
return hasExtensions;
}
use of org.hl7.fhir.r4b.model.CodeSystem.ConceptPropertyComponent in project org.hl7.fhir.core by hapifhir.
the class BaseWorkerContext method oid2Uri.
@Override
public String oid2Uri(String oid) {
synchronized (lock) {
if (oid != null && oid.startsWith("urn:oid:")) {
oid = oid.substring(8);
}
if (oidCache.containsKey(oid)) {
return oidCache.get(oid);
}
String uri = OIDUtils.getUriForOid(oid);
if (uri != null) {
oidCache.put(oid, uri);
return uri;
}
CodeSystem cs = fetchCodeSystem("http://terminology.hl7.org/CodeSystem/v2-tables");
if (cs != null) {
for (ConceptDefinitionComponent cc : cs.getConcept()) {
for (ConceptPropertyComponent cp : cc.getProperty()) {
if (Utilities.existsInList(cp.getCode(), "v2-table-oid", "v2-cs-oid") && oid.equals(cp.getValue().primitiveValue())) {
for (ConceptPropertyComponent cp2 : cc.getProperty()) {
if ("v2-cs-uri".equals(cp2.getCode())) {
oidCache.put(oid, cp2.getValue().primitiveValue());
return cp2.getValue().primitiveValue();
}
}
}
}
}
}
for (CodeSystem css : codeSystems.getList()) {
if (("urn:oid:" + oid).equals(css.getUrl())) {
oidCache.put(oid, css.getUrl());
return css.getUrl();
}
for (Identifier id : css.getIdentifier()) {
if ("urn:ietf:rfc:3986".equals(id.getSystem()) && ("urn:oid:" + oid).equals(id.getValue())) {
oidCache.put(oid, css.getUrl());
return css.getUrl();
}
}
}
for (NamingSystem ns : systems.getList()) {
if (hasOid(ns, oid)) {
uri = getUri(ns);
if (uri != null) {
oidCache.put(oid, null);
return null;
}
}
}
}
oidCache.put(oid, null);
return null;
}
use of org.hl7.fhir.r4b.model.CodeSystem.ConceptPropertyComponent in project org.hl7.fhir.core by hapifhir.
the class CodeSystemUtilities method setNotSelectable.
public static void setNotSelectable(CodeSystem cs, ConceptDefinitionComponent concept) throws FHIRFormatError {
defineNotSelectableProperty(cs);
ConceptPropertyComponent p = getProperty(concept, "abstract");
if (p != null)
p.setValue(new BooleanType(true));
else
concept.addProperty().setCode("notSelectable").setValue(new BooleanType(true));
}
Aggregations