From 0fb57007c4b08f662f104331c674c9f70a581342 Mon Sep 17 00:00:00 2001 From: Mark Iantorno Date: Fri, 5 Jun 2020 18:47:17 -0400 Subject: [PATCH] Release v5.0.6 (#226) * reenable test and fix recursion * remove disabled r4 fml tests * add conformsTo test and support for FML * Snapshot builder fix (#223) * Update module-snapshot-publishing.yml for Azure Pipelines * Changing pipeline, because intermodule depenedecies are not being read in correctly. * Update README.md * Fixed bad link * Release: v5.0.6 ***NO_CI*** * Updating version to: 5.0.7-SNAPSHOT ***NO_CI*** * Fixing issues and preparing for release (#225) * Issue #189 - improve Questionnaire error message * fix for issue #187 * more work on comparison * Fix for NamingSystem display Co-authored-by: Oliver Egger Co-authored-by: Grahame Grieve --- README.md | 91 ++++++++-- RELEASE_NOTES.md | 1 - org.hl7.fhir.convertors/pom.xml | 2 +- org.hl7.fhir.dstu2/pom.xml | 2 +- org.hl7.fhir.dstu2016may/pom.xml | 2 +- org.hl7.fhir.dstu3/pom.xml | 2 +- org.hl7.fhir.r4/pom.xml | 2 +- .../r4/test/FHIRMappingLanguageTests.java | 149 ---------------- .../src/test/resources/fml/.gitignore | 1 - .../src/test/resources/fml/manifest.xml | 6 - .../src/test/resources/fml/qr.json | 39 ---- .../resources/fml/qr2pat-assignment-res.json | 4 - .../test/resources/fml/qr2pat-assignment.map | 8 - .../test/resources/fml/qr2pat-gender-res.json | 4 - .../src/test/resources/fml/qr2pat-gender.map | 12 -- .../fml/qr2pat-humannameshared-res.json | 8 - .../resources/fml/qr2pat-humannameshared.map | 26 --- .../fml/qr2pat-humannametwice-res.json | 10 -- .../resources/fml/qr2pat-humannametwice.map | 26 --- org.hl7.fhir.r5/pom.xml | 2 +- .../r5/comparison/CodeSystemComparer.java | 2 - .../r5/comparison/ComparisonRenderer.java | 166 ++++++++++++++++++ .../fhir/r5/comparison/ComparisonSession.java | 19 +- .../fhir/r5/comparison/ProfileComparer.java | 14 +- .../fhir/r5/context/SimpleWorkerContext.java | 56 +++--- .../hl7/fhir/r5/renderers/DataRenderer.java | 5 +- .../fhir/r5/utils/StructureMapUtilities.java | 18 +- org.hl7.fhir.report/pom.xml | 2 +- org.hl7.fhir.utilities/pom.xml | 2 +- .../cache/FilesystemPackageCacheManager.java | 2 +- .../src/main/resources/Messages.properties | 2 +- org.hl7.fhir.validation.cli/pom.xml | 2 +- org.hl7.fhir.validation/pom.xml | 2 +- .../instance/type/QuestionnaireValidator.java | 2 +- .../r5/test/FHIRMappingLanguageTests.java | 8 +- pom.xml | 2 +- 36 files changed, 334 insertions(+), 367 deletions(-) delete mode 100644 org.hl7.fhir.r4/src/test/java/org/hl7/fhir/r4/test/FHIRMappingLanguageTests.java delete mode 100644 org.hl7.fhir.r4/src/test/resources/fml/.gitignore delete mode 100644 org.hl7.fhir.r4/src/test/resources/fml/manifest.xml delete mode 100644 org.hl7.fhir.r4/src/test/resources/fml/qr.json delete mode 100644 org.hl7.fhir.r4/src/test/resources/fml/qr2pat-assignment-res.json delete mode 100644 org.hl7.fhir.r4/src/test/resources/fml/qr2pat-assignment.map delete mode 100644 org.hl7.fhir.r4/src/test/resources/fml/qr2pat-gender-res.json delete mode 100644 org.hl7.fhir.r4/src/test/resources/fml/qr2pat-gender.map delete mode 100644 org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannameshared-res.json delete mode 100644 org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannameshared.map delete mode 100644 org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannametwice-res.json delete mode 100644 org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannametwice.map create mode 100644 org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/ComparisonRenderer.java rename {org.hl7.fhir.r5 => org.hl7.fhir.validation}/src/test/java/org/hl7/fhir/r5/test/FHIRMappingLanguageTests.java (93%) diff --git a/README.md b/README.md index 84fb46353..fd201e4b1 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,97 @@ -HAPI FHIR - HL7 FHIR Core Artifacts -=================================== +# HAPI FHIR - HL7 FHIR Core Artifacts -[![Build Status](https://travis-ci.org/hapifhir/org.hl7.fhir.core.svg?branch=master)](https://travis-ci.org/hapifhir/org.hl7.fhir.core) -[![Maven Central](https://maven-badges.herokuapp.com/maven-central/hapifhir/org.hl7.fhir.core/badge.svg)](http://search.maven.org/#search|ga|1|hapifhir/org.hl7.fhir.core) +### CI/CD +| master Branch CI | SNAPSHOT Publisher | +| :---: | :---: | +| [![Build Status][Badge-BuildPipeline]][Link-BuildPipeline] | [![Build Status][Badge-SnapshotPipeline]][Link-SnapshotPipeline] | +All intergration and delivery done on Azure pipelines. Every successful merge to master branch will result in a new SNAPSHOT build being published to Sonatype. Azure project can be viewed [here][Link-AzureProject]. -# Building this Project +### Current Versions +| Project | Latest SNAPSHOT | Current Release | +| :---: | :---: | :---: | +| org.hl7.fhir.validation.cli | [![Snapshot Artifact][Badge-cliSonatypeSnapshot]][Link-cliSonatypeSnapshot] | [![Release Artifacts][Badge-cliSonatypeRelease]][Link-cliSonatypeRelease] | +| org.hl7.fhir.r4 | [![Snapshot Artifact][Badge-r4SonatypeSnapshot]][Link-r4SonatypeSnapshot] | [![Release Artifacts][Badge-r4SonatypeRelease]][Link-r4SonatypeRelease] | +| org.hl7.fhir.r5 | [![Snapshot Artifact][Badge-r5SonatypeSnapshot]][Link-r5SonatypeSnapshot] | [![Release Artifacts][Badge-r5SonatypeRelease]][Link-r5SonatypeRelease] | +### Building this Project This project uses [Apache Maven](http://maven.apache.org) to build. To build: - ``` mvn install ``` - Note that unit tests will run, but are currently not set to fail the build as they do not all pass. This is being worked on. To skip unit tests: - ``` mvn -Dmaven.test.skip install ``` -== Maintenance +### Download +##### org.hl7.fhir.validation.cli +###### Maven +```xml + + ca.uhn.hapi.fhir + org.hl7.fhir.validation.cli + (latest version) + +``` -This project is maintained by Grahame Grieve and James Agnew on behalf of the FHIR community. \ No newline at end of file +###### Gradle +```groovy +compile group: 'ca.uhn.hapi.fhir', name: 'org.hl7.fhir.validation.cli', version: '(latest version)' +``` + +##### org.hl7.fhir.r4 +###### Maven +```xml + + ca.uhn.hapi.fhir + hapi-fhir-structures-r4 + (latest version) + +``` + +###### Gradle +```groovy +compile group: 'ca.uhn.hapi.fhir', name: 'hapi-fhir-structures-r4', version: '(latest version)' +``` + +##### org.hl7.fhir.r5 +###### Maven +```xml + + ca.uhn.hapi.fhir + hapi-fhir-structures-r5 + (latest version) + +``` + +###### Gradle +```groovy +compile group: 'ca.uhn.hapi.fhir', name: 'hapi-fhir-structures-r5', version: '(latest version)' +``` + +### Maintenance +This project is maintained by [Grahame Grieve][Link-grahameGithub] and [James Agnew][Link-jamesGithub] on behalf of the FHIR community. + +[Link-AzureProject]: https://dev.azure.com/fhir-pipelines/fhir-core-library +[Link-BuildPipeline]: https://dev.azure.com/fhir-pipelines/fhir-core-library/_build/latest?definitionId=16&branchName=master +[Link-SnapshotPipeline]: https://dev.azure.com/fhir-pipelines/fhir-core-library/_build/latest?definitionId=17&branchName=master +[Link-r4SonatypeSnapshot]: https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=ca.uhn.hapi.fhir&a=org.hl7.fhir.r4&v=LATEST "Sonatype Snapshot" +[Link-r4SonatypeRelease]: https://oss.sonatype.org/service/local/artifact/maven/redirect?r=releases&g=ca.uhn.hapi.fhir&a=org.hl7.fhir.r4&v=LATEST "Sonatype Release" +[Link-r5SonatypeSnapshot]: https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=ca.uhn.hapi.fhir&a=org.hl7.fhir.r5&v=LATEST "Sonatype Snapshot" +[Link-r5SonatypeRelease]: https://oss.sonatype.org/service/local/artifact/maven/redirect?r=releases&g=ca.uhn.hapi.fhir&a=org.hl7.fhir.r5&v=LATEST "Sonatype Release" +[Link-cliSonatypeSnapshot]: https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=ca.uhn.hapi.fhir&a=org.hl7.fhir.validation.cli&v=LATEST "Sonatype Snapshot" +[Link-cliSonatypeRelease]: https://oss.sonatype.org/service/local/artifact/maven/redirect?r=releases&g=ca.uhn.hapi.fhir&a=org.hl7.fhir.validation.cli&v=LATEST "Sonatype Release" +[Link-grahameGithub]: https://github.com/grahamegrieve +[Link-jamesGithub]: https://github.com/jamesagnew + +[Badge-BuildPipeline]: https://dev.azure.com/fhir-pipelines/fhir-core-library/_apis/build/status/Build%20%26%20Test?branchName=master +[Badge-SnapshotPipeline]: https://dev.azure.com/fhir-pipelines/fhir-core-library/_apis/build/status/Module%20SNAPSHOT%20Publisher?branchName=master +[Badge-r4SonatypeRelease]: https://img.shields.io/nexus/r/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.r4.svg "Sonatype Releases" +[Badge-r4SonatypeSnapshot]: https://img.shields.io/nexus/s/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.r4.svg "Sonatype Snapshots" +[Badge-r5SonatypeRelease]: https://img.shields.io/nexus/r/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.r5.svg "Sonatype Releases" +[Badge-r5SonatypeSnapshot]: https://img.shields.io/nexus/s/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.r5.svg "Sonatype Snapshots" +[Badge-cliSonatypeRelease]: https://img.shields.io/nexus/r/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.validation.cli.svg "Sonatype Releases" +[Badge-cliSonatypeSnapshot]: https://img.shields.io/nexus/s/https/oss.sonatype.org/ca.uhn.hapi.fhir/org.hl7.fhir.validation.cli.svg "Sonatype Snapshots" diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 8b1378917..e69de29bb 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1 +0,0 @@ - diff --git a/org.hl7.fhir.convertors/pom.xml b/org.hl7.fhir.convertors/pom.xml index 790cd8ef4..4f47ba949 100644 --- a/org.hl7.fhir.convertors/pom.xml +++ b/org.hl7.fhir.convertors/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu2/pom.xml b/org.hl7.fhir.dstu2/pom.xml index cb8ce861e..bfd69d158 100644 --- a/org.hl7.fhir.dstu2/pom.xml +++ b/org.hl7.fhir.dstu2/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu2016may/pom.xml b/org.hl7.fhir.dstu2016may/pom.xml index 4b35e3db5..938155227 100644 --- a/org.hl7.fhir.dstu2016may/pom.xml +++ b/org.hl7.fhir.dstu2016may/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu3/pom.xml b/org.hl7.fhir.dstu3/pom.xml index c1024f976..e920f6c58 100644 --- a/org.hl7.fhir.dstu3/pom.xml +++ b/org.hl7.fhir.dstu3/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.r4/pom.xml b/org.hl7.fhir.r4/pom.xml index 9a2756416..da372c33a 100644 --- a/org.hl7.fhir.r4/pom.xml +++ b/org.hl7.fhir.r4/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.r4/src/test/java/org/hl7/fhir/r4/test/FHIRMappingLanguageTests.java b/org.hl7.fhir.r4/src/test/java/org/hl7/fhir/r4/test/FHIRMappingLanguageTests.java deleted file mode 100644 index 5ba09a2a7..000000000 --- a/org.hl7.fhir.r4/src/test/java/org/hl7/fhir/r4/test/FHIRMappingLanguageTests.java +++ /dev/null @@ -1,149 +0,0 @@ -package org.hl7.fhir.r4.test; - -import org.hl7.fhir.exceptions.FHIRException; -import org.hl7.fhir.r4.context.SimpleWorkerContext; -import org.hl7.fhir.r4.elementmodel.Manager; -import org.hl7.fhir.r4.elementmodel.Manager.FhirFormat; -import org.hl7.fhir.r4.formats.IParser.OutputStyle; -import org.hl7.fhir.r4.formats.JsonParser; -import org.hl7.fhir.r4.model.*; -import org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind; -import org.hl7.fhir.r4.terminologies.ConceptMapEngine; -import org.hl7.fhir.r4.test.utils.TestingUtilities; -import org.hl7.fhir.r4.utils.StructureMapUtilities; -import org.hl7.fhir.r4.utils.StructureMapUtilities.ITransformerServices; -import org.hl7.fhir.utilities.TextFile; -import org.hl7.fhir.utilities.Utilities; -import org.hl7.fhir.utilities.cache.FilesystemPackageCacheManager; -import org.hl7.fhir.utilities.cache.ToolsVersion; -import org.hl7.fhir.utilities.xml.XMLUtil; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.SAXException; - -import javax.xml.parsers.ParserConfigurationException; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Stream; - -import static org.junit.Assert.assertTrue; - -@Disabled -public class FHIRMappingLanguageTests implements ITransformerServices { - - private List outputs = new ArrayList(); - - static private SimpleWorkerContext context; - static private JsonParser jsonParser; - - public static Stream data() - throws FileNotFoundException, IOException, ParserConfigurationException, SAXException { - Document tests = XMLUtil.parseFileToDom(TestingUtilities.resourceNameToFile("fml", "manifest.xml")); - Element test = XMLUtil.getFirstChild(tests.getDocumentElement()); - List objects = new ArrayList(); - while (test != null && test.getNodeName().equals("test")) { - objects.add(Arguments.of(test.getAttribute("name"), test.getAttribute("source"), test.getAttribute("map"), - test.getAttribute("output"))); - test = XMLUtil.getNextSibling(test); - } - return objects.stream(); - } - - @BeforeAll - static public void setUp() throws Exception { - if (context == null) { - FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION); - context = SimpleWorkerContext.fromPackage(pcm.loadPackage("hl7.fhir.core", "4.0.0")); - jsonParser = new JsonParser(); - jsonParser.setOutputStyle(OutputStyle.PRETTY); - } - } - - @ParameterizedTest(name = "{index}: {0}") - @MethodSource("data") - public void test(String name, String source, String map, String output) throws Exception { - - String fileSource = TestingUtilities.resourceNameToFile("fml", source); - String fileMap = TestingUtilities.resourceNameToFile("fml", map); - String fileOutput = TestingUtilities.resourceNameToFile("fml", output); - String fileOutputRes = TestingUtilities.resourceNameToFile("fml", output) + ".out"; - - outputs.clear(); - - boolean ok = false; - String msg = null; - Resource resource = null; - try { - StructureMapUtilities scu = new StructureMapUtilities(context, this); - org.hl7.fhir.r4.elementmodel.Element src = Manager.parse(context, - new ByteArrayInputStream(TextFile.fileToBytes(fileSource)), FhirFormat.JSON); - StructureMap structureMap = scu.parse(TextFile.fileToString(fileMap), name); - String typeName = scu.getTargetType(structureMap).getType(); - resource = ResourceFactory.createResource(typeName); - scu.transform(null, src, structureMap, resource); - ok = true; - } catch (Exception e) { - ok = false; - msg = e.getMessage(); - } - if (ok) { - ByteArrayOutputStream boas = new ByteArrayOutputStream(); - jsonParser.compose(boas, resource); - log(boas.toString()); - TextFile.bytesToFile(boas.toByteArray(), fileOutputRes); - msg = TestingUtilities.checkJsonIsSame(fileOutputRes, fileOutput); - assertTrue(msg, Utilities.noString(msg)); - } else - assertTrue("Error, but proper output was expected (" + msg + ")", output.equals("$error")); - } - - @Override - public void log(String message) { - System.out.println(message); - } - - @Override - public Base createType(Object appInfo, String name) throws FHIRException { - StructureDefinition sd = context.fetchResource(StructureDefinition.class, name); - if (sd != null && sd.getKind() == StructureDefinitionKind.LOGICAL) { - return Manager.build(context, sd); - } else { - if (name.startsWith("http://hl7.org/fhir/StructureDefinition/")) - name = name.substring("http://hl7.org/fhir/StructureDefinition/".length()); - return ResourceFactory.createResourceOrType(name); - } - } - - @Override - public Base createResource(Object appInfo, Base res, boolean atRootofTransform) { - if (atRootofTransform) - outputs.add((Resource) res); - return res; - } - - @Override - public Coding translate(Object appInfo, Coding source, String conceptMapUrl) throws FHIRException { - ConceptMapEngine cme = new ConceptMapEngine(context); - return cme.translate(source, conceptMapUrl); - } - - @Override - public Base resolveReference(Object appContext, String url) throws FHIRException { - throw new FHIRException("resolveReference is not supported yet"); - } - - @Override - public List performSearch(Object appContext, String url) throws FHIRException { - throw new FHIRException("performSearch is not supported yet"); - } - -} \ No newline at end of file diff --git a/org.hl7.fhir.r4/src/test/resources/fml/.gitignore b/org.hl7.fhir.r4/src/test/resources/fml/.gitignore deleted file mode 100644 index fa929750c..000000000 --- a/org.hl7.fhir.r4/src/test/resources/fml/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.out \ No newline at end of file diff --git a/org.hl7.fhir.r4/src/test/resources/fml/manifest.xml b/org.hl7.fhir.r4/src/test/resources/fml/manifest.xml deleted file mode 100644 index 89b3d6b31..000000000 --- a/org.hl7.fhir.r4/src/test/resources/fml/manifest.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/org.hl7.fhir.r4/src/test/resources/fml/qr.json b/org.hl7.fhir.r4/src/test/resources/fml/qr.json deleted file mode 100644 index f0d14a3c1..000000000 --- a/org.hl7.fhir.r4/src/test/resources/fml/qr.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "resourceType": "QuestionnaireResponse", - "status": "in-progress", - "item": [ - { - "linkId": "patient", - "text": "Patient", - "item": [ - { - "linkId": "patient.lastname", - "text": "Name", - "answer": [ - { - "valueString": "Brönnimann-Bertholet" - } - ] - }, - { - "linkId": "patient.firstname", - "text": "Vorname", - "answer": [ - { - "valueString": "Elisabeth" - } - ] - }, - { - "linkId": "patient.sex", - "text": "Geschlecht", - "answer": [ - { - "valueString": "female" - } - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-assignment-res.json b/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-assignment-res.json deleted file mode 100644 index c29553577..000000000 --- a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-assignment-res.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "resourceType" : "Patient", - "gender" : "female" -} \ No newline at end of file diff --git a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-assignment.map b/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-assignment.map deleted file mode 100644 index 79ddfb89b..000000000 --- a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-assignment.map +++ /dev/null @@ -1,8 +0,0 @@ -map "http://github.com/hapifhir/org.hl7.fhir.core/org.hl7.fhir.r4.tests/qr2patassignment" = "qr2patassignment" - -uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QuestionnaireResponse as source -uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as target - -group QuestionnaireResponse(source src : QuestionnaireResponse, target tgt : Patient) { - src -> tgt.gender = 'female' "Simple Assignment"; -} \ No newline at end of file diff --git a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-gender-res.json b/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-gender-res.json deleted file mode 100644 index c29553577..000000000 --- a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-gender-res.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "resourceType" : "Patient", - "gender" : "female" -} \ No newline at end of file diff --git a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-gender.map b/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-gender.map deleted file mode 100644 index ee25265c6..000000000 --- a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-gender.map +++ /dev/null @@ -1,12 +0,0 @@ -map "http://github.com/hapifhir/org.hl7.fhir.core/org.hl7.fhir.r4.tests/qr2patgender" = "qr2patgender" - -uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QuestionnaireResponse as source -uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as target - -group QuestionnaireResponse(source src : QuestionnaireResponse, target tgt : Patient) { - src.item as item -> tgt as patient then item(item, patient); -} - -group item(source src, target tgt: Patient) { - src.item as item where linkId.value in ('patient.sex') -> tgt.gender = (item.answer.valueString); -} diff --git a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannameshared-res.json b/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannameshared-res.json deleted file mode 100644 index 240a91c69..000000000 --- a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannameshared-res.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "resourceType" : "Patient", - "name" : [{ - "family" : "Brönnimann-Bertholet", - "given" : ["Elisabeth"] - }], - "gender" : "female" -} diff --git a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannameshared.map b/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannameshared.map deleted file mode 100644 index 178a5d658..000000000 --- a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannameshared.map +++ /dev/null @@ -1,26 +0,0 @@ -map "http://github.com/hapifhir/org.hl7.fhir.core/org.hl7.fhir.r4.tests/qr2pathumannameshared" = "qr2pathumannametwice" - -uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QuestionnaireResponse as source -uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as target - -group entry(source src : QuestionnaireResponse, target tgt : Patient) { - src.item as item then item(item, tgt); -} - -group item(source src, target tgt) { - src.item as item then item(item, tgt); - src.item as item where linkId.value = 'patient.lastname' -> tgt.name as name share patientName then humanNameFamily(item, name); - src.item as item where linkId.value = 'patient.firstname' -> tgt.name as name share patientName then humanNameGiven(item, name); - src.item as item where linkId.value = 'patient.sex' -> tgt.gender = (item.answer.valueString); -} - -group humanNameFamily(source src, target tgt: HumanName) { - src.answer as answer -> tgt.family = (answer.valueString); -} -group humanNameGiven(source src, target tgt: HumanName) { - src.answer as answer -> tgt.given = (answer.valueString); -} - -group administrativeGender(source src, target tgt: code) { - src.answer as answer -> tgt = (answer.valueString); -} diff --git a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannametwice-res.json b/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannametwice-res.json deleted file mode 100644 index 9d9bab7db..000000000 --- a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannametwice-res.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "resourceType" : "Patient", - "name" : [{ - "family" : "Brönnimann-Bertholet" - }, - { - "given" : ["Elisabeth"] - }], - "gender" : "female" -} \ No newline at end of file diff --git a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannametwice.map b/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannametwice.map deleted file mode 100644 index 6de8b3c88..000000000 --- a/org.hl7.fhir.r4/src/test/resources/fml/qr2pat-humannametwice.map +++ /dev/null @@ -1,26 +0,0 @@ -map "http://github.com/hapifhir/org.hl7.fhir.core/org.hl7.fhir.r4.tests/qr2pathumannametwice" = "qr2pathumannametwice" - -uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QuestionnaireResponse as source -uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as target - -group entry(source src : QuestionnaireResponse, target tgt : Patient) { - src.item as item then item(item, tgt); -} - -group item(source src, target tgt) { - src.item as item then item(item, tgt); - src.item as item where linkId.value = 'patient.lastname' -> tgt.name as name then humanNameFamily(item, name); - src.item as item where linkId.value = 'patient.firstname' -> tgt.name as name then humanNameGiven(item, name); - src.item as item where linkId.value = 'patient.sex' -> tgt.gender = (item.answer.valueString); -} - -group humanNameFamily(source src, target tgt: HumanName) { - src.answer as answer -> tgt.family = (answer.valueString); -} -group humanNameGiven(source src, target tgt: HumanName) { - src.answer as answer -> tgt.given = (answer.valueString); -} - -group administrativeGender(source src, target tgt: code) { - src.answer as answer -> tgt = (answer.valueString); -} diff --git a/org.hl7.fhir.r5/pom.xml b/org.hl7.fhir.r5/pom.xml index 77d6cbe22..4f5a7f2b0 100644 --- a/org.hl7.fhir.r5/pom.xml +++ b/org.hl7.fhir.r5/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/CodeSystemComparer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/CodeSystemComparer.java index 59b4f3a1b..2e472e1aa 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/CodeSystemComparer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/CodeSystemComparer.java @@ -226,7 +226,6 @@ public class CodeSystemComparer extends CanonicalResourceComparer { } } - private boolean hasDesignation(ConceptDefinitionDesignationComponent td, List designation) { for (ConceptDefinitionDesignationComponent t : designation) { if (designationsMatch(td, t)) { @@ -303,7 +302,6 @@ public class CodeSystemComparer extends CanonicalResourceComparer { return null; } - public XhtmlNode renderConcepts(CodeSystemComparison comparison, String id, String prefix) throws FHIRException, IOException { // columns: code, display (left|right), properties (left|right) HierarchicalTableGenerator gen = new HierarchicalTableGenerator(Utilities.path("[tmp]", "compare"), false); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/ComparisonRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/ComparisonRenderer.java new file mode 100644 index 000000000..63c3e3196 --- /dev/null +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/ComparisonRenderer.java @@ -0,0 +1,166 @@ +package org.hl7.fhir.r5.comparison; + +import java.awt.image.renderable.RenderContext; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.exceptions.PathEngineException; +import org.hl7.fhir.r5.comparison.CodeSystemComparer.CodeSystemComparison; +import org.hl7.fhir.r5.comparison.ProfileComparer.ProfileComparison; +import org.hl7.fhir.r5.comparison.ResourceComparer.ResourceComparison; +import org.hl7.fhir.r5.comparison.ValueSetComparer.ValueSetComparison; +import org.hl7.fhir.r5.context.IWorkerContext; +import org.hl7.fhir.r5.formats.IParser.OutputStyle; +import org.hl7.fhir.r5.model.Base; +import org.hl7.fhir.r5.model.CodeSystem; +import org.hl7.fhir.r5.model.ExpressionNode.CollectionStatus; +import org.hl7.fhir.r5.model.StringType; +import org.hl7.fhir.r5.model.StructureDefinition; +import org.hl7.fhir.r5.model.TypeDetails; +import org.hl7.fhir.r5.model.ValueSet; +import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext; +import org.hl7.fhir.r5.utils.LiquidEngine; +import org.hl7.fhir.r5.utils.LiquidEngine.LiquidDocument; +import org.hl7.fhir.utilities.TextFile; +import org.hl7.fhir.utilities.Utilities; +import org.hl7.fhir.utilities.xhtml.XhtmlComposer; + +public class ComparisonRenderer implements IEvaluationContext { + + private IWorkerContext context; + private ComparisonSession session; + private Map templates = new HashMap<>(); + private String folder; + + public ComparisonRenderer(IWorkerContext context, String folder) { + super(); + this.context = context; + this.folder = folder; + } + + public Map getTemplates() { + return templates; + } + + public void render() throws IOException { + for (String id : session.getCompares().keySet()) { + renderComparison(id, session.getCompares().get(id)); + } + } + + private void renderComparison(String id, ResourceComparison comp) throws IOException { + if (comp instanceof ProfileComparison) { + renderProfile(id, (ProfileComparison) comp); + } else if (comp instanceof ValueSetComparison) { + renderValueSet(id, (ValueSetComparison) comp); + } else if (comp instanceof CodeSystemComparison) { + renderCodeSystem(id, (CodeSystemComparison) comp); + } + } + + private void renderCodeSystem(String id, CodeSystemComparison comp) throws IOException { + String template = templates.get("CodeSystem"); + Map vars = new HashMap<>(); + CodeSystemComparer cs = new CodeSystemComparer(session); + vars.put("errors", new StringType(new XhtmlComposer(true).compose(cs.renderErrors(comp)))); + vars.put("metadata", new StringType(new XhtmlComposer(true).compose(cs.renderMetadata(comp, "", "")))); + vars.put("concepts", new StringType(new XhtmlComposer(true).compose(cs.renderConcepts(comp, "", "")))); + String cnt = processTemplate(template, "CodeSystem", vars); + TextFile.stringToFile(cnt, file(id+".html")); + new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "comparison", id + "-union.json")), comp.getUnion()); + new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "comparison", id + "-intersection.json")), comp.getIntersection()); + } + + private String file(String name) throws IOException { + return Utilities.path(folder, name); + } + + private void renderValueSet(String id, ValueSetComparison comp) throws FHIRException, IOException { + String template = templates.get("ValueSet"); + Map vars = new HashMap<>(); + ValueSetComparer cs = new ValueSetComparer(session); + vars.put("errors", new StringType(new XhtmlComposer(true).compose(cs.renderErrors(comp)))); + vars.put("metadata", new StringType(new XhtmlComposer(true).compose(cs.renderMetadata(comp, "", "")))); + vars.put("compose", new StringType(new XhtmlComposer(true).compose(cs.renderCompose(comp, "", "")))); + vars.put("expnsion", new StringType(new XhtmlComposer(true).compose(cs.renderExpansion(comp, "", "")))); + String cnt = processTemplate(template, "ValueSet", vars); + TextFile.stringToFile(cnt, file(id+".html")); + new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "comparison", id + "-union.json")), comp.getUnion()); + new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "comparison", id + "-intersection.json")), comp.getIntersection()); + } + + private void renderProfile(String id, ProfileComparison comp) throws IOException { + String template = templates.get("Profile"); + Map vars = new HashMap<>(); + ProfileComparer cs = new ProfileComparer(session); + vars.put("errors", new StringType(new XhtmlComposer(true).compose(cs.renderErrors(comp)))); + vars.put("metadata", new StringType(new XhtmlComposer(true).compose(cs.renderMetadata(comp, "", "")))); +// vars.put("concepts", new StringType(new XhtmlComposer(true).compose(cs.renderConcepts(comp, "", "")))); + String cnt = processTemplate(template, "CodeSystem", vars); + TextFile.stringToFile(cnt, file(id+".html")); + new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "comparison", id + "-union.json")), comp.getUnion()); + new org.hl7.fhir.r5.formats.JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "comparison", id + "-intersection.json")), comp.getIntersection()); + } + + private String processTemplate(String template, String name, Map vars) { + LiquidEngine engine = new LiquidEngine(context, this); + LiquidDocument doc = engine.parse(template, name+".template"); + return engine.evaluate(doc, null, vars); + } + + @Override + public Base resolveConstant(Object appContext, String name, boolean beforeContext) throws PathEngineException { + @SuppressWarnings("unchecked") + Map vars = (Map) appContext; + return vars.get(name); + } + + @Override + public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException { + @SuppressWarnings("unchecked") + Map vars = (Map) appContext; + Base b = vars.get(name); + return new TypeDetails(CollectionStatus.SINGLETON, b == null ? "Base" : b.fhirType()); + } + + @Override + public boolean log(String argument, List focus) { + return false; + } + + @Override + public FunctionDetails resolveFunction(String functionName) { + return null; + } + + @Override + public TypeDetails checkFunction(Object appContext, String functionName, List parameters) throws PathEngineException { + return null; + } + + @Override + public List executeFunction(Object appContext, String functionName, List> parameters) { + return null; + } + + @Override + public Base resolveReference(Object appContext, String url, Base refContext) throws FHIRException { + return null; + } + + @Override + public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException { + return false; + } + + @Override + public ValueSet resolveValueSet(Object appContext, String url) { + return null; + } + +} diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/ComparisonSession.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/ComparisonSession.java index 24ac1d639..e3451abac 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/ComparisonSession.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/ComparisonSession.java @@ -25,6 +25,7 @@ public class ComparisonSession { private IWorkerContext context; private String sessiondId; private int count; + private boolean debug; public ComparisonSession(IWorkerContext context) { super(); @@ -90,6 +91,22 @@ public class ComparisonSession { public void identify(ResourceComparison res) { count++; res.setId(sessiondId+"-"+count); - } + + public boolean isDebug() { + return debug; + } + + public void setDebug(boolean debug) { + this.debug = debug; + } + + public Map getCompares() { + return compares; + } + + + + + } \ No newline at end of file diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/ProfileComparer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/ProfileComparer.java index 0863bdfc2..aa924e741 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/ProfileComparer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/comparison/ProfileComparer.java @@ -113,6 +113,10 @@ public class ProfileComparer extends CanonicalResourceComparer { assert(right != null); assert(left.path().equals(right.path())); + if (session.isDebug()) { + System.out.println("Compare elements at "+path); + } + // not allowed to be different: ruleEqual(comp, res, left.current().getDefaultValue(), right.current().getDefaultValue(), "defaultValue", path); ruleEqual(comp, res, left.current().getMeaningWhenMissingElement(), right.current().getMeaningWhenMissingElement(), "meaningWhenMissing", path); @@ -256,7 +260,7 @@ public class ProfileComparer extends CanonicalResourceComparer { matchR.add(r); StructuralMatch sm = new StructuralMatch(l.current(), r.current()); res.getChildren().add(sm); - compareElements(comp, sm, l.path(), null, left, right); + compareElements(comp, sm, l.path(), null, l, r); } } for (DefinitionNavigator r : rc) { @@ -332,7 +336,6 @@ public class ProfileComparer extends CanonicalResourceComparer { return "left: "+left+"; right: "+right; } - private List mergeCodings(List left, List right) { List result = new ArrayList(); result.addAll(left); @@ -347,7 +350,6 @@ public class ProfileComparer extends CanonicalResourceComparer { return result; } - private List mergeStrings(List left, List right) { List result = new ArrayList(); result.addAll(left); @@ -434,7 +436,6 @@ public class ProfileComparer extends CanonicalResourceComparer { return Integer.toString(defn.current().getMin())+".."+defn.current().getMax(); } - private Collection unionTypes(ProfileComparison comp, StructuralMatch res, String path, List left, List right) throws DefinitionException, IOException, FHIRFormatError { List result = new ArrayList(); for (TypeRefComponent l : left) @@ -514,14 +515,12 @@ public class ProfileComparer extends CanonicalResourceComparer { results.add(nw); } - private boolean derivesFrom(StructureDefinition left, StructureDefinition right) { // left derives from right if it's base is the same as right // todo: recursive... return left.hasBaseDefinition() && left.getBaseDefinition().equals(right.getUrl()); } - private Collection intersectTypes(ProfileComparison comp, StructuralMatch res, ElementDefinition ed, String path, List left, List right) throws DefinitionException, IOException, FHIRFormatError { List result = new ArrayList(); for (TypeRefComponent l : left) { @@ -601,7 +600,6 @@ public class ProfileComparer extends CanonicalResourceComparer { return b.toString(); } - private boolean compareBindings(ProfileComparison comp, StructuralMatch res, ElementDefinition subset, ElementDefinition superset, String path, ElementDefinition lDef, ElementDefinition rDef) throws FHIRFormatError, DefinitionException, IOException { assert(lDef.hasBinding() || rDef.hasBinding()); if (!lDef.hasBinding()) { @@ -746,8 +744,6 @@ public class ProfileComparer extends CanonicalResourceComparer { return sd; } - - private boolean isPreferredOrExample(ElementDefinitionBindingComponent binding) { return binding.getStrength() == BindingStrength.EXAMPLE || binding.getStrength() == BindingStrength.PREFERRED; } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java index 324b2518b..28be4fb2c 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java @@ -1,33 +1,33 @@ package org.hl7.fhir.r5.context; -/* - Copyright (c) 2011+, HL7, Inc. - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of HL7 nor the names of its contributors may be used to - endorse or promote products derived from this software without specific - prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - - */ +/* + Copyright (c) 2011+, HL7, Inc. + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of HL7 nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + */ 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 32fa5d827..182abbafc 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 @@ -231,6 +231,9 @@ public class DataRenderer { } public String display(DataType type) { + if (type.isEmpty()) + return ""; + if (type instanceof Coding) { return displayCoding((Coding) type); } else if (type instanceof CodeableConcept) { @@ -693,7 +696,7 @@ public class DataRenderer { } public static String displayPeriod(Period p) { - String s = !p.hasStart() ? "?ngen-5?" : p.getStartElement().toHumanDisplay(); + String s = !p.hasStart() ? "(?)" : p.getStartElement().toHumanDisplay(); s = s + " --> "; return s + (!p.hasEnd() ? "(ongoing)" : p.getEndElement().toHumanDisplay()); } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/StructureMapUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/StructureMapUtilities.java index 218a559b8..ce002eeb6 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/StructureMapUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/StructureMapUtilities.java @@ -213,18 +213,26 @@ public class StructureMapUtilities { return services.resolveReference(appContext, url); } + private boolean noErrorValidationMessages(List valerrors) { + boolean ok = true; + for (ValidationMessage v : valerrors) + ok = ok && !v.getLevel().isError(); + return ok; + } + @Override public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException { IResourceValidator val = worker.newValidator(); List valerrors = new ArrayList(); if (item instanceof Resource) { val.validate(appContext, valerrors, (Resource) item, url); - boolean ok = true; - for (ValidationMessage v : valerrors) - ok = ok && v.getLevel().isError(); - return ok; + return noErrorValidationMessages(valerrors); } - throw new NotImplementedException("Not done yet (FFHIRPathHostServices.conformsToProfile), when item is element"); + if (item instanceof Element) { + val.validate(appContext, valerrors, (Element) item, url); + return noErrorValidationMessages(valerrors); + } + throw new NotImplementedException("Not done yet (FFHIRPathHostServices.conformsToProfile), when item is not element or not resource"); } @Override diff --git a/org.hl7.fhir.report/pom.xml b/org.hl7.fhir.report/pom.xml index f22730c90..751c9b176 100644 --- a/org.hl7.fhir.report/pom.xml +++ b/org.hl7.fhir.report/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.utilities/pom.xml b/org.hl7.fhir.utilities/pom.xml index 802120eb6..31cce8d7f 100644 --- a/org.hl7.fhir.utilities/pom.xml +++ b/org.hl7.fhir.utilities/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/FilesystemPackageCacheManager.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/FilesystemPackageCacheManager.java index b6495eb78..f4923011a 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/FilesystemPackageCacheManager.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/cache/FilesystemPackageCacheManager.java @@ -182,7 +182,7 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple if (!CACHE_VERSION.equals(v)) { clearCache(); ini.setStringProperty("cache", "version", CACHE_VERSION, null); - save = true; + ini.save(); } } diff --git a/org.hl7.fhir.utilities/src/main/resources/Messages.properties b/org.hl7.fhir.utilities/src/main/resources/Messages.properties index eddb6c610..70092ec8e 100644 --- a/org.hl7.fhir.utilities/src/main/resources/Messages.properties +++ b/org.hl7.fhir.utilities/src/main/resources/Messages.properties @@ -99,7 +99,7 @@ Questionnaire_QR_Q_NotFound = The questionnaire "{0}" could not be resolved, so Questionnaire_Q_EnableWhen_After = The target of this enableWhen rule ({0}) comes after the question itself Questionnaire_Q_EnableWhen_IsInner = Questions with an enableWhen cannot refer to an inner question for it''s enableWhen condition Questionnaire_Q_EnableWhen_NoLink = Questions with an enableWhen must have a value for the question link -Questionnaire_Q_EnableWhen_NoTarget = Unable to find target "{0}" for this question enableWhen +Questionnaire_Q_EnableWhen_NoTarget = Unable to find an item with the linkId "{0}" which is referenced in the enableWhen for "{1}" Questionnaire_Q_EnableWhen_Self = Target for this question enableWhen can''t reference itself Reference_REF_Aggregation = Reference is {0} which isn''t supported by the specified aggregation mode(s) for the reference Reference_REF_BadTargetType = Invalid Resource target type. Found {0}, but expected one of ({1}) diff --git a/org.hl7.fhir.validation.cli/pom.xml b/org.hl7.fhir.validation.cli/pom.xml index 452f855a1..12e1debb4 100644 --- a/org.hl7.fhir.validation.cli/pom.xml +++ b/org.hl7.fhir.validation.cli/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.validation/pom.xml b/org.hl7.fhir.validation/pom.xml index 234ed6fc1..edb3a3418 100644 --- a/org.hl7.fhir.validation/pom.xml +++ b/org.hl7.fhir.validation/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/QuestionnaireValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/QuestionnaireValidator.java index d54213efc..227d68f94 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/QuestionnaireValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/QuestionnaireValidator.java @@ -95,7 +95,7 @@ public class QuestionnaireValidator extends BaseValidator { Element tgt = getQuestionById(item, ql); if (rule(errors, IssueType.BUSINESSRULE, ns.getLiteralPath(), tgt == null, I18nConstants.QUESTIONNAIRE_Q_ENABLEWHEN_ISINNER)) { tgt = getQuestionById(questionnaire, ql); - if (rule(errors, IssueType.BUSINESSRULE, ns.getLiteralPath(), tgt != null, I18nConstants.QUESTIONNAIRE_Q_ENABLEWHEN_NOTARGET, ql)) { + if (rule(errors, IssueType.BUSINESSRULE, ns.getLiteralPath(), tgt != null, I18nConstants.QUESTIONNAIRE_Q_ENABLEWHEN_NOTARGET, ql, item.getChildValue("linkId"))) { if (rule(errors, IssueType.BUSINESSRULE, ns.getLiteralPath(), tgt != item, I18nConstants.QUESTIONNAIRE_Q_ENABLEWHEN_SELF)) { if (!isBefore(item, tgt, parents)) { warning(errors, IssueType.BUSINESSRULE, ns.getLiteralPath(), false, I18nConstants.QUESTIONNAIRE_Q_ENABLEWHEN_AFTER, ql); diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRMappingLanguageTests.java b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/r5/test/FHIRMappingLanguageTests.java similarity index 93% rename from org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRMappingLanguageTests.java rename to org.hl7.fhir.validation/src/test/java/org/hl7/fhir/r5/test/FHIRMappingLanguageTests.java index ad2fbde39..a39648b17 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRMappingLanguageTests.java +++ b/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/r5/test/FHIRMappingLanguageTests.java @@ -36,8 +36,8 @@ import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.cache.FilesystemPackageCacheManager; import org.hl7.fhir.utilities.cache.ToolsVersion; import org.hl7.fhir.utilities.xml.XMLUtil; +import org.hl7.fhir.validation.instance.InstanceValidatorFactory; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -68,14 +68,16 @@ public class FHIRMappingLanguageTests implements ITransformerServices { @BeforeAll public static void setUp() throws Exception { FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION); - context = SimpleWorkerContext.fromPackage(pcm.loadPackage("hl7.fhir.core", "4.0.1")); + context = SimpleWorkerContext.fromPackage(pcm.loadPackage("hl7.fhir.r5.core", "current")); + if (context.getValidatorFactory() == null) { + context.setValidatorFactory(new InstanceValidatorFactory()); + } jsonParser = new JsonParser(); jsonParser.setOutputStyle(OutputStyle.PRETTY); } @ParameterizedTest(name = "{index}: {0}") @MethodSource("data") - @Disabled // Test fails: java.lang.AssertionError: Error, but proper output was expected (This does not appear to be a FHIR resource (unknown name "QuestionnaireResponse") public void test(String name, String source, String map, String output) throws Exception { InputStream fileSource = TestingUtilities.loadTestResourceStream("r5", "fml", source); diff --git a/pom.xml b/pom.xml index 3038bc875..cec25c65e 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ each other. It is fine to bump the point version of this POM without affecting HAPI FHIR. --> - 5.0.6-SNAPSHOT + 5.0.7-SNAPSHOT 5.0.0