use of org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent in project kindling by HL7.
the class PageProcessor method genScList.
private String genScList(String path) throws Exception {
ResourceDefn r = definitions.getResourceByName(path.substring(0, path.indexOf(".")));
if (r == null)
throw new Exception("Unable to process sclist (1): " + path);
ElementDefn e = r.getRoot().getElementByName(definitions, path.substring(path.indexOf(".") + 1), true, false);
if (e == null)
throw new Exception("Unable to process sclist (2): " + path);
if (e.typeCode().equals("boolean"))
return "true | false";
else {
StringBuilder b = new StringBuilder();
boolean first = true;
for (ConceptSetComponent inc : e.getBinding().getValueSet().getCompose().getInclude()) {
CodeSystem cs = definitions.getCodeSystems().get(inc.getSystem());
if (cs != null) {
for (ConceptDefinitionComponent cc : cs.getConcept()) {
if (first)
first = false;
else
b.append(" | ");
b.append("<span title=\"" + cc.getDisplay() + ": " + Utilities.escapeXml(cc.getDefinition()) + "\">" + cc.getCode() + "</span>");
}
}
}
return b.toString();
}
}
use of org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent in project kindling by HL7.
the class PageProcessor method codelist.
// private String atomHeader(String n, String mode) {
// if (n.contains("-"))
// n = n.substring(0, n.indexOf('-'));
// StringBuilder b = new StringBuilder();
// b.append("<div class=\"navtop\">");
// b.append("<ul class=\"navtop\"><li class=\"spacerleft\"><span> </span></li>");
// if (mode == null || mode.equals("content"))
// b.append("<li class=\"selected\"><span>Content</span></li>");
// else
// b.append("<li class=\"nselected\"><span><a href=\""+n+".html\">Content</a></span></li>");
// if ("examples".equals(mode))
// b.append("<li class=\"selected\"><span>Examples</span></li>");
// else
// b.append("<li class=\"nselected\"><span><a href=\""+n+"-examples.html\">Examples</a></span></li>");
// b.append("<li class=\"spacerright\" style=\"width: 370px\"><span> </span></li>");
// b.append("</ul></div>\r\n");
// return b.toString();
// }
private String codelist(CodeSystem cs, String mode, boolean links, boolean heading, String source) throws Exception {
if (cs == null)
cs = definitions.getCodeSystems().get(mode);
if (cs == null)
throw new Exception("No Code system for " + mode + " from " + source);
boolean hasComments = false;
for (ConceptDefinitionComponent c : cs.getConcept()) hasComments = hasComments || checkHasComment(c);
StringBuilder b = new StringBuilder();
if (heading && !Utilities.noString(cs.getDescription()))
b.append("<h3>" + cs.getDescription() + "</h3>\r\n");
b.append("<table class=\"codes\">\r\n");
for (ConceptDefinitionComponent c : cs.getConcept()) {
genCodeItem(links, hasComments, b, c);
}
b.append("</table>\r\n");
return b.toString();
}
use of org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent in project kindling by HL7.
the class CodeListToValueSetParser method processV3ConceptDefs.
private void processV3ConceptDefs(ConceptMap cm, String url, List<ConceptDefinitionComponent> list) throws Exception {
for (ConceptDefinitionComponent c : list) {
processV3Map(cm, url, c.getCode(), c.getUserString("v3"));
processV3ConceptDefs(cm, url, c.getConcept());
}
}
use of org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent in project kindling by HL7.
the class CodeListToValueSetParser method execute.
public void execute(String v2map, String v3map, boolean utg) throws Exception {
boolean hasDefine = false;
for (int row = 0; row < sheet.rows.size(); row++) {
hasDefine = hasDefine || Utilities.noString(sheet.getColumn(row, "System"));
}
Map<String, ConceptDefinitionComponent> codes = new HashMap<String, ConceptDefinitionComponent>();
Map<String, ConceptDefinitionComponent> codesById = new HashMap<String, ConceptDefinitionComponent>();
Map<String, ConceptSetComponent> includes = new HashMap<String, ConceptSetComponent>();
CodeSystem cs = null;
if (hasDefine) {
cs = new CodeSystem();
if (utg)
cs.setUrl("http://terminology.hl7.org/CodeSystem/" + sheetName);
else
cs.setUrl("http://hl7.org/fhir/" + sheetName);
if (!valueSet.hasCompose())
valueSet.setCompose(new ValueSetComposeComponent());
valueSet.getCompose().addInclude().setSystem(cs.getUrl());
cs.setVersion(version);
cs.setCaseSensitive(true);
cs.setContent(CodeSystemContentMode.COMPLETE);
codeSystems.see(cs, packageInfo);
for (int row = 0; row < sheet.rows.size(); row++) {
if (Utilities.noString(sheet.getColumn(row, "System"))) {
ConceptDefinitionComponent cc = new ConceptDefinitionComponent();
cc.setUserData("id", sheet.getColumn(row, "Id"));
cc.setCode(sheet.getColumn(row, "Code"));
if (codes.containsKey(cc.getCode()))
throw new Exception("Duplicate Code " + cc.getCode());
codes.put(cc.getCode(), cc);
codesById.put(cc.getUserString("id"), cc);
cc.setDisplay(sheet.getColumn(row, "Display"));
if (sheet.getColumn(row, "Abstract").toUpperCase().equals("Y"))
CodeSystemUtilities.setNotSelectable(cs, cc);
if (cc.hasCode() && !cc.hasDisplay())
cc.setDisplay(Utilities.humanize(cc.getCode()));
cc.setDefinition(Utilities.appendPeriod(sheet.getColumn(row, "Definition")));
if (!Utilities.noString(sheet.getColumn(row, "Comment")))
ToolingExtensions.addCSComment(cc, sheet.getColumn(row, "Comment"));
cc.setUserData("v2", sheet.getColumn(row, "v2"));
cc.setUserData("v3", sheet.getColumn(row, "v3"));
for (String ct : sheet.columns) if (ct.startsWith("Display:") && !Utilities.noString(sheet.getColumn(row, ct)))
cc.addDesignation().setLanguage(ct.substring(8)).setValue(sheet.getColumn(row, ct));
String parent = sheet.getColumn(row, "Parent");
if (Utilities.noString(parent))
cs.addConcept(cc);
else if (parent.startsWith("#") && codesById.containsKey(parent.substring(1)))
codesById.get(parent.substring(1)).addConcept(cc);
else if (codes.containsKey(parent))
codes.get(parent).addConcept(cc);
else
throw new Exception("Parent " + parent + " not resolved in " + sheetName);
}
}
}
for (int row = 0; row < sheet.rows.size(); row++) {
if (!Utilities.noString(sheet.getColumn(row, "System"))) {
String system = sheet.getColumn(row, "System");
ConceptSetComponent t = includes.get(system);
if (t == null) {
if (!valueSet.hasCompose())
valueSet.setCompose(new ValueSetComposeComponent());
t = valueSet.getCompose().addInclude();
t.setSystem(system);
includes.put(system, t);
}
ConceptReferenceComponent cc = t.addConcept();
cc.setCode(sheet.getColumn(row, "Code"));
if (codes.containsKey(cc.getCode()))
throw new Exception("Duplicate Code " + cc.getCode());
codes.put(cc.getCode(), null);
cc.setDisplay(sheet.getColumn(row, "Display"));
if (!Utilities.noString(sheet.getColumn(row, "Definition")))
ToolingExtensions.addDefinition(cc, sheet.getColumn(row, "Definition"));
if (!Utilities.noString(sheet.getColumn(row, "Comment")))
ToolingExtensions.addVSComment(cc, sheet.getColumn(row, "Comment"));
cc.setUserDataINN("v2", sheet.getColumn(row, "v2"));
cc.setUserDataINN("v3", sheet.getColumn(row, "v3"));
for (String ct : sheet.columns) if (ct.startsWith("Display:") && !Utilities.noString(sheet.getColumn(row, ct)))
cc.addDesignation().setLanguage(ct.substring(8)).setValue(sheet.getColumn(row, ct));
}
}
if (!Utilities.noString(v2map)) {
generateConceptMapV2(v2map, valueSet, cs);
}
if (!Utilities.noString(v3map)) {
generateConceptMapV3(v3map, valueSet, cs);
}
if (cs != null)
CodeSystemConvertor.populate(cs, valueSet);
}
use of org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent in project kindling by HL7.
the class PageProcessor method codetoc.
private String codetoc(String n) throws Exception {
CodeSystem cs = definitions.getCodeSystems().get(n);
if (cs == null)
throw new Exception("Unable to find code system '" + n + "'");
StringBuilder b = new StringBuilder();
for (ConceptDefinitionComponent c : cs.getConcept()) b.append("<a href=\"#" + c.getCode() + "\">" + c.getDisplay() + "</a><br/>\r\n");
return b.toString();
}
Aggregations