From 5c413822bda2d56421ea5f52bd67486c4e89b84b Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 15 Feb 2023 11:55:18 +1100 Subject: [PATCH 1/3] Search Parameter Rendering improvements --- .../r5/renderers/OperationDefinitionRenderer.java | 8 ++------ .../java/org/hl7/fhir/r5/renderers/Renderer.java | 11 +++++++++++ .../r5/renderers/SearchParameterRenderer.java | 15 ++++++++++++--- .../fhir/r5/renderers/utils/RenderingContext.java | 11 +++++++++++ 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/OperationDefinitionRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/OperationDefinitionRenderer.java index 2bb75e365..341ebe95d 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/OperationDefinitionRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/OperationDefinitionRenderer.java @@ -110,12 +110,7 @@ public class OperationDefinitionRenderer extends TerminologyRenderer { XhtmlNode td = tr.td(); td.addText(path+p.getName()); StandardsStatus ss = ToolingExtensions.getStandardsStatus(p); - if (ss != null) { - td.tx(" "); - XhtmlNode a = td.ah("versions.html#std-process", "Standards Status = "+ss.toDisplay()); - a.style("padding-left: 3px; padding-right: 3px; border: 1px grey solid; font-weight: bold; color: black; background-color: "+ss.getColor()); - a.tx(ss.getAbbrev()); - } + genStandardsStatus(td, ss); td = tr.td(); if (p.hasScope()) { CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder(); @@ -161,4 +156,5 @@ public class OperationDefinitionRenderer extends TerminologyRenderer { } } + } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/Renderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/Renderer.java index 296ed62fc..21302ecda 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/Renderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/Renderer.java @@ -6,8 +6,10 @@ import org.hl7.fhir.r5.renderers.utils.RenderingContext.GenerationRules; import org.hl7.fhir.r5.renderers.utils.RenderingContext.ResourceRendererMode; import org.hl7.fhir.r5.utils.TranslatingUtilities; import org.hl7.fhir.utilities.MarkDownProcessor; +import org.hl7.fhir.utilities.StandardsStatus; import org.hl7.fhir.utilities.MarkDownProcessor.Dialect; import org.hl7.fhir.utilities.validation.ValidationOptions; +import org.hl7.fhir.utilities.xhtml.XhtmlNode; /** * Rendering framework: @@ -71,4 +73,13 @@ public class Renderer extends TranslatingUtilities { return context.getWorker().formatMessage(theMessage, theMessageArguments); } + public void genStandardsStatus(XhtmlNode td, StandardsStatus ss) { + if (ss != null) { + td.tx(" "); + XhtmlNode a = td.ah("versions.html#std-process", "Standards Status = "+ss.toDisplay()); + a.style("padding-left: 3px; padding-right: 3px; border: 1px grey solid; font-weight: bold; color: black; background-color: "+ss.getColor()); + a.tx(ss.getAbbrev()); + } + } + } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/SearchParameterRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/SearchParameterRenderer.java index 768540e24..b8822d749 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/SearchParameterRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/SearchParameterRenderer.java @@ -19,6 +19,8 @@ import org.hl7.fhir.r5.renderers.utils.RenderingContext; import org.hl7.fhir.r5.renderers.utils.RenderingContext.KnownLinkType; import org.hl7.fhir.r5.renderers.utils.Resolver.ResourceContext; import org.hl7.fhir.r5.utils.EOperationOutcome; +import org.hl7.fhir.r5.utils.ToolingExtensions; +import org.hl7.fhir.utilities.StandardsStatus; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.xhtml.XhtmlNode; @@ -37,7 +39,12 @@ public class SearchParameterRenderer extends TerminologyRenderer { } public boolean render(XhtmlNode x, SearchParameter spd) throws IOException, FHIRException, EOperationOutcome { - x.h2().addText(spd.getName()); + XhtmlNode h2 = x.h2(); + h2.addText(spd.getName()); + StandardsStatus ss = ToolingExtensions.getStandardsStatus(spd); + if (ss != context.getDefaultStandardsStatus()) { + genStandardsStatus(h2, ss); + } XhtmlNode p = x.para(); p.tx("Parameter "); p.code().tx(spd.getCode()); @@ -52,9 +59,11 @@ public class SearchParameterRenderer extends TerminologyRenderer { for (CodeType t : spd.getBase()) { StructureDefinition sd = context.getWorker().fetchTypeDefinition(t.toString()); if (sd != null && sd.hasUserData("path")) { - td.ah(sd.getUserString("path")).sep(", ").tx(t.getCode()); + td.sep(", "); + td.ah(sd.getUserString("path")).tx(t.getCode()); } else { - td.sep(", ").tx(t.getCode()); + td.sep(", "); + td.tx(t.getCode()); } } tr = tbl.tr(); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/RenderingContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/RenderingContext.java index 46804dc84..4560431af 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/RenderingContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/RenderingContext.java @@ -22,6 +22,7 @@ import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext; import org.hl7.fhir.utilities.FhirPublication; import org.hl7.fhir.utilities.MarkDownProcessor; import org.hl7.fhir.utilities.MarkDownProcessor.Dialect; +import org.hl7.fhir.utilities.StandardsStatus; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.validation.ValidationOptions; @@ -143,6 +144,7 @@ public class RenderingContext { private String definitionsTarget; private String destDir; private boolean inlineGraphics; + private StandardsStatus defaultStandardsStatus; private QuestionnaireRendererMode questionnaireMode = QuestionnaireRendererMode.FORM; private StructureDefinitionRendererMode structureMode = StructureDefinitionRendererMode.SUMMARY; @@ -184,6 +186,7 @@ public class RenderingContext { // default to US locale - discussion here: https://github.com/hapifhir/org.hl7.fhir.core/issues/666 this.locale = new Locale.Builder().setLanguageTag("en-US").build(); } + public RenderingContext copy() { RenderingContext res = new RenderingContext(worker, markdown, terminologyServiceOptions, getLink(KnownLinkType.SPEC), localPrefix, lang, mode, rules); @@ -223,6 +226,7 @@ public class RenderingContext { res.showComments = showComments; res.copyButton = copyButton; res.pkp = pkp; + res.defaultStandardsStatus = defaultStandardsStatus; res.terminologyServiceOptions = terminologyServiceOptions.copy(); return res; @@ -660,5 +664,12 @@ public class RenderingContext { public void setRules(GenerationRules rules) { this.rules = rules; } + public StandardsStatus getDefaultStandardsStatus() { + return defaultStandardsStatus; + } + public RenderingContext setDefaultStandardsStatus(StandardsStatus defaultStandardsStatus) { + this.defaultStandardsStatus = defaultStandardsStatus; + return this; + } } \ No newline at end of file From 26f7b3a8034a6c76f02efe4841fcdc597e0ae485 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 15 Feb 2023 12:12:28 +1100 Subject: [PATCH 2/3] FHIR-38789 SD_Dependencies extension needs work --- .../java/org/hl7/fhir/r5/utils/ToolingExtensions.java | 2 +- .../hl7/fhir/validation/instance/InstanceValidator.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java index e1c107d92..91c7104ef 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java @@ -208,7 +208,7 @@ public class ToolingExtensions { public static final String EXT_REND_MD = "http://hl7.org/fhir/StructureDefinition/rendering-markdown"; public static final String EXT_CAP_STMT_EXPECT = "http://hl7.org/fhir/StructureDefinition/capabilitystatement-expectation"; public static final String EXT_ED_HEIRARCHY = "http://hl7.org/fhir/StructureDefinition/elementdefinition-heirarchy"; - public static final String EXT_SD_DEPENDENCY = "http://hl7.org/fhir/StructureDefinition/structuredefinition-dependencies"; + public static final String EXT_SD_IMPOSE_PROFILE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-imposeProfile"; public static final String EXT_XML_NO_ORDER = "http://hl7.org/fhir/StructureDefinition/structuredefinition-xml-no-order"; public static final String EXT_DEF_TYPE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-defaulttype"; public static final String EXT_TYPE_SPEC = "http://hl7.org/fhir/tools/StructureDefinition/type-specifier"; diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java index c622ed3d1..7a0a193e7 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java @@ -863,8 +863,8 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat int i = 0; while (i < profiles.size()) { StructureDefinition sd = profiles.get(i); - if (sd.hasExtension(ToolingExtensions.EXT_SD_DEPENDENCY)) { - for (Extension ext : sd.getExtensionsByUrl(ToolingExtensions.EXT_SD_DEPENDENCY)) { + if (sd.hasExtension(ToolingExtensions.EXT_SD_IMPOSE_PROFILE)) { + for (Extension ext : sd.getExtensionsByUrl(ToolingExtensions.EXT_SD_IMPOSE_PROFILE)) { StructureDefinition dep = context.fetchResource( StructureDefinition.class, ext.getValue().primitiveValue(), sd); if (dep == null) { warning(errors, NO_RULE_DATE, IssueType.BUSINESSRULE, element.line(), element.col(), stack.getLiteralPath(), false, I18nConstants.VALIDATION_VAL_PROFILE_DEPENDS_NOT_RESOLVED, ext.getValue().primitiveValue(), sd.getVersionedUrl()); @@ -4794,8 +4794,8 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat if (pctOwned) { pct.done(); } - if (sd.hasExtension(ToolingExtensions.EXT_SD_DEPENDENCY)) { - for (Extension ext : sd.getExtensionsByUrl(ToolingExtensions.EXT_SD_DEPENDENCY)) { + if (sd.hasExtension(ToolingExtensions.EXT_SD_IMPOSE_PROFILE)) { + for (Extension ext : sd.getExtensionsByUrl(ToolingExtensions.EXT_SD_IMPOSE_PROFILE)) { StructureDefinition sdi = context.fetchResource(StructureDefinition.class, ext.getValue().primitiveValue()); if (sdi == null) { warning(errors, NO_RULE_DATE, IssueType.BUSINESSRULE, element.line(), element.col(), stack.getLiteralPath() + ".meta.profile[" + i + "]", false, I18nConstants.VALIDATION_VAL_PROFILE_DEPENDS_NOT_RESOLVED, ext.getValue().primitiveValue(), sd.getVersionedUrl()); From 7f454098b975ac2dcf3dcba65f3a23bc365e2e53 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 15 Feb 2023 12:14:48 +1100 Subject: [PATCH 3/3] search parameter rendering improvements --- .../java/org/hl7/fhir/r5/renderers/SearchParameterRenderer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/SearchParameterRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/SearchParameterRenderer.java index b8822d749..bbd477022 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/SearchParameterRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/SearchParameterRenderer.java @@ -75,7 +75,7 @@ public class SearchParameterRenderer extends TerminologyRenderer { } if (spd.hasProcessingMode()) { tr = tbl.tr(); - tr.td().tx("Usage"); + tr.td().tx("Processing Mode"); tr.td().tx(spd.getProcessingMode().getDisplay()); } if (spd.hasTarget()) {