From fa7341ca4459c3f468761815f05f34694ee3ef25 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Thu, 14 Jan 2021 12:18:17 +1100 Subject: [PATCH 1/4] add primitive type factory --- .../hl7/fhir/r5/model/ResourceFactory.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/ResourceFactory.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/ResourceFactory.java index e46de5e56..821dbf809 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/ResourceFactory.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/ResourceFactory.java @@ -678,5 +678,32 @@ public class ResourceFactory extends Factory { } } + public static DataType createPrimitive(String type, String value) { + switch (type) { + case "boolean": return new BooleanType(value); + case "integer": return new IntegerType(value); + case "integer64": return new Integer64Type(value); + case "string": return new StringType(value); + case "decimal": return new DecimalType(value); + case "uri": return new UriType(value); + case "url": return new UrlType(value); + case "canonical": return new CanonicalType(value); + case "base64Binary": return new Base64BinaryType(value); + case "instant": return new InstantType(value); + case "date": return new DateType(value); + case "dateTime": return new DateTimeType(value); + case "time": return new TimeType(value); + case "code": return new CodeType(value); + case "oid": return new OidType(value); + case "id": return new IdType(value); + case "markdown": return new MarkdownType(value); + case "unsignedInt": return new UnsignedIntType(value); + case "positiveInt": return new PositiveIntType(value); + case "uuid": return new UuidType(value); + default: + throw new FHIRException("Unknown Primitive Type '"+type+"'"); + } + } + } \ No newline at end of file From 9bdd663497b27fef834edc0992440d7ec348a1c1 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Thu, 14 Jan 2021 12:19:14 +1100 Subject: [PATCH 2/4] makeshareable changes --- .../hl7/fhir/r5/terminologies/CodeSystemUtilities.java | 10 ++++++++++ .../hl7/fhir/r5/terminologies/ValueSetUtilities.java | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/CodeSystemUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/CodeSystemUtilities.java index 9de226f72..5482a2645 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/CodeSystemUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/CodeSystemUtilities.java @@ -282,6 +282,16 @@ public class CodeSystemUtilities { return cs; } + public static boolean makeCSShareable(CodeSystem cs) { + if (!cs.hasMeta()) + cs.setMeta(new Meta()); + for (UriType t : cs.getMeta().getProfile()) + if (t.getValue().equals("http://hl7.org/fhir/StructureDefinition/shareablecodesystem")) + return false; + cs.getMeta().getProfile().add(new CanonicalType("http://hl7.org/fhir/StructureDefinition/shareablecodesystem")); + return true; + } + public static void setOID(CodeSystem cs, String oid) { if (!oid.startsWith("urn:oid:")) oid = "urn:oid:" + oid; diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetUtilities.java index 1fb3bb354..ae0f24f9e 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetUtilities.java @@ -57,6 +57,16 @@ public class ValueSetUtilities { return vs; } + public static boolean makeVSShareable(ValueSet vs) { + if (!vs.hasMeta()) + vs.setMeta(new Meta()); + for (UriType t : vs.getMeta().getProfile()) + if (t.getValue().equals("http://hl7.org/fhir/StructureDefinition/shareablevalueset")) + return false; + vs.getMeta().getProfile().add(new CanonicalType("http://hl7.org/fhir/StructureDefinition/shareablevalueset")); + return true; + } + public static void checkShareable(ValueSet vs) { if (!vs.hasMeta()) throw new Error("ValueSet "+vs.getUrl()+" is not shareable"); From e0dabe6f33cf81b4b48561d8832c85843d4599a1 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Thu, 14 Jan 2021 12:21:33 +1100 Subject: [PATCH 3/4] fix profile generation issues --- .../fhir/r5/conformance/ProfileUtilities.java | 16 +++++++++++++-- .../fhir/r5/test/utils/TestingUtilities.java | 2 +- .../hl7/fhir/r5/utils/ToolingExtensions.java | 4 +++- .../xhtml/HierarchicalTableGenerator.java | 20 ++++++++++--------- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java index 70610135f..65f8ad753 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java @@ -459,6 +459,10 @@ public class ProfileUtilities extends TranslatingUtilities { } public List getChildList(StructureDefinition profile, String path, String id, boolean diff) { + return getChildList(profile, path, id, diff, false); + } + + public List getChildList(StructureDefinition profile, String path, String id, boolean diff, boolean refs) { List res = new ArrayList(); boolean capturing = id==null; @@ -483,7 +487,7 @@ public class ProfileUtilities extends TranslatingUtilities { if (capturing) { String p = e.getPath(); - if (!Utilities.noString(e.getContentReference()) && path.startsWith(p)) { + if (refs && !Utilities.noString(e.getContentReference()) && path.startsWith(p)) { if (path.length() > p.length()) { return getChildList(profile, e.getContentReference()+"."+path.substring(p.length()+1), null, diff); } else if (e.getContentReference().startsWith("#")) { @@ -511,6 +515,10 @@ public class ProfileUtilities extends TranslatingUtilities { return res; } + public List getChildList(StructureDefinition structure, ElementDefinition element, boolean diff, boolean refs) { + return getChildList(structure, element.getPath(), element.getId(), diff, refs); + } + public List getChildList(StructureDefinition structure, ElementDefinition element, boolean diff) { return getChildList(structure, element.getPath(), element.getId(), diff); } @@ -3313,7 +3321,7 @@ public class ProfileUtilities extends TranslatingUtilities { c.getPieces().add(gen.new Piece("#"+ed.getElement().getPath(), tail(ed.getElement().getPath()), ed.getElement().getPath())); } else { c.getPieces().add(gen.new Piece(null, translate("sd.table", "See ", ed.getElement().getPath()), null)); - c.getPieces().add(gen.new Piece(corePath+ed.getSource().getUserString("path")+"#"+ed.getElement().getPath(), tail(ed.getElement().getPath())+" ("+ed.getSource().getType()+")", ed.getElement().getPath())); + c.getPieces().add(gen.new Piece(pfx(corePath, ed.getSource().getUserString("path"))+"#"+ed.getElement().getPath(), tail(ed.getElement().getPath())+" ("+ed.getSource().getType()+")", ed.getElement().getPath())); } } return c; @@ -3446,6 +3454,10 @@ public class ProfileUtilities extends TranslatingUtilities { } + private String pfx(String prefix, String url) { + return Utilities.isAbsoluteUrl(url) ? url : prefix + url; + } + public void genTargetLink(HierarchicalTableGenerator gen, String profileBaseFileName, String corePath, Cell c, TypeRefComponent t, String u) { if (u.startsWith("http://hl7.org/fhir/StructureDefinition/")) { StructureDefinition sd = context.fetchResource(StructureDefinition.class, u); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java index 071fc44a9..036cebaf1 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java @@ -149,7 +149,7 @@ public class TestingUtilities extends BaseTestingUtilities { public static String checkXMLIsSame(String f1, String f2) throws Exception { String result = compareXml(f1, f2); if (result != null && SHOW_DIFF) { - String diff = Utilities.path(System.getenv("ProgramFiles(X86)"), "WinMerge", "WinMergeU.exe"); + String diff = Utilities.path(System.getenv("ProgramFiles"), "WinMerge", "WinMergeU.exe"); List command = new ArrayList(); command.add("\"" + diff + "\" \"" + f1 + "\" \"" + f2 + "\""); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java index 175fec654..4af353d13 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java @@ -181,7 +181,9 @@ public class ToolingExtensions { public static final String EXT_EXP_FRAGMENT = "http://hl7.org/fhir/tools/StructureDefinition/expansion-codesystem-fragment"; public static final String EXT_EXP_TOOCOSTLY = "http://hl7.org/fhir/StructureDefinition/valueset-toocostly"; public static final String EXT_MUST_SUPPORT = "http://hl7.org/fhir/StructureDefinition/elementdefinition-type-must-support"; - + public static final String EXT_TRANSLATABLE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-translatable"; + public static final String EXT_PATTERN = "http://hl7.org/fhir/StructureDefinition/elementdefinition-pattern"; + // specific extension helpers public static Extension makeIssueSource(Source source) { diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xhtml/HierarchicalTableGenerator.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xhtml/HierarchicalTableGenerator.java index e6e09522c..0a814823f 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xhtml/HierarchicalTableGenerator.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xhtml/HierarchicalTableGenerator.java @@ -240,16 +240,18 @@ public class HierarchicalTableGenerator extends TranslatingUtilities { pieces.add(piece); return this; } - + public Cell addMarkdown(String md) { - try { - Parser parser = Parser.builder().build(); - Node document = parser.parse(md); - HtmlRenderer renderer = HtmlRenderer.builder().escapeHtml(true).build(); - String html = renderer.render(document); - pieces.addAll(htmlToParagraphPieces(html, null)); - } catch (Exception e) { - e.printStackTrace(); + if (!Utilities.noString(md)) { + try { + Parser parser = Parser.builder().build(); + Node document = parser.parse(md); + HtmlRenderer renderer = HtmlRenderer.builder().escapeHtml(true).build(); + String html = renderer.render(document); + pieces.addAll(htmlToParagraphPieces(html, null)); + } catch (Exception e) { + e.printStackTrace(); + } } return this; } From d92935894a4f0cd4f1bc4ec57b760abda94ad3d5 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Thu, 14 Jan 2021 13:34:34 +1100 Subject: [PATCH 4/4] fix problem with references --- .../java/org/hl7/fhir/r5/renderers/utils/ElementWrappers.java | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/ElementWrappers.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/ElementWrappers.java index 0cbc02f30..e9be59897 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/ElementWrappers.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/ElementWrappers.java @@ -72,7 +72,7 @@ public class ElementWrappers { @Override public List children() { if (list == null) { - children = context.getProfileUtilities().getChildList(structure, definition); + children = context.getProfileUtilities().getChildList(structure, definition, false, true); if (children.isEmpty() && !Utilities.noString(type)) { StructureDefinition sd = context.getWorker().fetchTypeDefinition(type); children = context.getProfileUtilities().getChildList(sd, sd.getSnapshot().getElementFirstRep()); diff --git a/pom.xml b/pom.xml index 33512ef10..6d8cc6ab2 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 5.1.0 - 1.1.56 + 1.1.57-SNAPSHOT 5.6.2 3.0.0-M4 0.8.5