From 8e3833f58a72b5f047ab51f535398f03e4d5788c Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Sat, 19 Nov 2022 03:39:35 -0300 Subject: [PATCH] Fix broken LOINC link --- .../org/hl7/fhir/dstu2/utils/NarrativeGenerator.java | 3 ++- .../fhir/dstu2016may/utils/NarrativeGenerator.java | 3 ++- .../org/hl7/fhir/dstu3/utils/NarrativeGenerator.java | 5 +++-- .../org/hl7/fhir/r4/utils/NarrativeGenerator.java | 5 +++-- .../hl7/fhir/r4b/renderers/CodeSystemRenderer.java | 3 ++- .../org/hl7/fhir/r4b/renderers/ValueSetRenderer.java | 3 ++- .../hl7/fhir/r5/renderers/CodeSystemRenderer.java | 3 ++- .../java/org/hl7/fhir/r5/renderers/DataRenderer.java | 12 ++++++------ .../org/hl7/fhir/r5/renderers/ValueSetRenderer.java | 3 ++- .../java/org/hl7/fhir/utilities/LoincLinker.java | 8 ++++++++ 10 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/LoincLinker.java diff --git a/org.hl7.fhir.dstu2/src/main/java/org/hl7/fhir/dstu2/utils/NarrativeGenerator.java b/org.hl7.fhir.dstu2/src/main/java/org/hl7/fhir/dstu2/utils/NarrativeGenerator.java index 149d38b54..9bd711086 100644 --- a/org.hl7.fhir.dstu2/src/main/java/org/hl7/fhir/dstu2/utils/NarrativeGenerator.java +++ b/org.hl7.fhir.dstu2/src/main/java/org/hl7/fhir/dstu2/utils/NarrativeGenerator.java @@ -150,6 +150,7 @@ import org.hl7.fhir.exceptions.DefinitionException; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRFormatError; import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; +import org.hl7.fhir.utilities.LoincLinker; import org.hl7.fhir.utilities.MarkDownProcessor; import org.hl7.fhir.utilities.MarkDownProcessor.Dialect; import org.hl7.fhir.utilities.Utilities; @@ -2421,7 +2422,7 @@ public class NarrativeGenerator implements INarrativeGenerator { if (cc.getSystem().equals("http://snomed.info/sct")) return "http://snomed.info/sct/"+cc.getCode(); if (cc.getSystem().equals("http://loinc.org")) - return "http://s.details.loinc.org/LOINC/"+cc.getCode()+".html"; + return LoincLinker.getLinkForCode(cc.getCode()); return null; } diff --git a/org.hl7.fhir.dstu2016may/src/main/java/org/hl7/fhir/dstu2016may/utils/NarrativeGenerator.java b/org.hl7.fhir.dstu2016may/src/main/java/org/hl7/fhir/dstu2016may/utils/NarrativeGenerator.java index 5cd355771..ecb7837f7 100644 --- a/org.hl7.fhir.dstu2016may/src/main/java/org/hl7/fhir/dstu2016may/utils/NarrativeGenerator.java +++ b/org.hl7.fhir.dstu2016may/src/main/java/org/hl7/fhir/dstu2016may/utils/NarrativeGenerator.java @@ -154,6 +154,7 @@ import org.hl7.fhir.exceptions.DefinitionException; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRFormatError; import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; +import org.hl7.fhir.utilities.LoincLinker; import org.hl7.fhir.utilities.MarkDownProcessor; import org.hl7.fhir.utilities.MarkDownProcessor.Dialect; import org.hl7.fhir.utilities.Utilities; @@ -2482,7 +2483,7 @@ public class NarrativeGenerator implements INarrativeGenerator { if (cc.getSystem().equals("http://snomed.info/sct")) return "http://snomed.info/sct/"+cc.getCode(); if (cc.getSystem().equals("http://loinc.org")) - return "http://s.details.loinc.org/LOINC/"+cc.getCode()+".html"; + return LoincLinker.getLinkForCode(cc.getCode()); return null; } diff --git a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/NarrativeGenerator.java b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/NarrativeGenerator.java index 8f8dd32de..35bb777f9 100644 --- a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/NarrativeGenerator.java +++ b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/NarrativeGenerator.java @@ -184,6 +184,7 @@ import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRFormatError; import org.hl7.fhir.exceptions.TerminologyServiceException; import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; +import org.hl7.fhir.utilities.LoincLinker; import org.hl7.fhir.utilities.MarkDownProcessor; import org.hl7.fhir.utilities.MarkDownProcessor.Dialect; import org.hl7.fhir.utilities.Utilities; @@ -3093,7 +3094,7 @@ public class NarrativeGenerator implements INarrativeGenerator { else if ("http://snomed.info/sct".equals(system)) { td.ah("http://browser.ihtsdotools.org/?perspective=full&conceptId1="+code).addText(code); } else if ("http://loinc.org".equals(system)) { - td.ah("http://details.loinc.org/LOINC/"+code+".html").addText(code); + td.ah(LoincLinker.getLinkForCode(code)).addText(code); } else td.addText(code); } else { @@ -3220,7 +3221,7 @@ public class NarrativeGenerator implements INarrativeGenerator { if (cc.getSystem().equals("http://snomed.info/sct")) return "http://snomed.info/sct/"+cc.getCode(); if (cc.getSystem().equals("http://loinc.org")) - return "http://s.details.loinc.org/LOINC/"+cc.getCode()+".html"; + return LoincLinker.getLinkForCode(cc.getCode()); return null; } diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/NarrativeGenerator.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/NarrativeGenerator.java index 46938a103..3834e0ebf 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/NarrativeGenerator.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/NarrativeGenerator.java @@ -74,6 +74,7 @@ import org.hl7.fhir.r4.terminologies.ValueSetExpander.ValueSetExpansionOutcome; import org.hl7.fhir.r4.utils.FHIRPathEngine.IEvaluationContext; import org.hl7.fhir.r4.utils.LiquidEngine.LiquidDocument; import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; +import org.hl7.fhir.utilities.LoincLinker; import org.hl7.fhir.utilities.MarkDownProcessor; import org.hl7.fhir.utilities.MarkDownProcessor.Dialect; import org.hl7.fhir.utilities.TerminologyServiceOptions; @@ -3263,7 +3264,7 @@ public class NarrativeGenerator implements INarrativeGenerator { else if ("http://snomed.info/sct".equals(system)) { td.ah(sctLink(code)).addText(code); } else if ("http://loinc.org".equals(system)) { - td.ah("http://details.loinc.org/LOINC/"+code+".html").addText(code); + td.ah(LoincLinker.getLinkForCode(code)).addText(code); } else td.addText(code); } else { @@ -3500,7 +3501,7 @@ public class NarrativeGenerator implements INarrativeGenerator { if (cc.getSystem().equals("http://snomed.info/sct")) return "http://snomed.info/sct/"+cc.getCode(); if (cc.getSystem().equals("http://loinc.org")) - return "http://s.details.loinc.org/LOINC/"+cc.getCode()+".html"; + return LoincLinker.getLinkForCode(cc.getCode()); return null; } diff --git a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/renderers/CodeSystemRenderer.java b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/renderers/CodeSystemRenderer.java index 241da9890..bc22c8f5d 100644 --- a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/renderers/CodeSystemRenderer.java +++ b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/renderers/CodeSystemRenderer.java @@ -25,6 +25,7 @@ import org.hl7.fhir.r4b.renderers.utils.Resolver.ResourceContext; import org.hl7.fhir.r4b.terminologies.CodeSystemUtilities; import org.hl7.fhir.r4b.terminologies.CodeSystemUtilities.CodeSystemNavigator; import org.hl7.fhir.r4b.utils.ToolingExtensions; +import org.hl7.fhir.utilities.LoincLinker; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.xhtml.XhtmlNode; @@ -534,7 +535,7 @@ public class CodeSystemRenderer extends TerminologyRenderer { if (cc.getSystem().equals("http://snomed.info/sct")) return "http://snomed.info/sct/"+cc.getCode(); if (cc.getSystem().equals("http://loinc.org")) - return "http://s.details.loinc.org/LOINC/"+cc.getCode()+".html"; + return LoincLinker.getLinkForCode(cc.getCode())+".html"; return null; } diff --git a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/renderers/ValueSetRenderer.java b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/renderers/ValueSetRenderer.java index a6871ebd8..13a695268 100644 --- a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/renderers/ValueSetRenderer.java +++ b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/renderers/ValueSetRenderer.java @@ -47,6 +47,7 @@ import org.hl7.fhir.r4b.renderers.utils.Resolver.ResourceContext; import org.hl7.fhir.r4b.terminologies.CodeSystemUtilities; import org.hl7.fhir.r4b.terminologies.ValueSetExpander.ValueSetExpansionOutcome; import org.hl7.fhir.r4b.utils.ToolingExtensions; +import org.hl7.fhir.utilities.LoincLinker; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.xhtml.XhtmlNode; @@ -717,7 +718,7 @@ public class ValueSetRenderer extends TerminologyRenderer { else if ("http://snomed.info/sct".equals(system)) { td.ah(sctLink(code)).addText(code); } else if ("http://loinc.org".equals(system)) { - td.ah("http://details.loinc.org/LOINC/"+code+".html").addText(code); + td.ah(LoincLinker.getLinkForCode(code)).addText(code); } else td.addText(code); } else { diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/CodeSystemRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/CodeSystemRenderer.java index 9d99a600c..92d94b5a0 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/CodeSystemRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/CodeSystemRenderer.java @@ -25,6 +25,7 @@ import org.hl7.fhir.r5.renderers.utils.Resolver.ResourceContext; import org.hl7.fhir.r5.terminologies.CodeSystemUtilities; import org.hl7.fhir.r5.terminologies.CodeSystemUtilities.CodeSystemNavigator; import org.hl7.fhir.r5.utils.ToolingExtensions; +import org.hl7.fhir.utilities.LoincLinker; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.xhtml.XhtmlNode; @@ -547,7 +548,7 @@ public class CodeSystemRenderer extends TerminologyRenderer { if (cc.getSystem().equals("http://snomed.info/sct")) return "http://snomed.info/sct/"+cc.getCode(); if (cc.getSystem().equals("http://loinc.org")) - return "http://s.details.loinc.org/LOINC/"+cc.getCode()+".html"; + return LoincLinker.getLinkForCode(cc.getCode()); return null; } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/DataRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/DataRenderer.java index c7a11d68d..5d000ebd7 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/DataRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/DataRenderer.java @@ -1129,25 +1129,25 @@ public class DataRenderer extends Renderer { if (ii.hasType()) { if (ii.getType().hasText()) - s = ii.getType().getText()+": "+s; + s = ii.getType().getText()+": "+s; else if (ii.getType().hasCoding() && ii.getType().getCoding().get(0).hasDisplay()) s = ii.getType().getCoding().get(0).getDisplay()+": "+s; else if (ii.getType().hasCoding() && ii.getType().getCoding().get(0).hasCode()) s = lookupCode(ii.getType().getCoding().get(0).getSystem(), ii.getType().getCoding().get(0).getVersion(), ii.getType().getCoding().get(0).getCode())+": "+s; } else { - s = "id: "+s; + s = "id: "+s; } if (ii.hasUse() || ii.hasPeriod()) { - s = s + "("; + s = s + " ("; if (ii.hasUse()) { - s = s + "use: "+ii.getUse().toString(); + s = s + "use: "+ii.getUse().toString(); } if (ii.hasUse() && ii.hasPeriod()) { - s = s + ", "; + s = s + ", "; } if (ii.hasPeriod()) { - s = s + "period: "+displayPeriod(ii.getPeriod()); + s = s + "period: "+displayPeriod(ii.getPeriod()); } s = s + ")"; } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ValueSetRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ValueSetRenderer.java index 33b529d42..b475568da 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ValueSetRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ValueSetRenderer.java @@ -45,6 +45,7 @@ import org.hl7.fhir.r5.renderers.utils.Resolver.ResourceContext; import org.hl7.fhir.r5.terminologies.CodeSystemUtilities; import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome; import org.hl7.fhir.r5.utils.ToolingExtensions; +import org.hl7.fhir.utilities.LoincLinker; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator; import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row; @@ -835,7 +836,7 @@ public class ValueSetRenderer extends TerminologyRenderer { else if ("http://snomed.info/sct".equals(system)) { td.ah(sctLink(code)).addText(code); } else if ("http://loinc.org".equals(system)) { - td.ah("http://details.loinc.org/LOINC/"+code+".html").addText(code); + td.ah(LoincLinker.getLinkForCode(code)).addText(code); } else td.addText(code); } else { diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/LoincLinker.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/LoincLinker.java new file mode 100644 index 000000000..7940b1254 --- /dev/null +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/LoincLinker.java @@ -0,0 +1,8 @@ +package org.hl7.fhir.utilities; + +public class LoincLinker { + + public static String getLinkForCode(String code) { + return "https://loinc.org/"+code+"/"; + } +}