From 49a6c9d7465730e9e391312eec094f5ce5225071 Mon Sep 17 00:00:00 2001 From: Rob Hausam Date: Sat, 28 Mar 2020 20:37:56 -0500 Subject: [PATCH] Support listing multiple "Expansion based on" versions. --- .../fhir/dstu3/utils/NarrativeGenerator.java | 50 ++++++++++--------- .../hl7/fhir/r4/utils/NarrativeGenerator.java | 50 ++++++++++--------- .../hl7/fhir/r5/utils/NarrativeGenerator.java | 50 ++++++++++--------- 3 files changed, 78 insertions(+), 72 deletions(-) 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 85c48c4cc..f5030239a 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 @@ -2727,39 +2727,41 @@ public class NarrativeGenerator implements INarrativeGenerator { @SuppressWarnings("rawtypes") private void generateVersionNotice(XhtmlNode x, ValueSetExpansionComponent expansion) { Map versions = new HashMap(); + StringBuilder b = new StringBuilder(); for (ValueSetExpansionParameterComponent p : expansion.getParameter()) { if (p.getName().equals("version")) { String[] parts = ((PrimitiveType) p.getValue()).asStringValue().split("\\|"); + if (b.length() > 0) + b.append("
"); if (parts.length == 2) versions.put(parts[0], parts[1]); - } - } - if (!versions.isEmpty()) { - StringBuilder b = new StringBuilder(); - b.append("Expansion based on "); - boolean first = true; - for (String s : versions.keySet()) { - if (first) - first = false; - else - b.append(", "); - if (!s.equals("http://snomed.info/sct")) - b.append(describeSystem(s)+" version "+versions.get(s)); - else { - String[] parts = versions.get(s).split("\\/"); - if (parts.length >= 5) { - String m = describeModule(parts[4]); - if (parts.length == 7) - b.append("SNOMED CT "+m+" edition "+formatSCTDate(parts[6])); + if (!versions.isEmpty()) { + b.append("Expansion based on "); + boolean first = true; + for (String s : versions.keySet()) { + if (first) + first = false; else - b.append("SNOMED CT "+m+" edition"); - } else - b.append(describeSystem(s)+" version "+versions.get(s)); + b.append(", "); + if (!s.equals("http://snomed.info/sct")) + b.append(describeSystem(s)+" version "+versions.get(s)); + else { + parts = versions.get(s).split("\\/"); + if (parts.length >= 5) { + String m = describeModule(parts[4]); + if (parts.length == 7) + b.append("SNOMED CT "+m+" edition "+formatSCTDate(parts[6])); + else + b.append("SNOMED CT "+m+" edition"); + } else + b.append(describeSystem(s)+" version "+versions.get(s)); + } + } } } - - x.para().setAttribute("style", "border: black 1px dotted; background-color: #EEEEEE; padding: 8px").addText(b.toString()); } + if (b.length() > 0) + x.para().setAttribute("style", "border: black 1px dotted; background-color: #EEEEEE; padding: 8px").addText(b.toString()); } private String formatSCTDate(String ds) { 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 9ff6e48a8..672a97c47 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 @@ -2882,39 +2882,41 @@ public class NarrativeGenerator implements INarrativeGenerator { @SuppressWarnings("rawtypes") private void generateVersionNotice(XhtmlNode x, ValueSetExpansionComponent expansion) { Map versions = new HashMap(); + StringBuilder b = new StringBuilder(); for (ValueSetExpansionParameterComponent p : expansion.getParameter()) { if (p.getName().equals("version")) { String[] parts = ((PrimitiveType) p.getValue()).asStringValue().split("\\|"); + if (b.length() > 0) + b.append("
"); if (parts.length == 2) versions.put(parts[0], parts[1]); - } - } - if (!versions.isEmpty()) { - StringBuilder b = new StringBuilder(); - b.append("Expansion based on "); - boolean first = true; - for (String s : versions.keySet()) { - if (first) - first = false; - else - b.append(", "); - if (!s.equals("http://snomed.info/sct")) - b.append(describeSystem(s)+" version "+versions.get(s)); - else { - String[] parts = versions.get(s).split("\\/"); - if (parts.length >= 5) { - String m = describeModule(parts[4]); - if (parts.length == 7) - b.append("SNOMED CT "+m+" edition "+formatSCTDate(parts[6])); + if (!versions.isEmpty()) { + b.append("Expansion based on "); + boolean first = true; + for (String s : versions.keySet()) { + if (first) + first = false; else - b.append("SNOMED CT "+m+" edition"); - } else - b.append(describeSystem(s)+" version "+versions.get(s)); + b.append(", "); + if (!s.equals("http://snomed.info/sct")) + b.append(describeSystem(s)+" version "+versions.get(s)); + else { + parts = versions.get(s).split("\\/"); + if (parts.length >= 5) { + String m = describeModule(parts[4]); + if (parts.length == 7) + b.append("SNOMED CT "+m+" edition "+formatSCTDate(parts[6])); + else + b.append("SNOMED CT "+m+" edition"); + } else + b.append(describeSystem(s)+" version "+versions.get(s)); + } + } } } - - x.para().setAttribute("style", "border: black 1px dotted; background-color: #EEEEEE; padding: 8px").addText(b.toString()); } + if (b.length() > 0) + x.para().setAttribute("style", "border: black 1px dotted; background-color: #EEEEEE; padding: 8px").addText(b.toString()); } private String formatSCTDate(String ds) { diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NarrativeGenerator.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NarrativeGenerator.java index ec5efe2b3..7457230b6 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NarrativeGenerator.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NarrativeGenerator.java @@ -3213,39 +3213,41 @@ public class NarrativeGenerator implements INarrativeGenerator { @SuppressWarnings("rawtypes") private void generateVersionNotice(XhtmlNode x, ValueSetExpansionComponent expansion) { Map versions = new HashMap(); + StringBuilder b = new StringBuilder(); for (ValueSetExpansionParameterComponent p : expansion.getParameter()) { if (p.getName().equals("version")) { String[] parts = ((PrimitiveType) p.getValue()).asStringValue().split("\\|"); + if (b.length() > 0) + b.append("
"); if (parts.length == 2) versions.put(parts[0], parts[1]); - } - } - if (!versions.isEmpty()) { - StringBuilder b = new StringBuilder(); - b.append("Expansion based on "); - boolean first = true; - for (String s : versions.keySet()) { - if (first) - first = false; - else - b.append(", "); - if (!s.equals("http://snomed.info/sct")) - b.append(describeSystem(s)+" version "+versions.get(s)); - else { - String[] parts = versions.get(s).split("\\/"); - if (parts.length >= 5) { - String m = describeModule(parts[4]); - if (parts.length == 7) - b.append("SNOMED CT "+m+" edition "+formatSCTDate(parts[6])); + if (!versions.isEmpty()) { + b.append("Expansion based on "); + boolean first = true; + for (String s : versions.keySet()) { + if (first) + first = false; else - b.append("SNOMED CT "+m+" edition"); - } else - b.append(describeSystem(s)+" version "+versions.get(s)); + b.append(", "); + if (!s.equals("http://snomed.info/sct")) + b.append(describeSystem(s)+" version "+versions.get(s)); + else { + parts = versions.get(s).split("\\/"); + if (parts.length >= 5) { + String m = describeModule(parts[4]); + if (parts.length == 7) + b.append("SNOMED CT "+m+" edition "+formatSCTDate(parts[6])); + else + b.append("SNOMED CT "+m+" edition"); + } else + b.append(describeSystem(s)+" version "+versions.get(s)); + } + } } } - - x.para().setAttribute("style", "border: black 1px dotted; background-color: #EEEEEE; padding: 8px").addText(b.toString()); } + if (b.length() > 0) + x.para().setAttribute("style", "border: black 1px dotted; background-color: #EEEEEE; padding: 8px").addText(b.toString()); } private String formatSCTDate(String ds) {