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

Fix split logic of canonical into url and version in several places #1619

Closed
Closed
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
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 @@ -1976,25 +1976,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.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 @@ -320,6 +321,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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<commons_compress_version>1.26.0</commons_compress_version>
<guava_version>32.0.1-jre</guava_version>
<hapi_fhir_version>6.4.1</hapi_fhir_version>
<validator_test_case_version>1.5.7</validator_test_case_version>
<validator_test_case_version>1.5.8-SNAPSHOT</validator_test_case_version>
<jackson_version>2.17.0</jackson_version>
<junit_jupiter_version>5.9.2</junit_jupiter_version>
<junit_platform_launcher_version>1.8.2</junit_platform_launcher_version>
Expand Down
Loading