From 4dde2474663dc0ebe120f3a7413899d06843a571 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 7 Sep 2022 08:10:39 +1000 Subject: [PATCH 1/8] fix npe in narrative generation (r4b) --- .../java/org/hl7/fhir/r4b/renderers/QuestionnaireRenderer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/renderers/QuestionnaireRenderer.java b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/renderers/QuestionnaireRenderer.java index f68e255b4..5530cbd9c 100644 --- a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/renderers/QuestionnaireRenderer.java +++ b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/renderers/QuestionnaireRenderer.java @@ -713,7 +713,7 @@ public class QuestionnaireRenderer extends TerminologyRenderer { XhtmlNode ans = item(ul, "Answers"); if (!Utilities.noString(i.getAnswerValueSet()) && i.getAnswerValueSet().startsWith("#")) { ValueSet vs = (ValueSet) q.getContained(i.getAnswerValueSet().substring(1)); - if (vs == null) { + if (vs == null || !vs.hasUserData("path")) { ans.tx(i.getAnswerValueSet()); } else { ans.ah(vs.getUserString("path")).tx(vs.present()); From 44aeaa1a80ead846f031ad1f0e7cc940e1c3813a Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 7 Sep 2022 08:10:51 +1000 Subject: [PATCH 2/8] R4b Narrative tests fix up --- .../r4b/test/NarrativeGenerationTests.java | 81 ++++++++++++++++--- 1 file changed, 69 insertions(+), 12 deletions(-) diff --git a/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/NarrativeGenerationTests.java b/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/NarrativeGenerationTests.java index 554bacd4b..58e0b7416 100644 --- a/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/NarrativeGenerationTests.java +++ b/org.hl7.fhir.r4b/src/test/java/org/hl7/fhir/r4b/test/NarrativeGenerationTests.java @@ -8,16 +8,21 @@ import java.util.stream.Stream; import javax.xml.parsers.ParserConfigurationException; +import org.apache.commons.lang3.NotImplementedException; import org.apache.commons.lang3.SystemUtils; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRFormatError; +import org.hl7.fhir.r4b.conformance.ProfileUtilities; +import org.hl7.fhir.r4b.conformance.ProfileUtilities.ProfileKnowledgeProvider; import org.hl7.fhir.r4b.context.IWorkerContext; import org.hl7.fhir.r4b.elementmodel.Manager; import org.hl7.fhir.r4b.elementmodel.Manager.FhirFormat; import org.hl7.fhir.r4b.formats.JsonParser; import org.hl7.fhir.r4b.formats.XmlParser; import org.hl7.fhir.r4b.model.Base; +import org.hl7.fhir.r4b.model.ElementDefinition.ElementDefinitionBindingComponent; import org.hl7.fhir.r4b.model.Resource; +import org.hl7.fhir.r4b.model.StructureDefinition; import org.hl7.fhir.r4b.renderers.RendererFactory; import org.hl7.fhir.r4b.renderers.utils.ElementWrappers; @@ -28,6 +33,7 @@ import org.hl7.fhir.r4b.test.utils.TestingUtilities; import org.hl7.fhir.utilities.TerminologyServiceOptions; import org.hl7.fhir.utilities.TextFile; +import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.xhtml.XhtmlComposer; import org.hl7.fhir.utilities.xhtml.XhtmlNode; import org.hl7.fhir.utilities.xml.XMLUtil; @@ -42,6 +48,64 @@ import org.xml.sax.SAXException; public class NarrativeGenerationTests { + public class TestProfileKnowledgeProvider implements ProfileKnowledgeProvider { + + private IWorkerContext context; + + public TestProfileKnowledgeProvider(IWorkerContext context) { + this.context = context; + } + + @Override + public boolean isDatatype(String typeSimple) { + throw new NotImplementedException(); + } + + @Override + public boolean isResource(String typeSimple) { + throw new NotImplementedException(); + } + + @Override + public boolean hasLinkFor(String typeSimple) { + throw new NotImplementedException(); + } + + @Override + public String getLinkFor(String corePath, String typeSimple) { + throw new NotImplementedException(); + } + + @Override + public BindingResolution resolveBinding(StructureDefinition def, ElementDefinitionBindingComponent binding, String path) throws FHIRException { + throw new NotImplementedException(); + } + + @Override + public BindingResolution resolveBinding(StructureDefinition def, String url, String path) throws FHIRException { + throw new NotImplementedException(); + } + + @Override + public String getLinkForProfile(StructureDefinition profile, String url) { + if ("http://hl7.org/fhir/StructureDefinition/Composition".equals(url)) { + return "http://hl7.org/fhir/composition.html|TestComposition"; + } + throw new NotImplementedException(); + } + + @Override + public boolean prependLinks() { + throw new NotImplementedException(); + } + + @Override + public String getLinkForUrl(String corePath, String s) { + throw new NotImplementedException(); + } + + } + public class TestTypeParser implements ITypeParser { @Override @@ -98,15 +162,7 @@ public class NarrativeGenerationTests { List objects = new ArrayList<>(); while (test != null && test.getNodeName().equals("test")) { TestDetails t = new TestDetails(test); - if (t.getId().equals("sdc")) { - if (SystemUtils.OS_NAME.contains(WINDOWS)) { - objects.add(Arguments.of(t.getId(), t)); - } else { - System.out.println("sdc test not being adding because the current OS will not pass the test..."); - } - } else { - objects.add(Arguments.of(t.getId(), t)); - } + objects.add(Arguments.of(t.getId(), t)); test = XMLUtil.getNextSibling(test); } return objects.stream(); @@ -121,7 +177,7 @@ public class NarrativeGenerationTests { @MethodSource("data") public void test(String id, TestDetails test) throws Exception { RenderingContext rc = new RenderingContext(context, null, null, "http://hl7.org/fhir", "", null, ResourceRendererMode.END_USER); - rc.setDestDir(""); + rc.setDestDir(Utilities.path("[tmp]", "narrative")); rc.setHeader(test.isHeader()); rc.setDefinitionsTarget("test.html"); rc.setTerminologyServiceOptions(TerminologyServiceOptions.defaults()); @@ -135,6 +191,7 @@ public class NarrativeGenerationTests { rc.setDateFormatString("yyyy-MM-dd"); rc.setMode(test.technical ? ResourceRendererMode.TECHNICAL : ResourceRendererMode.END_USER); + rc.setProfileUtilities(new ProfileUtilities(rc.getContext(), null, new TestProfileKnowledgeProvider(rc.getContext()))); Resource source; @@ -145,7 +202,7 @@ public class NarrativeGenerationTests { } XhtmlNode x = RendererFactory.factory(source, rc).build(source); - String target = TextFile.streamToString(TestingUtilities.loadTestResourceStream("r5", "narrative", test.getId() + ".html")); + String target = TextFile.streamToString(TestingUtilities.loadTestResourceStream("r4b", "narrative", test.getId() + ".html")); String output = HEADER+new XhtmlComposer(true, true).compose(x)+FOOTER; String tfn = TestingUtilities.tempFile("narrative", test.getId() + ".target.html"); String ofn = TestingUtilities.tempFile("narrative", test.getId() + ".output.html"); @@ -155,7 +212,7 @@ public class NarrativeGenerationTests { Assertions.assertTrue(msg == null, "Output does not match expected: "+msg); if (test.isMeta()) { - org.hl7.fhir.r4b.elementmodel.Element e = Manager.parseSingle(context, TestingUtilities.loadTestResourceStream("r5", "narrative", test.getId() + ".xml"), FhirFormat.XML); + org.hl7.fhir.r4b.elementmodel.Element e = Manager.parseSingle(context, TestingUtilities.loadTestResourceStream("r4b", "narrative", test.getId() + ".xml"), FhirFormat.XML); x = RendererFactory.factory(source, rc).render(new ElementWrappers.ResourceWrapperMetaElement(rc, e)); target = TextFile.streamToString(TestingUtilities.loadTestResourceStream("r4b", "narrative", test.getId() + "-meta.html")); From c3ab401f56e71f07e541313de3910a01fb994208 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 7 Sep 2022 08:11:09 +1000 Subject: [PATCH 3/8] Fix bug with validator hanging on some XML instances --- .../org/hl7/fhir/r5/elementmodel/XmlParser.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java index bd1642270..44a41fdb6 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java @@ -307,15 +307,16 @@ public class XmlParser extends ParserBase { Node n = node.getFirstChild(); while (n != null) { if (n.getNodeType() == Node.TEXT_NODE && !Utilities.noString(n.getTextContent().trim())) { - while (n.getNextSibling() != null && n.getNodeType() != Node.ELEMENT_NODE) { - n = n.getNextSibling(); + Node nt = n; + while (nt.getNextSibling() != null && nt.getNodeType() != Node.ELEMENT_NODE) { + nt = nt.getNextSibling(); } - while (n.getPreviousSibling() != null && n.getNodeType() != Node.ELEMENT_NODE) { - n = n.getPreviousSibling(); + while (nt.getPreviousSibling() != null && nt.getNodeType() != Node.ELEMENT_NODE) { + nt = nt.getPreviousSibling(); } - line = line(n); - col = col(n); - logError(line, col, path, IssueType.STRUCTURE, context.formatMessage(I18nConstants.TEXT_SHOULD_NOT_BE_PRESENT, text), IssueSeverity.ERROR); + line = line(nt); + col = col(nt); + logError(line, col, path, IssueType.STRUCTURE, context.formatMessage(I18nConstants.TEXT_SHOULD_NOT_BE_PRESENT, Utilities.makeSingleLine(text)), IssueSeverity.ERROR); } n = n.getNextSibling(); } From fbca3fda51b3bac509405b88e4e44e19ff1ecae5 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 7 Sep 2022 08:11:44 +1000 Subject: [PATCH 4/8] Fix bug where header is always rendered with Operation Definition --- .../r5/renderers/OperationDefinitionRenderer.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/OperationDefinitionRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/OperationDefinitionRenderer.java index 9d693aae1..4b4aa889a 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/OperationDefinitionRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/OperationDefinitionRenderer.java @@ -35,11 +35,12 @@ public class OperationDefinitionRenderer extends TerminologyRenderer { } public boolean render(XhtmlNode x, OperationDefinition opd) throws IOException, FHIRException, EOperationOutcome { - x.h2().addText(opd.getName()); - x.para().addText(Utilities.capitalize(opd.getKind().toString())+": "+opd.getName()); - x.para().tx("The official URL for this operation definition is: "); - x.pre().tx(opd.getUrl()); - addMarkdown(x, opd.getDescription()); + if (context.isHeader()) { + x.h2().addText(opd.getName()); + x.para().addText(Utilities.capitalize(opd.getKind().toString())+": "+opd.getName()); + x.para().tx("The official URL for this operation definition is: "); + x.pre().tx(opd.getUrl()); + addMarkdown(x, opd.getDescription());} if (opd.getSystem()) x.para().tx("URL: [base]/$"+opd.getCode()); From 6cf6d139c43230a47eb8522bb072f2580ec6524d Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 7 Sep 2022 08:12:20 +1000 Subject: [PATCH 5/8] fix up for r5 tests --- .../src/main/java/org/hl7/fhir/utilities/Utilities.java | 9 +++++++++ .../org.hl7.fhir.validation/4.0.1/all-systems.cache | 8 ++++++++ pom.xml | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java index 3eb5189b0..343490142 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/Utilities.java @@ -1745,4 +1745,13 @@ public class Utilities { return Utilities.padLeft(Long.toString(i), ' ', len); } + public static Object makeSingleLine(String text) { + text = text.replace("\r", " "); + text = text.replace("\n", " "); + while (text.contains(" ")) { + text = text.replace(" ", " "); + } + return text; + } + } \ No newline at end of file diff --git a/org.hl7.fhir.validation/src/test/resources/txCache/org.hl7.fhir.validation/4.0.1/all-systems.cache b/org.hl7.fhir.validation/src/test/resources/txCache/org.hl7.fhir.validation/4.0.1/all-systems.cache index 795bf7576..f8c814514 100644 --- a/org.hl7.fhir.validation/src/test/resources/txCache/org.hl7.fhir.validation/4.0.1/all-systems.cache +++ b/org.hl7.fhir.validation/src/test/resources/txCache/org.hl7.fhir.validation/4.0.1/all-systems.cache @@ -1551,3 +1551,11 @@ v: { "system" : "urn:ietf:bcp:47" } ------------------------------------------------------------------------------------- +{"code" : { + "code" : "[%payloadFormat%]" +}, "url": "http://hl7.org/fhir/ValueSet/mimetypes", "version": "4.0.1", "lang":"null", "useServer":"true", "useClient":"true", "guessSystem":"true", "valueSetMode":"ALL_CHECKS", "versionFlexible":"false"}#### +v: { + "severity" : "error", + "error" : "The code \"[%payloadFormat%]\" is not valid in the system urn:ietf:bcp:13; The code provided (urn:ietf:bcp:13#[%payloadFormat%]) is not valid in the value set 'Mime Types' (from http://tx.fhir.org/r4)" +} +------------------------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index d5588b6ad..4cce2c35d 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 5.4.0 - v1.1.105 + 1.1.106-SNAPSHOT 5.7.1 1.8.2 3.0.0-M5 From f30f3e9ca9bdd161f626e76cb97d18d02f8a7417 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 7 Sep 2022 11:12:57 +1000 Subject: [PATCH 6/8] fix failing rendering test --- org.hl7.fhir.r4b/.classpath | 83 +++++++++++-------- org.hl7.fhir.r4b/.project | 11 +++ .../r4b/renderers/ConceptMapRenderer.java | 33 ++++++-- 3 files changed, 85 insertions(+), 42 deletions(-) diff --git a/org.hl7.fhir.r4b/.classpath b/org.hl7.fhir.r4b/.classpath index 2e0656c10..15f02af33 100644 --- a/org.hl7.fhir.r4b/.classpath +++ b/org.hl7.fhir.r4b/.classpath @@ -1,33 +1,50 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/org.hl7.fhir.r4b/.project b/org.hl7.fhir.r4b/.project index e773e3aec..50e7ef90f 100644 --- a/org.hl7.fhir.r4b/.project +++ b/org.hl7.fhir.r4b/.project @@ -20,4 +20,15 @@ org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature + + + 1662504185037 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + diff --git a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/renderers/ConceptMapRenderer.java b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/renderers/ConceptMapRenderer.java index 7420cc8df..e49de6193 100644 --- a/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/renderers/ConceptMapRenderer.java +++ b/org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/renderers/ConceptMapRenderer.java @@ -59,7 +59,7 @@ public class ConceptMapRenderer extends TerminologyRenderer { p.addText(Utilities.capitalize(cm.getStatus().toString())+" (not intended for production usage). "); else p.addText(Utilities.capitalize(cm.getStatus().toString())+". "); - p.tx("Published on "+(cm.hasDate() ? cm.getDateElement().toHumanDisplay() : "?ngen-10?")+" by "+cm.getPublisher()); + p.tx("Published on "+(cm.hasDate() ? display(cm.getDateElement()) : "?ngen-10?")+" by "+cm.getPublisher()); if (!cm.getContact().isEmpty()) { p.tx(" ("); boolean firsti = true; @@ -129,14 +129,28 @@ public class ConceptMapRenderer extends TerminologyRenderer { XhtmlNode tr = tbl.tr(); tr.td().b().tx("Source Code"); tr.td().b().tx("Relationship"); - tr.td().b().tx("Destination Code"); + tr.td().b().tx("Target Code"); if (comment) tr.td().b().tx("Comment"); + tr = tbl.tr(); + XhtmlNode td = tr.td().colspan(comment ? "4" : "3"); + td.tx("Mapping from "); + if (grp.hasSource()) { + renderCanonical(cm, td, grp.getSource()); + } else { + td.code("unspecified code system"); + } + td.tx(" to "); + if (grp.hasTarget()) { + renderCanonical(cm, td, grp.getTarget()); + } else { + td.code("unspecified code system"); + } for (SourceElementComponent ccl : grp.getElement()) { tr = tbl.tr(); - XhtmlNode td = tr.td(); + td = tr.td(); td.addText(ccl.getCode()); - display = getDisplayForConcept(systemFromCanonical(grp.getSource()), versionFromCanonical(grp.getSource()), ccl.getCode()); + display = ccl.hasDisplay() ? ccl.getDisplay() : getDisplayForConcept(systemFromCanonical(grp.getSource()), versionFromCanonical(grp.getSource()), ccl.getCode()); if (display != null && !isSameCodeAndDisplay(ccl.getCode(), display)) td.tx(" ("+display+")"); TargetElementComponent ccm = ccl.getTarget().get(0); @@ -148,7 +162,7 @@ public class ConceptMapRenderer extends TerminologyRenderer { } td = tr.td(); td.addText(ccm.getCode()); - display = getDisplayForConcept(systemFromCanonical(grp.getTarget()), versionFromCanonical(grp.getTarget()), ccm.getCode()); + display = ccm.hasDisplay() ? ccm.getDisplay() : getDisplayForConcept(systemFromCanonical(grp.getTarget()), versionFromCanonical(grp.getTarget()), ccm.getCode()); if (display != null && !isSameCodeAndDisplay(ccm.getCode(), display)) td.tx(" ("+display+")"); if (comment) @@ -174,7 +188,7 @@ public class ConceptMapRenderer extends TerminologyRenderer { if (hasRelationships) { tr.td().b().tx("Relationship"); } - tr.td().colspan(Integer.toString(1+targets.size())).b().tx("Destination Concept Details"); + tr.td().colspan(Integer.toString(1+targets.size())).b().tx("Target Concept Details"); if (comment) { tr.td().b().tx("Comment"); } @@ -403,7 +417,7 @@ public class ConceptMapRenderer extends TerminologyRenderer { for (OtherElementComponent c : list) { if (s.equals(c.getProperty())) if (withSystem) - return c.getSystem()+" / "+c.getValue(); + return /*c.getSystem()+" / "+*/c.getValue(); else return c.getValue(); } @@ -412,8 +426,9 @@ public class ConceptMapRenderer extends TerminologyRenderer { private String getDisplay(List list, String s) { for (OtherElementComponent c : list) { - if (s.equals(c.getProperty())) - return getDisplayForConcept(systemFromCanonical(c.getSystem()), versionFromCanonical(c.getSystem()), c.getValue()); + if (s.equals(c.getProperty())) { + // return getDisplayForConcept(systemFromCanonical(c.getSystem()), versionFromCanonical(c.getSystem()), c.getValue()); + } } return null; } From fc2e2fe9bcb04e04f8e64ddbb07266080590289b Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 7 Sep 2022 11:13:19 +1000 Subject: [PATCH 7/8] refix hung parser --- .../main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java index 44a41fdb6..dde9e9c04 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java @@ -307,10 +307,10 @@ public class XmlParser extends ParserBase { Node n = node.getFirstChild(); while (n != null) { if (n.getNodeType() == Node.TEXT_NODE && !Utilities.noString(n.getTextContent().trim())) { - Node nt = n; - while (nt.getNextSibling() != null && nt.getNodeType() != Node.ELEMENT_NODE) { - nt = nt.getNextSibling(); + while (n.getNextSibling() != null && n.getNodeType() != Node.ELEMENT_NODE) { + n = n.getNextSibling(); } + Node nt = n; while (nt.getPreviousSibling() != null && nt.getNodeType() != Node.ELEMENT_NODE) { nt = nt.getPreviousSibling(); } From 8dad875cac56535fe9e84018a12293948428f0e4 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 7 Sep 2022 11:38:27 +1000 Subject: [PATCH 8/8] qb url --- .../java/org/hl7/fhir/r5/utils/QuestionnaireBuilder.java | 7 +++++-- .../org/hl7/fhir/r5/test/QuestionnaireBuilderTester.java | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/QuestionnaireBuilder.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/QuestionnaireBuilder.java index 36e8759ac..15c153c45 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/QuestionnaireBuilder.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/QuestionnaireBuilder.java @@ -123,11 +123,13 @@ public class QuestionnaireBuilder { // we don't do the intensive parts of the work (save time) private Questionnaire prebuiltQuestionnaire; private ProfileUtilities profileUtilities; + private String rootPath; - public QuestionnaireBuilder(IWorkerContext context) { + public QuestionnaireBuilder(IWorkerContext context, String rootPath) { super(); this.context = context; profileUtilities = new ProfileUtilities(context, null, null); + this.rootPath = rootPath; } public Resource getReference() { @@ -235,7 +237,8 @@ public class QuestionnaireBuilder { questionnaire.addItem(item); item.setLinkId("meta"); item.getCode().addAll(profile.getKeyword()); - questionnaire.setId(nextId("qs-"+profile.getType())); + questionnaire.setId(nextId("qgen-"+profile.getId())); + questionnaire.setUrl(Utilities.pathURL(rootPath, "Questionnaire", questionnaire.getId())); } if (response != null) { diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/QuestionnaireBuilderTester.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/QuestionnaireBuilderTester.java index f2ddaf341..989c3240c 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/QuestionnaireBuilderTester.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/QuestionnaireBuilderTester.java @@ -15,7 +15,7 @@ public class QuestionnaireBuilderTester { // private static final String TEST_DEST = Utilities.path("[tmp]", "questionnaires\\"); public static void main(String[] args) { - QuestionnaireBuilder b = new QuestionnaireBuilder(null); + QuestionnaireBuilder b = new QuestionnaireBuilder(null, "http://hl7.org/fhir/test"); for (String f : new File(TEST_PROFILE_DIR).list()) { if (f.endsWith(".profile.xml") && !f.contains("type-")) { System.out.println("process "+f);