Merge pull request #915 from hapifhir/gg-202209-r5-ballot

Gg 202209 r5 ballot
This commit is contained in:
Grahame Grieve 2022-09-07 12:11:08 +10:00 committed by GitHub
commit a6df7bfc0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 191 additions and 69 deletions

View File

@ -19,7 +19,7 @@
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -29,5 +29,22 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -20,4 +20,15 @@
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
<filteredResources>
<filter>
<id>1662504185037</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>

View File

@ -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<OtherElementComponent> 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;
}

View File

@ -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());

View File

@ -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<Arguments> 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));
}
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"));

View File

@ -310,12 +310,13 @@ public class XmlParser extends ParserBase {
while (n.getNextSibling() != null && n.getNodeType() != Node.ELEMENT_NODE) {
n = n.getNextSibling();
}
while (n.getPreviousSibling() != null && n.getNodeType() != Node.ELEMENT_NODE) {
n = n.getPreviousSibling();
Node nt = n;
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();
}

View File

@ -35,11 +35,12 @@ public class OperationDefinitionRenderer extends TerminologyRenderer {
}
public boolean render(XhtmlNode x, OperationDefinition opd) throws IOException, FHIRException, EOperationOutcome {
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());
addMarkdown(x, opd.getDescription());}
if (opd.getSystem())
x.para().tx("URL: [base]/$"+opd.getCode());

View File

@ -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) {

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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)"
}
-------------------------------------------------------------------------------------

View File

@ -19,7 +19,7 @@
<properties>
<hapi_fhir_version>5.4.0</hapi_fhir_version>
<validator_test_case_version>v1.1.105</validator_test_case_version>
<validator_test_case_version>1.1.106-SNAPSHOT</validator_test_case_version>
<junit_jupiter_version>5.7.1</junit_jupiter_version>
<junit_platform_launcher_version>1.8.2</junit_platform_launcher_version>
<maven_surefire_version>3.0.0-M5</maven_surefire_version>