Search Parameter Rendering improvements

This commit is contained in:
Grahame Grieve 2023-02-15 11:55:18 +11:00
parent 33a84012f2
commit 5c413822bd
4 changed files with 36 additions and 9 deletions

View File

@ -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 {
}
}
}

View File

@ -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());
}
}
}

View File

@ -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();

View File

@ -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;
}
}