Add support for logical_container extension

This commit is contained in:
Grahame Grieve 2023-12-15 02:44:37 -05:00
parent bb020dd739
commit ea4ccdf527
5 changed files with 45 additions and 5 deletions

View File

@ -6017,7 +6017,7 @@ public class FHIRPathEngine {
if (url.startsWith(TypeDetails.FP_NS)) { if (url.startsWith(TypeDetails.FP_NS)) {
return; return;
} else { } else {
throw makeException(expr, I18nConstants.FHIRPATH_UNKNOWN_TYPE, url, "getChildTypesByName"); throw makeException(expr, I18nConstants.FHIRPATH_UNKNOWN_TYPE, url, "getChildTypesByName#1");
} }
} }
List<StructureDefinition> sdl = new ArrayList<StructureDefinition>(); List<StructureDefinition> sdl = new ArrayList<StructureDefinition>();
@ -6028,14 +6028,14 @@ public class FHIRPathEngine {
if (m.fixedType != null) { if (m.fixedType != null) {
StructureDefinition dt = worker.fetchResource(StructureDefinition.class, ProfileUtilities.sdNs(m.fixedType, null), sd); StructureDefinition dt = worker.fetchResource(StructureDefinition.class, ProfileUtilities.sdNs(m.fixedType, null), sd);
if (dt == null) { if (dt == null) {
throw makeException(expr, I18nConstants.FHIRPATH_UNKNOWN_TYPE, ProfileUtilities.sdNs(m.fixedType, null), "getChildTypesByName"); throw makeException(expr, I18nConstants.FHIRPATH_UNKNOWN_TYPE, ProfileUtilities.sdNs(m.fixedType, null), "getChildTypesByName#2");
} }
sdl.add(dt); sdl.add(dt);
} else } else
for (TypeRefComponent t : m.definition.getType()) { for (TypeRefComponent t : m.definition.getType()) {
StructureDefinition dt = worker.fetchResource(StructureDefinition.class, ProfileUtilities.sdNs(t.getCode(), null)); StructureDefinition dt = worker.fetchResource(StructureDefinition.class, ProfileUtilities.sdNs(t.getCode(), null));
if (dt == null) { if (dt == null) {
throw makeException(expr, I18nConstants.FHIRPATH_UNKNOWN_TYPE, ProfileUtilities.sdNs(t.getCode(), null), "getChildTypesByName"); throw makeException(expr, I18nConstants.FHIRPATH_UNKNOWN_TYPE, ProfileUtilities.sdNs(t.getCode(), null), "getChildTypesByName#3");
} }
addTypeAndDescendents(sdl, dt, cu.allStructures()); addTypeAndDescendents(sdl, dt, cu.allStructures());
// also add any descendant types // also add any descendant types

View File

@ -1524,6 +1524,19 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
c.addPiece(gen.new Piece(null, "Instances of this type are validated using an unknown approach: "+ps, null).addStyle("font-weight:bold")); c.addPiece(gen.new Piece(null, "Instances of this type are validated using an unknown approach: "+ps, null).addStyle("font-weight:bold"));
} }
} }
Extension lc = ToolingExtensions.getExtension(profile, ToolingExtensions.EXT_LOGICAL_CONTAINER);
if (lc != null && lc.hasValueUriType()) {
if (!c.getPieces().isEmpty()) { c.addPiece(gen.new Piece("br")); }
c.getPieces().add(gen.new Piece(null, translate("sd.table", "Logical Container")+": ", "The root class that contains instances of this class").addStyle("font-weight:bold"));
String uri = lc.getValue().primitiveValue();
StructureDefinition lct = context.getContext().fetchTypeDefinition(uri);
if (lct != null) {
c.addPiece(gen.new Piece(lct.getWebPath(), lct.present(), null));
} else {
c.addPiece(gen.new Piece(null, uri, null));
}
}
} }
} }
if (definition != null) { if (definition != null) {
@ -3583,6 +3596,18 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
} else { } else {
tableRow(tbl, "Logical Model", null, strikethrough, "Instances of this logical model cannot be the target of a Reference"); tableRow(tbl, "Logical Model", null, strikethrough, "Instances of this logical model cannot be the target of a Reference");
} }
Extension lc = ToolingExtensions.getExtension(sd, ToolingExtensions.EXT_LOGICAL_CONTAINER);
if (lc != null && lc.hasValueUriType()) {
String uri = lc.getValue().primitiveValue();
StructureDefinition lct = context.getContext().fetchTypeDefinition(uri);
if (lct != null) {
tableRowLink(tbl, "Logical Container", null, strikethrough, lct.present(), lct.getWebPath());
} else {
tableRow(tbl, "Logical Container", null, strikethrough, uri);
}
}
String ps = ToolingExtensions.readStringExtension(sd, ToolingExtensions.EXT_PROFILE_STYLE); String ps = ToolingExtensions.readStringExtension(sd, ToolingExtensions.EXT_PROFILE_STYLE);
if (ps != null) { if (ps != null) {
if ("cda".equals(ps)) { if ("cda".equals(ps)) {
@ -3984,6 +4009,17 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
} }
} }
private void tableRowLink(XhtmlNode x, String name, String defRef, boolean strikethrough, String text, String link) throws IOException {
if (!Utilities.noString(text)) {
var tr = x.tr();
if (strikethrough) {
tr.style("text-decoration: line-through");
}
addFirstCell(name, defRef, tr);
tr.td().ah(link).tx(text);
}
}
private void addFirstCell(String name, String defRef, XhtmlNode tr) { private void addFirstCell(String name, String defRef, XhtmlNode tr) {
var td = tr.td(); var td = tr.td();
if (name.length() <= 16) { if (name.length() <= 16) {

View File

@ -143,6 +143,7 @@ public class ToolingExtensions {
public static final String EXT_BINDING_STYLE = "http://hl7.org/fhir/tools/StructureDefinition/elementdefinition-binding-style"; public static final String EXT_BINDING_STYLE = "http://hl7.org/fhir/tools/StructureDefinition/elementdefinition-binding-style";
public static final String EXT_EXTENSION_STYLE = "http://hl7.org/fhir/tools/StructureDefinition/elementdefinition-extension-style"; public static final String EXT_EXTENSION_STYLE = "http://hl7.org/fhir/tools/StructureDefinition/elementdefinition-extension-style";
public static final String EXT_LOGICAL_TARGET = "http://hl7.org/fhir/tools/StructureDefinition/logical-target"; public static final String EXT_LOGICAL_TARGET = "http://hl7.org/fhir/tools/StructureDefinition/logical-target";
public static final String EXT_LOGICAL_CONTAINER = "http://hl7.org/fhir/tools/StructureDefinition/logical-container";
public static final String EXT_PROFILE_MAPPING = "http://hl7.org/fhir/tools/StructureDefinition/profile-mapping"; public static final String EXT_PROFILE_MAPPING = "http://hl7.org/fhir/tools/StructureDefinition/profile-mapping";
public static final String EXT_CS_ALTERNATE_USE = "http://hl7.org/fhir/StructureDefinition/alternate-code-use"; public static final String EXT_CS_ALTERNATE_USE = "http://hl7.org/fhir/StructureDefinition/alternate-code-use";
public static final String EXT_CS_ALTERNATE_STATUS = "http://hl7.org/fhir/StructureDefinition/alternate-code-status"; public static final String EXT_CS_ALTERNATE_STATUS = "http://hl7.org/fhir/StructureDefinition/alternate-code-status";

View File

@ -7046,7 +7046,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
return true; return true;
} }
if (format == FhirFormat.XML) { if (format == FhirFormat.XML) {
String xn = ToolingExtensions.readStringExtension(defn, "http://hl7.org/fhir/StructureDefinition/elementdefinition-xml-name"); String xn = ToolingExtensions.readStringExtension(defn, ToolingExtensions.EXT_XML_NAME);
if (resourceName.equals(xn)) { if (resourceName.equals(xn)) {
return true; return true;
} }

View File

@ -576,6 +576,9 @@ public class StructureDefinitionValidator extends BaseValidator {
StructureDefinition sd = context.fetchTypeDefinition(rootPath); StructureDefinition sd = context.fetchTypeDefinition(rootPath);
if (sd != null && sd.getKind() == StructureDefinitionKind.RESOURCE) { if (sd != null && sd.getKind() == StructureDefinitionKind.RESOURCE) {
fpe.checkOnTypes(vc, rootPath, types, fpe.parse(exp), warnings); fpe.checkOnTypes(vc, rootPath, types, fpe.parse(exp), warnings);
} else if (sd != null && sd.getKind() == StructureDefinitionKind.LOGICAL) {
String tn = ToolingExtensions.readStringExtension(sd, ToolingExtensions.EXT_LOGICAL_CONTAINER);
fpe.checkOnTypes(vc, tn == null ? rootPath : tn, types, fpe.parse(exp), warnings);
} else { } else {
fpe.checkOnTypes(vc, "DomainResource", types, fpe.parse(exp), warnings); fpe.checkOnTypes(vc, "DomainResource", types, fpe.parse(exp), warnings);
} }
@ -1078,7 +1081,7 @@ public class StructureDefinitionValidator extends BaseValidator {
} }
} }
} }
if (ToolingExtensions.readBoolExtension(t, "http://hl7.org/fhir/tools/StructureDefinition/logical-target")) { if (ToolingExtensions.readBoolExtension(t, ToolingExtensions.EXT_LOGICAL_TARGET)) {
return true; return true;
} }
return false; return false;