use of org.hl7.fhir.r4.model.ValueSet in project kindling by HL7.
the class PageProcessor method xreferencesForV2.
private String xreferencesForV2(String name, String level) {
if (!definitions.getValuesets().has("http://terminology.hl7.org/ValueSet/v2-" + name))
return ". ";
String n = definitions.getValuesets().get("http://terminology.hl7.org/ValueSet/v2-" + name).present().replace("-", "").replace(" ", "").replace("_", "").toLowerCase();
StringBuilder b = new StringBuilder();
String pfx = "../../";
if (level.equals("l3"))
pfx = "../../../";
ValueSet ae = findRelatedValueset(n, definitions.getValuesets(), "http://hl7.org/fhir/ValueSet/");
if (ae != null)
b.append(". Related FHIR content: <a href=\"").append(pfx).append(ae.getUserData("path")).append("\">").append(ae.present()).append("</a>");
ae = findRelatedValueset(n, definitions.getValuesets(), "http://terminology.hl7.org/ValueSet/v3-");
if (ae != null)
b.append(". Related v3 content: <a href=\"").append(pfx).append(ae.getUserData("path")).append("\">").append(ae.present()).append("</a>");
return b.toString() + ". ";
}
use of org.hl7.fhir.r4.model.ValueSet in project kindling by HL7.
the class PageProcessor method describeReference.
private String describeReference(ElementDefinitionBindingComponent binding) throws FHIRException {
if (binding.hasValueSet()) {
ValueSet vs = workerContext.fetchResource(ValueSet.class, binding.getValueSet());
String disp = vs != null ? vs.present() : "??";
return "<a href=\"" + (vs == null ? binding.getValueSet() : vs.getUserData("filename")) + "\">" + disp + "</a>";
} else
return "??";
}
use of org.hl7.fhir.r4.model.ValueSet in project kindling by HL7.
the class PageProcessor method resolveBinding.
public BindingResolution resolveBinding(StructureDefinition profile, String ref, String description, String path) throws FHIRException {
BindingResolution br = new BindingResolution();
if (ref.contains("|"))
ref = ref.substring(0, ref.indexOf("|"));
if (ref.startsWith("http://terminology.hl7.org/ValueSet/v3-") || ref.startsWith("http://terminology.hl7.org/ValueSet/v2-")) {
ValueSet vs = workerContext.fetchResource(ValueSet.class, ref);
if (vs == null) {
br.url = "v3/" + ref.substring(39) + "/vs.html";
br.display = ref.substring(39);
} else {
br.url = vs.getUserString("path");
br.display = vs.present();
}
} else if (definitions.getValuesets().has(ref)) {
ValueSet vs = definitions.getValuesets().get(ref);
br.url = vs.getUserString("path");
br.display = vs.present();
} else if (ref.startsWith("ValueSet/")) {
ValueSet vs = definitions.getValuesets().get(ref.substring(8));
if (vs == null) {
br.url = ref.substring(9) + ".html";
br.display = ref.substring(9);
} else {
br.url = vs.getUserString("path");
br.display = vs.present();
}
} else if (ref.startsWith("http://hl7.org/fhir/ValueSet/")) {
ValueSet vs = definitions.getValuesets().get(ref);
if (vs == null)
vs = definitions.getExtraValuesets().get(ref);
if (vs != null) {
br.url = vs.getUserString("path");
if (Utilities.noString(br.url))
br.url = ref.substring(23) + ".html";
br.display = vs.present();
} else if (ref.substring(23).equals("use-context")) {
// special case because this happens before the value set is created
br.url = "valueset-" + ref.substring(23) + ".html";
br.display = "Context of Use ValueSet";
} else if (ref.startsWith("http://terminology.hl7.org/ValueSet/v3-")) {
br.url = "v3/" + ref.substring(26) + "/index.html";
br.display = ref.substring(26);
} else if (ref.startsWith("http://terminology.hl7.org/ValueSet/v2-")) {
br.url = "v2/" + ref.substring(26) + "/index.html";
br.display = ref.substring(26);
} else if (ref.startsWith("#")) {
br.url = null;
br.display = ref;
} else {
br.url = ref;
br.display = "????";
getValidationErrors().add(new ValidationMessage(Source.Publisher, IssueType.NOTFOUND, -1, -1, path, "Unresolved Value set " + ref, IssueSeverity.WARNING));
}
} else {
br.url = ref;
if (ref.equals("http://tools.ietf.org/html/bcp47"))
br.display = "IETF BCP-47";
else if (ref.equals("http://www.rfc-editor.org/bcp/bcp13.txt"))
br.display = "IETF BCP-13";
else if (ref.equals("http://www.ncbi.nlm.nih.gov/nuccore?db=nuccore"))
br.display = "NucCore";
else if (ref.equals("https://rtmms.nist.gov/rtmms/index.htm#!rosetta"))
br.display = "Rosetta";
else if (ref.equals("http://www.iso.org/iso/country_codes.htm"))
br.display = "ISO Country Codes";
else if (ref.equals("http://www.ncbi.nlm.nih.gov/clinvar/variation"))
br.display = "ClinVar";
else if (!Utilities.noString(description))
br.display = description;
else
br.display = "????";
}
return br;
}
use of org.hl7.fhir.r4.model.ValueSet in project kindling by HL7.
the class PageProcessor method usageSummary.
private String usageSummary(ValueSet vs) throws FHIRException {
String s = (String) vs.getUserData(ToolResourceUtilities.NAME_SPEC_USAGE);
if (Utilities.noString(s))
return "??";
else {
String[] ps = s.split("\\,");
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
for (String p : ps) {
if (!definitions.getIgs().containsKey(p))
b.append(p);
else if (!Utilities.noString(definitions.getIgs().get(p).getHomePage()))
b.append("<a href=\"" + definitions.getIgs().get(p).getCode() + "/" + definitions.getIgs().get(p).getHomePage() + "\" title=\"" + definitions.getIgs().get(p).getName() + "\">" + p + "</a>");
else
b.append("<span title=\"" + definitions.getIgs().get(p).getCode() + "/" + definitions.getIgs().get(p).getName() + "\">" + p + "</span>");
}
return b.toString();
}
}
use of org.hl7.fhir.r4.model.ValueSet in project kindling by HL7.
the class PageProcessor method expandVS.
public String expandVS(ValueSet vs, String prefix, String base) {
try {
ValueSetExpansionOutcome result = workerContext.expandVS(vs, true, true);
if (result.getError() != null)
return "<hr/>\r\n" + VS_INC_START + "<!--3-->" + processExpansionError(result.getError()) + VS_INC_END;
if (result.getValueset() == null)
return "<hr/>\r\n" + VS_INC_START + "<!--4-->" + processExpansionError("(no error returned)") + VS_INC_END;
ValueSet exp = result.getValueset();
if (exp == vs)
throw new Exception("Expansion cannot be the same instance");
exp.setCompose(null);
exp.setText(null);
exp.setDescription("Value Set Contents (Expansion) for " + vs.present() + " at " + Config.DATE_FORMAT().format(new Date()));
int i = countContains(exp.getExpansion().getContains());
IniFile sini = new IniFile(Utilities.path(folders.rootDir, "temp", "stats.ini"));
sini.setIntegerProperty("valuesets", vs.getId(), i, null);
sini.save();
RenderingContext lrc = rc.copy().setLocalPrefix(prefix).setTooCostlyNoteEmpty(TOO_MANY_CODES_TEXT_EMPTY).setTooCostlyNoteNotEmpty(TOO_MANY_CODES_TEXT_NOT_EMPTY);
RendererFactory.factory(exp, lrc).render(exp);
return "<hr/>\r\n" + VS_INC_START + "" + new XhtmlComposer(XhtmlComposer.HTML).compose(exp.getText().getDiv()) + VS_INC_END;
} catch (Exception e) {
e.printStackTrace();
return "<hr/>\r\n" + VS_INC_START + "<!--5-->" + processExpansionError(e instanceof NullPointerException ? "NullPointerException" : e.getMessage()) + " " + Utilities.escapeXml(stack(e)) + VS_INC_END;
}
}
Aggregations