use of org.hl7.fhir.r4.model.Enumerations.FHIRDefinedType in project kindling by HL7.
the class TerminologyNotesGenerator method gen.
private void gen(String prefix, Map<BindingSpecification, List<CDUsage>> txusages2) throws Exception {
List<BindingSpecification> cds = new ArrayList<BindingSpecification>();
cds.addAll(txusages.keySet());
if (cds.size() == 0)
return;
Collections.sort(cds, new MyCompare());
if (noHeader)
write("<p>\r\n<b>Terminology Bindings</b>\r\n</p>\r\n");
else
write("<h3>\r\nTerminology Bindings\r\n</h3>\r\n");
// 1. new form
write("<table class=\"grid\">\r\n");
write(" <tr><th>Path</th><th>Definition</th><th>Type</th><th>Reference</th></tr>\r\n");
for (BindingSpecification cd : cds) {
String path;
List<CDUsage> list = txusages.get(cd);
for (int i = 2; i < list.size(); i++) {
if (!matchesTypes(list.get(i).element.typeCodeNoParams(), list.get(1).element.typeCodeNoParams()))
throw new Exception("Mixed types on one concept domain in one type - not yet supported by the build process for binding " + cd.getName() + " (" + list.get(i).element.typeCode() + " vs " + list.get(1).element.typeCode() + ")");
}
String name = cd.getValueSet() != null ? cd.getValueSet().present() : cd.getName();
write(" <tr><td valign=\"top\" title=\"" + name + "\">");
boolean first = true;
for (int i = 1; i < list.size(); i++) {
if (!first)
write("<br/>");
first = false;
write(list.get(i).path);
}
write(" </td>");
write("<td valign=\"top\">" + Utilities.escapeXml(cd.getDefinition()) + "</td>");
if (cd.getBinding() == BindingMethod.Unbound)
write("<td>Unknown</td><td valign=\"top\">No details provided yet</td>");
else {
if (cd.hasMax()) {
ValueSet vs = cd.getMaxValueSet();
if (vs == null) {
write("<td><a href=\"" + prefix + "terminologies.html#" + cd.getStrength().toCode() + "\">" + cd.getStrength().getDisplay() + "</a>, but limited to <a href=\"" + cd.getMaxReference() + "\">" + cd.getMaxReference() + "</a></td>");
} else {
String pp = vs.hasUserData("external.url") ? vs.getUserString("external.url") : vs.getUserString("path");
write("<td><a href=\"" + prefix + "terminologies.html#" + cd.getStrength().toCode() + "\">" + cd.getStrength().getDisplay() + "</a>, but limited to <a href=\"" + prefix + pp.replace(File.separatorChar, '/') + "\">" + vs.getName() + "</a></td>");
}
} else
write("<td><a href=\"" + prefix + "terminologies.html#" + cd.getStrength().toCode() + "\">" + cd.getStrength().getDisplay() + "</a></td>");
write("<td valign=\"top\">");
if (cd.getBinding() == BindingSpecification.BindingMethod.Special) {
if (name.equals("MessageEvent"))
write("<a href=\"" + prefix + "valueset-message-events.html\">Message Events</a>");
else if (name.equals("ResourceType"))
write("<a href=\"" + prefix + "valueset-resource-types.html\">Resource Types</a>");
else if (name.equals("DataType"))
write("<a href=\"" + prefix + "valueset-data-types.html\">Data Types</a>");
else if (name.equals("FHIRDefinedType"))
write("<a href=\"" + prefix + "valueset-defined-types.html\">Defined Types</a>");
else if (name.equals("FHIRAllTypes"))
write("<a href=\"" + prefix + "valueset-all-types.html\">All Types</a>");
else
throw new Exception("Unknown special type " + name);
} else if (cd.getValueSet() != null) {
ValueSet vs = cd.getValueSet();
String pp = vs.hasUserData("external.url") ? vs.getUserString("external.url") : vs.getUserString("path");
if (pp == null)
throw new Exception("unknown path on " + cd.getReference());
write("<a href=\"" + prefix + pp.replace(File.separatorChar, '/') + "\">" + vs.getName() + "</a><!-- b -->");
} else if (cd.getBinding() == BindingSpecification.BindingMethod.ValueSet) {
if (Utilities.noString(cd.getReference()))
write("??");
else if (cd.getReference().startsWith("valueset-"))
write("<a href=\"" + prefix + cd.getReference() + ".html\">http://hl7.org/fhir/ValueSet/" + cd.getReference().substring(9) + "</a><!-- a -->");
else if (cd.getReference().startsWith("http://hl7.org/fhir")) {
if (cd.getReference().startsWith("http://terminology.hl7.org/ValueSet/v3-")) {
ValueSet vs = page.getValueSets().get(cd.getReference());
String pp = vs.hasUserData("external.url") ? vs.getUserString("external.url") : vs.getUserString("path");
if (pp == null)
throw new Exception("unknown path on " + cd.getReference());
write("<a href=\"" + prefix + pp.replace(File.separatorChar, '/') + "\">" + cd.getReference() + "</a><!-- b -->");
} else if (cd.getReference().startsWith("http://terminology.hl7.org/ValueSet/v2-")) {
ValueSet vs = page.getValueSets().get(cd.getReference());
String pp = vs.hasUserData("external.url") ? vs.getUserString("external.url") : vs.getUserString("path");
write("<a href=\"" + prefix + pp.replace(File.separatorChar, '/') + "\">" + cd.getReference() + "</a><!-- c -->");
} else if (cd.getReference().startsWith("http://hl7.org/fhir/ValueSet/")) {
String ref = getBindingLink(cd);
write("<a href=\"" + prefix + ref + "\">" + cd.getReference() + "</a><!-- d -->");
// BindingSpecification bs1 = page.getDefinitions().getBindingByURL(cd.getReference());
// if (bs1 != null)
// write("<a href=\""+cd.getReference().substring(23)+".html\">"+cd.getReference()+"</a><!-- d -->");
// else
// write("<a href=\"valueset-"+cd.getReference().substring(23)+".html\">"+cd.getReference()+"</a><!-- d -->");
} else
throw new Exception("Internal reference " + cd.getReference() + " not handled yet");
} else if (cd.getReference().startsWith("http:"))
write("<a href=\"" + cd.getReference() + "\">" + cd.getReference() + "</a><!-- e -->");
else
write("<a href=\"" + prefix + "valueset-" + cd.getReference() + ".html\">http://hl7.org/fhir/" + cd.getReference() + "</a><!-- e -->");
} else if (cd.getBinding() == BindingSpecification.BindingMethod.CodeList) {
write("<a href=\"" + prefix + "valueset-" + cd.getReference().substring(1) + ".html\">http://hl7.org/fhir/" + cd.getReference().substring(1) + "</a><!-- f -->");
}
write("</td>");
}
write(" </tr>\r\n");
}
write("</table>\r\n<p> </p>\r\n");
}
use of org.hl7.fhir.r4.model.Enumerations.FHIRDefinedType in project pathling by aehrc.
the class ElementPath method getInstance.
@Nonnull
private static ElementPath getInstance(@Nonnull final String expression, @Nonnull final Dataset<Row> dataset, @Nonnull final Column idColumn, @Nonnull final Optional<Column> eidColumn, @Nonnull final Column valueColumn, final boolean singular, @Nonnull final Optional<ResourcePath> currentResource, @Nonnull final Optional<Column> thisColumn, @Nonnull final FHIRDefinedType fhirType) {
// Look up the class that represents an element with the specified FHIR type.
final Class<? extends ElementPath> elementPathClass = ElementDefinition.elementClassForType(fhirType).orElse(ElementPath.class);
final DatasetWithColumnMap datasetWithColumns = eidColumn.map(eidCol -> createColumns(dataset, eidCol, valueColumn)).orElseGet(() -> createColumns(dataset, valueColumn));
try {
// Call its constructor and return.
final Constructor<? extends ElementPath> constructor = elementPathClass.getDeclaredConstructor(String.class, Dataset.class, Column.class, Optional.class, Column.class, boolean.class, Optional.class, Optional.class, FHIRDefinedType.class);
return constructor.newInstance(expression, datasetWithColumns.getDataset(), idColumn, eidColumn.map(datasetWithColumns::getColumn), datasetWithColumns.getColumn(valueColumn), singular, currentResource, thisColumn, fhirType);
} catch (final NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException("Problem building an ElementPath class", e);
}
}
use of org.hl7.fhir.r4.model.Enumerations.FHIRDefinedType in project pathling by aehrc.
the class DateTimePath method valueFromRow.
/**
* Gets a value from a row for a DateTime or DateTime literal.
*
* @param row The {@link Row} from which to extract the value
* @param columnNumber The column number to extract the value from
* @param fhirType The FHIR type to assume when extracting the value
* @return A {@link BaseDateTimeType}, or the absence of a value
*/
@Nonnull
public static Optional<BaseDateTimeType> valueFromRow(@Nonnull final Row row, final int columnNumber, final FHIRDefinedType fhirType) {
if (row.isNullAt(columnNumber)) {
return Optional.empty();
}
if (fhirType == FHIRDefinedType.INSTANT) {
final InstantType value = new InstantType(row.getTimestamp(columnNumber));
value.setTimeZone(TIME_ZONE);
return Optional.of(value);
} else {
final DateTimeType value = new DateTimeType(row.getString(columnNumber));
value.setTimeZone(TIME_ZONE);
return Optional.of(value);
}
}
use of org.hl7.fhir.r4.model.Enumerations.FHIRDefinedType in project pathling by aehrc.
the class ElementPath method build.
/**
* Builds the appropriate subtype of ElementPath based upon the supplied {@link
* ElementDefinition}.
* <p>
* Use this builder when the path is the child of another path, and will need to be traversable.
*
* @param expression the FHIRPath representation of this path
* @param dataset a {@link Dataset} that can be used to evaluate this path against data
* @param idColumn a {@link Column} within the dataset containing the identity of the subject
* resource
* @param eidColumn a {@link Column} within the dataset containing the element identity
* @param valueColumn a {@link Column} within the dataset containing the values of the nodes
* @param singular an indicator of whether this path represents a single-valued collection
* @param currentResource the current resource within this path
* @param thisColumn collection values where this path originated from {@code $this}
* @param definition the HAPI element definition that this path should be based upon
* @return a new ElementPath
*/
@Nonnull
public static ElementPath build(@Nonnull final String expression, @Nonnull final Dataset<Row> dataset, @Nonnull final Column idColumn, @Nonnull final Optional<Column> eidColumn, @Nonnull final Column valueColumn, final boolean singular, @Nonnull final Optional<ResourcePath> currentResource, @Nonnull final Optional<Column> thisColumn, @Nonnull final ElementDefinition definition) {
final Optional<FHIRDefinedType> optionalFhirType = definition.getFhirType();
if (optionalFhirType.isPresent()) {
final FHIRDefinedType fhirType = optionalFhirType.get();
final ElementPath path = ElementPath.build(expression, dataset, idColumn, eidColumn, valueColumn, singular, currentResource, thisColumn, fhirType);
path.definition = Optional.of(definition);
return path;
} else {
throw new IllegalArgumentException("Attempted to build an ElementPath with an ElementDefinition with no fhirType");
}
}
use of org.hl7.fhir.r4.model.Enumerations.FHIRDefinedType in project kindling by HL7.
the class TerminologyNotesGenerator method describeBinding.
public static String describeBinding(String prefix, BindingSpecification cd, PageProcessor page) throws Exception {
if (cd.getBinding() == BindingSpecification.BindingMethod.Unbound)
return cd.getDefinition();
if (cd.getBinding() == BindingSpecification.BindingMethod.Special) {
if (cd.getValueSet().getName().equals("MessageEvent"))
return "the <a href=\"" + prefix + "valueset-message-events.html\">Event List in the messaging framework</a>";
else if (cd.getValueSet().getName().equals("ResourceType"))
return "<a href=\"" + prefix + "valueset-resource-types.html\">Any defined Resource Type name</a>";
else if (cd.getValueSet().getName().equals("DataType"))
return "<a href=\"" + prefix + "valueset-data-types.html\">Any defined Data Type name</a>";
else if (cd.getValueSet().getName().equals("FHIRDefinedType"))
return "<a href=\"" + prefix + "valueset-defined-types.html\">Any defined Resource or Data Type name</a>";
else if (cd.getValueSet().getName().equals("FHIRAllTypes"))
return "<a href=\"" + prefix + "valueset-all-types.html\">Any defined Resource or Data Type name (including \"Any\" and \"Type\")</a>";
else
throw new Exception("Unknown special type " + cd.getValueSet().getName());
}
String mx = "";
if (cd.hasMax()) {
if (cd.getMaxValueSet() == null)
mx = " but limited to ??";
else {
String pp = cd.getMaxValueSet().hasUserData("external.url") ? cd.getMaxValueSet().getUserString("external.url") : cd.getMaxValueSet().getUserString("path");
mx = " but limited to <a href=\"" + prefix + pp.replace(File.separatorChar, '/') + "\">" + cd.getMaxValueSet().present() + "</a>";
}
}
String bs = "<a href=\"" + prefix + "terminologies.html#" + cd.getStrength().toCode() + "\">" + cd.getStrength().getDisplay() + "</a>";
if (cd.getValueSet() != null) {
ValueSet vs = cd.getValueSet();
String pp = vs.hasUserData("external.url") ? vs.getUserString("external.url") : vs.getUserString("path");
return "<a href=\"" + prefix + pp.replace(File.separatorChar, '/') + "\">" + cd.getValueSet().present() + "</a> (" + bs + mx + ")";
} else if (cd.getBinding() == BindingSpecification.BindingMethod.ValueSet) {
if (Utilities.noString(cd.getReference()))
return cd.getDescription();
else if (cd.getValueSet() == null)
return bs + ": <a href=\"" + (cd.getReference().startsWith("http") ? cd.getReference() : prefix + cd.getReference() + ".html") + "\">See " + cd.getDescription() + "</a> (" + cd.getDefinition() + mx + ")";
else
return bs + ": <a href=\"" + prefix + cd.getReference() + ".html\">See " + cd.getValueSet().getUrl() + "</a> (" + cd.getDefinition() + mx + ")";
} else if (cd.getBinding() == BindingSpecification.BindingMethod.CodeList) {
if (Utilities.noString(cd.getReference()))
return bs + ": " + cd.getDescription() + " (" + cd.getDefinition() + mx + ")";
else
return bs + ": <a href=\"" + prefix + "valueset-" + cd.getReference().substring(1) + ".html\">http://hl7.org/fhir/" + cd.getReference().substring(1) + "</a> (" + cd.getDefinition() + mx + ")";
}
return "??";
}
Aggregations