Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Fix: Fix split logic of canonical into url and version in several places #1663

Merged
merged 5 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,4 @@ This project is maintained by [Grahame Grieve][Link-grahameGithub], [James Agnew
[Badge-cliSonatypeSnapshot]: https://img.shields.io/nexus/s/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.validation.cli.svg "Sonatype Snapshots"
[Badge-validationSonatypeRelease]: https://img.shields.io/nexus/r/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.validation.svg "Sonatype Releases"
[Badge-validationSonatypeSnapshot]: https://img.shields.io/nexus/s/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.validation.svg "Sonatype Snapshots"

Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ public boolean render(XhtmlNode x, ConceptMap cm) throws FHIRFormatError, Defini
td = tr.td();
td.addText(ccl.getCode());
display = ccl.hasDisplay() ? ccl.getDisplay()
: getDisplayForConcept(systemFromCanonical(grp.getSource()), versionFromCanonical(grp.getSource()),
ccl.getCode());
: getDisplayForConcept(grp.getSource(), ccl.getCode());
if (display != null && !isSameCodeAndDisplay(ccl.getCode(), display))
td.tx(" (" + display + ")");
TargetElementComponent ccm = ccl.getTarget().get(0);
Expand All @@ -166,8 +165,7 @@ public boolean render(XhtmlNode x, ConceptMap cm) throws FHIRFormatError, Defini
td = tr.td();
td.addText(ccm.getCode());
display = ccm.hasDisplay() ? ccm.getDisplay()
: getDisplayForConcept(systemFromCanonical(grp.getTarget()), versionFromCanonical(grp.getTarget()),
ccm.getCode());
: getDisplayForConcept(grp.getTarget(), ccm.getCode());
if (display != null && !isSameCodeAndDisplay(ccm.getCode(), display))
td.tx(" (" + display + ")");
if (comment)
Expand Down Expand Up @@ -247,8 +245,7 @@ public boolean render(XhtmlNode x, ConceptMap cm) throws FHIRFormatError, Defini
td.addText(ccl.getCode());
else
td.addText(grp.getSource() + " / " + ccl.getCode());
display = getDisplayForConcept(systemFromCanonical(grp.getSource()), versionFromCanonical(grp.getSource()),
ccl.getCode());
display = getDisplayForConcept(grp.getSource(), ccl.getCode());
tr.td().style("border-left-width: 0px").tx(display == null ? "" : display);
tr.td().colspan("4").style("background-color: #efefef").tx("(not mapped)");

Expand All @@ -270,8 +267,7 @@ else if (!last)
else
td.addText(grp.getSource() + " / " + ccl.getCode());
display = ccl.hasDisplay() ? ccl.getDisplay()
: getDisplayForConcept(systemFromCanonical(grp.getSource()), versionFromCanonical(grp.getSource()),
ccl.getCode());
: getDisplayForConcept(grp.getSource(), ccl.getCode());
td = tr.td();
if (!last)
td.style("border-left-width: 0px; border-bottom-style: none");
Expand Down Expand Up @@ -311,7 +307,7 @@ else if (!last)
else
td.addText(grp.getTarget() + " / " + ccm.getCode());
display = ccm.hasDisplay() ? ccm.getDisplay()
: getDisplayForConcept(systemFromCanonical(grp.getTarget()), versionFromCanonical(grp.getTarget()),
: getDisplayForConcept(grp.getTarget(),
ccm.getCode());
tr.td().style("border-left-width: 0px").tx(display == null ? "" : display);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1731,24 +1731,5 @@ private String getStackTrace(Exception e) {
return b.toString();
}

protected String versionFromCanonical(String system) {
if (system == null) {
return null;
} else if (system.contains("|")) {
return system.substring(0, system.indexOf("|"));
} else {
return null;
}
}

protected String systemFromCanonical(String system) {
if (system == null) {
return null;
} else if (system.contains("|")) {
return system.substring(system.indexOf("|") + 1);
} else {
return system;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.hl7.fhir.r4b.renderers.utils.Resolver.ResourceContext;
import org.hl7.fhir.r4b.terminologies.CodeSystemUtilities;
import org.hl7.fhir.r4b.utils.ToolingExtensions;
import org.hl7.fhir.utilities.CanonicalPair;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.xhtml.XhtmlNode;

Expand Down Expand Up @@ -325,8 +326,14 @@ protected void AddVsRef(String value, XhtmlNode li) {
}
}
}


protected String getDisplayForConcept(String system, String version, String value) {
protected String getDisplayForConcept(String canonical, String value) {
var split = CanonicalPair.of(canonical);
return getDisplayForConcept(split.getUrl(), split.getVersion(), value);
}

private String getDisplayForConcept(String system, String version, String value) {
if (value == null || system == null)
return null;
ValidationResult cl = getContext().getWorker().validateCode(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ public boolean render(XhtmlNode x, ConceptMap cm, boolean header) throws FHIRFor
tr = tbl.tr();
XhtmlNode td = tr.td();
td.addText(ccl.getCode());
display = ccl.hasDisplay() ? ccl.getDisplay() : getDisplayForConcept(systemFromCanonical(grp.getSource()), versionFromCanonical(grp.getSource()), ccl.getCode());
display = ccl.hasDisplay() ? ccl.getDisplay() : getDisplayForConcept(grp.getSource(), ccl.getCode());
if (display != null && !isSameCodeAndDisplay(ccl.getCode(), display))
td.tx(" ("+display+")");
if (ccl.getNoMap()) {
Expand All @@ -447,7 +447,7 @@ public boolean render(XhtmlNode x, ConceptMap cm, boolean header) throws FHIRFor
}
td = tr.td();
td.addText(ccm.getCode());
display = ccm.hasDisplay() ? ccm.getDisplay() : getDisplayForConcept(systemFromCanonical(grp.getTarget()), versionFromCanonical(grp.getTarget()), ccm.getCode());
display = ccm.hasDisplay() ? ccm.getDisplay() : getDisplayForConcept(grp.getTarget(), ccm.getCode());
if (display != null && !isSameCodeAndDisplay(ccm.getCode(), display))
td.tx(" ("+display+")");
if (comment)
Expand Down Expand Up @@ -539,7 +539,7 @@ public boolean render(XhtmlNode x, ConceptMap cm, boolean header) throws FHIRFor
td.addText(ccl.getCode());
else
td.addText(grp.getSource()+" / "+ccl.getCode());
display = ccl.hasDisplay() ? ccl.getDisplay() : getDisplayForConcept(systemFromCanonical(grp.getSource()), versionFromCanonical(grp.getSource()), ccl.getCode());
display = ccl.hasDisplay() ? ccl.getDisplay() : getDisplayForConcept(grp.getSource(), ccl.getCode());
tr.td().style("border-left-width: 0px").tx(display == null ? "" : display);
tr.td().colspan("4").style("background-color: #efefef").tx("(not mapped)");

Expand All @@ -560,7 +560,7 @@ else if (!last)
td.addText(ccl.getCode());
else
td.addText(grp.getSource()+" / "+ccl.getCode());
display = ccl.hasDisplay() ? ccl.getDisplay() : getDisplayForConcept(systemFromCanonical(grp.getSource()), versionFromCanonical(grp.getSource()), ccl.getCode());
display = ccl.hasDisplay() ? ccl.getDisplay() : getDisplayForConcept(grp.getSource(), ccl.getCode());
td = tr.td();
if (!last)
td.style("border-left-width: 0px; border-bottom-style: none");
Expand Down Expand Up @@ -603,7 +603,7 @@ else if (!last)
td.addText(ccm.getCode());
else
td.addText(grp.getTarget()+" / "+ccm.getCode());
display = ccm.hasDisplay() ? ccm.getDisplay() : getDisplayForConcept(systemFromCanonical(grp.getTarget()), versionFromCanonical(grp.getTarget()), ccm.getCode());
display = ccm.hasDisplay() ? ccm.getDisplay() : getDisplayForConcept(grp.getSource(), ccm.getCode());
tr.td().style("border-left-width: 0px").tx(display == null ? "" : display);

for (String s : targets.keySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1956,26 +1956,5 @@ private String getStackTrace(Exception e) {
}
return b.toString();
}

protected String versionFromCanonical(String system) {
if (system == null) {
return null;
} else if (system.contains("|")) {
return system.substring(0, system.indexOf("|"));
} else {
return null;
}
}

protected String systemFromCanonical(String system) {
if (system == null) {
return null;
} else if (system.contains("|")) {
return system.substring(system.indexOf("|")+1);
} else {
return system;
}
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public void renderCanonical(ResourceWrapper rw, XhtmlNode x, String url, boolean
} else {
url = url.substring(0, url.indexOf("|"));
x.code().tx(url);
x.tx(": "+cr.present()+ context.formatPhrase(RenderingContext.RES_REND_VER) +cr.getVersion()+")");
x.tx(": "+cr.present()+ " " + context.formatPhrase(RenderingContext.RES_REND_VER) + " " + cr.getVersion()+")");
}
} else {
if (target.hasWebPath()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.hl7.fhir.r5.terminologies.CodeSystemUtilities;
import org.hl7.fhir.r5.terminologies.utilities.ValidationResult;
import org.hl7.fhir.r5.utils.ToolingExtensions;
import org.hl7.fhir.utilities.CanonicalPair;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.xhtml.XhtmlNode;

Expand Down Expand Up @@ -325,6 +326,11 @@ protected void AddVsRef(String value, XhtmlNode li, Resource source) {
}
}

protected String getDisplayForConcept(String canonical, String value) {
var split = CanonicalPair.of(canonical);
return getDisplayForConcept(split.getUrl(), split.getVersion(), value);
}

protected String getDisplayForConcept(String system, String version, String value) {
if (value == null || system == null)
return null;
Expand Down
Loading