Merge branch 'hapifhir:master' into master
This commit is contained in:
commit
34d8dfa24d
|
@ -0,0 +1,28 @@
|
||||||
|
name: BIDI CHECK
|
||||||
|
|
||||||
|
# Controls when the workflow will run
|
||||||
|
on:
|
||||||
|
# Triggers the workflow on push or pull request events but only for the main branch
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
# Allows you to run this workflow manually from the Actions tab
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
bidi_checker_job:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Check for bidi unicode characters in repo
|
||||||
|
steps:
|
||||||
|
# Checkout the repo code. IMPORTANT, this step is needed to populate the directory defined by GITHUB_WORKSPACE
|
||||||
|
- name: Checkout repo
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
id: checkout
|
||||||
|
# Run the check for bidi characters.
|
||||||
|
- name: Check for bidi characters
|
||||||
|
id: bidi_check
|
||||||
|
uses: HL7/bidi-checker-action@v1.5
|
||||||
|
- name: Get the output time
|
||||||
|
run: echo "The time was ${{ steps.bidi_check.outputs.time }}"
|
|
@ -4,7 +4,7 @@
|
||||||
| :---: |
|
| :---: |
|
||||||
| [![Build Status][Badge-BuildPipeline]][Link-BuildPipeline] |
|
| [![Build Status][Badge-BuildPipeline]][Link-BuildPipeline] |
|
||||||
|
|
||||||
This is the core object handling code, with utilities (including validator), for the FHIR specification.
|
This is the java core object handling code, with utilities (including validator), for the FHIR specification.
|
||||||
included in this repo:
|
included in this repo:
|
||||||
|
|
||||||
* org.fhir.fhir.utilities: Shared code used by all the other projects - including the internationalization code
|
* org.fhir.fhir.utilities: Shared code used by all the other projects - including the internationalization code
|
||||||
|
@ -17,6 +17,11 @@ included in this repo:
|
||||||
* org.fhir.fhir.validation: The FHIR Java validator (note: based on R5 internally, but validates all the above versions)
|
* org.fhir.fhir.validation: The FHIR Java validator (note: based on R5 internally, but validates all the above versions)
|
||||||
* org.fhir.fhir.validation.cli: Holder project for releasing the FHIR validator as as single fat jar (will be removed in the future)
|
* org.fhir.fhir.validation.cli: Holder project for releasing the FHIR validator as as single fat jar (will be removed in the future)
|
||||||
|
|
||||||
|
This code is used in all HAPI servers and clients, and also is the HL7 maintained
|
||||||
|
FHIR Validator. In addition, this is the core code for the HL7 maintained IG publisher
|
||||||
|
and FHIR main build publisher. As such, this code is considered an authoritatively
|
||||||
|
correct implementation of the core FHIR specification that it implements.
|
||||||
|
|
||||||
### CI/CD
|
### CI/CD
|
||||||
|
|
||||||
All integration and delivery done on Azure pipelines. Azure project can be viewed [here][Link-AzureProject].
|
All integration and delivery done on Azure pipelines. Azure project can be viewed [here][Link-AzureProject].
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
Code changes:
|
|
||||||
* remove erroneous logging to c:\temp
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>5.5.12-SNAPSHOT</version>
|
<version>5.6.16-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>1.18.16</version>
|
<version>${lombok_version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
|
@ -613,10 +613,10 @@ public class ElementDefinition30_40 {
|
||||||
Type t = ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getValueSet());
|
Type t = ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().convertType(src.getValueSet());
|
||||||
if (t instanceof org.hl7.fhir.r4.model.Reference) {
|
if (t instanceof org.hl7.fhir.r4.model.Reference) {
|
||||||
tgt.setValueSet(((org.hl7.fhir.r4.model.Reference) t).getReference());
|
tgt.setValueSet(((org.hl7.fhir.r4.model.Reference) t).getReference());
|
||||||
tgt.getValueSetElement().addExtension(VersionConvertor_30_40.EXT_SRC_TYPE, new UriType("Reference"));
|
tgt.getValueSetElement().addExtension(VersionConvertor_30_40.EXT_SRC_TYPE, new org.hl7.fhir.r4.model.UrlType("Reference"));
|
||||||
} else {
|
} else {
|
||||||
tgt.setValueSet(t.primitiveValue());
|
tgt.setValueSet(t.primitiveValue());
|
||||||
tgt.getValueSetElement().addExtension(VersionConvertor_30_40.EXT_SRC_TYPE, new UriType("uri"));
|
tgt.getValueSetElement().addExtension(VersionConvertor_30_40.EXT_SRC_TYPE, new org.hl7.fhir.r4.model.UrlType("uri"));
|
||||||
}
|
}
|
||||||
tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet()));
|
tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -625,10 +625,10 @@ public class ElementDefinition30_50 {
|
||||||
DataType t = ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getValueSet());
|
DataType t = ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getValueSet());
|
||||||
if (t instanceof org.hl7.fhir.r5.model.Reference) {
|
if (t instanceof org.hl7.fhir.r5.model.Reference) {
|
||||||
tgt.setValueSet(((org.hl7.fhir.r5.model.Reference) t).getReference());
|
tgt.setValueSet(((org.hl7.fhir.r5.model.Reference) t).getReference());
|
||||||
tgt.getValueSetElement().addExtension(VersionConvertor_30_50.EXT_SRC_TYPE, new UriType("Reference"));
|
tgt.getValueSetElement().addExtension(VersionConvertor_30_50.EXT_SRC_TYPE, new org.hl7.fhir.r5.model.UrlType("Reference"));
|
||||||
} else {
|
} else {
|
||||||
tgt.setValueSet(t.primitiveValue());
|
tgt.setValueSet(t.primitiveValue());
|
||||||
tgt.getValueSetElement().addExtension(VersionConvertor_30_50.EXT_SRC_TYPE, new UriType("uri"));
|
tgt.getValueSetElement().addExtension(VersionConvertor_30_50.EXT_SRC_TYPE, new org.hl7.fhir.r5.model.UrlType("uri"));
|
||||||
}
|
}
|
||||||
tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet()));
|
tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ public abstract class BaseLoaderR5 implements IContextResourceLoader {
|
||||||
if (VersionUtilities.isR5Ver(npm.fhirVersion())) {
|
if (VersionUtilities.isR5Ver(npm.fhirVersion())) {
|
||||||
return new R5ToR5Loader(types, lkp.forNewPackage(npm));
|
return new R5ToR5Loader(types, lkp.forNewPackage(npm));
|
||||||
} else if (VersionUtilities.isR4Ver(npm.fhirVersion())) {
|
} else if (VersionUtilities.isR4Ver(npm.fhirVersion())) {
|
||||||
return new R4ToR5Loader(types, lkp.forNewPackage(npm));
|
return new R4ToR5Loader(types, lkp.forNewPackage(npm), npm.version());
|
||||||
} else if (VersionUtilities.isR3Ver(npm.fhirVersion())) {
|
} else if (VersionUtilities.isR3Ver(npm.fhirVersion())) {
|
||||||
return new R3ToR5Loader(types, lkp.forNewPackage(npm));
|
return new R3ToR5Loader(types, lkp.forNewPackage(npm));
|
||||||
} else if (VersionUtilities.isR2Ver(npm.fhirVersion())) {
|
} else if (VersionUtilities.isR2Ver(npm.fhirVersion())) {
|
||||||
|
|
|
@ -36,12 +36,14 @@ import org.hl7.fhir.exceptions.FHIRException;
|
||||||
import org.hl7.fhir.r4.formats.JsonParser;
|
import org.hl7.fhir.r4.formats.JsonParser;
|
||||||
import org.hl7.fhir.r4.formats.XmlParser;
|
import org.hl7.fhir.r4.formats.XmlParser;
|
||||||
import org.hl7.fhir.r4.model.Resource;
|
import org.hl7.fhir.r4.model.Resource;
|
||||||
|
import org.hl7.fhir.r5.conformance.StructureDefinitionHacker;
|
||||||
import org.hl7.fhir.r5.context.IWorkerContext.IContextResourceLoader;
|
import org.hl7.fhir.r5.context.IWorkerContext.IContextResourceLoader;
|
||||||
import org.hl7.fhir.r5.model.*;
|
import org.hl7.fhir.r5.model.*;
|
||||||
import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent;
|
import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent;
|
||||||
import org.hl7.fhir.r5.model.Bundle.BundleType;
|
import org.hl7.fhir.r5.model.Bundle.BundleType;
|
||||||
import org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent;
|
import org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent;
|
||||||
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
|
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
|
||||||
|
import org.hl7.fhir.utilities.VersionUtilities;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -52,9 +54,11 @@ import java.util.UUID;
|
||||||
public class R4ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader {
|
public class R4ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader {
|
||||||
|
|
||||||
private final BaseAdvisor_40_50 advisor = new BaseAdvisor_40_50();
|
private final BaseAdvisor_40_50 advisor = new BaseAdvisor_40_50();
|
||||||
|
private String version;
|
||||||
|
|
||||||
public R4ToR5Loader(String[] types, ILoaderKnowledgeProviderR5 lkp) {
|
public R4ToR5Loader(String[] types, ILoaderKnowledgeProviderR5 lkp, String version) { // might be 4B
|
||||||
super(types, lkp);
|
super(types, lkp);
|
||||||
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -123,6 +127,9 @@ public class R4ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
|
||||||
if (killPrimitives) {
|
if (killPrimitives) {
|
||||||
throw new FHIRException("Cannot kill primitives when using deferred loading");
|
throw new FHIRException("Cannot kill primitives when using deferred loading");
|
||||||
}
|
}
|
||||||
|
if (r5 instanceof StructureDefinition && VersionUtilities.isR4BVer(version)) {
|
||||||
|
r5 = new StructureDefinitionHacker(version).fixSD((StructureDefinition) r5);
|
||||||
|
}
|
||||||
if (patchUrls) {
|
if (patchUrls) {
|
||||||
if (r5 instanceof StructureDefinition) {
|
if (r5 instanceof StructureDefinition) {
|
||||||
StructureDefinition sd = (StructureDefinition) r5;
|
StructureDefinition sd = (StructureDefinition) r5;
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class DicomPackageBuilder {
|
||||||
vs.setId(vs.getId().substring(0, 64));
|
vs.setId(vs.getId().substring(0, 64));
|
||||||
}
|
}
|
||||||
if (ids.contains(vs.getId())) {
|
if (ids.contains(vs.getId())) {
|
||||||
throw new Error("Duplicate Id once Ids cut off at 64 char: "+vs.getId());
|
throw new Error("Duplicate Id (note Ids cut off at 64 char): "+vs.getId());
|
||||||
}
|
}
|
||||||
ids.add(vs.getId());
|
ids.add(vs.getId());
|
||||||
gen.addFile(Category.RESOURCE, "ValueSet-"+vs.getId()+".json", new JsonParser().setOutputStyle(OutputStyle.NORMAL).composeBytes(vs));
|
gen.addFile(Category.RESOURCE, "ValueSet-"+vs.getId()+".json", new JsonParser().setOutputStyle(OutputStyle.NORMAL).composeBytes(vs));
|
||||||
|
@ -113,7 +113,7 @@ public class DicomPackageBuilder {
|
||||||
private JsonObject buildPackage() {
|
private JsonObject buildPackage() {
|
||||||
JsonObject npm = new JsonObject();
|
JsonObject npm = new JsonObject();
|
||||||
npm.addProperty("tools-version", 3);
|
npm.addProperty("tools-version", 3);
|
||||||
npm.addProperty("type", "fhir.ig");
|
npm.addProperty("type", "Conformance");
|
||||||
npm.addProperty("license", "free");
|
npm.addProperty("license", "free");
|
||||||
npm.addProperty("author", "FHIR Project for DICOM");
|
npm.addProperty("author", "FHIR Project for DICOM");
|
||||||
npm.addProperty("name", "fhir.dicom");
|
npm.addProperty("name", "fhir.dicom");
|
||||||
|
|
|
@ -0,0 +1,387 @@
|
||||||
|
package org.hl7.fhir.convertors.misc;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import javax.naming.ldap.StartTlsRequest;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
|
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||||
|
import org.hl7.fhir.utilities.Utilities;
|
||||||
|
import org.hl7.fhir.utilities.json.JsonTrackingParser;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
public class XVerPackegeFixer {
|
||||||
|
|
||||||
|
private static final String R5_FOLDER = "C:\\work\\org.hl7.fhir\\packages\\hl7.fhir.rX\\hl7.fhir.r5.core\\package";
|
||||||
|
private static final String R4_FOLDER = "C:\\work\\org.hl7.fhir\\packages\\hl7.fhir.rX\\hl7.fhir.r4.core\\package";
|
||||||
|
private static final String R3_FOLDER = "C:\\work\\org.hl7.fhir\\packages\\hl7.fhir.rX\\hl7.fhir.r3.core\\package";
|
||||||
|
private static final String R2B_FOLDER = "C:\\work\\org.hl7.fhir\\packages\\hl7.fhir.rX\\hl7.fhir.r2b.core\\package";
|
||||||
|
private static final String R2_FOLDER = "C:\\work\\org.hl7.fhir\\packages\\hl7.fhir.rX\\hl7.fhir.r2.core\\package";
|
||||||
|
private static int mod;
|
||||||
|
|
||||||
|
private static Map<String, org.hl7.fhir.r5.model.StructureDefinition> map5 = new HashMap<>();
|
||||||
|
private static Map<String, org.hl7.fhir.r4.model.StructureDefinition> map4 = new HashMap<>();
|
||||||
|
private static Map<String, org.hl7.fhir.dstu3.model.StructureDefinition> map3 = new HashMap<>();
|
||||||
|
private static Map<String, org.hl7.fhir.dstu2.model.StructureDefinition> map2 = new HashMap<>();
|
||||||
|
private static Map<String, org.hl7.fhir.dstu2016may.model.StructureDefinition> map2b = new HashMap<>();
|
||||||
|
|
||||||
|
public static void main(String[] args) throws FileNotFoundException, ParserConfigurationException, SAXException, IOException {
|
||||||
|
mod = 0;
|
||||||
|
for (File f : new File(args[0]).listFiles()) {
|
||||||
|
if (f.getName().startsWith("xver-")) {
|
||||||
|
JsonObject j = JsonTrackingParser.parseJson(f);
|
||||||
|
fixUp(j, f.getName());
|
||||||
|
JsonTrackingParser.write(j, f, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("all done: "+mod+" modifiers");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void fixUp(JsonObject j, String name) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||||
|
name = name.replace(".json", "");
|
||||||
|
System.out.println("Process "+name);
|
||||||
|
String version = name.substring(name.lastIndexOf("-")+1);
|
||||||
|
int i = 0;
|
||||||
|
for (Entry<String, JsonElement> e : j.entrySet()) {
|
||||||
|
if (i == 50) {
|
||||||
|
i = 0;
|
||||||
|
System.out.print(".");
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
String n = e.getKey();
|
||||||
|
JsonObject o = ((JsonObject) e.getValue());
|
||||||
|
boolean ok = (o.has("types") && o.getAsJsonArray("types").size() > 0) || (o.has("elements") && o.getAsJsonArray("elements").size() > 0);
|
||||||
|
if (!ok) {
|
||||||
|
List<String> types = new ArrayList<>();
|
||||||
|
List<String> elements = new ArrayList<>();
|
||||||
|
getElementInfo(version, n, types, elements);
|
||||||
|
if (elements.size() > 0) {
|
||||||
|
JsonArray arr = o.getAsJsonArray("elements");
|
||||||
|
if (arr == null) {
|
||||||
|
arr = new JsonArray();
|
||||||
|
o.add("elements", arr);
|
||||||
|
}
|
||||||
|
for (String s : types) {
|
||||||
|
arr.add(s);
|
||||||
|
}
|
||||||
|
} else if (types.size() > 0) {
|
||||||
|
JsonArray arr = o.getAsJsonArray("types");
|
||||||
|
if (arr == null) {
|
||||||
|
arr = new JsonArray();
|
||||||
|
o.add("types", arr);
|
||||||
|
}
|
||||||
|
for (String s : types) {
|
||||||
|
arr.add(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("done");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean getElementInfo(String version, String n, List<String> types, List<String> elements) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||||
|
if ("contained".equals(n.substring(n.indexOf(".")+1))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
switch (version) {
|
||||||
|
case "4.6": return getElementInfoR5(n, types, elements);
|
||||||
|
case "4.0": return getElementInfoR4(n, types, elements);
|
||||||
|
case "3.0": return getElementInfoR3(n, types, elements);
|
||||||
|
case "1.4": return getElementInfoR2B(n, types, elements);
|
||||||
|
case "1.0": return getElementInfoR2(n, types, elements);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Object tail(String value) {
|
||||||
|
return value.contains("/") ? value.substring(value.lastIndexOf("/")+1) : value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean getElementInfoR5(String n, List<String> types, List<String> elements) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||||
|
String tn = n.substring(0, n.indexOf("."));
|
||||||
|
org.hl7.fhir.r5.model.StructureDefinition sd = null;
|
||||||
|
if (map5.containsKey(tn)) {
|
||||||
|
sd = map5.get(tn);
|
||||||
|
} else {
|
||||||
|
sd = (org.hl7.fhir.r5.model.StructureDefinition) new org.hl7.fhir.r5.formats.JsonParser().parse(new FileInputStream(Utilities.path(R5_FOLDER, "StructureDefinition-"+tn+".json")));
|
||||||
|
map5.put(tn, sd);
|
||||||
|
}
|
||||||
|
for (org.hl7.fhir.r5.model.ElementDefinition ed : sd.getSnapshot().getElement()) {
|
||||||
|
if (ed.getPath().equals(n)) {
|
||||||
|
List<org.hl7.fhir.r5.model.ElementDefinition> children = listChildrenR5(sd.getSnapshot().getElement(), ed);
|
||||||
|
if (children.size() > 0) {
|
||||||
|
for (org.hl7.fhir.r5.model.ElementDefinition c : children) {
|
||||||
|
String en = c.getPath().substring(ed.getPath().length()+1);
|
||||||
|
elements.add(en);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent t : ed.getType()) {
|
||||||
|
if (t.hasTargetProfile()) {
|
||||||
|
StringBuilder b = new StringBuilder();
|
||||||
|
b.append(t.getWorkingCode());
|
||||||
|
b.append("(");
|
||||||
|
boolean first = true;
|
||||||
|
for (org.hl7.fhir.r5.model.CanonicalType u : t.getTargetProfile()) {
|
||||||
|
if (first) first = false; else b.append("|");
|
||||||
|
b.append(tail(u.getValue()));
|
||||||
|
}
|
||||||
|
b.append(")");
|
||||||
|
types.add(b.toString());
|
||||||
|
} else {
|
||||||
|
types.add(t.getWorkingCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static List<org.hl7.fhir.r5.model.ElementDefinition> listChildrenR5(List<org.hl7.fhir.r5.model.ElementDefinition> list, org.hl7.fhir.r5.model.ElementDefinition ed) {
|
||||||
|
List<org.hl7.fhir.r5.model.ElementDefinition> res = new ArrayList<>();
|
||||||
|
for (org.hl7.fhir.r5.model.ElementDefinition t : list) {
|
||||||
|
String p = t.getPath();
|
||||||
|
if (p.startsWith(ed.getPath()+".")) {
|
||||||
|
p = p.substring(ed.getPath().length()+1);
|
||||||
|
if (!p.contains(".")) {
|
||||||
|
res.add(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean getElementInfoR4(String n, List<String> types, List<String> elements) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||||
|
String tn = n.substring(0, n.indexOf("."));
|
||||||
|
org.hl7.fhir.r4.model.StructureDefinition sd = null;
|
||||||
|
if (map4.containsKey(tn)) {
|
||||||
|
sd = map4.get(tn);
|
||||||
|
} else {
|
||||||
|
sd = (org.hl7.fhir.r4.model.StructureDefinition) new org.hl7.fhir.r4.formats.JsonParser().parse(new FileInputStream(Utilities.path(R4_FOLDER, "StructureDefinition-"+tn+".json")));
|
||||||
|
map4.put(tn, sd);
|
||||||
|
}
|
||||||
|
for (org.hl7.fhir.r4.model.ElementDefinition ed : sd.getSnapshot().getElement()) {
|
||||||
|
if (ed.getPath().equals(n)) {
|
||||||
|
List<org.hl7.fhir.r4.model.ElementDefinition> children = listChildrenR4(sd.getSnapshot().getElement(), ed);
|
||||||
|
if (children.size() > 0) {
|
||||||
|
for (org.hl7.fhir.r4.model.ElementDefinition c : children) {
|
||||||
|
String en = c.getPath().substring(ed.getPath().length()+1);
|
||||||
|
elements.add(en);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent t : ed.getType()) {
|
||||||
|
if (t.hasTargetProfile()) {
|
||||||
|
StringBuilder b = new StringBuilder();
|
||||||
|
b.append(t.getWorkingCode());
|
||||||
|
b.append("(");
|
||||||
|
boolean first = true;
|
||||||
|
for (org.hl7.fhir.r4.model.CanonicalType u : t.getTargetProfile()) {
|
||||||
|
if (first) first = false; else b.append("|");
|
||||||
|
b.append(tail(u.getValue()));
|
||||||
|
}
|
||||||
|
b.append(")");
|
||||||
|
types.add(b.toString());
|
||||||
|
} else {
|
||||||
|
types.add(t.getWorkingCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static List<org.hl7.fhir.r4.model.ElementDefinition> listChildrenR4(List<org.hl7.fhir.r4.model.ElementDefinition> list, org.hl7.fhir.r4.model.ElementDefinition ed) {
|
||||||
|
List<org.hl7.fhir.r4.model.ElementDefinition> res = new ArrayList<>();
|
||||||
|
for (org.hl7.fhir.r4.model.ElementDefinition t : list) {
|
||||||
|
String p = t.getPath();
|
||||||
|
if (p.startsWith(ed.getPath()+".")) {
|
||||||
|
p = p.substring(ed.getPath().length()+1);
|
||||||
|
if (!p.contains(".")) {
|
||||||
|
res.add(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static boolean getElementInfoR3(String n, List<String> types, List<String> elements) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||||
|
String tn = n.substring(0, n.indexOf("."));
|
||||||
|
org.hl7.fhir.dstu3.model.StructureDefinition sd = null;
|
||||||
|
if (map3.containsKey(tn)) {
|
||||||
|
sd = map3.get(tn);
|
||||||
|
} else {
|
||||||
|
sd = (org.hl7.fhir.dstu3.model.StructureDefinition) new org.hl7.fhir.dstu3.formats.JsonParser().parse(new FileInputStream(Utilities.path(R3_FOLDER, "StructureDefinition-"+tn+".json")));
|
||||||
|
map3.put(tn, sd);
|
||||||
|
}
|
||||||
|
for (org.hl7.fhir.dstu3.model.ElementDefinition ed : sd.getSnapshot().getElement()) {
|
||||||
|
if (ed.getPath().equals(n)) {
|
||||||
|
List<org.hl7.fhir.dstu3.model.ElementDefinition> children = listChildrenR3(sd.getSnapshot().getElement(), ed);
|
||||||
|
if (children.size() > 0) {
|
||||||
|
for (org.hl7.fhir.dstu3.model.ElementDefinition c : children) {
|
||||||
|
String en = c.getPath().substring(ed.getPath().length()+1);
|
||||||
|
elements.add(en);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (org.hl7.fhir.dstu3.model.ElementDefinition.TypeRefComponent t : ed.getType()) {
|
||||||
|
if (t.hasTargetProfile()) {
|
||||||
|
StringBuilder b = new StringBuilder();
|
||||||
|
b.append(t.getCode());
|
||||||
|
b.append("(");
|
||||||
|
b.append(tail(t.getTargetProfile()));
|
||||||
|
b.append(")");
|
||||||
|
types.add(b.toString());
|
||||||
|
} else {
|
||||||
|
types.add(t.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static List<org.hl7.fhir.dstu3.model.ElementDefinition> listChildrenR3(List<org.hl7.fhir.dstu3.model.ElementDefinition> list, org.hl7.fhir.dstu3.model.ElementDefinition ed) {
|
||||||
|
List<org.hl7.fhir.dstu3.model.ElementDefinition> res = new ArrayList<>();
|
||||||
|
for (org.hl7.fhir.dstu3.model.ElementDefinition t : list) {
|
||||||
|
String p = t.getPath();
|
||||||
|
if (p.startsWith(ed.getPath()+".")) {
|
||||||
|
p = p.substring(ed.getPath().length()+1);
|
||||||
|
if (!p.contains(".")) {
|
||||||
|
res.add(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static boolean getElementInfoR2(String n, List<String> types, List<String> elements) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||||
|
String tn = n.substring(0, n.indexOf("."));
|
||||||
|
org.hl7.fhir.dstu2.model.StructureDefinition sd = null;
|
||||||
|
if (map2.containsKey(tn)) {
|
||||||
|
sd = map2.get(tn);
|
||||||
|
} else {
|
||||||
|
sd = (org.hl7.fhir.dstu2.model.StructureDefinition) new org.hl7.fhir.dstu2.formats.JsonParser().parse(new FileInputStream(Utilities.path(R2_FOLDER, "StructureDefinition-"+tn+".json")));
|
||||||
|
map2.put(tn, sd);
|
||||||
|
}
|
||||||
|
for (org.hl7.fhir.dstu2.model.ElementDefinition ed : sd.getSnapshot().getElement()) {
|
||||||
|
if (ed.getPath().equals(n)) {
|
||||||
|
List<org.hl7.fhir.dstu2.model.ElementDefinition> children = listChildrenR2(sd.getSnapshot().getElement(), ed);
|
||||||
|
if (children.size() > 0) {
|
||||||
|
for (org.hl7.fhir.dstu2.model.ElementDefinition c : children) {
|
||||||
|
String en = c.getPath().substring(ed.getPath().length()+1);
|
||||||
|
elements.add(en);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent t : ed.getType()) {
|
||||||
|
if (t.hasProfile()) {
|
||||||
|
StringBuilder b = new StringBuilder();
|
||||||
|
b.append(t.getCode());
|
||||||
|
b.append("(");
|
||||||
|
boolean first = true;
|
||||||
|
for (org.hl7.fhir.dstu2.model.UriType u : t.getProfile()) {
|
||||||
|
if (first) first = false; else b.append("|");
|
||||||
|
b.append(tail(u.getValue()));
|
||||||
|
}
|
||||||
|
b.append(")");
|
||||||
|
types.add(b.toString());
|
||||||
|
} else {
|
||||||
|
types.add(t.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static List<org.hl7.fhir.dstu2.model.ElementDefinition> listChildrenR2(List<org.hl7.fhir.dstu2.model.ElementDefinition> list, org.hl7.fhir.dstu2.model.ElementDefinition ed) {
|
||||||
|
List<org.hl7.fhir.dstu2.model.ElementDefinition> res = new ArrayList<>();
|
||||||
|
for (org.hl7.fhir.dstu2.model.ElementDefinition t : list) {
|
||||||
|
String p = t.getPath();
|
||||||
|
if (p.startsWith(ed.getPath()+".")) {
|
||||||
|
p = p.substring(ed.getPath().length()+1);
|
||||||
|
if (!p.contains(".")) {
|
||||||
|
res.add(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static boolean getElementInfoR2B(String n, List<String> types, List<String> elements) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||||
|
String tn = n.substring(0, n.indexOf("."));
|
||||||
|
org.hl7.fhir.dstu2016may.model.StructureDefinition sd = null;
|
||||||
|
if (map2b.containsKey(tn)) {
|
||||||
|
sd = map2b.get(tn);
|
||||||
|
} else {
|
||||||
|
sd = (org.hl7.fhir.dstu2016may.model.StructureDefinition) new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(new FileInputStream(Utilities.path(R2B_FOLDER, "StructureDefinition-"+tn+".json")));
|
||||||
|
map2b.put(tn, sd);
|
||||||
|
}
|
||||||
|
for (org.hl7.fhir.dstu2016may.model.ElementDefinition ed : sd.getSnapshot().getElement()) {
|
||||||
|
if (ed.getPath().equals(n)) {
|
||||||
|
List<org.hl7.fhir.dstu2016may.model.ElementDefinition> children = listChildrenR2B(sd.getSnapshot().getElement(), ed);
|
||||||
|
if (children.size() > 0) {
|
||||||
|
for (org.hl7.fhir.dstu2016may.model.ElementDefinition c : children) {
|
||||||
|
String en = c.getPath().substring(ed.getPath().length()+1);
|
||||||
|
elements.add(en);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (org.hl7.fhir.dstu2016may.model.ElementDefinition.TypeRefComponent t : ed.getType()) {
|
||||||
|
if (t.hasProfile()) {
|
||||||
|
StringBuilder b = new StringBuilder();
|
||||||
|
b.append(t.getCode());
|
||||||
|
b.append("(");
|
||||||
|
boolean first = true;
|
||||||
|
for (org.hl7.fhir.dstu2016may.model.UriType u : t.getProfile()) {
|
||||||
|
if (first) first = false; else b.append("|");
|
||||||
|
b.append(tail(u.getValue()));
|
||||||
|
}
|
||||||
|
b.append(")");
|
||||||
|
types.add(b.toString());
|
||||||
|
} else {
|
||||||
|
types.add(t.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static List<org.hl7.fhir.dstu2016may.model.ElementDefinition> listChildrenR2B(List<org.hl7.fhir.dstu2016may.model.ElementDefinition> list, org.hl7.fhir.dstu2016may.model.ElementDefinition ed) {
|
||||||
|
List<org.hl7.fhir.dstu2016may.model.ElementDefinition> res = new ArrayList<>();
|
||||||
|
for (org.hl7.fhir.dstu2016may.model.ElementDefinition t : list) {
|
||||||
|
String p = t.getPath();
|
||||||
|
if (p.startsWith(ed.getPath()+".")) {
|
||||||
|
p = p.substring(ed.getPath().length()+1);
|
||||||
|
if (!p.contains(".")) {
|
||||||
|
res.add(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>5.5.12-SNAPSHOT</version>
|
<version>5.6.16-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ import org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent;
|
||||||
import org.hl7.fhir.dstu2.model.ValueSet.ConceptSetComponent;
|
import org.hl7.fhir.dstu2.model.ValueSet.ConceptSetComponent;
|
||||||
import org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionComponent;
|
import org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionComponent;
|
||||||
import org.hl7.fhir.dstu2.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
|
import org.hl7.fhir.dstu2.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
|
||||||
|
import org.hl7.fhir.dstu2.utils.validation.IResourceValidator;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ import org.hl7.fhir.dstu2.model.ValueSet;
|
||||||
import org.hl7.fhir.dstu2.terminologies.ValueSetExpansionCache;
|
import org.hl7.fhir.dstu2.terminologies.ValueSetExpansionCache;
|
||||||
import org.hl7.fhir.dstu2.utils.ProfileUtilities.ProfileKnowledgeProvider;
|
import org.hl7.fhir.dstu2.utils.ProfileUtilities.ProfileKnowledgeProvider;
|
||||||
import org.hl7.fhir.dstu2.utils.client.FHIRToolingClient;
|
import org.hl7.fhir.dstu2.utils.client.FHIRToolingClient;
|
||||||
|
import org.hl7.fhir.dstu2.utils.validation.IResourceValidator;
|
||||||
import org.hl7.fhir.exceptions.DefinitionException;
|
import org.hl7.fhir.exceptions.DefinitionException;
|
||||||
import org.hl7.fhir.exceptions.FHIRException;
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
import org.hl7.fhir.utilities.CSFileInputStream;
|
import org.hl7.fhir.utilities.CSFileInputStream;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.hl7.fhir.dstu2.utils;
|
package org.hl7.fhir.dstu2.utils.validation;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2011+, HL7, Inc.
|
Copyright (c) 2011+, HL7, Inc.
|
||||||
|
@ -34,6 +34,9 @@ package org.hl7.fhir.dstu2.utils;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hl7.fhir.dstu2.model.StructureDefinition;
|
import org.hl7.fhir.dstu2.model.StructureDefinition;
|
||||||
|
import org.hl7.fhir.dstu2.utils.validation.constants.BestPracticeWarningLevel;
|
||||||
|
import org.hl7.fhir.dstu2.utils.validation.constants.CheckDisplayOption;
|
||||||
|
import org.hl7.fhir.dstu2.utils.validation.constants.IdStatus;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
@ -42,29 +45,6 @@ import com.google.gson.JsonObject;
|
||||||
|
|
||||||
public interface IResourceValidator {
|
public interface IResourceValidator {
|
||||||
|
|
||||||
/**
|
|
||||||
* whether the validator should enforce best practice guidelines
|
|
||||||
* as defined by various HL7 committees
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author Grahame Grieve
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public enum BestPracticeWarningLevel {
|
|
||||||
Ignore,
|
|
||||||
Hint,
|
|
||||||
Warning,
|
|
||||||
Error
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum CheckDisplayOption {
|
|
||||||
Ignore,
|
|
||||||
Check,
|
|
||||||
CheckCaseAndSpace,
|
|
||||||
CheckCase,
|
|
||||||
CheckSpace
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* how much to check displays for coded elements
|
* how much to check displays for coded elements
|
||||||
* @return
|
* @return
|
||||||
|
@ -77,10 +57,6 @@ public interface IResourceValidator {
|
||||||
*/
|
*/
|
||||||
void setCheckDisplay(CheckDisplayOption checkDisplay);
|
void setCheckDisplay(CheckDisplayOption checkDisplay);
|
||||||
|
|
||||||
enum IdStatus {
|
|
||||||
OPTIONAL, REQUIRED, PROHIBITED
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* whether the resource must have an id or not (depends on context)
|
* whether the resource must have an id or not (depends on context)
|
||||||
*
|
*
|
||||||
|
@ -93,39 +69,26 @@ public interface IResourceValidator {
|
||||||
BestPracticeWarningLevel getBasePracticeWarningLevel();
|
BestPracticeWarningLevel getBasePracticeWarningLevel();
|
||||||
void setBestPracticeWarningLevel(BestPracticeWarningLevel value);
|
void setBestPracticeWarningLevel(BestPracticeWarningLevel value);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a DOM element, return a list of errors in the resource
|
* Given a DOM element, return a list of errors in the resource
|
||||||
*
|
|
||||||
* @param errors
|
|
||||||
* @param elem
|
|
||||||
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
||||||
*/
|
*/
|
||||||
void validate(List<ValidationMessage> errors, Element element) throws Exception;
|
void validate(List<ValidationMessage> errors, Element element) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a JSON Object, return a list of errors in the resource
|
* Given a JSON Object, return a list of errors in the resource
|
||||||
*
|
|
||||||
* @param errors
|
|
||||||
* @param elem
|
|
||||||
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
||||||
*/
|
*/
|
||||||
void validate(List<ValidationMessage> errors, JsonObject object) throws Exception;
|
void validate(List<ValidationMessage> errors, JsonObject object) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a DOM element, return a list of errors in the resource
|
* Given a DOM element, return a list of errors in the resource
|
||||||
*
|
|
||||||
* @param errors
|
|
||||||
* @param elem
|
|
||||||
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
||||||
*/
|
*/
|
||||||
List<ValidationMessage> validate(Element element) throws Exception;
|
List<ValidationMessage> validate(Element element) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a DOM element, return a list of errors in the resource
|
* Given a DOM element, return a list of errors in the resource
|
||||||
*
|
|
||||||
* @param errors
|
|
||||||
* @param elem
|
|
||||||
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
||||||
*/
|
*/
|
||||||
List<ValidationMessage> validate(JsonObject object) throws Exception;
|
List<ValidationMessage> validate(JsonObject object) throws Exception;
|
||||||
|
@ -133,10 +96,6 @@ public interface IResourceValidator {
|
||||||
/**
|
/**
|
||||||
* Given a DOM element, return a list of errors in the resource
|
* Given a DOM element, return a list of errors in the resource
|
||||||
* with regard to the specified profile (by logical identifier)
|
* with regard to the specified profile (by logical identifier)
|
||||||
*
|
|
||||||
* @param errors
|
|
||||||
* @param element
|
|
||||||
* @param profile
|
|
||||||
* @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
|
* @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
|
||||||
*/
|
*/
|
||||||
void validate(List<ValidationMessage> errors, Element element, String profile) throws Exception;
|
void validate(List<ValidationMessage> errors, Element element, String profile) throws Exception;
|
||||||
|
@ -144,10 +103,6 @@ public interface IResourceValidator {
|
||||||
/**
|
/**
|
||||||
* Given a DOM element, return a list of errors in the resource
|
* Given a DOM element, return a list of errors in the resource
|
||||||
* with regard to the specified profile (by logical identifier)
|
* with regard to the specified profile (by logical identifier)
|
||||||
*
|
|
||||||
* @param errors
|
|
||||||
* @param element
|
|
||||||
* @param profile
|
|
||||||
* @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
|
* @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
|
||||||
*/
|
*/
|
||||||
List<ValidationMessage> validate(Element element, String profile) throws Exception;
|
List<ValidationMessage> validate(Element element, String profile) throws Exception;
|
||||||
|
@ -155,10 +110,6 @@ public interface IResourceValidator {
|
||||||
/**
|
/**
|
||||||
* Given a DOM element, return a list of errors in the resource
|
* Given a DOM element, return a list of errors in the resource
|
||||||
* with regard to the specified profile (by logical identifier)
|
* with regard to the specified profile (by logical identifier)
|
||||||
*
|
|
||||||
* @param errors
|
|
||||||
* @param element
|
|
||||||
* @param profile
|
|
||||||
* @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
|
* @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
|
||||||
*/
|
*/
|
||||||
List<ValidationMessage> validate(JsonObject object, StructureDefinition profile) throws Exception;
|
List<ValidationMessage> validate(JsonObject object, StructureDefinition profile) throws Exception;
|
||||||
|
@ -166,10 +117,6 @@ public interface IResourceValidator {
|
||||||
/**
|
/**
|
||||||
* Given a DOM element, return a list of errors in the resource
|
* Given a DOM element, return a list of errors in the resource
|
||||||
* with regard to the specified profile (by logical identifier)
|
* with regard to the specified profile (by logical identifier)
|
||||||
*
|
|
||||||
* @param errors
|
|
||||||
* @param element
|
|
||||||
* @param profile
|
|
||||||
* @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
|
* @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
|
||||||
*/
|
*/
|
||||||
List<ValidationMessage> validate(JsonObject object, String profile) throws Exception;
|
List<ValidationMessage> validate(JsonObject object, String profile) throws Exception;
|
||||||
|
@ -177,10 +124,6 @@ public interface IResourceValidator {
|
||||||
/**
|
/**
|
||||||
* Given a DOM element, return a list of errors in the resource
|
* Given a DOM element, return a list of errors in the resource
|
||||||
* with regard to the specified profile
|
* with regard to the specified profile
|
||||||
*
|
|
||||||
* @param errors
|
|
||||||
* @param element
|
|
||||||
* @param profile
|
|
||||||
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
||||||
*/
|
*/
|
||||||
void validate(List<ValidationMessage> errors, Element element, StructureDefinition profile) throws Exception;
|
void validate(List<ValidationMessage> errors, Element element, StructureDefinition profile) throws Exception;
|
||||||
|
@ -188,10 +131,6 @@ public interface IResourceValidator {
|
||||||
/**
|
/**
|
||||||
* Given a DOM element, return a list of errors in the resource
|
* Given a DOM element, return a list of errors in the resource
|
||||||
* with regard to the specified profile
|
* with regard to the specified profile
|
||||||
*
|
|
||||||
* @param errors
|
|
||||||
* @param element
|
|
||||||
* @param profile
|
|
||||||
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
||||||
*/
|
*/
|
||||||
void validate(List<ValidationMessage> errors, JsonObject object, StructureDefinition profile) throws Exception;
|
void validate(List<ValidationMessage> errors, JsonObject object, StructureDefinition profile) throws Exception;
|
||||||
|
@ -199,10 +138,6 @@ public interface IResourceValidator {
|
||||||
/**
|
/**
|
||||||
* Given a DOM element, return a list of errors in the resource
|
* Given a DOM element, return a list of errors in the resource
|
||||||
* with regard to the specified profile
|
* with regard to the specified profile
|
||||||
*
|
|
||||||
* @param errors
|
|
||||||
* @param element
|
|
||||||
* @param profile
|
|
||||||
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
||||||
*/
|
*/
|
||||||
void validate(List<ValidationMessage> errors, JsonObject object, String profile) throws Exception;
|
void validate(List<ValidationMessage> errors, JsonObject object, String profile) throws Exception;
|
||||||
|
@ -210,10 +145,6 @@ public interface IResourceValidator {
|
||||||
/**
|
/**
|
||||||
* Given a DOM element, return a list of errors in the resource
|
* Given a DOM element, return a list of errors in the resource
|
||||||
* with regard to the specified profile
|
* with regard to the specified profile
|
||||||
*
|
|
||||||
* @param errors
|
|
||||||
* @param element
|
|
||||||
* @param profile
|
|
||||||
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
||||||
*/
|
*/
|
||||||
List<ValidationMessage> validate(Element element, StructureDefinition profile) throws Exception;
|
List<ValidationMessage> validate(Element element, StructureDefinition profile) throws Exception;
|
||||||
|
@ -221,18 +152,12 @@ public interface IResourceValidator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a DOM document, return a list of errors in the resource
|
* Given a DOM document, return a list of errors in the resource
|
||||||
*
|
|
||||||
* @param errors
|
|
||||||
* @param elem
|
|
||||||
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
||||||
*/
|
*/
|
||||||
void validate(List<ValidationMessage> errors, Document document) throws Exception;
|
void validate(List<ValidationMessage> errors, Document document) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a DOM document, return a list of errors in the resource
|
* Given a DOM document, return a list of errors in the resource
|
||||||
*
|
|
||||||
* @param errors
|
|
||||||
* @param elem
|
|
||||||
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
||||||
*/
|
*/
|
||||||
List<ValidationMessage> validate(Document document) throws Exception;
|
List<ValidationMessage> validate(Document document) throws Exception;
|
||||||
|
@ -240,10 +165,6 @@ public interface IResourceValidator {
|
||||||
/**
|
/**
|
||||||
* Given a DOM document, return a list of errors in the resource
|
* Given a DOM document, return a list of errors in the resource
|
||||||
* with regard to the specified profile (by logical identifier)
|
* with regard to the specified profile (by logical identifier)
|
||||||
*
|
|
||||||
* @param errors
|
|
||||||
* @param element
|
|
||||||
* @param profile
|
|
||||||
* @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
|
* @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
|
||||||
*/
|
*/
|
||||||
void validate(List<ValidationMessage> errors, Document document, String profile) throws Exception;
|
void validate(List<ValidationMessage> errors, Document document, String profile) throws Exception;
|
||||||
|
@ -251,10 +172,6 @@ public interface IResourceValidator {
|
||||||
/**
|
/**
|
||||||
* Given a DOM document, return a list of errors in the resource
|
* Given a DOM document, return a list of errors in the resource
|
||||||
* with regard to the specified profile (by logical identifier)
|
* with regard to the specified profile (by logical identifier)
|
||||||
*
|
|
||||||
* @param errors
|
|
||||||
* @param element
|
|
||||||
* @param profile
|
|
||||||
* @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
|
* @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
|
||||||
*/
|
*/
|
||||||
List<ValidationMessage> validate(Document document, String profile) throws Exception;
|
List<ValidationMessage> validate(Document document, String profile) throws Exception;
|
||||||
|
@ -262,10 +179,6 @@ public interface IResourceValidator {
|
||||||
/**
|
/**
|
||||||
* Given a DOM document, return a list of errors in the resource
|
* Given a DOM document, return a list of errors in the resource
|
||||||
* with regard to the specified profile
|
* with regard to the specified profile
|
||||||
*
|
|
||||||
* @param errors
|
|
||||||
* @param element
|
|
||||||
* @param profile
|
|
||||||
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
||||||
*/
|
*/
|
||||||
void validate(List<ValidationMessage> errors, Document document, StructureDefinition profile) throws Exception;
|
void validate(List<ValidationMessage> errors, Document document, StructureDefinition profile) throws Exception;
|
||||||
|
@ -273,10 +186,6 @@ public interface IResourceValidator {
|
||||||
/**
|
/**
|
||||||
* Given a DOM document, return a list of errors in the resource
|
* Given a DOM document, return a list of errors in the resource
|
||||||
* with regard to the specified profile
|
* with regard to the specified profile
|
||||||
*
|
|
||||||
* @param errors
|
|
||||||
* @param element
|
|
||||||
* @param profile
|
|
||||||
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
* @- if the underlying infrastructure fails (not if the resource is invalid)
|
||||||
*/
|
*/
|
||||||
List<ValidationMessage> validate(Document document, StructureDefinition profile) throws Exception;
|
List<ValidationMessage> validate(Document document, StructureDefinition profile) throws Exception;
|
|
@ -0,0 +1,12 @@
|
||||||
|
package org.hl7.fhir.dstu2.utils.validation.constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* whether the validator should enforce best practice guidelines
|
||||||
|
* as defined by various HL7 committees
|
||||||
|
*/
|
||||||
|
public enum BestPracticeWarningLevel {
|
||||||
|
Ignore,
|
||||||
|
Hint,
|
||||||
|
Warning,
|
||||||
|
Error
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package org.hl7.fhir.dstu2.utils.validation.constants;
|
||||||
|
|
||||||
|
public enum CheckDisplayOption {
|
||||||
|
Ignore,
|
||||||
|
Check,
|
||||||
|
CheckCaseAndSpace,
|
||||||
|
CheckCase,
|
||||||
|
CheckSpace
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package org.hl7.fhir.dstu2.utils.validation.constants;
|
||||||
|
|
||||||
|
public enum IdStatus {
|
||||||
|
OPTIONAL,
|
||||||
|
REQUIRED,
|
||||||
|
PROHIBITED
|
||||||
|
}
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>5.5.12-SNAPSHOT</version>
|
<version>5.6.16-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>5.5.12-SNAPSHOT</version>
|
<version>5.6.16-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ import org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionComponent;
|
||||||
import org.hl7.fhir.dstu3.terminologies.ValueSetExpander.TerminologyServiceErrorClass;
|
import org.hl7.fhir.dstu3.terminologies.ValueSetExpander.TerminologyServiceErrorClass;
|
||||||
import org.hl7.fhir.dstu3.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
|
import org.hl7.fhir.dstu3.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
|
||||||
import org.hl7.fhir.dstu3.utils.INarrativeGenerator;
|
import org.hl7.fhir.dstu3.utils.INarrativeGenerator;
|
||||||
import org.hl7.fhir.dstu3.utils.IResourceValidator;
|
import org.hl7.fhir.dstu3.utils.validation.IResourceValidator;
|
||||||
import org.hl7.fhir.exceptions.FHIRException;
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
import org.hl7.fhir.exceptions.TerminologyServiceException;
|
import org.hl7.fhir.exceptions.TerminologyServiceException;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||||
|
|
|
@ -80,7 +80,7 @@ import org.hl7.fhir.dstu3.model.StructureMap.StructureMapStructureComponent;
|
||||||
import org.hl7.fhir.dstu3.model.ValueSet;
|
import org.hl7.fhir.dstu3.model.ValueSet;
|
||||||
import org.hl7.fhir.dstu3.terminologies.ValueSetExpansionCache;
|
import org.hl7.fhir.dstu3.terminologies.ValueSetExpansionCache;
|
||||||
import org.hl7.fhir.dstu3.utils.INarrativeGenerator;
|
import org.hl7.fhir.dstu3.utils.INarrativeGenerator;
|
||||||
import org.hl7.fhir.dstu3.utils.IResourceValidator;
|
import org.hl7.fhir.dstu3.utils.validation.IResourceValidator;
|
||||||
import org.hl7.fhir.dstu3.utils.NarrativeGenerator;
|
import org.hl7.fhir.dstu3.utils.NarrativeGenerator;
|
||||||
import org.hl7.fhir.dstu3.utils.client.FHIRToolingClient;
|
import org.hl7.fhir.dstu3.utils.client.FHIRToolingClient;
|
||||||
import org.hl7.fhir.exceptions.DefinitionException;
|
import org.hl7.fhir.exceptions.DefinitionException;
|
||||||
|
|
|
@ -206,14 +206,19 @@ public class FhirRequestBuilder {
|
||||||
|
|
||||||
public <T extends Resource> ResourceRequest<T> execute() throws IOException {
|
public <T extends Resource> ResourceRequest<T> execute() throws IOException {
|
||||||
formatHeaders(httpRequest, resourceFormat, headers);
|
formatHeaders(httpRequest, resourceFormat, headers);
|
||||||
Response response = getHttpClient().newCall(httpRequest.build()).execute();
|
final Request request = httpRequest.build();
|
||||||
|
log(request.method(), request.url().toString(), request.headers(), request.body() != null ? request.body().toString().getBytes() : null);
|
||||||
|
Response response = getHttpClient().newCall(request).execute();
|
||||||
T resource = unmarshalReference(response, resourceFormat);
|
T resource = unmarshalReference(response, resourceFormat);
|
||||||
return new ResourceRequest<T>(resource, response.code(), getLocationHeader(response.headers()));
|
return new ResourceRequest<T>(resource, response.code(), getLocationHeader(response.headers()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bundle executeAsBatch() throws IOException {
|
public Bundle executeAsBatch() throws IOException {
|
||||||
formatHeaders(httpRequest, resourceFormat, null);
|
formatHeaders(httpRequest, resourceFormat, null);
|
||||||
Response response = getHttpClient().newCall(httpRequest.build()).execute();
|
final Request request = httpRequest.build();
|
||||||
|
log(request.method(), request.url().toString(), request.headers(), request.body() != null ? request.body().toString().getBytes() : null);
|
||||||
|
|
||||||
|
Response response = getHttpClient().newCall(request).execute();
|
||||||
return unmarshalFeed(response, resourceFormat);
|
return unmarshalFeed(response, resourceFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,6 +307,26 @@ public class FhirRequestBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs the given {@link Request}, using the current {@link ToolingClientLogger}. If the current
|
||||||
|
* {@link FhirRequestBuilder#logger} is null, no action is taken.
|
||||||
|
*
|
||||||
|
* @param method HTTP request method
|
||||||
|
* @param url request URL
|
||||||
|
* @param requestHeaders {@link Headers} for request
|
||||||
|
* @param requestBody Byte array request
|
||||||
|
*/
|
||||||
|
protected void log(String method, String url, Headers requestHeaders, byte[] requestBody) {
|
||||||
|
if (logger != null) {
|
||||||
|
List<String> headerList = new ArrayList<>(Collections.emptyList());
|
||||||
|
Map<String, List<String>> headerMap = requestHeaders.toMultimap();
|
||||||
|
headerMap.keySet().forEach(key -> headerMap.get(key).forEach(value -> headerList.add(key + ":" + value)));
|
||||||
|
|
||||||
|
logger.logRequest(method, url, headerList, requestBody);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs the given {@link Response}, using the current {@link ToolingClientLogger}. If the current
|
* Logs the given {@link Response}, using the current {@link ToolingClientLogger}. If the current
|
||||||
* {@link FhirRequestBuilder#logger} is null, no action is taken.
|
* {@link FhirRequestBuilder#logger} is null, no action is taken.
|
||||||
|
|
|
@ -34,8 +34,8 @@ public class RetryInterceptor implements Interceptor {
|
||||||
try {
|
try {
|
||||||
// If we are retrying a failed request that failed due to a bad response from the server, we must close it first
|
// If we are retrying a failed request that failed due to a bad response from the server, we must close it first
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
System.out.println("Previous " + chain.request().method() + " attempt returned HTTP<" + (response.code())
|
// System.out.println("Previous " + chain.request().method() + " attempt returned HTTP<" + (response.code())
|
||||||
+ "> from url -> " + chain.request().url() + ".");
|
// + "> from url -> " + chain.request().url() + ".");
|
||||||
response.close();
|
response.close();
|
||||||
}
|
}
|
||||||
// System.out.println(chain.request().method() + " attempt <" + (retryCounter + 1) + "> to url -> " + chain.request().url());
|
// System.out.println(chain.request().method() + " attempt <" + (retryCounter + 1) + "> to url -> " + chain.request().url());
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.hl7.fhir.dstu3.utils;
|
package org.hl7.fhir.dstu3.utils.validation;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2011+, HL7, Inc.
|
Copyright (c) 2011+, HL7, Inc.
|
||||||
|
@ -30,21 +30,20 @@ package org.hl7.fhir.dstu3.utils;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import org.hl7.fhir.dstu3.elementmodel.Manager.FhirFormat;
|
||||||
|
import org.hl7.fhir.dstu3.model.StructureDefinition;
|
||||||
|
import org.hl7.fhir.dstu3.utils.ValidationProfileSet;
|
||||||
|
import org.hl7.fhir.dstu3.utils.validation.constants.BestPracticeWarningLevel;
|
||||||
|
import org.hl7.fhir.dstu3.utils.validation.constants.CheckDisplayOption;
|
||||||
|
import org.hl7.fhir.dstu3.utils.validation.constants.IdStatus;
|
||||||
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
|
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hl7.fhir.dstu3.elementmodel.Element;
|
|
||||||
import org.hl7.fhir.dstu3.elementmodel.Manager.FhirFormat;
|
|
||||||
import org.hl7.fhir.dstu3.model.StructureDefinition;
|
|
||||||
import org.hl7.fhir.exceptions.DefinitionException;
|
|
||||||
import org.hl7.fhir.exceptions.FHIRException;
|
|
||||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface to the instance validator. This takes a resource, in one of many forms, and
|
* Interface to the instance validator. This takes a resource, in one of many forms, and
|
||||||
* checks whether it is valid
|
* checks whether it is valid
|
||||||
|
@ -54,49 +53,6 @@ import com.google.gson.JsonObject;
|
||||||
*/
|
*/
|
||||||
public interface IResourceValidator {
|
public interface IResourceValidator {
|
||||||
|
|
||||||
public enum ReferenceValidationPolicy {
|
|
||||||
IGNORE, CHECK_TYPE_IF_EXISTS, CHECK_EXISTS, CHECK_EXISTS_AND_TYPE, CHECK_VALID;
|
|
||||||
|
|
||||||
public boolean checkExists() {
|
|
||||||
return this == CHECK_EXISTS_AND_TYPE || this == CHECK_EXISTS || this == CHECK_VALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkType() {
|
|
||||||
return this == CHECK_TYPE_IF_EXISTS || this == CHECK_EXISTS_AND_TYPE || this == CHECK_VALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkValid() {
|
|
||||||
return this == CHECK_VALID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IValidatorResourceFetcher {
|
|
||||||
Element fetch(Object appContext, String url) throws FHIRFormatError, DefinitionException, IOException, FHIRException;
|
|
||||||
ReferenceValidationPolicy validationPolicy(Object appContext, String path, String url);
|
|
||||||
boolean resolveURL(Object appContext, String path, String url) throws IOException, FHIRException;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum BestPracticeWarningLevel {
|
|
||||||
Ignore,
|
|
||||||
Hint,
|
|
||||||
Warning,
|
|
||||||
Error
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum CheckDisplayOption {
|
|
||||||
Ignore,
|
|
||||||
Check,
|
|
||||||
CheckCaseAndSpace,
|
|
||||||
CheckCase,
|
|
||||||
CheckSpace
|
|
||||||
}
|
|
||||||
|
|
||||||
enum IdStatus {
|
|
||||||
OPTIONAL, REQUIRED, PROHIBITED
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* how much to check displays for coded elements
|
* how much to check displays for coded elements
|
||||||
* @return
|
* @return
|
||||||
|
@ -124,21 +80,24 @@ public interface IResourceValidator {
|
||||||
IValidatorResourceFetcher getFetcher();
|
IValidatorResourceFetcher getFetcher();
|
||||||
IResourceValidator setFetcher(IValidatorResourceFetcher value);
|
IResourceValidator setFetcher(IValidatorResourceFetcher value);
|
||||||
|
|
||||||
|
IValidationPolicyAdvisor getPolicyAdvisor();
|
||||||
|
IResourceValidator setPolicyAdvisor(IValidationPolicyAdvisor advisor);
|
||||||
|
|
||||||
boolean isNoBindingMsgSuppressed();
|
boolean isNoBindingMsgSuppressed();
|
||||||
IResourceValidator setNoBindingMsgSuppressed(boolean noBindingMsgSuppressed);
|
IResourceValidator setNoBindingMsgSuppressed(boolean noBindingMsgSuppressed);
|
||||||
|
|
||||||
public boolean isNoInvariantChecks();
|
boolean isNoInvariantChecks();
|
||||||
public IResourceValidator setNoInvariantChecks(boolean value) ;
|
IResourceValidator setNoInvariantChecks(boolean value) ;
|
||||||
|
|
||||||
public boolean isNoTerminologyChecks();
|
boolean isNoTerminologyChecks();
|
||||||
public IResourceValidator setNoTerminologyChecks(boolean noTerminologyChecks);
|
IResourceValidator setNoTerminologyChecks(boolean noTerminologyChecks);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether being unable to resolve a profile in found in Resource.meta.profile or ElementDefinition.type.profile or targetProfile is an error or just a warning
|
* Whether being unable to resolve a profile in found in Resource.meta.profile or ElementDefinition.type.profile or targetProfile is an error or just a warning
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isErrorForUnknownProfiles();
|
boolean isErrorForUnknownProfiles();
|
||||||
public void setErrorForUnknownProfiles(boolean errorForUnknownProfiles);
|
void setErrorForUnknownProfiles(boolean errorForUnknownProfiles);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate suite
|
* Validate suite
|
|
@ -0,0 +1,21 @@
|
||||||
|
package org.hl7.fhir.dstu3.utils.validation;
|
||||||
|
|
||||||
|
import org.hl7.fhir.dstu3.elementmodel.Element;
|
||||||
|
import org.hl7.fhir.dstu3.utils.validation.constants.ReferenceValidationPolicy;
|
||||||
|
|
||||||
|
public interface IValidationPolicyAdvisor {
|
||||||
|
|
||||||
|
ReferenceValidationPolicy policyForReference(IResourceValidator validator,
|
||||||
|
Object appContext,
|
||||||
|
String path,
|
||||||
|
String url);
|
||||||
|
|
||||||
|
ReferenceValidationPolicy policyForContained(IResourceValidator validator,
|
||||||
|
Object appContext,
|
||||||
|
String containerType,
|
||||||
|
String containerId,
|
||||||
|
Element.SpecialElement containingResourceType,
|
||||||
|
String path,
|
||||||
|
String url);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package org.hl7.fhir.dstu3.utils.validation;
|
||||||
|
|
||||||
|
import org.hl7.fhir.dstu3.elementmodel.Element;
|
||||||
|
import org.hl7.fhir.exceptions.DefinitionException;
|
||||||
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
|
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public interface IValidatorResourceFetcher {
|
||||||
|
Element fetch(Object appContext, String url) throws IOException, FHIRException;
|
||||||
|
boolean resolveURL(Object appContext, String path, String url) throws IOException, FHIRException;
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package org.hl7.fhir.dstu3.utils.validation.constants;
|
||||||
|
|
||||||
|
public enum BestPracticeWarningLevel {
|
||||||
|
Ignore,
|
||||||
|
Hint,
|
||||||
|
Warning,
|
||||||
|
Error
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package org.hl7.fhir.dstu3.utils.validation.constants;
|
||||||
|
|
||||||
|
public enum CheckDisplayOption {
|
||||||
|
Ignore,
|
||||||
|
Check,
|
||||||
|
CheckCaseAndSpace,
|
||||||
|
CheckCase,
|
||||||
|
CheckSpace
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package org.hl7.fhir.dstu3.utils.validation.constants;
|
||||||
|
|
||||||
|
public enum IdStatus {
|
||||||
|
OPTIONAL,
|
||||||
|
REQUIRED,
|
||||||
|
PROHIBITED
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package org.hl7.fhir.dstu3.utils.validation.constants;
|
||||||
|
|
||||||
|
public enum ReferenceValidationPolicy {
|
||||||
|
IGNORE,
|
||||||
|
CHECK_TYPE_IF_EXISTS,
|
||||||
|
CHECK_EXISTS,
|
||||||
|
CHECK_EXISTS_AND_TYPE,
|
||||||
|
CHECK_VALID;
|
||||||
|
|
||||||
|
public boolean checkExists() {
|
||||||
|
return this == CHECK_EXISTS_AND_TYPE || this == CHECK_EXISTS || this == CHECK_VALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkType() {
|
||||||
|
return this == CHECK_TYPE_IF_EXISTS || this == CHECK_EXISTS_AND_TYPE || this == CHECK_VALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkValid() {
|
||||||
|
return this == CHECK_VALID;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,101 @@
|
||||||
|
package org.hl7.fhir.dstu3.utils.client.network;
|
||||||
|
|
||||||
|
import okhttp3.*;
|
||||||
|
import org.hl7.fhir.dstu3.formats.IParser;
|
||||||
|
|
||||||
|
import org.hl7.fhir.utilities.ToolingClientLogger;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Nested;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.mockito.AdditionalMatchers;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
import org.mockito.ArgumentMatchers;
|
||||||
|
|
||||||
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ExtendWith(MockitoExtension.class)
|
||||||
|
public class FhirRequestBuilderTests {
|
||||||
|
|
||||||
|
private static final String DUMMY_URL = "https://some-url.com/";
|
||||||
|
|
||||||
|
Request mockRequest = new Request.Builder()
|
||||||
|
.url(DUMMY_URL)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
final String RESPONSE_BODY_STRING = "{}";
|
||||||
|
|
||||||
|
Response response = new Response.Builder()
|
||||||
|
.request(mockRequest)
|
||||||
|
.protocol(Protocol.HTTP_2)
|
||||||
|
.code(200) // status code
|
||||||
|
.message("")
|
||||||
|
.body(ResponseBody.create(RESPONSE_BODY_STRING,
|
||||||
|
MediaType.get("application/json; charset=utf-8")
|
||||||
|
))
|
||||||
|
.addHeader("Content-Type", "")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
final Request.Builder requestBuilder = new Request.Builder()
|
||||||
|
.url(DUMMY_URL);
|
||||||
|
|
||||||
|
final FhirRequestBuilder fhirRequestBuilder = Mockito.spy(new FhirRequestBuilder(requestBuilder));
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
OkHttpClient client;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
Call mockCall;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
ToolingClientLogger logger;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
public void beforeEach() {
|
||||||
|
Mockito.doReturn(client).when(fhirRequestBuilder).getHttpClient();
|
||||||
|
fhirRequestBuilder.withLogger(logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
class RequestLoggingTests {
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
public void beforeEach() throws IOException {
|
||||||
|
Mockito.doReturn(response).when(mockCall).execute();
|
||||||
|
Mockito.doReturn(mockCall).when(client).newCall(ArgumentMatchers.any());
|
||||||
|
|
||||||
|
Mockito.doReturn(null).when(fhirRequestBuilder).unmarshalReference(ArgumentMatchers.any(), ArgumentMatchers.isNull());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExecuteLogging() throws IOException {
|
||||||
|
fhirRequestBuilder.execute();
|
||||||
|
Mockito.verify(logger).logRequest(ArgumentMatchers.eq("GET"), ArgumentMatchers.eq(DUMMY_URL), ArgumentMatchers.anyList(), ArgumentMatchers.isNull());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testExecuteBatchLogging() throws IOException {
|
||||||
|
fhirRequestBuilder.executeAsBatch();
|
||||||
|
Mockito.verify(logger).logRequest(ArgumentMatchers.eq("GET"), ArgumentMatchers.eq(DUMMY_URL), ArgumentMatchers.anyList(), ArgumentMatchers.isNull());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUnmarshallReferenceLogging() {
|
||||||
|
IParser parser = Mockito.mock(IParser.class);
|
||||||
|
Mockito.doReturn(parser).when(fhirRequestBuilder).getParser(ArgumentMatchers.eq("json"));
|
||||||
|
|
||||||
|
fhirRequestBuilder.unmarshalReference(response, "json");
|
||||||
|
Mockito.verify(logger).logResponse(ArgumentMatchers.eq("200"), ArgumentMatchers.anyList(), AdditionalMatchers.aryEq(RESPONSE_BODY_STRING.getBytes()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUnmarshallFeedLogging() {
|
||||||
|
fhirRequestBuilder.unmarshalFeed(response, "application/json");
|
||||||
|
Mockito.verify(logger).logResponse(ArgumentMatchers.eq("200"), ArgumentMatchers.anyList(), AdditionalMatchers.aryEq(RESPONSE_BODY_STRING.getBytes()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>5.5.12-SNAPSHOT</version>
|
<version>5.6.16-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@ package org.hl7.fhir.r4.context;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.fhir.ucum.UcumService;
|
import org.fhir.ucum.UcumService;
|
||||||
|
@ -58,8 +57,7 @@ import org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent;
|
||||||
import org.hl7.fhir.r4.terminologies.ValueSetExpander.TerminologyServiceErrorClass;
|
import org.hl7.fhir.r4.terminologies.ValueSetExpander.TerminologyServiceErrorClass;
|
||||||
import org.hl7.fhir.r4.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
|
import org.hl7.fhir.r4.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
|
||||||
import org.hl7.fhir.r4.utils.INarrativeGenerator;
|
import org.hl7.fhir.r4.utils.INarrativeGenerator;
|
||||||
import org.hl7.fhir.r4.utils.IResourceValidator;
|
import org.hl7.fhir.r4.utils.validation.IResourceValidator;
|
||||||
import org.hl7.fhir.utilities.TerminologyServiceOptions;
|
|
||||||
import org.hl7.fhir.utilities.TranslationServices;
|
import org.hl7.fhir.utilities.TranslationServices;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationOptions;
|
import org.hl7.fhir.utilities.validation.ValidationOptions;
|
||||||
|
|
|
@ -75,7 +75,7 @@ import org.hl7.fhir.r4.model.StructureMap.StructureMapModelMode;
|
||||||
import org.hl7.fhir.r4.model.StructureMap.StructureMapStructureComponent;
|
import org.hl7.fhir.r4.model.StructureMap.StructureMapStructureComponent;
|
||||||
import org.hl7.fhir.r4.terminologies.TerminologyClient;
|
import org.hl7.fhir.r4.terminologies.TerminologyClient;
|
||||||
import org.hl7.fhir.r4.utils.INarrativeGenerator;
|
import org.hl7.fhir.r4.utils.INarrativeGenerator;
|
||||||
import org.hl7.fhir.r4.utils.IResourceValidator;
|
import org.hl7.fhir.r4.utils.validation.IResourceValidator;
|
||||||
import org.hl7.fhir.r4.utils.NarrativeGenerator;
|
import org.hl7.fhir.r4.utils.NarrativeGenerator;
|
||||||
import org.hl7.fhir.utilities.CSFileInputStream;
|
import org.hl7.fhir.utilities.CSFileInputStream;
|
||||||
import org.hl7.fhir.utilities.Utilities;
|
import org.hl7.fhir.utilities.Utilities;
|
||||||
|
|
|
@ -10036,6 +10036,7 @@ The primary difference between a medication statement and a medication administr
|
||||||
* R4B - manually added
|
* R4B - manually added
|
||||||
*/
|
*/
|
||||||
_4_1_0,
|
_4_1_0,
|
||||||
|
_4_3_0_CIBUILD,
|
||||||
NULL;
|
NULL;
|
||||||
public static FHIRVersion fromCode(String codeString) throws FHIRException {
|
public static FHIRVersion fromCode(String codeString) throws FHIRException {
|
||||||
if (codeString == null || "".equals(codeString))
|
if (codeString == null || "".equals(codeString))
|
||||||
|
@ -10088,6 +10089,8 @@ The primary difference between a medication statement and a medication administr
|
||||||
return _4_0_1;
|
return _4_0_1;
|
||||||
if ("4.1.0".equals(codeString))
|
if ("4.1.0".equals(codeString))
|
||||||
return _4_1_0;
|
return _4_1_0;
|
||||||
|
if ("4.3.0-CIBUILD".equals(codeString))
|
||||||
|
return _4_3_0_CIBUILD;
|
||||||
throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'");
|
throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'");
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
@ -10120,6 +10123,8 @@ The primary difference between a medication statement and a medication administr
|
||||||
case _4_0_0: return "4.0.0";
|
case _4_0_0: return "4.0.0";
|
||||||
case _4_0_1: return "4.0.1";
|
case _4_0_1: return "4.0.1";
|
||||||
case _4_1_0: return "4.1.0";
|
case _4_1_0: return "4.1.0";
|
||||||
|
case _4_3_0_CIBUILD: return "4.3.0-CIBUILD";
|
||||||
|
|
||||||
case NULL: return null;
|
case NULL: return null;
|
||||||
default: return "?";
|
default: return "?";
|
||||||
}
|
}
|
||||||
|
@ -10150,6 +10155,7 @@ The primary difference between a medication statement and a medication administr
|
||||||
case _4_0_0: return "http://hl7.org/fhir/FHIR-version";
|
case _4_0_0: return "http://hl7.org/fhir/FHIR-version";
|
||||||
case _4_0_1: return "http://hl7.org/fhir/FHIR-version";
|
case _4_0_1: return "http://hl7.org/fhir/FHIR-version";
|
||||||
case _4_1_0: return "http://hl7.org/fhir/FHIR-version";
|
case _4_1_0: return "http://hl7.org/fhir/FHIR-version";
|
||||||
|
case _4_3_0_CIBUILD: return "http://hl7.org/fhir/FHIR-version";
|
||||||
case NULL: return null;
|
case NULL: return null;
|
||||||
default: return "?";
|
default: return "?";
|
||||||
}
|
}
|
||||||
|
@ -10179,7 +10185,8 @@ The primary difference between a medication statement and a medication administr
|
||||||
case _3_5_0: return "R4 Ballot #2.";
|
case _3_5_0: return "R4 Ballot #2.";
|
||||||
case _4_0_0: return "FHIR Release 4 (Normative + STU).";
|
case _4_0_0: return "FHIR Release 4 (Normative + STU).";
|
||||||
case _4_0_1: return "FHIR Release 4 Technical Correction #1.";
|
case _4_0_1: return "FHIR Release 4 Technical Correction #1.";
|
||||||
case _4_1_0: return "FHIR Release 4B";
|
case _4_1_0: return "FHIR Release 4B Ballot #1";
|
||||||
|
case _4_3_0_CIBUILD: return "FHIR Release 4B CI-Builld";
|
||||||
case NULL: return null;
|
case NULL: return null;
|
||||||
default: return "?";
|
default: return "?";
|
||||||
}
|
}
|
||||||
|
@ -10210,6 +10217,7 @@ The primary difference between a medication statement and a medication administr
|
||||||
case _4_0_0: return "4.0.0";
|
case _4_0_0: return "4.0.0";
|
||||||
case _4_0_1: return "4.0.1";
|
case _4_0_1: return "4.0.1";
|
||||||
case _4_1_0: return "4.1.0";
|
case _4_1_0: return "4.1.0";
|
||||||
|
case _4_3_0_CIBUILD: return "4.3.0-CIBUILD";
|
||||||
case NULL: return null;
|
case NULL: return null;
|
||||||
default: return "?";
|
default: return "?";
|
||||||
}
|
}
|
||||||
|
@ -10275,6 +10283,8 @@ The primary difference between a medication statement and a medication administr
|
||||||
return FHIRVersion._4_0_1;
|
return FHIRVersion._4_0_1;
|
||||||
if ("4.1.0".equals(codeString))
|
if ("4.1.0".equals(codeString))
|
||||||
return FHIRVersion._4_1_0;
|
return FHIRVersion._4_1_0;
|
||||||
|
if ("4.3.0-CIBUILD".equals(codeString))
|
||||||
|
return FHIRVersion._4_3_0_CIBUILD;
|
||||||
throw new IllegalArgumentException("Unknown FHIRVersion code '"+codeString+"'");
|
throw new IllegalArgumentException("Unknown FHIRVersion code '"+codeString+"'");
|
||||||
}
|
}
|
||||||
public Enumeration<FHIRVersion> fromType(Base code) throws FHIRException {
|
public Enumeration<FHIRVersion> fromType(Base code) throws FHIRException {
|
||||||
|
@ -10333,6 +10343,8 @@ The primary difference between a medication statement and a medication administr
|
||||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_0_1);
|
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_0_1);
|
||||||
if ("4.1.0".equals(codeString))
|
if ("4.1.0".equals(codeString))
|
||||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_1_0);
|
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_1_0);
|
||||||
|
if ("4.3.0-CIBUILD".equals(codeString))
|
||||||
|
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_3_0_CIBUILD);
|
||||||
throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'");
|
throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'");
|
||||||
}
|
}
|
||||||
public String toCode(FHIRVersion code) {
|
public String toCode(FHIRVersion code) {
|
||||||
|
@ -10384,6 +10396,8 @@ The primary difference between a medication statement and a medication administr
|
||||||
return "4.0.1";
|
return "4.0.1";
|
||||||
if (code == FHIRVersion._4_1_0)
|
if (code == FHIRVersion._4_1_0)
|
||||||
return "4.1.0";
|
return "4.1.0";
|
||||||
|
if (code == FHIRVersion._4_3_0_CIBUILD)
|
||||||
|
return "4.3.0_CIBUILD";
|
||||||
return "?";
|
return "?";
|
||||||
}
|
}
|
||||||
public String toSystem(FHIRVersion code) {
|
public String toSystem(FHIRVersion code) {
|
||||||
|
|
|
@ -115,6 +115,7 @@ import org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent;
|
||||||
import org.hl7.fhir.r4.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
|
import org.hl7.fhir.r4.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
|
||||||
import org.hl7.fhir.r4.utils.FHIRLexer.FHIRLexerException;
|
import org.hl7.fhir.r4.utils.FHIRLexer.FHIRLexerException;
|
||||||
import org.hl7.fhir.r4.utils.FHIRPathEngine.IEvaluationContext;
|
import org.hl7.fhir.r4.utils.FHIRPathEngine.IEvaluationContext;
|
||||||
|
import org.hl7.fhir.r4.utils.validation.IResourceValidator;
|
||||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||||
import org.hl7.fhir.utilities.TerminologyServiceOptions;
|
import org.hl7.fhir.utilities.TerminologyServiceOptions;
|
||||||
import org.hl7.fhir.utilities.Utilities;
|
import org.hl7.fhir.utilities.Utilities;
|
||||||
|
|
|
@ -2,8 +2,8 @@ package org.hl7.fhir.r4.utils.client.network;
|
||||||
|
|
||||||
import okhttp3.*;
|
import okhttp3.*;
|
||||||
import org.hl7.fhir.utilities.ToolingClientLogger;
|
import org.hl7.fhir.utilities.ToolingClientLogger;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -22,9 +22,8 @@ public class FhirLoggingInterceptor implements Interceptor {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public Response intercept(@NotNull Interceptor.Chain chain) throws IOException {
|
public Response intercept(@Nonnull Interceptor.Chain chain) throws IOException {
|
||||||
// Log Request
|
// Log Request
|
||||||
Request request = chain.request();
|
Request request = chain.request();
|
||||||
logger.logRequest(request.method(), request.url().toString(), new ArrayList<>(request.headers().names()),
|
logger.logRequest(request.method(), request.url().toString(), new ArrayList<>(request.headers().names()),
|
||||||
|
|
|
@ -34,8 +34,8 @@ public class RetryInterceptor implements Interceptor {
|
||||||
try {
|
try {
|
||||||
// If we are retrying a failed request that failed due to a bad response from the server, we must close it first
|
// If we are retrying a failed request that failed due to a bad response from the server, we must close it first
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
System.out.println("Previous " + chain.request().method() + " attempt returned HTTP<" + (response.code())
|
// System.out.println("Previous " + chain.request().method() + " attempt returned HTTP<" + (response.code())
|
||||||
+ "> from url -> " + chain.request().url() + ".");
|
// + "> from url -> " + chain.request().url() + ".");
|
||||||
response.close();
|
response.close();
|
||||||
}
|
}
|
||||||
// System.out.println(chain.request().method() + " attempt <" + (retryCounter + 1) + "> to url -> " + chain.request().url());
|
// System.out.println(chain.request().method() + " attempt <" + (retryCounter + 1) + "> to url -> " + chain.request().url());
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.hl7.fhir.r4.utils;
|
package org.hl7.fhir.r4.utils.validation;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2011+, HL7, Inc.
|
Copyright (c) 2011+, HL7, Inc.
|
||||||
|
@ -29,18 +29,17 @@ package org.hl7.fhir.r4.utils;
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hl7.fhir.exceptions.DefinitionException;
|
|
||||||
import org.hl7.fhir.exceptions.FHIRException;
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
|
||||||
import org.hl7.fhir.r4.elementmodel.Element;
|
|
||||||
import org.hl7.fhir.r4.elementmodel.Manager.FhirFormat;
|
import org.hl7.fhir.r4.elementmodel.Manager.FhirFormat;
|
||||||
import org.hl7.fhir.r4.model.StructureDefinition;
|
import org.hl7.fhir.r4.model.StructureDefinition;
|
||||||
|
import org.hl7.fhir.r4.utils.ValidationProfileSet;
|
||||||
|
import org.hl7.fhir.r4.utils.validation.constants.BestPracticeWarningLevel;
|
||||||
|
import org.hl7.fhir.r4.utils.validation.constants.CheckDisplayOption;
|
||||||
|
import org.hl7.fhir.r4.utils.validation.constants.IdStatus;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
@ -54,69 +53,21 @@ import com.google.gson.JsonObject;
|
||||||
*/
|
*/
|
||||||
public interface IResourceValidator {
|
public interface IResourceValidator {
|
||||||
|
|
||||||
public enum ReferenceValidationPolicy {
|
|
||||||
IGNORE, CHECK_TYPE_IF_EXISTS, CHECK_EXISTS, CHECK_EXISTS_AND_TYPE, CHECK_VALID;
|
|
||||||
|
|
||||||
public boolean checkExists() {
|
|
||||||
return this == CHECK_EXISTS_AND_TYPE || this == CHECK_EXISTS || this == CHECK_VALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkType() {
|
|
||||||
return this == CHECK_TYPE_IF_EXISTS || this == CHECK_EXISTS_AND_TYPE || this == CHECK_VALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkValid() {
|
|
||||||
return this == CHECK_VALID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IValidatorResourceFetcher {
|
|
||||||
Element fetch(Object appContext, String url) throws FHIRFormatError, DefinitionException, FHIRException, IOException;
|
|
||||||
ReferenceValidationPolicy validationPolicy(Object appContext, String path, String url);
|
|
||||||
boolean resolveURL(Object appContext, String path, String url) throws IOException, FHIRException;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum BestPracticeWarningLevel {
|
|
||||||
Ignore,
|
|
||||||
Hint,
|
|
||||||
Warning,
|
|
||||||
Error
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum CheckDisplayOption {
|
|
||||||
Ignore,
|
|
||||||
Check,
|
|
||||||
CheckCaseAndSpace,
|
|
||||||
CheckCase,
|
|
||||||
CheckSpace
|
|
||||||
}
|
|
||||||
|
|
||||||
enum IdStatus {
|
|
||||||
OPTIONAL, REQUIRED, PROHIBITED
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* how much to check displays for coded elements
|
* how much to check displays for coded elements
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
CheckDisplayOption getCheckDisplay();
|
CheckDisplayOption getCheckDisplay();
|
||||||
void setCheckDisplay(CheckDisplayOption checkDisplay);
|
void setCheckDisplay(CheckDisplayOption checkDisplay);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* whether the resource must have an id or not (depends on context)
|
* whether the resource must have an id or not (depends on context)
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
IdStatus getResourceIdRule();
|
IdStatus getResourceIdRule();
|
||||||
void setResourceIdRule(IdStatus resourceIdRule);
|
void setResourceIdRule(IdStatus resourceIdRule);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* whether the validator should enforce best practice guidelines
|
* whether the validator should enforce best practice guidelines
|
||||||
* as defined by various HL7 committees
|
* as defined by various HL7 committees
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
BestPracticeWarningLevel getBestPracticeWarningLevel();
|
BestPracticeWarningLevel getBestPracticeWarningLevel();
|
||||||
IResourceValidator setBestPracticeWarningLevel(BestPracticeWarningLevel value);
|
IResourceValidator setBestPracticeWarningLevel(BestPracticeWarningLevel value);
|
||||||
|
@ -124,27 +75,29 @@ public interface IResourceValidator {
|
||||||
IValidatorResourceFetcher getFetcher();
|
IValidatorResourceFetcher getFetcher();
|
||||||
IResourceValidator setFetcher(IValidatorResourceFetcher value);
|
IResourceValidator setFetcher(IValidatorResourceFetcher value);
|
||||||
|
|
||||||
|
IValidationPolicyAdvisor getPolicyAdvisor();
|
||||||
|
IResourceValidator setPolicyAdvisor(IValidationPolicyAdvisor advisor);
|
||||||
|
|
||||||
boolean isNoBindingMsgSuppressed();
|
boolean isNoBindingMsgSuppressed();
|
||||||
IResourceValidator setNoBindingMsgSuppressed(boolean noBindingMsgSuppressed);
|
IResourceValidator setNoBindingMsgSuppressed(boolean noBindingMsgSuppressed);
|
||||||
|
|
||||||
public boolean isNoInvariantChecks();
|
boolean isNoInvariantChecks();
|
||||||
public IResourceValidator setNoInvariantChecks(boolean value) ;
|
IResourceValidator setNoInvariantChecks(boolean value) ;
|
||||||
|
|
||||||
public boolean isNoTerminologyChecks();
|
boolean isNoTerminologyChecks();
|
||||||
public IResourceValidator setNoTerminologyChecks(boolean noTerminologyChecks);
|
IResourceValidator setNoTerminologyChecks(boolean noTerminologyChecks);
|
||||||
|
|
||||||
public boolean isNoExtensibleWarnings();
|
boolean isNoExtensibleWarnings();
|
||||||
public IResourceValidator setNoExtensibleWarnings(boolean noExtensibleWarnings);
|
IResourceValidator setNoExtensibleWarnings(boolean noExtensibleWarnings);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether being unable to resolve a profile in found in Resource.meta.profile or ElementDefinition.type.profile or targetProfile is an error or just a warning
|
* Whether being unable to resolve a profile in found in Resource.meta.profile or ElementDefinition.type.profile or targetProfile is an error or just a warning
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public boolean isErrorForUnknownProfiles();
|
boolean isErrorForUnknownProfiles();
|
||||||
public void setErrorForUnknownProfiles(boolean errorForUnknownProfiles);
|
void setErrorForUnknownProfiles(boolean errorForUnknownProfiles);
|
||||||
|
|
||||||
public String getValidationLanguage();
|
String getValidationLanguage();
|
||||||
public void setValidationLanguage(String value);
|
void setValidationLanguage(String value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate suite
|
* Validate suite
|
||||||
|
@ -194,5 +147,4 @@ public interface IResourceValidator {
|
||||||
org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, JsonObject object, String profile) throws FHIRException;
|
org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, JsonObject object, String profile) throws FHIRException;
|
||||||
org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, JsonObject object, StructureDefinition profile) throws FHIRException;
|
org.hl7.fhir.r4.elementmodel.Element validate(Object Context, List<ValidationMessage> errors, JsonObject object, StructureDefinition profile) throws FHIRException;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package org.hl7.fhir.r4.utils.validation;
|
||||||
|
|
||||||
|
import org.hl7.fhir.r4.elementmodel.Element;
|
||||||
|
import org.hl7.fhir.r4.utils.validation.constants.ReferenceValidationPolicy;
|
||||||
|
|
||||||
|
public interface IValidationPolicyAdvisor {
|
||||||
|
|
||||||
|
ReferenceValidationPolicy policyForReference(IResourceValidator validator,
|
||||||
|
Object appContext,
|
||||||
|
String path,
|
||||||
|
String url);
|
||||||
|
|
||||||
|
ReferenceValidationPolicy policyForContained(IResourceValidator validator,
|
||||||
|
Object appContext,
|
||||||
|
String containerType,
|
||||||
|
String containerId,
|
||||||
|
Element.SpecialElement containingResourceType,
|
||||||
|
String path,
|
||||||
|
String url);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package org.hl7.fhir.r4.utils.validation;
|
||||||
|
|
||||||
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
|
import org.hl7.fhir.r4.elementmodel.Element;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public interface IValidatorResourceFetcher {
|
||||||
|
Element fetch(Object appContext, String url) throws FHIRException, IOException;
|
||||||
|
boolean resolveURL(Object appContext, String path, String url) throws IOException, FHIRException;
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package org.hl7.fhir.r4.utils.validation.constants;
|
||||||
|
|
||||||
|
public enum BestPracticeWarningLevel {
|
||||||
|
Ignore,
|
||||||
|
Hint,
|
||||||
|
Warning,
|
||||||
|
Error
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package org.hl7.fhir.r4.utils.validation.constants;
|
||||||
|
|
||||||
|
public enum CheckDisplayOption {
|
||||||
|
Ignore,
|
||||||
|
Check,
|
||||||
|
CheckCaseAndSpace,
|
||||||
|
CheckCase,
|
||||||
|
CheckSpace
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package org.hl7.fhir.r4.utils.validation.constants;
|
||||||
|
|
||||||
|
public enum IdStatus {
|
||||||
|
OPTIONAL,
|
||||||
|
REQUIRED,
|
||||||
|
PROHIBITED
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package org.hl7.fhir.r4.utils.validation.constants;
|
||||||
|
|
||||||
|
public enum ReferenceValidationPolicy {
|
||||||
|
IGNORE,
|
||||||
|
CHECK_TYPE_IF_EXISTS,
|
||||||
|
CHECK_EXISTS,
|
||||||
|
CHECK_EXISTS_AND_TYPE,
|
||||||
|
CHECK_VALID;
|
||||||
|
|
||||||
|
public boolean checkExists() {
|
||||||
|
return this == CHECK_EXISTS_AND_TYPE || this == CHECK_EXISTS || this == CHECK_VALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkType() {
|
||||||
|
return this == CHECK_TYPE_IF_EXISTS || this == CHECK_EXISTS_AND_TYPE || this == CHECK_VALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkValid() {
|
||||||
|
return this == CHECK_VALID;
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,7 +21,7 @@ import java.io.*;
|
||||||
public class ResourceRoundTripTests {
|
public class ResourceRoundTripTests {
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public void setUp() throws Exception {
|
public static void setUp() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.hl7.fhir.r4.model.ValueSet;
|
||||||
import org.hl7.fhir.r4.test.utils.TestingUtilities;
|
import org.hl7.fhir.r4.test.utils.TestingUtilities;
|
||||||
import org.hl7.fhir.r4.utils.FHIRPathEngine;
|
import org.hl7.fhir.r4.utils.FHIRPathEngine;
|
||||||
import org.hl7.fhir.r4.utils.FHIRPathEngine.IEvaluationContext;
|
import org.hl7.fhir.r4.utils.FHIRPathEngine.IEvaluationContext;
|
||||||
import org.hl7.fhir.r4.utils.IResourceValidator;
|
import org.hl7.fhir.r4.utils.validation.IResourceValidator;
|
||||||
import org.hl7.fhir.r4.utils.NarrativeGenerator;
|
import org.hl7.fhir.r4.utils.NarrativeGenerator;
|
||||||
import org.hl7.fhir.utilities.Utilities;
|
import org.hl7.fhir.utilities.Utilities;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>5.5.12-SNAPSHOT</version>
|
<version>5.6.16-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -691,8 +691,8 @@ public class ProfileUtilities extends TranslatingUtilities {
|
||||||
}
|
}
|
||||||
if (!e.hasUserData(GENERATED_IN_SNAPSHOT)) {
|
if (!e.hasUserData(GENERATED_IN_SNAPSHOT)) {
|
||||||
b.append(e.hasId() ? "id: "+e.getId() : "path: "+e.getPath());
|
b.append(e.hasId() ? "id: "+e.getId() : "path: "+e.getPath());
|
||||||
|
ce++;
|
||||||
if (e.hasId()) {
|
if (e.hasId()) {
|
||||||
ce++;
|
|
||||||
String msg = "No match found in the generated snapshot: check that the path and definitions are legal in the differential (including order)";
|
String msg = "No match found in the generated snapshot: check that the path and definitions are legal in the differential (including order)";
|
||||||
messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+e.getId(), msg, ValidationMessage.IssueSeverity.ERROR));
|
messages.add(new ValidationMessage(Source.ProfileValidator, ValidationMessage.IssueType.VALUE, url+"#"+e.getId(), msg, ValidationMessage.IssueSeverity.ERROR));
|
||||||
}
|
}
|
||||||
|
@ -2470,7 +2470,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < markdown.length()) {
|
while (i < markdown.length()) {
|
||||||
if (i < markdown.length()-3 && markdown.substring(i, i+2).equals("](")) {
|
if (i < markdown.length()-3 && markdown.substring(i, i+2).equals("](")) {
|
||||||
int j = i + 2;
|
int j = i + 2;
|
||||||
while (j < markdown.length() && markdown.charAt(j) != ')')
|
while (j < markdown.length() && markdown.charAt(j) != ')')
|
||||||
j++;
|
j++;
|
||||||
if (j < markdown.length()) {
|
if (j < markdown.length()) {
|
||||||
|
@ -2492,7 +2492,8 @@ public class ProfileUtilities extends TranslatingUtilities {
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
} else {
|
} else {
|
||||||
b.append("](");
|
b.append("](");
|
||||||
b.append(webUrl);
|
// disabled 7-Dec 2021 GDG - we don't want to fool with relative URLs at all?
|
||||||
|
// b.append(webUrl);
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
@ -4773,7 +4774,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
||||||
|
|
||||||
private void genFixedValue(HierarchicalTableGenerator gen, Row erow, DataType value, boolean snapshot, boolean pattern, String corePath, boolean skipnoValue) {
|
private void genFixedValue(HierarchicalTableGenerator gen, Row erow, DataType value, boolean snapshot, boolean pattern, String corePath, boolean skipnoValue) {
|
||||||
String ref = pkp.getLinkFor(corePath, value.fhirType());
|
String ref = pkp.getLinkFor(corePath, value.fhirType());
|
||||||
if (ref != null) {
|
if (ref != null && ref.contains(".html")) {
|
||||||
ref = ref.substring(0, ref.indexOf(".html"))+"-definitions.html#";
|
ref = ref.substring(0, ref.indexOf(".html"))+"-definitions.html#";
|
||||||
} else {
|
} else {
|
||||||
ref = "?gen-fv?";
|
ref = "?gen-fv?";
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
package org.hl7.fhir.r5.conformance;
|
||||||
|
|
||||||
|
import org.hl7.fhir.r5.model.ElementDefinition;
|
||||||
|
import org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent;
|
||||||
|
import org.hl7.fhir.r5.model.Resource;
|
||||||
|
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||||
|
import org.hl7.fhir.utilities.VersionUtilities;
|
||||||
|
|
||||||
|
public class StructureDefinitionHacker {
|
||||||
|
|
||||||
|
private String version;
|
||||||
|
|
||||||
|
public StructureDefinitionHacker(String version) {
|
||||||
|
super();
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Resource fixSD(StructureDefinition sd) {
|
||||||
|
if (VersionUtilities.isR4BVer(version) && sd.getUrl().equals("http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type")) {
|
||||||
|
// the definition of this one is wrong in R4B
|
||||||
|
return fixR4BFhirType(sd);
|
||||||
|
}
|
||||||
|
return sd;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Resource fixR4BFhirType(StructureDefinition sd) {
|
||||||
|
for (ElementDefinition ed : sd.getDifferential().getElement()) {
|
||||||
|
if (ed.getPath().equals("Extension.value[x]")) {
|
||||||
|
fixEDType(ed, "url", "uri");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (ElementDefinition ed : sd.getSnapshot().getElement()) {
|
||||||
|
if (ed.getPath().equals("Extension.value[x]")) {
|
||||||
|
fixEDType(ed, "url", "uri");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sd;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fixEDType(ElementDefinition ed, String orig, String repl) {
|
||||||
|
for (TypeRefComponent t : ed.getType()) {
|
||||||
|
if (orig.equals(t.getCode())) {
|
||||||
|
t.setCode(repl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -52,6 +52,7 @@ import org.hl7.fhir.exceptions.FHIRException;
|
||||||
import org.hl7.fhir.exceptions.NoTerminologyServiceException;
|
import org.hl7.fhir.exceptions.NoTerminologyServiceException;
|
||||||
import org.hl7.fhir.exceptions.TerminologyServiceException;
|
import org.hl7.fhir.exceptions.TerminologyServiceException;
|
||||||
import org.hl7.fhir.r5.conformance.ProfileUtilities;
|
import org.hl7.fhir.r5.conformance.ProfileUtilities;
|
||||||
|
import org.hl7.fhir.r5.context.BaseWorkerContext.ResourceProxy;
|
||||||
import org.hl7.fhir.r5.context.CanonicalResourceManager.CanonicalResourceProxy;
|
import org.hl7.fhir.r5.context.CanonicalResourceManager.CanonicalResourceProxy;
|
||||||
import org.hl7.fhir.r5.context.IWorkerContext.PackageVersion;
|
import org.hl7.fhir.r5.context.IWorkerContext.PackageVersion;
|
||||||
import org.hl7.fhir.r5.context.IWorkerContext.ILoggingService.LogCategory;
|
import org.hl7.fhir.r5.context.IWorkerContext.ILoggingService.LogCategory;
|
||||||
|
@ -110,6 +111,7 @@ import org.hl7.fhir.r5.terminologies.ValueSetExpander.TerminologyServiceErrorCla
|
||||||
import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
|
import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
|
||||||
import org.hl7.fhir.r5.terminologies.ValueSetExpanderSimple;
|
import org.hl7.fhir.r5.terminologies.ValueSetExpanderSimple;
|
||||||
import org.hl7.fhir.r5.utils.ToolingExtensions;
|
import org.hl7.fhir.r5.utils.ToolingExtensions;
|
||||||
|
import org.hl7.fhir.r5.utils.validation.ValidationContextCarrier;
|
||||||
import org.hl7.fhir.utilities.OIDUtils;
|
import org.hl7.fhir.utilities.OIDUtils;
|
||||||
import org.hl7.fhir.utilities.TimeTracker;
|
import org.hl7.fhir.utilities.TimeTracker;
|
||||||
import org.hl7.fhir.utilities.ToolingClientLogger;
|
import org.hl7.fhir.utilities.ToolingClientLogger;
|
||||||
|
@ -129,6 +131,35 @@ import ca.uhn.fhir.model.valueset.BundleEntrySearchModeEnum;
|
||||||
|
|
||||||
public abstract class BaseWorkerContext extends I18nBase implements IWorkerContext{
|
public abstract class BaseWorkerContext extends I18nBase implements IWorkerContext{
|
||||||
|
|
||||||
|
public class ResourceProxy {
|
||||||
|
private Resource resource;
|
||||||
|
private CanonicalResourceProxy proxy;
|
||||||
|
|
||||||
|
public ResourceProxy(Resource resource) {
|
||||||
|
super();
|
||||||
|
this.resource = resource;
|
||||||
|
}
|
||||||
|
public ResourceProxy(CanonicalResourceProxy proxy) {
|
||||||
|
super();
|
||||||
|
this.proxy = proxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Resource getResource() {
|
||||||
|
return resource != null ? resource : proxy.getResource();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
if (resource == null) {
|
||||||
|
return proxy.getUrl();
|
||||||
|
} else if (resource instanceof CanonicalResource) {
|
||||||
|
return ((CanonicalResource) resource).getUrl();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public class MetadataResourceVersionComparator<T extends CanonicalResource> implements Comparator<T> {
|
public class MetadataResourceVersionComparator<T extends CanonicalResource> implements Comparator<T> {
|
||||||
|
|
||||||
private List<T> list;
|
private List<T> list;
|
||||||
|
@ -165,7 +196,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
private boolean isTxCaching;
|
private boolean isTxCaching;
|
||||||
private Set<String> cached = new HashSet<>();
|
private Set<String> cached = new HashSet<>();
|
||||||
|
|
||||||
private Map<String, Map<String, Resource>> allResourcesById = new HashMap<String, Map<String, Resource>>();
|
private Map<String, Map<String, ResourceProxy>> allResourcesById = new HashMap<String, Map<String, ResourceProxy>>();
|
||||||
// all maps are to the full URI
|
// all maps are to the full URI
|
||||||
private CanonicalResourceManager<CodeSystem> codeSystems = new CanonicalResourceManager<CodeSystem>(false);
|
private CanonicalResourceManager<CodeSystem> codeSystems = new CanonicalResourceManager<CodeSystem>(false);
|
||||||
private Set<String> supportedCodeSystems = new HashSet<String>();
|
private Set<String> supportedCodeSystems = new HashSet<String>();
|
||||||
|
@ -276,6 +307,12 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
|
|
||||||
public void registerResourceFromPackage(CanonicalResourceProxy r, PackageVersion packageInfo) throws FHIRException {
|
public void registerResourceFromPackage(CanonicalResourceProxy r, PackageVersion packageInfo) throws FHIRException {
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
|
Map<String, ResourceProxy> map = allResourcesById.get(r.getType());
|
||||||
|
if (map == null) {
|
||||||
|
map = new HashMap<String, ResourceProxy>();
|
||||||
|
allResourcesById.put(r.getType(), map);
|
||||||
|
}
|
||||||
|
map.put(r.getId(), new ResourceProxy(r));
|
||||||
|
|
||||||
String url = r.getUrl();
|
String url = r.getUrl();
|
||||||
if (!allowLoadingDuplicates && hasResource(r.getType(), url)) {
|
if (!allowLoadingDuplicates && hasResource(r.getType(), url)) {
|
||||||
|
@ -338,12 +375,14 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
|
|
||||||
public void cacheResourceFromPackage(Resource r, PackageVersion packageInfo) throws FHIRException {
|
public void cacheResourceFromPackage(Resource r, PackageVersion packageInfo) throws FHIRException {
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
Map<String, Resource> map = allResourcesById.get(r.fhirType());
|
Map<String, ResourceProxy> map = allResourcesById.get(r.fhirType());
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
map = new HashMap<String, Resource>();
|
map = new HashMap<String, ResourceProxy>();
|
||||||
allResourcesById.put(r.fhirType(), map);
|
allResourcesById.put(r.fhirType(), map);
|
||||||
}
|
}
|
||||||
map.put(r.getId(), r);
|
if ((packageInfo == null || !packageInfo.isExamplesPackage()) || !map.containsKey(r.getId())) {
|
||||||
|
map.put(r.getId(), new ResourceProxy(r));
|
||||||
|
}
|
||||||
|
|
||||||
if (r instanceof CodeSystem || r instanceof NamingSystem) {
|
if (r instanceof CodeSystem || r instanceof NamingSystem) {
|
||||||
oidCache.clear();
|
oidCache.clear();
|
||||||
|
@ -498,6 +537,14 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CodeSystem fetchCodeSystem(String system) {
|
public CodeSystem fetchCodeSystem(String system) {
|
||||||
|
if (system == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (system.contains("|")) {
|
||||||
|
String s = system.substring(0, system.indexOf("|"));
|
||||||
|
String v = system.substring(system.indexOf("|")+1);
|
||||||
|
return fetchCodeSystem(s, v);
|
||||||
|
}
|
||||||
CodeSystem cs;
|
CodeSystem cs;
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
cs = codeSystems.get(system);
|
cs = codeSystems.get(system);
|
||||||
|
@ -511,6 +558,23 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
return cs;
|
return cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CodeSystem fetchCodeSystem(String system, String version) {
|
||||||
|
if (version == null) {
|
||||||
|
return fetchCodeSystem(system);
|
||||||
|
}
|
||||||
|
CodeSystem cs;
|
||||||
|
synchronized (lock) {
|
||||||
|
cs = codeSystems.get(system, version);
|
||||||
|
}
|
||||||
|
if (cs == null && locator != null) {
|
||||||
|
locator.findResource(this, system);
|
||||||
|
synchronized (lock) {
|
||||||
|
cs = codeSystems.get(system);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cs;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsSystem(String system) throws TerminologyServiceException {
|
public boolean supportsSystem(String system) throws TerminologyServiceException {
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
|
@ -643,10 +707,18 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
if (expParameters == null)
|
if (expParameters == null)
|
||||||
throw new Error(formatMessage(I18nConstants.NO_EXPANSION_PARAMETERS_PROVIDED));
|
throw new Error(formatMessage(I18nConstants.NO_EXPANSION_PARAMETERS_PROVIDED));
|
||||||
Parameters p = expParameters.copy();
|
Parameters p = expParameters.copy();
|
||||||
return expandVS(vs, cacheOk, heirarchical, p);
|
return expandVS(vs, cacheOk, heirarchical, false, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ValueSetExpansionOutcome expandVS(ValueSet vs, boolean cacheOk, boolean heirarchical, Parameters p) {
|
@Override
|
||||||
|
public ValueSetExpansionOutcome expandVS(ValueSet vs, boolean cacheOk, boolean heirarchical, boolean incompleteOk) {
|
||||||
|
if (expParameters == null)
|
||||||
|
throw new Error(formatMessage(I18nConstants.NO_EXPANSION_PARAMETERS_PROVIDED));
|
||||||
|
Parameters p = expParameters.copy();
|
||||||
|
return expandVS(vs, cacheOk, heirarchical, incompleteOk, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ValueSetExpansionOutcome expandVS(ValueSet vs, boolean cacheOk, boolean heirarchical, boolean incompleteOk, Parameters p) {
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
throw new Error(formatMessage(I18nConstants.NO_PARAMETERS_PROVIDED_TO_EXPANDVS));
|
throw new Error(formatMessage(I18nConstants.NO_PARAMETERS_PROVIDED_TO_EXPANDVS));
|
||||||
}
|
}
|
||||||
|
@ -673,6 +745,9 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
}
|
}
|
||||||
p.setParameter("includeDefinition", false);
|
p.setParameter("includeDefinition", false);
|
||||||
p.setParameter("excludeNested", !heirarchical);
|
p.setParameter("excludeNested", !heirarchical);
|
||||||
|
if (incompleteOk) {
|
||||||
|
p.setParameter("incomplete-ok", true);
|
||||||
|
}
|
||||||
|
|
||||||
List<String> allErrors = new ArrayList<>();
|
List<String> allErrors = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -853,6 +928,12 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ValidationResult validateCode(ValidationOptions options, Coding code, ValueSet vs) {
|
public ValidationResult validateCode(ValidationOptions options, Coding code, ValueSet vs) {
|
||||||
|
ValidationContextCarrier ctxt = new ValidationContextCarrier();
|
||||||
|
return validateCode(options, code, vs, ctxt);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ValidationResult validateCode(ValidationOptions options, Coding code, ValueSet vs, ValidationContextCarrier ctxt) {
|
||||||
if (options == null) {
|
if (options == null) {
|
||||||
options = ValidationOptions.defaults();
|
options = ValidationOptions.defaults();
|
||||||
}
|
}
|
||||||
|
@ -872,7 +953,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
if (options.isUseClient()) {
|
if (options.isUseClient()) {
|
||||||
// ok, first we try to validate locally
|
// ok, first we try to validate locally
|
||||||
try {
|
try {
|
||||||
ValueSetCheckerSimple vsc = new ValueSetCheckerSimple(options, vs, this);
|
ValueSetCheckerSimple vsc = new ValueSetCheckerSimple(options, vs, this, ctxt);
|
||||||
if (!vsc.isServerSide(code.getSystem())) {
|
if (!vsc.isServerSide(code.getSystem())) {
|
||||||
res = vsc.validateCode(code);
|
res = vsc.validateCode(code);
|
||||||
if (txCache != null) {
|
if (txCache != null) {
|
||||||
|
@ -992,13 +1073,15 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (vs != null) {
|
if (vs != null) {
|
||||||
if (isTxCaching && cacheId != null && cached.contains(vs.getUrl()+"|"+vs.getVersion())) {
|
if (isTxCaching && cacheId != null && vs.getUrl() != null && cached.contains(vs.getUrl()+"|"+vs.getVersion())) {
|
||||||
pin.addParameter().setName("url").setValue(new UriType(vs.getUrl()+(vs.hasVersion() ? "|"+vs.getVersion() : "")));
|
pin.addParameter().setName("url").setValue(new UriType(vs.getUrl()+(vs.hasVersion() ? "|"+vs.getVersion() : "")));
|
||||||
} else if (options.getVsAsUrl()){
|
} else if (options.getVsAsUrl()){
|
||||||
pin.addParameter().setName("url").setValue(new StringType(vs.getUrl()));
|
pin.addParameter().setName("url").setValue(new StringType(vs.getUrl()));
|
||||||
} else {
|
} else {
|
||||||
pin.addParameter().setName("valueSet").setResource(vs);
|
pin.addParameter().setName("valueSet").setResource(vs);
|
||||||
cached.add(vs.getUrl()+"|"+vs.getVersion());
|
if (vs.getUrl() != null) {
|
||||||
|
cached.add(vs.getUrl()+"|"+vs.getVersion());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cache = true;
|
cache = true;
|
||||||
addDependentResources(pin, vs);
|
addDependentResources(pin, vs);
|
||||||
|
@ -1205,8 +1288,12 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
return fetchResourceWithException(cls, uri, null);
|
return fetchResourceWithException(cls, uri, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public <T extends Resource> T fetchResourceWithException(Class<T> class_, String uri, CanonicalResource source) throws FHIRException {
|
public <T extends Resource> T fetchResourceWithException(Class<T> class_, String uri, CanonicalResource source) throws FHIRException {
|
||||||
|
return fetchResourceWithException(class_, uri, null, source);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public <T extends Resource> T fetchResourceWithException(Class<T> class_, String uri, String version, CanonicalResource source) throws FHIRException {
|
||||||
if (uri == null) {
|
if (uri == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1216,7 +1303,6 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
}
|
}
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
|
|
||||||
String version = null;
|
|
||||||
if (uri.contains("|")) {
|
if (uri.contains("|")) {
|
||||||
version = uri.substring(uri.lastIndexOf("|")+1);
|
version = uri.substring(uri.lastIndexOf("|")+1);
|
||||||
uri = uri.substring(0, uri.lastIndexOf("|"));
|
uri = uri.substring(0, uri.lastIndexOf("|"));
|
||||||
|
@ -1264,12 +1350,22 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
if (questionnaires.has(uri)) {
|
if (questionnaires.has(uri)) {
|
||||||
return (T) questionnaires.get(uri, version);
|
return (T) questionnaires.get(uri, version);
|
||||||
}
|
}
|
||||||
for (Map<String, Resource> rt : allResourcesById.values()) {
|
if (uri.matches(Constants.URI_REGEX) && !uri.contains("ValueSet")) {
|
||||||
for (Resource r : rt.values()) {
|
return null;
|
||||||
if (r instanceof CanonicalResource) {
|
}
|
||||||
CanonicalResource mr = (CanonicalResource) r;
|
|
||||||
if (uri.equals(mr.getUrl())) {
|
// it might be a special URL.
|
||||||
return (T) mr;
|
if (Utilities.isAbsoluteUrl(uri) || uri.startsWith("ValueSet/")) {
|
||||||
|
Resource res = null; // findTxValueSet(uri);
|
||||||
|
if (res != null) {
|
||||||
|
return (T) res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Map<String, ResourceProxy> rt : allResourcesById.values()) {
|
||||||
|
for (ResourceProxy r : rt.values()) {
|
||||||
|
if (uri.equals(r.getUrl())) {
|
||||||
|
if (version == null || version == r.getResource().getMeta().getVersionId()) {
|
||||||
|
return (T) r.getResource();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1314,20 +1410,6 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
if (class_ == Questionnaire.class) {
|
if (class_ == Questionnaire.class) {
|
||||||
return (T) questionnaires.get(uri, version);
|
return (T) questionnaires.get(uri, version);
|
||||||
}
|
}
|
||||||
if (class_ == null) {
|
|
||||||
if (uri.matches(Constants.URI_REGEX) && !uri.contains("ValueSet")) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// it might be a special URL.
|
|
||||||
if (Utilities.isAbsoluteUrl(uri) || uri.startsWith("ValueSet/")) {
|
|
||||||
Resource res = null; // findTxValueSet(uri);
|
|
||||||
if (res != null) {
|
|
||||||
return (T) res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (supportedCodeSystems.contains(uri)) {
|
if (supportedCodeSystems.contains(uri)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1453,13 +1535,10 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
if (questionnaires.has(uri)) {
|
if (questionnaires.has(uri)) {
|
||||||
return (T) questionnaires.get(uri, version);
|
return (T) questionnaires.get(uri, version);
|
||||||
}
|
}
|
||||||
for (Map<String, Resource> rt : allResourcesById.values()) {
|
for (Map<String, ResourceProxy> rt : allResourcesById.values()) {
|
||||||
for (Resource r : rt.values()) {
|
for (ResourceProxy r : rt.values()) {
|
||||||
if (r instanceof CanonicalResource) {
|
if (uri.equals(r.getUrl())) {
|
||||||
CanonicalResource mr = (CanonicalResource) r;
|
return (T) r.getResource();
|
||||||
if (uri.equals(mr.getUrl())) {
|
|
||||||
return (T) mr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1533,7 +1612,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
String[] parts = uri.split("\\/");
|
String[] parts = uri.split("\\/");
|
||||||
if (!Utilities.noString(type) && parts.length == 1) {
|
if (!Utilities.noString(type) && parts.length == 1) {
|
||||||
if (allResourcesById.containsKey(type)) {
|
if (allResourcesById.containsKey(type)) {
|
||||||
return allResourcesById.get(type).get(parts[0]);
|
return allResourcesById.get(type).get(parts[0]).getResource();
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1544,7 +1623,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
throw new Error(formatMessage(I18nConstants.RESOURCE_TYPE_MISMATCH_FOR___, type, uri));
|
throw new Error(formatMessage(I18nConstants.RESOURCE_TYPE_MISMATCH_FOR___, type, uri));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return allResourcesById.get(parts[parts.length-2]).get(parts[parts.length-1]);
|
return allResourcesById.get(parts[parts.length-2]).get(parts[parts.length-1]).getResource();
|
||||||
} else {
|
} else {
|
||||||
throw new Error(formatMessage(I18nConstants.UNABLE_TO_PROCESS_REQUEST_FOR_RESOURCE_FOR___, type, uri));
|
throw new Error(formatMessage(I18nConstants.UNABLE_TO_PROCESS_REQUEST_FOR_RESOURCE_FOR___, type, uri));
|
||||||
}
|
}
|
||||||
|
@ -1567,6 +1646,14 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <T extends Resource> T fetchResource(Class<T> class_, String uri, String version) {
|
||||||
|
try {
|
||||||
|
return fetchResourceWithException(class_, uri, version, null);
|
||||||
|
} catch (FHIRException e) {
|
||||||
|
throw new Error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends Resource> boolean hasResource(Class<T> class_, String uri) {
|
public <T extends Resource> boolean hasResource(Class<T> class_, String uri) {
|
||||||
try {
|
try {
|
||||||
|
@ -1656,13 +1743,13 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
public void dropResource(String fhirType, String id) {
|
public void dropResource(String fhirType, String id) {
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
|
|
||||||
Map<String, Resource> map = allResourcesById.get(fhirType);
|
Map<String, ResourceProxy> map = allResourcesById.get(fhirType);
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
map = new HashMap<String, Resource>();
|
map = new HashMap<String, ResourceProxy>();
|
||||||
allResourcesById.put(fhirType, map);
|
allResourcesById.put(fhirType, map);
|
||||||
}
|
}
|
||||||
if (map.containsKey(id)) {
|
if (map.containsKey(id)) {
|
||||||
map.remove(id);
|
map.remove(id); // this is a challenge because we might have more than one resource with this id (different versions)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fhirType.equals("StructureDefinition")) {
|
if (fhirType.equals("StructureDefinition")) {
|
||||||
|
|
|
@ -236,6 +236,9 @@ public class CanonicalResourceManager<T extends CanonicalResource> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CachedCanonicalResource<T> existing = cr.hasVersion() ? map.get(cr.getUrl()+"|"+cr.getVersion()) : map.get(cr.getUrl()+"|#0");
|
CachedCanonicalResource<T> existing = cr.hasVersion() ? map.get(cr.getUrl()+"|"+cr.getVersion()) : map.get(cr.getUrl()+"|#0");
|
||||||
|
if (existing != null && (cr.getPackageInfo() != null && cr.getPackageInfo().isExamplesPackage())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (existing != null) {
|
if (existing != null) {
|
||||||
list.remove(existing);
|
list.remove(existing);
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,12 +89,13 @@ public class HTMLClientLogger extends BaseLogger implements ToolingClientLogger
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
System.out.println(" txlog resp: " +outcome+" "+present(body));
|
System.out.println(" txlog resp: " +outcome+" "+present(body));
|
||||||
}
|
}
|
||||||
req = false;
|
|
||||||
if (file == null)
|
if (file == null)
|
||||||
return;
|
return;
|
||||||
if (!req) {
|
if (!req) {
|
||||||
System.out.println("Record Response without request");
|
System.out.println("Record Response without request");
|
||||||
}
|
}
|
||||||
|
req = false;
|
||||||
file.println("<pre>");
|
file.println("<pre>");
|
||||||
file.println(outcome);
|
file.println(outcome);
|
||||||
for (String s : headers)
|
for (String s : headers)
|
||||||
|
|
|
@ -44,8 +44,8 @@ import org.fhir.ucum.UcumService;
|
||||||
import org.hl7.fhir.exceptions.DefinitionException;
|
import org.hl7.fhir.exceptions.DefinitionException;
|
||||||
import org.hl7.fhir.exceptions.FHIRException;
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
import org.hl7.fhir.exceptions.TerminologyServiceException;
|
import org.hl7.fhir.exceptions.TerminologyServiceException;
|
||||||
import org.hl7.fhir.r5.context.IWorkerContext.CodingValidationRequest;
|
|
||||||
import org.hl7.fhir.r5.context.TerminologyCache.CacheToken;
|
import org.hl7.fhir.r5.context.TerminologyCache.CacheToken;
|
||||||
|
import org.hl7.fhir.r5.elementmodel.Element;
|
||||||
import org.hl7.fhir.r5.formats.IParser;
|
import org.hl7.fhir.r5.formats.IParser;
|
||||||
import org.hl7.fhir.r5.formats.ParserType;
|
import org.hl7.fhir.r5.formats.ParserType;
|
||||||
import org.hl7.fhir.r5.model.Bundle;
|
import org.hl7.fhir.r5.model.Bundle;
|
||||||
|
@ -64,12 +64,14 @@ import org.hl7.fhir.r5.model.ValueSet;
|
||||||
import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent;
|
import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent;
|
||||||
import org.hl7.fhir.r5.terminologies.ValueSetExpander.TerminologyServiceErrorClass;
|
import org.hl7.fhir.r5.terminologies.ValueSetExpander.TerminologyServiceErrorClass;
|
||||||
import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
|
import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
|
||||||
import org.hl7.fhir.r5.utils.IResourceValidator;
|
import org.hl7.fhir.r5.utils.validation.IResourceValidator;
|
||||||
|
import org.hl7.fhir.r5.utils.validation.ValidationContextCarrier;
|
||||||
import org.hl7.fhir.utilities.TimeTracker;
|
import org.hl7.fhir.utilities.TimeTracker;
|
||||||
import org.hl7.fhir.utilities.TranslationServices;
|
import org.hl7.fhir.utilities.TranslationServices;
|
||||||
import org.hl7.fhir.utilities.npm.BasePackageCacheManager;
|
import org.hl7.fhir.utilities.npm.BasePackageCacheManager;
|
||||||
import org.hl7.fhir.utilities.npm.NpmPackage;
|
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||||
|
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationOptions;
|
import org.hl7.fhir.utilities.validation.ValidationOptions;
|
||||||
|
|
||||||
import com.google.gson.JsonSyntaxException;
|
import com.google.gson.JsonSyntaxException;
|
||||||
|
@ -168,6 +170,9 @@ public interface IWorkerContext {
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
public boolean isExamplesPackage() {
|
||||||
|
return !(id.startsWith("hl7.fhir.") && id.endsWith(".example"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PackageDetails extends PackageVersion {
|
public class PackageDetails extends PackageVersion {
|
||||||
|
@ -191,13 +196,14 @@ public interface IWorkerContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ICanonicalResourceLocator {
|
public interface ICanonicalResourceLocator {
|
||||||
void findResource(Object caller, String url); // if it can be found, put it in the context
|
void findResource(Object caller, String url); // if it can be found, put it in the context
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IContextResourceLoader {
|
public interface IContextResourceLoader {
|
||||||
/**
|
/**
|
||||||
* @return List of the resource types that shoud be loaded
|
* @return List of the resource types that should be loaded
|
||||||
*/
|
*/
|
||||||
String[] getTypes();
|
String[] getTypes();
|
||||||
|
|
||||||
|
@ -242,7 +248,6 @@ public interface IWorkerContext {
|
||||||
IContextResourceLoader getNewLoader(NpmPackage npm) throws JsonSyntaxException, IOException;
|
IContextResourceLoader getNewLoader(NpmPackage npm) throws JsonSyntaxException, IOException;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the versions of the definitions loaded in context
|
* Get the versions of the definitions loaded in context
|
||||||
* @return
|
* @return
|
||||||
|
@ -335,6 +340,7 @@ public interface IWorkerContext {
|
||||||
*/
|
*/
|
||||||
public <T extends Resource> T fetchResource(Class<T> class_, String uri);
|
public <T extends Resource> T fetchResource(Class<T> class_, String uri);
|
||||||
public <T extends Resource> T fetchResourceWithException(Class<T> class_, String uri) throws FHIRException;
|
public <T extends Resource> T fetchResourceWithException(Class<T> class_, String uri) throws FHIRException;
|
||||||
|
public <T extends Resource> T fetchResource(Class<T> class_, String uri, String version);
|
||||||
|
|
||||||
/** has the same functionality as fetchResource, but passes in information about the source of the
|
/** has the same functionality as fetchResource, but passes in information about the source of the
|
||||||
* reference (this may affect resolution of version)
|
* reference (this may affect resolution of version)
|
||||||
|
@ -476,6 +482,7 @@ public interface IWorkerContext {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public CodeSystem fetchCodeSystem(String system);
|
public CodeSystem fetchCodeSystem(String system);
|
||||||
|
public CodeSystem fetchCodeSystem(String system, String version);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if the underlying terminology service provider will do
|
* True if the underlying terminology service provider will do
|
||||||
|
@ -508,6 +515,14 @@ public interface IWorkerContext {
|
||||||
*/
|
*/
|
||||||
public ValueSetExpansionOutcome expandVS(ValueSet source, boolean cacheOk, boolean heiarchical);
|
public ValueSetExpansionOutcome expandVS(ValueSet source, boolean cacheOk, boolean heiarchical);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ValueSet Expansion - see $expand
|
||||||
|
*
|
||||||
|
* @param source
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public ValueSetExpansionOutcome expandVS(ValueSet source, boolean cacheOk, boolean heiarchical, boolean incompleteOk);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ValueSet Expansion - see $expand, but resolves the binding first
|
* ValueSet Expansion - see $expand, but resolves the binding first
|
||||||
*
|
*
|
||||||
|
@ -734,6 +749,8 @@ public interface IWorkerContext {
|
||||||
*/
|
*/
|
||||||
public ValidationResult validateCode(ValidationOptions options, Coding code, ValueSet vs);
|
public ValidationResult validateCode(ValidationOptions options, Coding code, ValueSet vs);
|
||||||
|
|
||||||
|
public ValidationResult validateCode(ValidationOptions options, Coding code, ValueSet vs, ValidationContextCarrier ctxt);
|
||||||
|
|
||||||
public void validateCodeBatch(ValidationOptions options, List<? extends CodingValidationRequest> codes, ValueSet vs);
|
public void validateCodeBatch(ValidationOptions options, List<? extends CodingValidationRequest> codes, ValueSet vs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -54,9 +54,7 @@ import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||||
import org.hl7.fhir.r5.conformance.ProfileUtilities;
|
import org.hl7.fhir.r5.conformance.ProfileUtilities;
|
||||||
import org.hl7.fhir.r5.conformance.ProfileUtilities.ProfileKnowledgeProvider;
|
import org.hl7.fhir.r5.conformance.ProfileUtilities.ProfileKnowledgeProvider;
|
||||||
import org.hl7.fhir.r5.context.CanonicalResourceManager.CanonicalResourceProxy;
|
import org.hl7.fhir.r5.context.CanonicalResourceManager.CanonicalResourceProxy;
|
||||||
import org.hl7.fhir.r5.context.IWorkerContext.PackageVersion;
|
|
||||||
import org.hl7.fhir.r5.context.IWorkerContext.ILoggingService.LogCategory;
|
import org.hl7.fhir.r5.context.IWorkerContext.ILoggingService.LogCategory;
|
||||||
import org.hl7.fhir.r5.context.SimpleWorkerContext.PackageResourceLoader;
|
|
||||||
import org.hl7.fhir.r5.formats.IParser;
|
import org.hl7.fhir.r5.formats.IParser;
|
||||||
import org.hl7.fhir.r5.formats.JsonParser;
|
import org.hl7.fhir.r5.formats.JsonParser;
|
||||||
import org.hl7.fhir.r5.formats.ParserType;
|
import org.hl7.fhir.r5.formats.ParserType;
|
||||||
|
@ -76,7 +74,7 @@ import org.hl7.fhir.r5.model.StructureMap;
|
||||||
import org.hl7.fhir.r5.model.StructureMap.StructureMapModelMode;
|
import org.hl7.fhir.r5.model.StructureMap.StructureMapModelMode;
|
||||||
import org.hl7.fhir.r5.model.StructureMap.StructureMapStructureComponent;
|
import org.hl7.fhir.r5.model.StructureMap.StructureMapStructureComponent;
|
||||||
import org.hl7.fhir.r5.terminologies.TerminologyClient;
|
import org.hl7.fhir.r5.terminologies.TerminologyClient;
|
||||||
import org.hl7.fhir.r5.utils.IResourceValidator;
|
import org.hl7.fhir.r5.utils.validation.IResourceValidator;
|
||||||
import org.hl7.fhir.r5.utils.XVerExtensionManager;
|
import org.hl7.fhir.r5.utils.XVerExtensionManager;
|
||||||
import org.hl7.fhir.utilities.CSFileInputStream;
|
import org.hl7.fhir.utilities.CSFileInputStream;
|
||||||
import org.hl7.fhir.utilities.TextFile;
|
import org.hl7.fhir.utilities.TextFile;
|
||||||
|
@ -85,15 +83,12 @@ import org.hl7.fhir.utilities.Utilities;
|
||||||
import org.hl7.fhir.utilities.VersionUtilities;
|
import org.hl7.fhir.utilities.VersionUtilities;
|
||||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||||
import org.hl7.fhir.utilities.npm.BasePackageCacheManager;
|
import org.hl7.fhir.utilities.npm.BasePackageCacheManager;
|
||||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
|
||||||
import org.hl7.fhir.utilities.npm.NpmPackage;
|
import org.hl7.fhir.utilities.npm.NpmPackage;
|
||||||
import org.hl7.fhir.utilities.npm.NpmPackage.PackageResourceInformation;
|
import org.hl7.fhir.utilities.npm.NpmPackage.PackageResourceInformation;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
|
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage.Source;
|
import org.hl7.fhir.utilities.validation.ValidationMessage.Source;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.parser.DataFormatException;
|
import ca.uhn.fhir.parser.DataFormatException;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -118,11 +118,13 @@ public abstract class ParserBase {
|
||||||
|
|
||||||
//FIXME: i18n should be done here
|
//FIXME: i18n should be done here
|
||||||
public void logError(int line, int col, String path, IssueType type, String message, IssueSeverity level) throws FHIRFormatError {
|
public void logError(int line, int col, String path, IssueType type, String message, IssueSeverity level) throws FHIRFormatError {
|
||||||
if (policy == ValidationPolicy.EVERYTHING) {
|
if (errors != null) {
|
||||||
ValidationMessage msg = new ValidationMessage(Source.InstanceValidator, type, line, col, path, message, level);
|
if (policy == ValidationPolicy.EVERYTHING) {
|
||||||
errors.add(msg);
|
ValidationMessage msg = new ValidationMessage(Source.InstanceValidator, type, line, col, path, message, level);
|
||||||
} else if (level == IssueSeverity.FATAL || (level == IssueSeverity.ERROR && policy == ValidationPolicy.QUICK))
|
errors.add(msg);
|
||||||
throw new FHIRFormatError(message+String.format(" at line %d col %d", line, col));
|
} else if (level == IssueSeverity.FATAL || (level == IssueSeverity.ERROR && policy == ValidationPolicy.QUICK))
|
||||||
|
throw new FHIRFormatError(message+String.format(" at line %d col %d", line, col));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -237,6 +237,7 @@ public class SHCParser extends ParserBase {
|
||||||
|
|
||||||
private static final int BUFFER_SIZE = 1024;
|
private static final int BUFFER_SIZE = 1024;
|
||||||
public static final String CURRENT_PACKAGE = "hl7.fhir.uv.shc-vaccination#0.6.2";
|
public static final String CURRENT_PACKAGE = "hl7.fhir.uv.shc-vaccination#0.6.2";
|
||||||
|
private static final int MAX_ALLOWED_SHC_LENGTH = 1195;
|
||||||
|
|
||||||
// todo: deal with chunking
|
// todo: deal with chunking
|
||||||
public static String decodeQRCode(String src) {
|
public static String decodeQRCode(String src) {
|
||||||
|
@ -253,10 +254,14 @@ public class SHCParser extends ParserBase {
|
||||||
return b.toString();
|
return b.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JWT decodeJWT(String jwt) throws IOException, DataFormatException {
|
public JWT decodeJWT(String jwt) throws IOException, DataFormatException {
|
||||||
if (jwt.startsWith("shc:/")) {
|
if (jwt.startsWith("shc:/")) {
|
||||||
jwt = decodeQRCode(jwt);
|
jwt = decodeQRCode(jwt);
|
||||||
}
|
}
|
||||||
|
if (jwt.length() > MAX_ALLOWED_SHC_LENGTH) {
|
||||||
|
logError(-1, -1, "jwt", IssueType.TOOLONG, "JWT Payload limit length is "+MAX_ALLOWED_SHC_LENGTH+" bytes for a single image - this has "+jwt.length()+" bytes", IssueSeverity.ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
String[] parts = splitToken(jwt);
|
String[] parts = splitToken(jwt);
|
||||||
byte[] headerJson;
|
byte[] headerJson;
|
||||||
byte[] payloadJson;
|
byte[] payloadJson;
|
||||||
|
|
|
@ -554,6 +554,10 @@ public abstract class CanonicalResource extends DomainResource {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getVersionedUrl() {
|
||||||
|
return hasVersion() ? getUrl()+"|"+getVersion() : getUrl();
|
||||||
|
}
|
||||||
|
|
||||||
// end addition
|
// end addition
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6716,6 +6716,10 @@ The MedicationUsage resource was previously called MedicationStatement.
|
||||||
* R5 Preview #1.
|
* R5 Preview #1.
|
||||||
*/
|
*/
|
||||||
_4_2_0,
|
_4_2_0,
|
||||||
|
/**
|
||||||
|
* R4B
|
||||||
|
*/
|
||||||
|
_4_3_0_CIBUILD,
|
||||||
/**
|
/**
|
||||||
* R5 Preview #2.
|
* R5 Preview #2.
|
||||||
*/
|
*/
|
||||||
|
@ -6733,8 +6737,6 @@ The MedicationUsage resource was previously called MedicationStatement.
|
||||||
*/
|
*/
|
||||||
NULL;
|
NULL;
|
||||||
|
|
||||||
public static final FHIRVersion R4B = FHIRVersion._4_1_0;
|
|
||||||
|
|
||||||
public static FHIRVersion fromCode(String codeString) throws FHIRException {
|
public static FHIRVersion fromCode(String codeString) throws FHIRException {
|
||||||
if (codeString == null || "".equals(codeString))
|
if (codeString == null || "".equals(codeString))
|
||||||
return null;
|
return null;
|
||||||
|
@ -6788,6 +6790,8 @@ The MedicationUsage resource was previously called MedicationStatement.
|
||||||
return _4_1_0;
|
return _4_1_0;
|
||||||
if ("4.2.0".equals(codeString))
|
if ("4.2.0".equals(codeString))
|
||||||
return _4_2_0;
|
return _4_2_0;
|
||||||
|
if ("4.3.0-CIBUILD".equals(codeString))
|
||||||
|
return _4_3_0_CIBUILD;
|
||||||
if ("4.4.0".equals(codeString))
|
if ("4.4.0".equals(codeString))
|
||||||
return _4_4_0;
|
return _4_4_0;
|
||||||
if ("4.5.0".equals(codeString))
|
if ("4.5.0".equals(codeString))
|
||||||
|
@ -6823,6 +6827,7 @@ The MedicationUsage resource was previously called MedicationStatement.
|
||||||
case _4_0_1: return "4.0.1";
|
case _4_0_1: return "4.0.1";
|
||||||
case _4_1_0: return "4.1.0";
|
case _4_1_0: return "4.1.0";
|
||||||
case _4_2_0: return "4.2.0";
|
case _4_2_0: return "4.2.0";
|
||||||
|
case _4_3_0_CIBUILD: return "4.3.0-CIBUILD";
|
||||||
case _4_4_0: return "4.4.0";
|
case _4_4_0: return "4.4.0";
|
||||||
case _4_5_0: return "4.5.0";
|
case _4_5_0: return "4.5.0";
|
||||||
case _4_6_0: return "4.6.0";
|
case _4_6_0: return "4.6.0";
|
||||||
|
@ -6857,6 +6862,7 @@ The MedicationUsage resource was previously called MedicationStatement.
|
||||||
case _4_0_1: return "http://hl7.org/fhir/FHIR-version";
|
case _4_0_1: return "http://hl7.org/fhir/FHIR-version";
|
||||||
case _4_1_0: return "http://hl7.org/fhir/FHIR-version";
|
case _4_1_0: return "http://hl7.org/fhir/FHIR-version";
|
||||||
case _4_2_0: return "http://hl7.org/fhir/FHIR-version";
|
case _4_2_0: return "http://hl7.org/fhir/FHIR-version";
|
||||||
|
case _4_3_0_CIBUILD: return "http://hl7.org/fhir/FHIR-version";
|
||||||
case _4_4_0: return "http://hl7.org/fhir/FHIR-version";
|
case _4_4_0: return "http://hl7.org/fhir/FHIR-version";
|
||||||
case _4_5_0: return "http://hl7.org/fhir/FHIR-version";
|
case _4_5_0: return "http://hl7.org/fhir/FHIR-version";
|
||||||
case _4_6_0: return "http://hl7.org/fhir/FHIR-version";
|
case _4_6_0: return "http://hl7.org/fhir/FHIR-version";
|
||||||
|
@ -6891,6 +6897,7 @@ The MedicationUsage resource was previously called MedicationStatement.
|
||||||
case _4_0_1: return "FHIR Release 4 (Normative + STU) with 1 technical errata.";
|
case _4_0_1: return "FHIR Release 4 (Normative + STU) with 1 technical errata.";
|
||||||
case _4_1_0: return "Interim Version.";
|
case _4_1_0: return "Interim Version.";
|
||||||
case _4_2_0: return "R5 Preview #1.";
|
case _4_2_0: return "R5 Preview #1.";
|
||||||
|
case _4_3_0_CIBUILD: return "R4B CIBuild";
|
||||||
case _4_4_0: return "R5 Preview #2.";
|
case _4_4_0: return "R5 Preview #2.";
|
||||||
case _4_5_0: return "R5 Preview #3.";
|
case _4_5_0: return "R5 Preview #3.";
|
||||||
case _4_6_0: return "R5 Draft Ballot.";
|
case _4_6_0: return "R5 Draft Ballot.";
|
||||||
|
@ -6925,6 +6932,7 @@ The MedicationUsage resource was previously called MedicationStatement.
|
||||||
case _4_0_1: return "4.0.1";
|
case _4_0_1: return "4.0.1";
|
||||||
case _4_1_0: return "4.1.0";
|
case _4_1_0: return "4.1.0";
|
||||||
case _4_2_0: return "4.2.0";
|
case _4_2_0: return "4.2.0";
|
||||||
|
case _4_3_0_CIBUILD: return "4.3.0-CIBUILD";
|
||||||
case _4_4_0: return "4.4.0";
|
case _4_4_0: return "4.4.0";
|
||||||
case _4_5_0: return "4.5.0";
|
case _4_5_0: return "4.5.0";
|
||||||
case _4_6_0: return "4.6.0";
|
case _4_6_0: return "4.6.0";
|
||||||
|
@ -6988,6 +6996,8 @@ public String toCode(int len) {
|
||||||
return true;
|
return true;
|
||||||
if ("4.2.0".equals(codeString))
|
if ("4.2.0".equals(codeString))
|
||||||
return true;
|
return true;
|
||||||
|
if ("4.3.0-CIBUILD".equals(codeString))
|
||||||
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6998,7 +7008,7 @@ public String toCode(int len) {
|
||||||
|
|
||||||
|
|
||||||
public boolean isR4B() {
|
public boolean isR4B() {
|
||||||
return toCode().startsWith("4.1");
|
return toCode().startsWith("4.1") || toCode().startsWith("4.3");
|
||||||
}
|
}
|
||||||
|
|
||||||
// end addition
|
// end addition
|
||||||
|
@ -7059,6 +7069,8 @@ public String toCode(int len) {
|
||||||
return FHIRVersion._4_1_0;
|
return FHIRVersion._4_1_0;
|
||||||
if ("4.2.0".equals(codeString))
|
if ("4.2.0".equals(codeString))
|
||||||
return FHIRVersion._4_2_0;
|
return FHIRVersion._4_2_0;
|
||||||
|
if ("4.3.0-CIBUILD".equals(codeString))
|
||||||
|
return FHIRVersion._4_3_0_CIBUILD;
|
||||||
if ("4.4.0".equals(codeString))
|
if ("4.4.0".equals(codeString))
|
||||||
return FHIRVersion._4_4_0;
|
return FHIRVersion._4_4_0;
|
||||||
if ("4.5.0".equals(codeString))
|
if ("4.5.0".equals(codeString))
|
||||||
|
@ -7125,6 +7137,8 @@ public String toCode(int len) {
|
||||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_1_0);
|
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_1_0);
|
||||||
if ("4.2.0".equals(codeString))
|
if ("4.2.0".equals(codeString))
|
||||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_2_0);
|
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_2_0);
|
||||||
|
if ("4.3.0-CIBUILD".equals(codeString))
|
||||||
|
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_3_0_CIBUILD);
|
||||||
if ("4.4.0".equals(codeString))
|
if ("4.4.0".equals(codeString))
|
||||||
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_4_0);
|
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_4_0);
|
||||||
if ("4.5.0".equals(codeString))
|
if ("4.5.0".equals(codeString))
|
||||||
|
@ -7184,6 +7198,8 @@ public String toCode(int len) {
|
||||||
return "4.1.0";
|
return "4.1.0";
|
||||||
if (code == FHIRVersion._4_2_0)
|
if (code == FHIRVersion._4_2_0)
|
||||||
return "4.2.0";
|
return "4.2.0";
|
||||||
|
if (code == FHIRVersion._4_3_0_CIBUILD)
|
||||||
|
return "4.3.0-CIBUILD";
|
||||||
if (code == FHIRVersion._4_4_0)
|
if (code == FHIRVersion._4_4_0)
|
||||||
return "4.4.0";
|
return "4.4.0";
|
||||||
if (code == FHIRVersion._4_5_0)
|
if (code == FHIRVersion._4_5_0)
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.hl7.fhir.r5.model.CapabilityStatement.ResourceInteractionComponent;
|
||||||
import org.hl7.fhir.r5.model.CapabilityStatement.SystemInteractionComponent;
|
import org.hl7.fhir.r5.model.CapabilityStatement.SystemInteractionComponent;
|
||||||
import org.hl7.fhir.r5.model.CapabilityStatement.SystemRestfulInteraction;
|
import org.hl7.fhir.r5.model.CapabilityStatement.SystemRestfulInteraction;
|
||||||
import org.hl7.fhir.r5.model.CapabilityStatement.TypeRestfulInteraction;
|
import org.hl7.fhir.r5.model.CapabilityStatement.TypeRestfulInteraction;
|
||||||
|
import org.hl7.fhir.r5.model.CanonicalType;
|
||||||
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
|
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
|
||||||
import org.hl7.fhir.r5.renderers.utils.BaseWrappers.ResourceWrapper;
|
import org.hl7.fhir.r5.renderers.utils.BaseWrappers.ResourceWrapper;
|
||||||
import org.hl7.fhir.r5.renderers.utils.Resolver.ResourceContext;
|
import org.hl7.fhir.r5.renderers.utils.Resolver.ResourceContext;
|
||||||
|
@ -79,12 +80,41 @@ public class CapabilityStatementRenderer extends ResourceRenderer {
|
||||||
if (hasHistory)
|
if (hasHistory)
|
||||||
tr.th().b().attribute("title", "GET changes for all resources of the type (history interaction on type)").tx("History");
|
tr.th().b().attribute("title", "GET changes for all resources of the type (history interaction on type)").tx("History");
|
||||||
|
|
||||||
|
XhtmlNode profCell = null;
|
||||||
|
boolean hasProf = false;
|
||||||
|
boolean hasSupProf = false;
|
||||||
for (CapabilityStatementRestResourceComponent r : rest.getResource()) {
|
for (CapabilityStatementRestResourceComponent r : rest.getResource()) {
|
||||||
tr = t.tr();
|
tr = t.tr();
|
||||||
tr.td().addText(r.getType());
|
tr.td().addText(r.getType());
|
||||||
if (r.hasProfile()) {
|
|
||||||
tr.td().ah(r.getProfile()).addText(r.getProfile());
|
//Show profiles
|
||||||
|
profCell = tr.td();
|
||||||
|
hasProf = r.hasProfile();
|
||||||
|
hasSupProf = r.hasSupportedProfile();
|
||||||
|
if ((!hasProf) && (!hasSupProf)) {
|
||||||
|
profCell.nbsp();
|
||||||
}
|
}
|
||||||
|
else if (hasProf) {
|
||||||
|
profCell.ah(r.getProfile()).addText(r.getProfile());
|
||||||
|
if (hasSupProf) {
|
||||||
|
profCell.br();
|
||||||
|
profCell.addText("Additional supported profiles:");
|
||||||
|
for (CanonicalType sp: r.getSupportedProfile()) {
|
||||||
|
profCell.br();
|
||||||
|
profCell.nbsp().nbsp();
|
||||||
|
profCell.ah(sp.getValue()).addText(sp.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else { //Case of only supported profiles
|
||||||
|
profCell.addText("Supported profiles:");
|
||||||
|
for (CanonicalType sp: r.getSupportedProfile()) {
|
||||||
|
profCell.br();
|
||||||
|
profCell.nbsp().nbsp();
|
||||||
|
profCell.ah(sp.getValue()).addText(sp.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Show capabilities
|
||||||
tr.td().addText(showOp(r, TypeRestfulInteraction.READ));
|
tr.td().addText(showOp(r, TypeRestfulInteraction.READ));
|
||||||
if (hasVRead)
|
if (hasVRead)
|
||||||
tr.td().addText(showOp(r, TypeRestfulInteraction.VREAD));
|
tr.td().addText(showOp(r, TypeRestfulInteraction.VREAD));
|
||||||
|
|
|
@ -94,8 +94,10 @@ public class CodeSystemRenderer extends TerminologyRenderer {
|
||||||
private void generateProperties(XhtmlNode x, CodeSystem cs) {
|
private void generateProperties(XhtmlNode x, CodeSystem cs) {
|
||||||
if (cs.hasProperty()) {
|
if (cs.hasProperty()) {
|
||||||
boolean hasRendered = false;
|
boolean hasRendered = false;
|
||||||
|
boolean hasURI = false;
|
||||||
for (PropertyComponent p : cs.getProperty()) {
|
for (PropertyComponent p : cs.getProperty()) {
|
||||||
hasRendered = hasRendered || !p.getCode().equals(ToolingExtensions.getPresentation(p, p.getCodeElement()));
|
hasRendered = hasRendered || !p.getCode().equals(ToolingExtensions.getPresentation(p, p.getCodeElement()));
|
||||||
|
hasURI = hasURI || p.hasUri();
|
||||||
}
|
}
|
||||||
|
|
||||||
x.para().b().tx(getContext().getWorker().translator().translate("xhtml-gen-cs", "Properties", getContext().getLang()));
|
x.para().b().tx(getContext().getWorker().translator().translate("xhtml-gen-cs", "Properties", getContext().getLang()));
|
||||||
|
@ -105,18 +107,22 @@ public class CodeSystemRenderer extends TerminologyRenderer {
|
||||||
tr.td().b().tx(getContext().getWorker().translator().translate("xhtml-gen-cs", "Name", getContext().getLang()));
|
tr.td().b().tx(getContext().getWorker().translator().translate("xhtml-gen-cs", "Name", getContext().getLang()));
|
||||||
}
|
}
|
||||||
tr.td().b().tx(getContext().getWorker().translator().translate("xhtml-gen-cs", "Code", getContext().getLang()));
|
tr.td().b().tx(getContext().getWorker().translator().translate("xhtml-gen-cs", "Code", getContext().getLang()));
|
||||||
tr.td().b().tx(getContext().getWorker().translator().translate("xhtml-gen-cs", "URL", getContext().getLang()));
|
if (hasURI) {
|
||||||
tr.td().b().tx(getContext().getWorker().translator().translate("xhtml-gen-cs", "Description", getContext().getLang()));
|
tr.td().b().tx(getContext().getWorker().translator().translate("xhtml-gen-cs", "URL", getContext().getLang()));
|
||||||
|
}
|
||||||
tr.td().b().tx(getContext().getWorker().translator().translate("xhtml-gen-cs", "Type", getContext().getLang()));
|
tr.td().b().tx(getContext().getWorker().translator().translate("xhtml-gen-cs", "Type", getContext().getLang()));
|
||||||
|
tr.td().b().tx(getContext().getWorker().translator().translate("xhtml-gen-cs", "Description", getContext().getLang()));
|
||||||
for (PropertyComponent p : cs.getProperty()) {
|
for (PropertyComponent p : cs.getProperty()) {
|
||||||
tr = tbl.tr();
|
tr = tbl.tr();
|
||||||
if (hasRendered) {
|
if (hasRendered) {
|
||||||
tr.td().tx(ToolingExtensions.getPresentation(p, p.getCodeElement()));
|
tr.td().tx(ToolingExtensions.getPresentation(p, p.getCodeElement()));
|
||||||
}
|
}
|
||||||
tr.td().tx(p.getCode());
|
tr.td().tx(p.getCode());
|
||||||
tr.td().tx(p.getUri());
|
if (hasURI) {
|
||||||
tr.td().tx(p.getDescription());
|
tr.td().tx(p.getUri());
|
||||||
|
}
|
||||||
tr.td().tx(p.hasType() ? p.getType().toCode() : "");
|
tr.td().tx(p.hasType() ? p.getType().toCode() : "");
|
||||||
|
tr.td().tx(p.getDescription());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +132,7 @@ public class CodeSystemRenderer extends TerminologyRenderer {
|
||||||
if (cs.getContent() == CodeSystemContentMode.COMPLETE)
|
if (cs.getContent() == CodeSystemContentMode.COMPLETE)
|
||||||
p.tx(getContext().getWorker().translator().translateAndFormat("xhtml-gen-cs", getContext().getLang(), "This code system %s defines the following codes", cs.getUrl())+":");
|
p.tx(getContext().getWorker().translator().translateAndFormat("xhtml-gen-cs", getContext().getLang(), "This code system %s defines the following codes", cs.getUrl())+":");
|
||||||
else if (cs.getContent() == CodeSystemContentMode.EXAMPLE)
|
else if (cs.getContent() == CodeSystemContentMode.EXAMPLE)
|
||||||
p.tx(getContext().getWorker().translator().translateAndFormat("xhtml-gen-cs", getContext().getLang(), "This code system %s defines many codes, of which the following are some examples", cs.getUrl())+":");
|
p.tx(getContext().getWorker().translator().translateAndFormat("xhtml-gen-cs", getContext().getLang(), "This code system %s defines some example codes", cs.getUrl())+":");
|
||||||
else if (cs.getContent() == CodeSystemContentMode.FRAGMENT )
|
else if (cs.getContent() == CodeSystemContentMode.FRAGMENT )
|
||||||
p.tx(getContext().getWorker().translator().translateAndFormat("xhtml-gen-cs", getContext().getLang(), "This code system %s defines many codes, of which the following are a subset", cs.getUrl())+":");
|
p.tx(getContext().getWorker().translator().translateAndFormat("xhtml-gen-cs", getContext().getLang(), "This code system %s defines many codes, of which the following are a subset", cs.getUrl())+":");
|
||||||
else if (cs.getContent() == CodeSystemContentMode.NOTPRESENT ) {
|
else if (cs.getContent() == CodeSystemContentMode.NOTPRESENT ) {
|
||||||
|
@ -141,6 +147,7 @@ public class CodeSystemRenderer extends TerminologyRenderer {
|
||||||
boolean hierarchy = false;
|
boolean hierarchy = false;
|
||||||
boolean version = false;
|
boolean version = false;
|
||||||
boolean ignoreStatus = false;
|
boolean ignoreStatus = false;
|
||||||
|
boolean isSupplement = cs.getContent() == CodeSystemContentMode.SUPPLEMENT;
|
||||||
List<PropertyComponent> properties = new ArrayList<>();
|
List<PropertyComponent> properties = new ArrayList<>();
|
||||||
for (PropertyComponent cp : cs.getProperty()) {
|
for (PropertyComponent cp : cs.getProperty()) {
|
||||||
if (showPropertyInTable(cp)) {
|
if (showPropertyInTable(cp)) {
|
||||||
|
@ -170,7 +177,7 @@ public class CodeSystemRenderer extends TerminologyRenderer {
|
||||||
List<String> langs = new ArrayList<>();
|
List<String> langs = new ArrayList<>();
|
||||||
addMapHeaders(addTableHeaderRowStandard(t, hierarchy, display, definitions, commentS, version, deprecated, properties, null, false), maps);
|
addMapHeaders(addTableHeaderRowStandard(t, hierarchy, display, definitions, commentS, version, deprecated, properties, null, false), maps);
|
||||||
for (ConceptDefinitionComponent c : csNav.getConcepts(null)) {
|
for (ConceptDefinitionComponent c : csNav.getConcepts(null)) {
|
||||||
hasExtensions = addDefineRowToTable(t, c, 0, hierarchy, display, definitions, commentS, version, deprecated, maps, cs.getUrl(), cs, properties, csNav, langs) || hasExtensions;
|
hasExtensions = addDefineRowToTable(t, c, 0, hierarchy, display, definitions, commentS, version, deprecated, maps, cs.getUrl(), cs, properties, csNav, langs, isSupplement) || hasExtensions;
|
||||||
}
|
}
|
||||||
if (langs.size() > 0) {
|
if (langs.size() > 0) {
|
||||||
Collections.sort(langs);
|
Collections.sort(langs);
|
||||||
|
@ -223,10 +230,10 @@ public class CodeSystemRenderer extends TerminologyRenderer {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
String uri = cp.getUri();
|
String uri = cp.getUri();
|
||||||
String code = null;
|
|
||||||
if (Utilities.noString(uri)){
|
if (Utilities.noString(uri)){
|
||||||
return false;
|
return true; // do we always want to render properties in this case? Not sure...
|
||||||
}
|
}
|
||||||
|
String code = null;
|
||||||
if (uri.contains("#")) {
|
if (uri.contains("#")) {
|
||||||
code = uri.substring(uri.indexOf("#")+1);
|
code = uri.substring(uri.indexOf("#")+1);
|
||||||
uri = uri.substring(0, uri.indexOf("#"));
|
uri = uri.substring(0, uri.indexOf("#"));
|
||||||
|
@ -290,7 +297,7 @@ public class CodeSystemRenderer extends TerminologyRenderer {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private boolean addDefineRowToTable(XhtmlNode t, ConceptDefinitionComponent c, int level, boolean hasHierarchy, boolean hasDisplay, boolean hasDefinitions, boolean comment, boolean version, boolean deprecated, List<UsedConceptMap> maps, String system, CodeSystem cs, List<PropertyComponent> properties, CodeSystemNavigator csNav, List<String> langs) throws FHIRFormatError, DefinitionException, IOException {
|
private boolean addDefineRowToTable(XhtmlNode t, ConceptDefinitionComponent c, int level, boolean hasHierarchy, boolean hasDisplay, boolean hasDefinitions, boolean comment, boolean version, boolean deprecated, List<UsedConceptMap> maps, String system, CodeSystem cs, List<PropertyComponent> properties, CodeSystemNavigator csNav, List<String> langs, boolean isSupplement) throws FHIRFormatError, DefinitionException, IOException {
|
||||||
boolean hasExtensions = false;
|
boolean hasExtensions = false;
|
||||||
XhtmlNode tr = t.tr();
|
XhtmlNode tr = t.tr();
|
||||||
XhtmlNode td = tr.td();
|
XhtmlNode td = tr.td();
|
||||||
|
@ -300,7 +307,12 @@ public class CodeSystemRenderer extends TerminologyRenderer {
|
||||||
String s = Utilities.padLeft("", '\u00A0', level*2);
|
String s = Utilities.padLeft("", '\u00A0', level*2);
|
||||||
td.addText(s);
|
td.addText(s);
|
||||||
}
|
}
|
||||||
td.attribute("style", "white-space:nowrap").addText(c.getCode());
|
String link = isSupplement ? getLinkForCode(cs.getSupplements(), null, c.getCode()) : null;
|
||||||
|
if (link != null) {
|
||||||
|
td.ah(link).attribute("style", "white-space:nowrap").addText(c.getCode());
|
||||||
|
} else {
|
||||||
|
td.attribute("style", "white-space:nowrap").addText(c.getCode());
|
||||||
|
}
|
||||||
XhtmlNode a;
|
XhtmlNode a;
|
||||||
if (c.hasCodeElement()) {
|
if (c.hasCodeElement()) {
|
||||||
td.an(cs.getId()+"-" + Utilities.nmtokenize(c.getCode()));
|
td.an(cs.getId()+"-" + Utilities.nmtokenize(c.getCode()));
|
||||||
|
@ -450,7 +462,7 @@ public class CodeSystemRenderer extends TerminologyRenderer {
|
||||||
}
|
}
|
||||||
List<ConceptDefinitionComponent> ocl = csNav.getOtherChildren(c);
|
List<ConceptDefinitionComponent> ocl = csNav.getOtherChildren(c);
|
||||||
for (ConceptDefinitionComponent cc : csNav.getConcepts(c)) {
|
for (ConceptDefinitionComponent cc : csNav.getConcepts(c)) {
|
||||||
hasExtensions = addDefineRowToTable(t, cc, level+1, hasHierarchy, hasDisplay, hasDefinitions, comment, version, deprecated, maps, system, cs, properties, csNav, langs) || hasExtensions;
|
hasExtensions = addDefineRowToTable(t, cc, level+1, hasHierarchy, hasDisplay, hasDefinitions, comment, version, deprecated, maps, system, cs, properties, csNav, langs, isSupplement) || hasExtensions;
|
||||||
}
|
}
|
||||||
for (ConceptDefinitionComponent cc : ocl) {
|
for (ConceptDefinitionComponent cc : ocl) {
|
||||||
tr = t.tr();
|
tr = t.tr();
|
||||||
|
|
|
@ -2,7 +2,18 @@ package org.hl7.fhir.r5.renderers;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.NumberFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.time.format.FormatStyle;
|
||||||
|
import java.util.Currency;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import org.hl7.fhir.exceptions.DefinitionException;
|
import org.hl7.fhir.exceptions.DefinitionException;
|
||||||
import org.hl7.fhir.exceptions.FHIRException;
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
|
@ -29,11 +40,14 @@ import org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem;
|
||||||
import org.hl7.fhir.r5.model.DataType;
|
import org.hl7.fhir.r5.model.DataType;
|
||||||
import org.hl7.fhir.r5.model.DateTimeType;
|
import org.hl7.fhir.r5.model.DateTimeType;
|
||||||
import org.hl7.fhir.r5.model.Enumeration;
|
import org.hl7.fhir.r5.model.Enumeration;
|
||||||
|
import org.hl7.fhir.r5.model.Expression;
|
||||||
import org.hl7.fhir.r5.model.Extension;
|
import org.hl7.fhir.r5.model.Extension;
|
||||||
import org.hl7.fhir.r5.model.HumanName;
|
import org.hl7.fhir.r5.model.HumanName;
|
||||||
import org.hl7.fhir.r5.model.HumanName.NameUse;
|
import org.hl7.fhir.r5.model.HumanName.NameUse;
|
||||||
|
import org.hl7.fhir.r5.model.IdType;
|
||||||
import org.hl7.fhir.r5.model.Identifier;
|
import org.hl7.fhir.r5.model.Identifier;
|
||||||
import org.hl7.fhir.r5.model.InstantType;
|
import org.hl7.fhir.r5.model.MarkdownType;
|
||||||
|
import org.hl7.fhir.r5.model.Money;
|
||||||
import org.hl7.fhir.r5.model.Period;
|
import org.hl7.fhir.r5.model.Period;
|
||||||
import org.hl7.fhir.r5.model.PrimitiveType;
|
import org.hl7.fhir.r5.model.PrimitiveType;
|
||||||
import org.hl7.fhir.r5.model.Quantity;
|
import org.hl7.fhir.r5.model.Quantity;
|
||||||
|
@ -63,6 +77,9 @@ import org.hl7.fhir.utilities.validation.ValidationOptions;
|
||||||
import org.hl7.fhir.utilities.xhtml.NodeType;
|
import org.hl7.fhir.utilities.xhtml.NodeType;
|
||||||
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
||||||
import org.hl7.fhir.utilities.xhtml.XhtmlParser;
|
import org.hl7.fhir.utilities.xhtml.XhtmlParser;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
||||||
|
|
||||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator;
|
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator;
|
||||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece;
|
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece;
|
||||||
|
|
||||||
|
@ -372,6 +389,8 @@ public class DataRenderer extends Renderer {
|
||||||
return displayTiming((Timing) type);
|
return displayTiming((Timing) type);
|
||||||
} else if (type instanceof SampledData) {
|
} else if (type instanceof SampledData) {
|
||||||
return displaySampledData((SampledData) type);
|
return displaySampledData((SampledData) type);
|
||||||
|
} else if (type.isDateTime()) {
|
||||||
|
return displayDateTime((BaseDateTimeType) type);
|
||||||
} else if (type.isPrimitive()) {
|
} else if (type.isPrimitive()) {
|
||||||
return type.primitiveValue();
|
return type.primitiveValue();
|
||||||
} else {
|
} else {
|
||||||
|
@ -379,11 +398,58 @@ public class DataRenderer extends Renderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String displayDateTime(BaseDateTimeType type) {
|
||||||
|
if (!type.hasPrimitiveValue()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// relevant inputs in rendering context:
|
||||||
|
// timeZone, dateTimeFormat, locale, mode
|
||||||
|
// timezone - application specified timezone to use.
|
||||||
|
// null = default to the time of the date/time itself
|
||||||
|
// dateTimeFormat - application specified format for date times
|
||||||
|
// null = default to ... depends on mode
|
||||||
|
// mode - if rendering mode is technical, format defaults to XML format
|
||||||
|
// locale - otherwise, format defaults to SHORT for the Locale (which defaults to default Locale)
|
||||||
|
if (isOnlyDate(type.getPrecision())) {
|
||||||
|
DateTimeFormatter fmt = context.getDateFormat();
|
||||||
|
if (fmt == null) {
|
||||||
|
if (context.isTechnicalMode()) {
|
||||||
|
fmt = DateTimeFormatter.ISO_DATE;
|
||||||
|
} else {
|
||||||
|
fmt = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT).withLocale(context.getLocale());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalDate date = LocalDate.of(type.getYear(), type.getMonth()+1, type.getDay());
|
||||||
|
return fmt.format(date);
|
||||||
|
}
|
||||||
|
|
||||||
|
DateTimeFormatter fmt = context.getDateTimeFormat();
|
||||||
|
if (fmt == null) {
|
||||||
|
if (context.isTechnicalMode()) {
|
||||||
|
fmt = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
|
||||||
|
} else {
|
||||||
|
fmt = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT).withLocale(context.getLocale());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ZonedDateTime zdt = ZonedDateTime.parse(type.primitiveValue());
|
||||||
|
ZoneId zone = context.getTimeZoneId();
|
||||||
|
if (zone != null) {
|
||||||
|
zdt = zdt.withZoneSameInstant(zone);
|
||||||
|
}
|
||||||
|
return fmt.format(zdt);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isOnlyDate(TemporalPrecisionEnum temporalPrecisionEnum) {
|
||||||
|
return temporalPrecisionEnum == TemporalPrecisionEnum.YEAR || temporalPrecisionEnum == TemporalPrecisionEnum.MONTH || temporalPrecisionEnum == TemporalPrecisionEnum.DAY;
|
||||||
|
}
|
||||||
|
|
||||||
public String display(BaseWrapper type) {
|
public String display(BaseWrapper type) {
|
||||||
return "to do";
|
return "to do";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(XhtmlNode x, BaseWrapper type) {
|
public void render(XhtmlNode x, BaseWrapper type) throws FHIRFormatError, DefinitionException, IOException {
|
||||||
Base base = null;
|
Base base = null;
|
||||||
try {
|
try {
|
||||||
base = type.getBase();
|
base = type.getBase();
|
||||||
|
@ -398,7 +464,7 @@ public class DataRenderer extends Renderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderBase(XhtmlNode x, Base b) {
|
public void renderBase(XhtmlNode x, Base b) throws FHIRFormatError, DefinitionException, IOException {
|
||||||
if (b instanceof DataType) {
|
if (b instanceof DataType) {
|
||||||
render(x, (DataType) b);
|
render(x, (DataType) b);
|
||||||
} else {
|
} else {
|
||||||
|
@ -406,9 +472,9 @@ public class DataRenderer extends Renderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(XhtmlNode x, DataType type) {
|
public void render(XhtmlNode x, DataType type) throws FHIRFormatError, DefinitionException, IOException {
|
||||||
if (type instanceof DateTimeType) {
|
if (type instanceof BaseDateTimeType) {
|
||||||
renderDateTime(x, (DateTimeType) type);
|
x.tx(displayDateTime((BaseDateTimeType) type));
|
||||||
} else if (type instanceof UriType) {
|
} else if (type instanceof UriType) {
|
||||||
renderUri(x, (UriType) type);
|
renderUri(x, (UriType) type);
|
||||||
} else if (type instanceof Annotation) {
|
} else if (type instanceof Annotation) {
|
||||||
|
@ -423,6 +489,10 @@ public class DataRenderer extends Renderer {
|
||||||
renderHumanName(x, (HumanName) type);
|
renderHumanName(x, (HumanName) type);
|
||||||
} else if (type instanceof Address) {
|
} else if (type instanceof Address) {
|
||||||
renderAddress(x, (Address) type);
|
renderAddress(x, (Address) type);
|
||||||
|
} else if (type instanceof Expression) {
|
||||||
|
renderExpression(x, (Expression) type);
|
||||||
|
} else if (type instanceof Money) {
|
||||||
|
renderMoney(x, (Money) type);
|
||||||
} else if (type instanceof ContactPoint) {
|
} else if (type instanceof ContactPoint) {
|
||||||
renderContactPoint(x, (ContactPoint) type);
|
renderContactPoint(x, (ContactPoint) type);
|
||||||
} else if (type instanceof Quantity) {
|
} else if (type instanceof Quantity) {
|
||||||
|
@ -437,10 +507,8 @@ public class DataRenderer extends Renderer {
|
||||||
renderSampledData(x, (SampledData) type);
|
renderSampledData(x, (SampledData) type);
|
||||||
} else if (type instanceof Reference) {
|
} else if (type instanceof Reference) {
|
||||||
renderReference(x, (Reference) type);
|
renderReference(x, (Reference) type);
|
||||||
} else if (type instanceof InstantType) {
|
} else if (type instanceof MarkdownType) {
|
||||||
x.tx(((InstantType) type).toHumanDisplay());
|
addMarkdown(x, ((MarkdownType) type).asStringValue());
|
||||||
} else if (type instanceof BaseDateTimeType) {
|
|
||||||
x.tx(((BaseDateTimeType) type).toHumanDisplay());
|
|
||||||
} else if (type.isPrimitive()) {
|
} else if (type.isPrimitive()) {
|
||||||
x.tx(type.primitiveValue());
|
x.tx(type.primitiveValue());
|
||||||
} else {
|
} else {
|
||||||
|
@ -460,22 +528,24 @@ public class DataRenderer extends Renderer {
|
||||||
|
|
||||||
public void renderDateTime(XhtmlNode x, Base e) {
|
public void renderDateTime(XhtmlNode x, Base e) {
|
||||||
if (e.hasPrimitiveValue()) {
|
if (e.hasPrimitiveValue()) {
|
||||||
x.addText(((DateTimeType) e).toHumanDisplay());
|
x.addText(displayDateTime((DateTimeType) e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderDateTime(XhtmlNode x, String s) {
|
public void renderDateTime(XhtmlNode x, String s) {
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
DateTimeType dt = new DateTimeType(s);
|
DateTimeType dt = new DateTimeType(s);
|
||||||
x.addText(dt.toHumanDisplay());
|
x.addText(displayDateTime(dt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renderUri(XhtmlNode x, UriType uri) {
|
protected void renderUri(XhtmlNode x, UriType uri) {
|
||||||
if (uri.getValue().startsWith("mailto:")) {
|
if (uri.getValue().startsWith("mailto:")) {
|
||||||
x.ah(uri.getValue()).addText(uri.getValue().substring(7));
|
x.ah(uri.getValue()).addText(uri.getValue().substring(7));
|
||||||
} else {
|
} else if (Utilities.isAbsoluteUrlLinkable(uri.getValue()) && !(uri instanceof IdType)) {
|
||||||
x.ah(uri.getValue()).addText(uri.getValue());
|
x.ah(uri.getValue()).addText(uri.getValue());
|
||||||
|
} else {
|
||||||
|
x.addText(uri.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -641,6 +711,38 @@ public class DataRenderer extends Renderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getLinkForCode(String system, String version, String code) {
|
||||||
|
if ("http://snomed.info/sct".equals(system)) {
|
||||||
|
if (!Utilities.noString(code)) {
|
||||||
|
return "http://snomed.info/id/"+code;
|
||||||
|
} else {
|
||||||
|
return "https://browser.ihtsdotools.org/";
|
||||||
|
}
|
||||||
|
} else if ("http://loinc.org".equals(system)) {
|
||||||
|
if (!Utilities.noString(code)) {
|
||||||
|
return "https://loinc.org/"+code;
|
||||||
|
} else {
|
||||||
|
return "https://loinc.org/";
|
||||||
|
}
|
||||||
|
} else if ("http://www.nlm.nih.gov/research/umls/rxnorm".equals(system)) {
|
||||||
|
if (!Utilities.noString(code)) {
|
||||||
|
return "https://mor.nlm.nih.gov/RxNav/search?searchBy=RXCUI&searchTerm="+code;
|
||||||
|
} else {
|
||||||
|
return "https://www.nlm.nih.gov/research/umls/rxnorm/index.html";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
CodeSystem cs = context.getWorker().fetchCodeSystem(system, version);
|
||||||
|
if (cs != null && cs.hasUserData("path")) {
|
||||||
|
if (!Utilities.noString(code)) {
|
||||||
|
return cs.getUserString("path")+"#"+Utilities.nmtokenize(code);
|
||||||
|
} else {
|
||||||
|
return cs.getUserString("path");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
protected void renderCodingWithDetails(XhtmlNode x, Coding c) {
|
protected void renderCodingWithDetails(XhtmlNode x, Coding c) {
|
||||||
String s = "";
|
String s = "";
|
||||||
if (c.hasDisplayElement())
|
if (c.hasDisplayElement())
|
||||||
|
@ -650,22 +752,13 @@ public class DataRenderer extends Renderer {
|
||||||
|
|
||||||
|
|
||||||
String sn = describeSystem(c.getSystem());
|
String sn = describeSystem(c.getSystem());
|
||||||
if ("http://snomed.info/sct".equals(c.getSystem())) {
|
String link = getLinkForCode(c.getSystem(), c.getVersion(), c.getCode());
|
||||||
if (c.hasCode()) {
|
if (link != null) {
|
||||||
x.ah("http://snomed.info/id/"+c.getCode()).tx(sn);
|
x.ah(link).tx(sn);
|
||||||
} else {
|
|
||||||
x.ah("https://browser.ihtsdotools.org/").tx(sn);
|
|
||||||
}
|
|
||||||
} else if ("http://loinc.org".equals(c.getSystem())) {
|
|
||||||
x.ah("https://loinc.org/").tx(sn);
|
|
||||||
} else {
|
} else {
|
||||||
CodeSystem cs = context.getWorker().fetchCodeSystem(c.getSystem());
|
x.tx(sn);
|
||||||
if (cs != null && cs.hasUserData("path")) {
|
|
||||||
x.ah(cs.getUserString("path")).tx(sn);
|
|
||||||
} else {
|
|
||||||
x.tx(sn);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
x.tx(" ");
|
x.tx(" ");
|
||||||
x.tx(c.getCode());
|
x.tx(c.getCode());
|
||||||
if (!Utilities.noString(s)) {
|
if (!Utilities.noString(s)) {
|
||||||
|
@ -903,6 +996,57 @@ public class DataRenderer extends Renderer {
|
||||||
return s.toString();
|
return s.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getLocalizedBigDecimalValue(BigDecimal input, Currency c) {
|
||||||
|
NumberFormat numberFormat = NumberFormat.getNumberInstance(context.getLocale());
|
||||||
|
numberFormat.setGroupingUsed(true);
|
||||||
|
numberFormat.setMaximumFractionDigits(c.getDefaultFractionDigits());
|
||||||
|
numberFormat.setMinimumFractionDigits(c.getDefaultFractionDigits());
|
||||||
|
return numberFormat.format(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void renderMoney(XhtmlNode x, Money money) {
|
||||||
|
Currency c = Currency.getInstance(money.getCurrency());
|
||||||
|
if (c != null) {
|
||||||
|
XhtmlNode s = x.span(null, c.getDisplayName());
|
||||||
|
s.tx(c.getSymbol(context.getLocale()));
|
||||||
|
s.tx(getLocalizedBigDecimalValue(money.getValue(), c));
|
||||||
|
x.tx(" ("+c.getCurrencyCode()+")");
|
||||||
|
} else {
|
||||||
|
x.tx(money.getCurrency());
|
||||||
|
x.tx(money.getValue().toPlainString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void renderExpression(XhtmlNode x, Expression expr) {
|
||||||
|
// there's two parts: what the expression is, and how it's described.
|
||||||
|
// we start with what it is, and then how it's desceibed
|
||||||
|
if (expr.hasExpression()) {
|
||||||
|
XhtmlNode c = x;
|
||||||
|
if (expr.hasReference()) {
|
||||||
|
c = x.ah(expr.getReference());
|
||||||
|
}
|
||||||
|
if (expr.hasLanguage()) {
|
||||||
|
c = c.span(null, expr.getLanguage());
|
||||||
|
}
|
||||||
|
c.code().tx(expr.getExpression());
|
||||||
|
} else if (expr.hasReference()) {
|
||||||
|
x.ah(expr.getReference()).tx("source");
|
||||||
|
}
|
||||||
|
if (expr.hasName() || expr.hasDescription()) {
|
||||||
|
x.tx("(");
|
||||||
|
if (expr.hasName()) {
|
||||||
|
x.b().tx(expr.getName());
|
||||||
|
}
|
||||||
|
if (expr.hasDescription()) {
|
||||||
|
x.tx("\"");
|
||||||
|
x.tx(expr.getDescription());
|
||||||
|
x.tx("\"");
|
||||||
|
}
|
||||||
|
x.tx(")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void renderContactPoint(XhtmlNode x, ContactPoint contact) {
|
protected void renderContactPoint(XhtmlNode x, ContactPoint contact) {
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
if (!contact.hasSystem()) {
|
if (!contact.hasSystem()) {
|
||||||
|
@ -1046,19 +1190,19 @@ public class DataRenderer extends Renderer {
|
||||||
x.tx(" "+q.getLow().getUnit());
|
x.tx(" "+q.getLow().getUnit());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String displayPeriod(Period p) {
|
public String displayPeriod(Period p) {
|
||||||
String s = !p.hasStart() ? "(?)" : p.getStartElement().toHumanDisplay();
|
String s = !p.hasStart() ? "(?)" : displayDateTime(p.getStartElement());
|
||||||
s = s + " --> ";
|
s = s + " --> ";
|
||||||
return s + (!p.hasEnd() ? "(ongoing)" : p.getEndElement().toHumanDisplay());
|
return s + (!p.hasEnd() ? "(ongoing)" : displayDateTime(p.getEndElement()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderPeriod(XhtmlNode x, Period p) {
|
public void renderPeriod(XhtmlNode x, Period p) {
|
||||||
x.addText(!p.hasStart() ? "??" : p.getStartElement().toHumanDisplay());
|
x.addText(!p.hasStart() ? "??" : displayDateTime(p.getStartElement()));
|
||||||
x.tx(" --> ");
|
x.tx(" --> ");
|
||||||
x.addText(!p.hasEnd() ? "(ongoing)" : p.getEndElement().toHumanDisplay());
|
x.addText(!p.hasEnd() ? "(ongoing)" : displayDateTime(p.getEndElement()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderDataRequirement(XhtmlNode x, DataRequirement dr) {
|
public void renderDataRequirement(XhtmlNode x, DataRequirement dr) throws FHIRFormatError, DefinitionException, IOException {
|
||||||
XhtmlNode tbl = x.table("grid");
|
XhtmlNode tbl = x.table("grid");
|
||||||
XhtmlNode tr = tbl.tr();
|
XhtmlNode tr = tbl.tr();
|
||||||
XhtmlNode td = tr.td().colspan("2");
|
XhtmlNode td = tr.td().colspan("2");
|
||||||
|
@ -1163,7 +1307,7 @@ public class DataRenderer extends Renderer {
|
||||||
CommaSeparatedStringBuilder c = new CommaSeparatedStringBuilder();
|
CommaSeparatedStringBuilder c = new CommaSeparatedStringBuilder();
|
||||||
for (DateTimeType p : s.getEvent()) {
|
for (DateTimeType p : s.getEvent()) {
|
||||||
if (p.hasValue()) {
|
if (p.hasValue()) {
|
||||||
c.append(p.toHumanDisplay());
|
c.append(displayDateTime(p));
|
||||||
} else if (!renderExpression(c, p)) {
|
} else if (!renderExpression(c, p)) {
|
||||||
c.append("??");
|
c.append("??");
|
||||||
}
|
}
|
||||||
|
@ -1174,7 +1318,7 @@ public class DataRenderer extends Renderer {
|
||||||
if (s.hasRepeat()) {
|
if (s.hasRepeat()) {
|
||||||
TimingRepeatComponent rep = s.getRepeat();
|
TimingRepeatComponent rep = s.getRepeat();
|
||||||
if (rep.hasBoundsPeriod() && rep.getBoundsPeriod().hasStart())
|
if (rep.hasBoundsPeriod() && rep.getBoundsPeriod().hasStart())
|
||||||
b.append("Starting "+rep.getBoundsPeriod().getStartElement().toHumanDisplay());
|
b.append("Starting "+displayDateTime(rep.getBoundsPeriod().getStartElement()));
|
||||||
if (rep.hasCount())
|
if (rep.hasCount())
|
||||||
b.append("Count "+Integer.toString(rep.getCount())+" times");
|
b.append("Count "+Integer.toString(rep.getCount())+" times");
|
||||||
if (rep.hasDuration())
|
if (rep.hasDuration())
|
||||||
|
@ -1206,7 +1350,7 @@ public class DataRenderer extends Renderer {
|
||||||
b.append("Do "+st);
|
b.append("Do "+st);
|
||||||
}
|
}
|
||||||
if (rep.hasBoundsPeriod() && rep.getBoundsPeriod().hasEnd())
|
if (rep.hasBoundsPeriod() && rep.getBoundsPeriod().hasEnd())
|
||||||
b.append("Until "+rep.getBoundsPeriod().getEndElement().toHumanDisplay());
|
b.append("Until "+displayDateTime(rep.getBoundsPeriod().getEndElement()));
|
||||||
}
|
}
|
||||||
return b.toString();
|
return b.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,8 @@ public class ListRenderer extends ResourceRenderer {
|
||||||
shortForRef(td, list.get("subject"));
|
shortForRef(td, list.get("subject"));
|
||||||
}
|
}
|
||||||
if (list.has("encounter")) {
|
if (list.has("encounter")) {
|
||||||
shortForRef(td.tx("Encounter: "), list.get("encounter"));
|
td.tx("Encounter: ");
|
||||||
|
shortForRef(td, list.get("encounter"));
|
||||||
}
|
}
|
||||||
if (list.has("source")) {
|
if (list.has("source")) {
|
||||||
td.tx("Source: ");
|
td.tx("Source: ");
|
||||||
|
|
|
@ -33,12 +33,14 @@ import org.hl7.fhir.r5.model.DomainResource;
|
||||||
import org.hl7.fhir.r5.model.Dosage;
|
import org.hl7.fhir.r5.model.Dosage;
|
||||||
import org.hl7.fhir.r5.model.ElementDefinition;
|
import org.hl7.fhir.r5.model.ElementDefinition;
|
||||||
import org.hl7.fhir.r5.model.Enumeration;
|
import org.hl7.fhir.r5.model.Enumeration;
|
||||||
|
import org.hl7.fhir.r5.model.Expression;
|
||||||
import org.hl7.fhir.r5.model.Extension;
|
import org.hl7.fhir.r5.model.Extension;
|
||||||
import org.hl7.fhir.r5.model.HumanName;
|
import org.hl7.fhir.r5.model.HumanName;
|
||||||
import org.hl7.fhir.r5.model.IdType;
|
import org.hl7.fhir.r5.model.IdType;
|
||||||
import org.hl7.fhir.r5.model.Identifier;
|
import org.hl7.fhir.r5.model.Identifier;
|
||||||
import org.hl7.fhir.r5.model.InstantType;
|
import org.hl7.fhir.r5.model.InstantType;
|
||||||
import org.hl7.fhir.r5.model.Meta;
|
import org.hl7.fhir.r5.model.Meta;
|
||||||
|
import org.hl7.fhir.r5.model.Money;
|
||||||
import org.hl7.fhir.r5.model.Narrative;
|
import org.hl7.fhir.r5.model.Narrative;
|
||||||
import org.hl7.fhir.r5.model.Narrative.NarrativeStatus;
|
import org.hl7.fhir.r5.model.Narrative.NarrativeStatus;
|
||||||
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
|
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
|
||||||
|
@ -118,6 +120,7 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
|
||||||
generateByProfile(r, sd, r.root(), sd.getSnapshot().getElement(), ed, context.getProfileUtilities().getChildList(sd, ed), x, r.fhirType(), context.isTechnicalMode(), 0);
|
generateByProfile(r, sd, r.root(), sd.getSnapshot().getElement(), ed, context.getProfileUtilities().getChildList(sd, ed), x, r.fhirType(), context.isTechnicalMode(), 0);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
System.out.println("Error Generating Narrative for "+r.fhirType()+"/"+r.getId()+": "+e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
x.para().b().style("color: maroon").tx("Exception generating Narrative: "+e.getMessage());
|
x.para().b().style("color: maroon").tx("Exception generating Narrative: "+e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -291,7 +294,6 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
|
||||||
if (ew == null)
|
if (ew == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
Base e = ew.getBase();
|
Base e = ew.getBase();
|
||||||
|
|
||||||
if (e instanceof StringType)
|
if (e instanceof StringType)
|
||||||
|
@ -308,9 +310,12 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
|
||||||
renderDateTime(x, e);
|
renderDateTime(x, e);
|
||||||
} else if (e instanceof Base64BinaryType)
|
} else if (e instanceof Base64BinaryType)
|
||||||
x.addText(new Base64().encodeAsString(((Base64BinaryType) e).getValue()));
|
x.addText(new Base64().encodeAsString(((Base64BinaryType) e).getValue()));
|
||||||
else if (e instanceof org.hl7.fhir.r5.model.DateType)
|
else if (e instanceof org.hl7.fhir.r5.model.DateType) {
|
||||||
x.addText(((org.hl7.fhir.r5.model.DateType) e).toHumanDisplay());
|
org.hl7.fhir.r5.model.DateType dt = ((org.hl7.fhir.r5.model.DateType) e);
|
||||||
else if (e instanceof Enumeration) {
|
if (((org.hl7.fhir.r5.model.DateType) e).hasValue()) {
|
||||||
|
x.addText(((org.hl7.fhir.r5.model.DateType) e).toHumanDisplay());
|
||||||
|
}
|
||||||
|
} else if (e instanceof Enumeration) {
|
||||||
Object ev = ((Enumeration<?>) e).getValue();
|
Object ev = ((Enumeration<?>) e).getValue();
|
||||||
x.addText(ev == null ? "" : ev.toString()); // todo: look up a display name if there is one
|
x.addText(ev == null ? "" : ev.toString()); // todo: look up a display name if there is one
|
||||||
} else if (e instanceof BooleanType) {
|
} else if (e instanceof BooleanType) {
|
||||||
|
@ -347,6 +352,10 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
|
||||||
renderAddress(x, (Address) e);
|
renderAddress(x, (Address) e);
|
||||||
} else if (e instanceof ContactPoint) {
|
} else if (e instanceof ContactPoint) {
|
||||||
renderContactPoint(x, (ContactPoint) e);
|
renderContactPoint(x, (ContactPoint) e);
|
||||||
|
} else if (e instanceof Expression) {
|
||||||
|
renderExpression(x, (Expression) e);
|
||||||
|
} else if (e instanceof Money) {
|
||||||
|
renderMoney(x, (Money) e);
|
||||||
} else if (e instanceof ContactDetail) {
|
} else if (e instanceof ContactDetail) {
|
||||||
ContactDetail cd = (ContactDetail) e;
|
ContactDetail cd = (ContactDetail) e;
|
||||||
if (cd.hasName()) {
|
if (cd.hasName()) {
|
||||||
|
|
|
@ -703,7 +703,7 @@ public class QuestionnaireRenderer extends TerminologyRenderer {
|
||||||
}
|
}
|
||||||
if (i.hasAnswerValueSet()) {
|
if (i.hasAnswerValueSet()) {
|
||||||
XhtmlNode ans = item(ul, "Answers");
|
XhtmlNode ans = item(ul, "Answers");
|
||||||
if (Utilities.noString(i.getAnswerValueSet()) && i.getAnswerValueSet().startsWith("#")) {
|
if (!Utilities.noString(i.getAnswerValueSet()) && i.getAnswerValueSet().startsWith("#")) {
|
||||||
ValueSet vs = (ValueSet) q.getContained(i.getAnswerValueSet().substring(1));
|
ValueSet vs = (ValueSet) q.getContained(i.getAnswerValueSet().substring(1));
|
||||||
if (vs == null) {
|
if (vs == null) {
|
||||||
ans.tx(i.getAnswerValueSet());
|
ans.tx(i.getAnswerValueSet());
|
||||||
|
@ -792,7 +792,7 @@ public class QuestionnaireRenderer extends TerminologyRenderer {
|
||||||
private void listOptions(Questionnaire q, QuestionnaireItemComponent i, XhtmlNode select) {
|
private void listOptions(Questionnaire q, QuestionnaireItemComponent i, XhtmlNode select) {
|
||||||
if (i.hasAnswerValueSet()) {
|
if (i.hasAnswerValueSet()) {
|
||||||
ValueSet vs = null;
|
ValueSet vs = null;
|
||||||
if (Utilities.noString(i.getAnswerValueSet()) && i.getAnswerValueSet().startsWith("#")) {
|
if (!Utilities.noString(i.getAnswerValueSet()) && i.getAnswerValueSet().startsWith("#")) {
|
||||||
vs = (ValueSet) q.getContained(i.getAnswerValueSet().substring(1));
|
vs = (ValueSet) q.getContained(i.getAnswerValueSet().substring(1));
|
||||||
if (vs != null && !vs.hasUrl()) {
|
if (vs != null && !vs.hasUrl()) {
|
||||||
vs = vs.copy();
|
vs = vs.copy();
|
||||||
|
|
|
@ -214,6 +214,11 @@ public abstract class ResourceRenderer extends DataRenderer {
|
||||||
if ((tr == null || !tr.getReference().startsWith("#")) && name != null) {
|
if ((tr == null || !tr.getReference().startsWith("#")) && name != null) {
|
||||||
x.addText(" \""+name+"\"");
|
x.addText(" \""+name+"\"");
|
||||||
}
|
}
|
||||||
|
if (r.hasExtension(ToolingExtensions.EXT_TARGET_ID)) {
|
||||||
|
x.addText("(#"+r.getExtensionString(ToolingExtensions.EXT_TARGET_ID)+")");
|
||||||
|
} else if (r.hasExtension(ToolingExtensions.EXT_TARGET_PATH)) {
|
||||||
|
x.addText("(#/"+r.getExtensionString(ToolingExtensions.EXT_TARGET_PATH)+")");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (display != null) {
|
if (display != null) {
|
||||||
c.addText(display);
|
c.addText(display);
|
||||||
|
@ -272,6 +277,11 @@ public abstract class ResourceRenderer extends DataRenderer {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
String version = null;
|
||||||
|
if (url.contains("/_history/")) {
|
||||||
|
version = url.substring(url.indexOf("/_history/")+10);
|
||||||
|
url = url.substring(0, url.indexOf("/_history/"));
|
||||||
|
}
|
||||||
|
|
||||||
if (rcontext != null) {
|
if (rcontext != null) {
|
||||||
BundleEntryComponent bundleResource = rcontext.resolve(url);
|
BundleEntryComponent bundleResource = rcontext.resolve(url);
|
||||||
|
@ -279,7 +289,7 @@ public abstract class ResourceRenderer extends DataRenderer {
|
||||||
String bundleUrl = "#" + bundleResource.getResource().getResourceType().name() + "_" + bundleResource.getResource().getId();
|
String bundleUrl = "#" + bundleResource.getResource().getResourceType().name() + "_" + bundleResource.getResource().getId();
|
||||||
return new ResourceWithReference(bundleUrl, new ResourceWrapperDirect(this.context, bundleResource.getResource()));
|
return new ResourceWithReference(bundleUrl, new ResourceWrapperDirect(this.context, bundleResource.getResource()));
|
||||||
}
|
}
|
||||||
org.hl7.fhir.r5.elementmodel.Element bundleElement = rcontext.resolveElement(url);
|
org.hl7.fhir.r5.elementmodel.Element bundleElement = rcontext.resolveElement(url, version);
|
||||||
if (bundleElement != null) {
|
if (bundleElement != null) {
|
||||||
String bundleUrl = null;
|
String bundleUrl = null;
|
||||||
Element br = bundleElement.getNamedChild("resource");
|
Element br = bundleElement.getNamedChild("resource");
|
||||||
|
@ -292,7 +302,7 @@ public abstract class ResourceRenderer extends DataRenderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Resource ae = getContext().getWorker().fetchResource(null, url);
|
Resource ae = getContext().getWorker().fetchResource(null, url, version);
|
||||||
if (ae != null)
|
if (ae != null)
|
||||||
return new ResourceWithReference(url, new ResourceWrapperDirect(this.context, ae));
|
return new ResourceWithReference(url, new ResourceWrapperDirect(this.context, ae));
|
||||||
else if (context.getResolver() != null) {
|
else if (context.getResolver() != null) {
|
||||||
|
@ -473,10 +483,10 @@ public abstract class ResourceRenderer extends DataRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPrimitiveValue(BaseWrapper b, String name) throws UnsupportedEncodingException, FHIRException, IOException {
|
private String getPrimitiveValue(BaseWrapper b, String name) throws UnsupportedEncodingException, FHIRException, IOException {
|
||||||
return b != null && b.getChildByName(name).hasValues() ? b.getChildByName(name).getValues().get(0).getBase().primitiveValue() : null;
|
return b != null && b.has(name) && b.getChildByName(name).hasValues() ? b.getChildByName(name).getValues().get(0).getBase().primitiveValue() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPrimitiveValue(ResourceWrapper r, String name) throws UnsupportedEncodingException, FHIRException, IOException {
|
private String getPrimitiveValue(ResourceWrapper r, String name) throws UnsupportedEncodingException, FHIRException, IOException {
|
||||||
return r.getChildByName(name).hasValues() ? r.getChildByName(name).getValues().get(0).getBase().primitiveValue() : null;
|
return r.has(name) && r.getChildByName(name).hasValues() ? r.getChildByName(name).getValues().get(0).getBase().primitiveValue() : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -176,23 +176,8 @@ public class ValueSetRenderer extends TerminologyRenderer {
|
||||||
else
|
else
|
||||||
x.para().tx("This value set contains "+count.toString()+" concepts");
|
x.para().tx("This value set contains "+count.toString()+" concepts");
|
||||||
}
|
}
|
||||||
if (ToolingExtensions.hasExtension(vs.getExpansion(), ToolingExtensions.EXT_EXP_FRAGMENT)) {
|
|
||||||
XhtmlNode div = x.div().style("border: maroon 1px solid; background-color: #FFCCCC; padding: 8px");
|
|
||||||
List<Extension> exl = vs.getExpansion().getExtensionsByUrl(ToolingExtensions.EXT_EXP_FRAGMENT);
|
|
||||||
if (exl.size() > 1) {
|
|
||||||
div.para().addText("Warning: this expansion is generated from fragments of the following code systems, and may be missing codes, or include codes that are not valid:");
|
|
||||||
XhtmlNode ul = div.ul();
|
|
||||||
for (Extension ex : exl) {
|
|
||||||
addCSRef(ul.li(), ex.getValue().primitiveValue());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
XhtmlNode p = div.para();
|
|
||||||
p.addText("Warning: this expansion is generated from a fragment of the code system ");
|
|
||||||
addCSRef(p, exl.get(0).getValue().primitiveValue());
|
|
||||||
p.addText(" and may be missing codes, or include codes that are not valid");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
generateContentModeNotices(x, vs.getExpansion());
|
||||||
generateVersionNotice(x, vs.getExpansion());
|
generateVersionNotice(x, vs.getExpansion());
|
||||||
|
|
||||||
CodeSystem allCS = null;
|
CodeSystem allCS = null;
|
||||||
|
@ -273,6 +258,46 @@ public class ValueSetRenderer extends TerminologyRenderer {
|
||||||
return hasExtensions;
|
return hasExtensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void generateContentModeNotices(XhtmlNode x, ValueSetExpansionComponent expansion) {
|
||||||
|
generateContentModeNotice(x, expansion, "example", "Expansion based on example code system");
|
||||||
|
generateContentModeNotice(x, expansion, "fragment", "Expansion based on code system fragment");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generateContentModeNotice(XhtmlNode x, ValueSetExpansionComponent expansion, String mode, String text) {
|
||||||
|
Multimap<String, String> versions = HashMultimap.create();
|
||||||
|
for (ValueSetExpansionParameterComponent p : expansion.getParameter()) {
|
||||||
|
if (p.getName().equals(mode)) {
|
||||||
|
String[] parts = ((PrimitiveType) p.getValue()).asStringValue().split("\\|");
|
||||||
|
if (parts.length == 2)
|
||||||
|
versions.put(parts[0], parts[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (versions.size() > 0) {
|
||||||
|
XhtmlNode div = null;
|
||||||
|
XhtmlNode ul = null;
|
||||||
|
boolean first = true;
|
||||||
|
for (String s : versions.keySet()) {
|
||||||
|
if (versions.size() == 1 && versions.get(s).size() == 1) {
|
||||||
|
for (String v : versions.get(s)) { // though there'll only be one
|
||||||
|
XhtmlNode p = x.para().style("border: black 1px dotted; background-color: #ffcccc; padding: 8px; margin-bottom: 8px");
|
||||||
|
p.tx(text+" ");
|
||||||
|
expRef(p, s, v);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (String v : versions.get(s)) {
|
||||||
|
if (first) {
|
||||||
|
div = x.div().style("border: black 1px dotted; background-color: #EEEEEE; padding: 8px; margin-bottom: 8px");
|
||||||
|
div.para().tx(text+"s: ");
|
||||||
|
ul = div.ul();
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
expRef(ul.li(), s, v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean checkDoSystem(ValueSet vs, ValueSet src) {
|
private boolean checkDoSystem(ValueSet vs, ValueSet src) {
|
||||||
if (src != null)
|
if (src != null)
|
||||||
vs = src;
|
vs = src;
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class DOMWrappers {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Base getBase() throws UnsupportedEncodingException, IOException, FHIRException {
|
public Base getBase() throws UnsupportedEncodingException, IOException, FHIRException {
|
||||||
if (type == null || type.equals("Resource") || type.equals("BackboneElement") || type.equals("Element"))
|
if (Utilities.noString(type) || type.equals("Resource") || type.equals("BackboneElement") || type.equals("Element"))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
String xml;
|
String xml;
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
package org.hl7.fhir.r5.renderers.utils;
|
package org.hl7.fhir.r5.renderers.utils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.time.format.FormatStyle;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import org.hl7.fhir.exceptions.FHIRException;
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||||
|
@ -117,6 +123,11 @@ public class RenderingContext {
|
||||||
private boolean addGeneratedNarrativeHeader = true;
|
private boolean addGeneratedNarrativeHeader = true;
|
||||||
|
|
||||||
private FhirPublication targetVersion;
|
private FhirPublication targetVersion;
|
||||||
|
private Locale locale;
|
||||||
|
private ZoneId timeZoneId;
|
||||||
|
private DateTimeFormatter dateTimeFormat;
|
||||||
|
private DateTimeFormatter dateFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param context - access to all related resources that might be needed
|
* @param context - access to all related resources that might be needed
|
||||||
|
@ -136,6 +147,8 @@ public class RenderingContext {
|
||||||
if (terminologyServiceOptions != null) {
|
if (terminologyServiceOptions != null) {
|
||||||
this.terminologyServiceOptions = terminologyServiceOptions;
|
this.terminologyServiceOptions = terminologyServiceOptions;
|
||||||
}
|
}
|
||||||
|
// default to US locale - discussion here: https://github.com/hapifhir/org.hl7.fhir.core/issues/666
|
||||||
|
this.locale = new Locale.Builder().setLanguageTag("en-US").build();
|
||||||
profileUtilities = new ProfileUtilities(worker, null, null);
|
profileUtilities = new ProfileUtilities(worker, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,4 +440,79 @@ public class RenderingContext {
|
||||||
return mode == ResourceRendererMode.TECHNICAL;
|
return mode == ResourceRendererMode.TECHNICAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasLocale() {
|
||||||
|
return locale != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Locale getLocale() {
|
||||||
|
if (locale == null) {
|
||||||
|
return Locale.getDefault();
|
||||||
|
} else {
|
||||||
|
return locale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocale(Locale locale) {
|
||||||
|
this.locale = locale;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* if the timezone is null, the rendering will default to the source timezone
|
||||||
|
* in the resource
|
||||||
|
*
|
||||||
|
* Note that if you're working server side, the FHIR project recommends the use
|
||||||
|
* of the Date header so that clients know what timezone the server defaults to,
|
||||||
|
*
|
||||||
|
* There is no standard way for the server to know what the client timezone is.
|
||||||
|
* In the case where the client timezone is unknown, the timezone should be null
|
||||||
|
*
|
||||||
|
* @return the specified timezone to render in
|
||||||
|
*/
|
||||||
|
public ZoneId getTimeZoneId() {
|
||||||
|
return timeZoneId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeZoneId(ZoneId timeZoneId) {
|
||||||
|
this.timeZoneId = timeZoneId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In the absence of a specified format, the renderers will default to
|
||||||
|
* the FormatStyle.MEDIUM for the current locale.
|
||||||
|
*
|
||||||
|
* @return the format to use
|
||||||
|
*/
|
||||||
|
public DateTimeFormatter getDateTimeFormat() {
|
||||||
|
return this.dateTimeFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDateTimeFormat(DateTimeFormatter dateTimeFormat) {
|
||||||
|
this.dateTimeFormat = dateTimeFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In the absence of a specified format, the renderers will default to
|
||||||
|
* the FormatStyle.MEDIUM for the current locale.
|
||||||
|
*
|
||||||
|
* @return the format to use
|
||||||
|
*/
|
||||||
|
public DateTimeFormatter getDateFormat() {
|
||||||
|
return this.dateFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDateFormat(DateTimeFormatter dateFormat) {
|
||||||
|
this.dateFormat = dateFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResourceRendererMode getMode() {
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMode(ResourceRendererMode mode) {
|
||||||
|
this.mode = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -101,7 +101,7 @@ public class Resolver {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public org.hl7.fhir.r5.elementmodel.Element resolveElement(String value) {
|
public org.hl7.fhir.r5.elementmodel.Element resolveElement(String value, String version) {
|
||||||
if (value.startsWith("#")) {
|
if (value.startsWith("#")) {
|
||||||
if (resourceElement != null) {
|
if (resourceElement != null) {
|
||||||
for (org.hl7.fhir.r5.elementmodel.Element r : resourceElement.getChildrenByName("contained")) {
|
for (org.hl7.fhir.r5.elementmodel.Element r : resourceElement.getChildrenByName("contained")) {
|
||||||
|
@ -115,10 +115,18 @@ public class Resolver {
|
||||||
if (containerElement != null) {
|
if (containerElement != null) {
|
||||||
for (org.hl7.fhir.r5.elementmodel.Element be : containerElement.getChildren("entry")) {
|
for (org.hl7.fhir.r5.elementmodel.Element be : containerElement.getChildren("entry")) {
|
||||||
org.hl7.fhir.r5.elementmodel.Element res = be.getNamedChild("resource");
|
org.hl7.fhir.r5.elementmodel.Element res = be.getNamedChild("resource");
|
||||||
if (value.equals(be.getChildValue("fullUrl")))
|
if (res != null) {
|
||||||
return be;
|
if (value.equals(be.getChildValue("fullUrl"))) {
|
||||||
if (value.equals(res.fhirType()+"/"+res.getChildValue("id")))
|
if (checkVersion(version, res)) {
|
||||||
return be;
|
return be;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (value.equals(res.fhirType()+"/"+res.getChildValue("id"))) {
|
||||||
|
if (checkVersion(version, res)) {
|
||||||
|
return be;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,13 +134,27 @@ public class Resolver {
|
||||||
if (containerElement != null) {
|
if (containerElement != null) {
|
||||||
for (org.hl7.fhir.r5.elementmodel.Element p : containerElement.getChildren("parameter")) {
|
for (org.hl7.fhir.r5.elementmodel.Element p : containerElement.getChildren("parameter")) {
|
||||||
org.hl7.fhir.r5.elementmodel.Element res = p.getNamedChild("resource");
|
org.hl7.fhir.r5.elementmodel.Element res = p.getNamedChild("resource");
|
||||||
if (res != null && value.equals(res.fhirType()+"/"+res.getChildValue("id")))
|
if (res != null && value.equals(res.fhirType()+"/"+res.getChildValue("id"))) {
|
||||||
return p;
|
if (checkVersion(version, res)) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean checkVersion(String version, org.hl7.fhir.r5.elementmodel.Element res) {
|
||||||
|
if (version == null) {
|
||||||
|
return true;
|
||||||
|
} else if (!res.hasChild("meta")) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
org.hl7.fhir.r5.elementmodel.Element meta = res.getNamedChild("meta");
|
||||||
|
return version.equals(meta.getChildValue("version"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ResourceWithReference {
|
public static class ResourceWithReference {
|
||||||
|
|
|
@ -33,6 +33,8 @@ package org.hl7.fhir.r5.terminologies;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -51,6 +53,7 @@ import org.hl7.fhir.r5.model.CodeType;
|
||||||
import org.hl7.fhir.r5.model.DataType;
|
import org.hl7.fhir.r5.model.DataType;
|
||||||
import org.hl7.fhir.r5.model.DateTimeType;
|
import org.hl7.fhir.r5.model.DateTimeType;
|
||||||
import org.hl7.fhir.r5.model.Enumerations.PublicationStatus;
|
import org.hl7.fhir.r5.model.Enumerations.PublicationStatus;
|
||||||
|
import org.hl7.fhir.r5.terminologies.CodeSystemUtilities.ConceptDefinitionComponentSorter;
|
||||||
import org.hl7.fhir.r5.model.Identifier;
|
import org.hl7.fhir.r5.model.Identifier;
|
||||||
import org.hl7.fhir.r5.model.Meta;
|
import org.hl7.fhir.r5.model.Meta;
|
||||||
import org.hl7.fhir.r5.model.UriType;
|
import org.hl7.fhir.r5.model.UriType;
|
||||||
|
@ -60,6 +63,15 @@ import org.hl7.fhir.utilities.Utilities;
|
||||||
|
|
||||||
public class CodeSystemUtilities {
|
public class CodeSystemUtilities {
|
||||||
|
|
||||||
|
public static class ConceptDefinitionComponentSorter implements Comparator<ConceptDefinitionComponent> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(ConceptDefinitionComponent o1, ConceptDefinitionComponent o2) {
|
||||||
|
return o1.getCode().compareTo(o2.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static final String USER_DATA_CROSS_LINK = "cs.utils.cross.link";
|
public static final String USER_DATA_CROSS_LINK = "cs.utils.cross.link";
|
||||||
|
|
||||||
public static class CodeSystemNavigator {
|
public static class CodeSystemNavigator {
|
||||||
|
@ -128,7 +140,7 @@ public class CodeSystemUtilities {
|
||||||
private List<String> getSubsumedBy(ConceptDefinitionComponent cd) {
|
private List<String> getSubsumedBy(ConceptDefinitionComponent cd) {
|
||||||
List<String> codes = new ArrayList<>();
|
List<String> codes = new ArrayList<>();
|
||||||
for (ConceptPropertyComponent cp : cd.getProperty()) {
|
for (ConceptPropertyComponent cp : cd.getProperty()) {
|
||||||
if (cp.getCode().equals("subsumedBy")) {
|
if ("subsumedBy".equals(cp.getCode())) {
|
||||||
codes.add(cp.getValue().primitiveValue());
|
codes.add(cp.getValue().primitiveValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,7 +161,7 @@ public class CodeSystemUtilities {
|
||||||
|
|
||||||
public static boolean isNotSelectable(CodeSystem cs, ConceptDefinitionComponent def) {
|
public static boolean isNotSelectable(CodeSystem cs, ConceptDefinitionComponent def) {
|
||||||
for (ConceptPropertyComponent p : def.getProperty()) {
|
for (ConceptPropertyComponent p : def.getProperty()) {
|
||||||
if (p.getCode().equals("notSelectable") && p.hasValue() && p.getValue() instanceof BooleanType)
|
if ("notSelectable".equals(p.getCode()) && p.hasValue() && p.getValue() instanceof BooleanType)
|
||||||
return ((BooleanType) p.getValue()).getValue();
|
return ((BooleanType) p.getValue()).getValue();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -212,14 +224,14 @@ public class CodeSystemUtilities {
|
||||||
try {
|
try {
|
||||||
for (ConceptPropertyComponent p : def.getProperty()) {
|
for (ConceptPropertyComponent p : def.getProperty()) {
|
||||||
if (!ignoreStatus) {
|
if (!ignoreStatus) {
|
||||||
if (p.getCode().equals("status") && p.hasValue() && p.hasValueCodeType() && p.getValueCodeType().getCode().equals("deprecated"))
|
if ("status".equals(p.getCode()) && p.hasValue() && p.hasValueCodeType() && "deprecated".equals(p.getValueCodeType().getCode()))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// this, though status should also be set
|
// this, though status should also be set
|
||||||
if (p.getCode().equals("deprecationDate") && p.hasValue() && p.getValue() instanceof DateTimeType)
|
if ("deprecationDate".equals(p.getCode()) && p.hasValue() && p.getValue() instanceof DateTimeType)
|
||||||
return ((DateTimeType) p.getValue()).before(new DateTimeType(Calendar.getInstance()));
|
return ((DateTimeType) p.getValue()).before(new DateTimeType(Calendar.getInstance()));
|
||||||
// legacy
|
// legacy
|
||||||
if (p.getCode().equals("deprecated") && p.hasValue() && p.getValue() instanceof BooleanType)
|
if ("deprecated".equals(p.getCode()) && p.hasValue() && p.getValue() instanceof BooleanType)
|
||||||
return ((BooleanType) p.getValue()).getValue();
|
return ((BooleanType) p.getValue()).getValue();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -236,7 +248,7 @@ public class CodeSystemUtilities {
|
||||||
|
|
||||||
public static boolean isInactive(CodeSystem cs, ConceptDefinitionComponent def) throws FHIRException {
|
public static boolean isInactive(CodeSystem cs, ConceptDefinitionComponent def) throws FHIRException {
|
||||||
for (ConceptPropertyComponent p : def.getProperty()) {
|
for (ConceptPropertyComponent p : def.getProperty()) {
|
||||||
if (p.getCode().equals("status") && p.hasValueStringType())
|
if ("status".equals(p.getCode()) && p.hasValueStringType())
|
||||||
return "inactive".equals(p.getValueStringType());
|
return "inactive".equals(p.getValueStringType());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -273,10 +285,14 @@ public class CodeSystemUtilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CodeSystem makeShareable(CodeSystem cs) {
|
public static CodeSystem makeShareable(CodeSystem cs) {
|
||||||
|
if (!cs.hasExperimental()) {
|
||||||
|
cs.setExperimental(false);
|
||||||
|
}
|
||||||
|
|
||||||
if (!cs.hasMeta())
|
if (!cs.hasMeta())
|
||||||
cs.setMeta(new Meta());
|
cs.setMeta(new Meta());
|
||||||
for (UriType t : cs.getMeta().getProfile())
|
for (UriType t : cs.getMeta().getProfile())
|
||||||
if (t.getValue().equals("http://hl7.org/fhir/StructureDefinition/shareablecodesystem"))
|
if ("http://hl7.org/fhir/StructureDefinition/shareablecodesystem".equals(t.getValue()))
|
||||||
return cs;
|
return cs;
|
||||||
cs.getMeta().getProfile().add(new CanonicalType("http://hl7.org/fhir/StructureDefinition/shareablecodesystem"));
|
cs.getMeta().getProfile().add(new CanonicalType("http://hl7.org/fhir/StructureDefinition/shareablecodesystem"));
|
||||||
return cs;
|
return cs;
|
||||||
|
@ -286,7 +302,7 @@ public class CodeSystemUtilities {
|
||||||
if (!cs.hasMeta())
|
if (!cs.hasMeta())
|
||||||
cs.setMeta(new Meta());
|
cs.setMeta(new Meta());
|
||||||
for (UriType t : cs.getMeta().getProfile())
|
for (UriType t : cs.getMeta().getProfile())
|
||||||
if (t.getValue().equals("http://hl7.org/fhir/StructureDefinition/shareablecodesystem"))
|
if ("http://hl7.org/fhir/StructureDefinition/shareablecodesystem".equals(t.getValue()))
|
||||||
return false;
|
return false;
|
||||||
cs.getMeta().getProfile().add(new CanonicalType("http://hl7.org/fhir/StructureDefinition/shareablecodesystem"));
|
cs.getMeta().getProfile().add(new CanonicalType("http://hl7.org/fhir/StructureDefinition/shareablecodesystem"));
|
||||||
return true;
|
return true;
|
||||||
|
@ -350,8 +366,12 @@ public class CodeSystemUtilities {
|
||||||
}
|
}
|
||||||
if (fmm != null) {
|
if (fmm != null) {
|
||||||
String sfmm = ToolingExtensions.readStringExtension(cs, ToolingExtensions.EXT_FMM_LEVEL);
|
String sfmm = ToolingExtensions.readStringExtension(cs, ToolingExtensions.EXT_FMM_LEVEL);
|
||||||
if (Utilities.noString(sfmm) || Integer.parseInt(sfmm) < Integer.parseInt(fmm))
|
if (Utilities.noString(sfmm) || Integer.parseInt(sfmm) < Integer.parseInt(fmm)) {
|
||||||
ToolingExtensions.setIntegerExtension(cs, ToolingExtensions.EXT_FMM_LEVEL, Integer.parseInt(fmm));
|
ToolingExtensions.setIntegerExtension(cs, ToolingExtensions.EXT_FMM_LEVEL, Integer.parseInt(fmm));
|
||||||
|
}
|
||||||
|
if (Integer.parseInt(fmm) <= 1) {
|
||||||
|
cs.setExperimental(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,4 +511,26 @@ public class CodeSystemUtilities {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hasHierarchy(CodeSystem cs) {
|
||||||
|
for (ConceptDefinitionComponent c : cs.getConcept()) {
|
||||||
|
if (c.hasConcept()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sortAllCodes(CodeSystem cs) {
|
||||||
|
sortAllCodes(cs.getConcept());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void sortAllCodes(List<ConceptDefinitionComponent> list) {
|
||||||
|
Collections.sort(list, new ConceptDefinitionComponentSorter());
|
||||||
|
for (ConceptDefinitionComponent cd : list) {
|
||||||
|
if (cd.hasConcept()) {
|
||||||
|
sortAllCodes(cd.getConcept());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -17,6 +17,7 @@ import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
@ -75,7 +76,8 @@ public class TerminologyCacheManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
IniFile ini = new IniFile(Utilities.path(cacheFolder, "cache.ini"));
|
IniFile ini = new IniFile(Utilities.path(cacheFolder, "cache.ini"));
|
||||||
ini.setStringProperty("version", "version", version, null);
|
ini.setStringProperty("cache", "version", version, null);
|
||||||
|
ini.setDateProperty("cache", "last-use", new Date(), null);
|
||||||
ini.save();
|
ini.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +118,7 @@ public class TerminologyCacheManager {
|
||||||
|
|
||||||
private String getCacheVersion() throws IOException {
|
private String getCacheVersion() throws IOException {
|
||||||
IniFile ini = new IniFile(Utilities.path(cacheFolder, "cache.ini"));
|
IniFile ini = new IniFile(Utilities.path(cacheFolder, "cache.ini"));
|
||||||
return ini.getStringProperty("version", "version");
|
return ini.getStringProperty("cache", "version");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFolder() {
|
public String getFolder() {
|
||||||
|
|
|
@ -56,6 +56,9 @@ import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent;
|
||||||
import org.hl7.fhir.r5.model.ValueSet.ConceptSetFilterComponent;
|
import org.hl7.fhir.r5.model.ValueSet.ConceptSetFilterComponent;
|
||||||
import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent;
|
import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent;
|
||||||
import org.hl7.fhir.r5.terminologies.ValueSetExpander.TerminologyServiceErrorClass;
|
import org.hl7.fhir.r5.terminologies.ValueSetExpander.TerminologyServiceErrorClass;
|
||||||
|
import org.hl7.fhir.r5.utils.ToolingExtensions;
|
||||||
|
import org.hl7.fhir.r5.utils.validation.ValidationContextCarrier;
|
||||||
|
import org.hl7.fhir.r5.utils.validation.ValidationContextCarrier.ValidationContextResourceProxy;
|
||||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||||
import org.hl7.fhir.utilities.Utilities;
|
import org.hl7.fhir.utilities.Utilities;
|
||||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||||
|
@ -69,6 +72,8 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe
|
||||||
private IWorkerContext context;
|
private IWorkerContext context;
|
||||||
private Map<String, ValueSetCheckerSimple> inner = new HashMap<>();
|
private Map<String, ValueSetCheckerSimple> inner = new HashMap<>();
|
||||||
private ValidationOptions options;
|
private ValidationOptions options;
|
||||||
|
private ValidationContextCarrier localContext;
|
||||||
|
private List<CodeSystem> localSystems = new ArrayList<>();
|
||||||
|
|
||||||
public ValueSetCheckerSimple(ValidationOptions options, ValueSet source, IWorkerContext context) {
|
public ValueSetCheckerSimple(ValidationOptions options, ValueSet source, IWorkerContext context) {
|
||||||
this.valueset = source;
|
this.valueset = source;
|
||||||
|
@ -76,6 +81,44 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe
|
||||||
this.options = options;
|
this.options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ValueSetCheckerSimple(ValidationOptions options, ValueSet source, IWorkerContext context, ValidationContextCarrier ctxt) {
|
||||||
|
this.valueset = source;
|
||||||
|
this.context = context;
|
||||||
|
this.options = options;
|
||||||
|
this.localContext = ctxt;
|
||||||
|
analyseValueSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void analyseValueSet() {
|
||||||
|
if (localContext != null) {
|
||||||
|
if (valueset != null) {
|
||||||
|
for (ConceptSetComponent i : valueset.getCompose().getInclude()) {
|
||||||
|
analyseComponent(i);
|
||||||
|
}
|
||||||
|
for (ConceptSetComponent i : valueset.getCompose().getExclude()) {
|
||||||
|
analyseComponent(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void analyseComponent(ConceptSetComponent i) {
|
||||||
|
if (i.getSystemElement().hasExtension(ToolingExtensions.EXT_VALUESET_SYSTEM)) {
|
||||||
|
String ref = i.getSystemElement().getExtensionString(ToolingExtensions.EXT_VALUESET_SYSTEM);
|
||||||
|
if (ref.startsWith("#")) {
|
||||||
|
String id = ref.substring(1);
|
||||||
|
for (ValidationContextResourceProxy t : localContext.getResources()) {
|
||||||
|
CodeSystem cs = (CodeSystem) t.loadContainedResource(id, CodeSystem.class);
|
||||||
|
if (cs != null) {
|
||||||
|
localSystems.add(cs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new Error("Not done yet #2: "+ref);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ValidationResult validateCode(CodeableConcept code) throws FHIRException {
|
public ValidationResult validateCode(CodeableConcept code) throws FHIRException {
|
||||||
// first, we validate the codings themselves
|
// first, we validate the codings themselves
|
||||||
List<String> errors = new ArrayList<String>();
|
List<String> errors = new ArrayList<String>();
|
||||||
|
@ -85,7 +128,7 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe
|
||||||
if (!c.hasSystem()) {
|
if (!c.hasSystem()) {
|
||||||
warnings.add(context.formatMessage(I18nConstants.CODING_HAS_NO_SYSTEM__CANNOT_VALIDATE));
|
warnings.add(context.formatMessage(I18nConstants.CODING_HAS_NO_SYSTEM__CANNOT_VALIDATE));
|
||||||
}
|
}
|
||||||
CodeSystem cs = context.fetchCodeSystem(c.getSystem());
|
CodeSystem cs = resolveCodeSystem(c.getSystem());
|
||||||
ValidationResult res = null;
|
ValidationResult res = null;
|
||||||
if (cs == null || cs.getContent() != CodeSystemContentMode.COMPLETE) {
|
if (cs == null || cs.getContent() != CodeSystemContentMode.COMPLETE) {
|
||||||
res = context.validateCode(options.noClient(), c, null);
|
res = context.validateCode(options.noClient(), c, null);
|
||||||
|
@ -124,6 +167,19 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CodeSystem resolveCodeSystem(String system) {
|
||||||
|
for (CodeSystem t : localSystems) {
|
||||||
|
if (t.getUrl().equals(system)) {
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CodeSystem cs = context.fetchCodeSystem(system);
|
||||||
|
if (cs == null) {
|
||||||
|
cs = findSpecialCodeSystem(system);
|
||||||
|
}
|
||||||
|
return cs;
|
||||||
|
}
|
||||||
|
|
||||||
public ValidationResult validateCode(Coding code) throws FHIRException {
|
public ValidationResult validateCode(Coding code) throws FHIRException {
|
||||||
String warningMessage = null;
|
String warningMessage = null;
|
||||||
// first, we validate the concept itself
|
// first, we validate the concept itself
|
||||||
|
@ -144,10 +200,7 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe
|
||||||
}
|
}
|
||||||
inExpansion = checkExpansion(code);
|
inExpansion = checkExpansion(code);
|
||||||
inInclude = checkInclude(code);
|
inInclude = checkInclude(code);
|
||||||
CodeSystem cs = context.fetchCodeSystem(system);
|
CodeSystem cs = resolveCodeSystem(system);
|
||||||
if (cs == null) {
|
|
||||||
cs = findSpecialCodeSystem(system);
|
|
||||||
}
|
|
||||||
if (cs == null) {
|
if (cs == null) {
|
||||||
warningMessage = "Unable to resolve system "+system;
|
warningMessage = "Unable to resolve system "+system;
|
||||||
if (!inExpansion) {
|
if (!inExpansion) {
|
||||||
|
@ -498,7 +551,7 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe
|
||||||
if (vsi.hasFilter()) {
|
if (vsi.hasFilter()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
CodeSystem cs = context.fetchCodeSystem(vsi.getSystem());
|
CodeSystem cs = resolveCodeSystem(vsi.getSystem());
|
||||||
if (cs == null) {
|
if (cs == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -604,7 +657,7 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe
|
||||||
if (!system.equals(vsi.getSystem()))
|
if (!system.equals(vsi.getSystem()))
|
||||||
return false;
|
return false;
|
||||||
// ok, we need the code system
|
// ok, we need the code system
|
||||||
CodeSystem cs = context.fetchCodeSystem(system);
|
CodeSystem cs = resolveCodeSystem(system);
|
||||||
if (cs == null || (cs.getContent() != CodeSystemContentMode.COMPLETE && cs.getContent() != CodeSystemContentMode.FRAGMENT)) {
|
if (cs == null || (cs.getContent() != CodeSystemContentMode.COMPLETE && cs.getContent() != CodeSystemContentMode.FRAGMENT)) {
|
||||||
// make up a transient value set with
|
// make up a transient value set with
|
||||||
ValueSet vs = new ValueSet();
|
ValueSet vs = new ValueSet();
|
||||||
|
@ -709,7 +762,7 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe
|
||||||
return inner.get(url);
|
return inner.get(url);
|
||||||
}
|
}
|
||||||
ValueSet vs = context.fetchResource(ValueSet.class, url);
|
ValueSet vs = context.fetchResource(ValueSet.class, url);
|
||||||
ValueSetCheckerSimple vsc = new ValueSetCheckerSimple(options, vs, context);
|
ValueSetCheckerSimple vsc = new ValueSetCheckerSimple(options, vs, context, localContext);
|
||||||
inner.put(url, vsc);
|
inner.put(url, vsc);
|
||||||
return vsc;
|
return vsc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -634,6 +634,9 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
|
||||||
if (cs.getContent() == CodeSystemContentMode.FRAGMENT) {
|
if (cs.getContent() == CodeSystemContentMode.FRAGMENT) {
|
||||||
addFragmentWarning(exp, cs);
|
addFragmentWarning(exp, cs);
|
||||||
}
|
}
|
||||||
|
if (cs.getContent() == CodeSystemContentMode.EXAMPLE) {
|
||||||
|
addExampleWarning(exp, cs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!inc.getConcept().isEmpty()) {
|
if (!inc.getConcept().isEmpty()) {
|
||||||
|
@ -645,6 +648,8 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
|
||||||
if (def == null) {
|
if (def == null) {
|
||||||
if (cs.getContent() == CodeSystemContentMode.FRAGMENT) {
|
if (cs.getContent() == CodeSystemContentMode.FRAGMENT) {
|
||||||
addFragmentWarning(exp, cs);
|
addFragmentWarning(exp, cs);
|
||||||
|
} else if (cs.getContent() == CodeSystemContentMode.EXAMPLE) {
|
||||||
|
addExampleWarning(exp, cs);
|
||||||
} else {
|
} else {
|
||||||
if (checkCodesWhenExpanding) {
|
if (checkCodesWhenExpanding) {
|
||||||
throw failTSE("Unable to find code '" + c.getCode() + "' in code system " + cs.getUrl());
|
throw failTSE("Unable to find code '" + c.getCode() + "' in code system " + cs.getUrl());
|
||||||
|
@ -733,12 +738,23 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addFragmentWarning(ValueSetExpansionComponent exp, CodeSystem cs) {
|
private void addFragmentWarning(ValueSetExpansionComponent exp, CodeSystem cs) {
|
||||||
for (Extension ex : cs.getExtensionsByUrl(ToolingExtensions.EXT_EXP_FRAGMENT)) {
|
String url = cs.getVersionedUrl();
|
||||||
if (ex.getValue().primitiveValue().equals(cs.getUrl())) {
|
for (ValueSetExpansionParameterComponent p : exp.getParameter()) {
|
||||||
|
if ("fragment".equals(p.getName()) && p.hasValueUriType() && url.equals(p.getValue().primitiveValue())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exp.addExtension(new Extension(ToolingExtensions.EXT_EXP_FRAGMENT).setValue(new UriType(cs.getUrl())));
|
exp.addParameter().setName("fragment").setValue(new UriType(url));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addExampleWarning(ValueSetExpansionComponent exp, CodeSystem cs) {
|
||||||
|
String url = cs.getVersionedUrl();
|
||||||
|
for (ValueSetExpansionParameterComponent p : exp.getParameter()) {
|
||||||
|
if ("example".equals(p.getName()) && p.hasValueUriType() && url.equals(p.getValue().primitiveValue())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exp.addParameter().setName("example").setValue(new UriType(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ConceptDefinitionDesignationComponent> convertDesignations(List<ConceptReferenceDesignationComponent> list) {
|
private List<ConceptDefinitionDesignationComponent> convertDesignations(List<ConceptReferenceDesignationComponent> list) {
|
||||||
|
|
|
@ -48,6 +48,9 @@ import org.hl7.fhir.utilities.Utilities;
|
||||||
public class ValueSetUtilities {
|
public class ValueSetUtilities {
|
||||||
|
|
||||||
public static ValueSet makeShareable(ValueSet vs) {
|
public static ValueSet makeShareable(ValueSet vs) {
|
||||||
|
if (!vs.hasExperimental()) {
|
||||||
|
vs.setExperimental(false);
|
||||||
|
}
|
||||||
if (!vs.hasMeta())
|
if (!vs.hasMeta())
|
||||||
vs.setMeta(new Meta());
|
vs.setMeta(new Meta());
|
||||||
for (UriType t : vs.getMeta().getProfile())
|
for (UriType t : vs.getMeta().getProfile())
|
||||||
|
@ -129,8 +132,12 @@ public class ValueSetUtilities {
|
||||||
}
|
}
|
||||||
if (fmm != null) {
|
if (fmm != null) {
|
||||||
String sfmm = ToolingExtensions.readStringExtension(vs, ToolingExtensions.EXT_FMM_LEVEL);
|
String sfmm = ToolingExtensions.readStringExtension(vs, ToolingExtensions.EXT_FMM_LEVEL);
|
||||||
if (Utilities.noString(sfmm) || Integer.parseInt(sfmm) < Integer.parseInt(fmm))
|
if (Utilities.noString(sfmm) || Integer.parseInt(sfmm) < Integer.parseInt(fmm)) {
|
||||||
ToolingExtensions.setIntegerExtension(vs, ToolingExtensions.EXT_FMM_LEVEL, Integer.parseInt(fmm));
|
ToolingExtensions.setIntegerExtension(vs, ToolingExtensions.EXT_FMM_LEVEL, Integer.parseInt(fmm));
|
||||||
|
}
|
||||||
|
if (Integer.parseInt(fmm) <= 1) {
|
||||||
|
vs.setExperimental(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (vs.hasUserData("cs"))
|
if (vs.hasUserData("cs"))
|
||||||
CodeSystemUtilities.markStatus((CodeSystem) vs.getUserData("cs"), wg, status, pckage, fmm, normativeVersion);
|
CodeSystemUtilities.markStatus((CodeSystem) vs.getUserData("cs"), wg, status, pckage, fmm, normativeVersion);
|
||||||
|
|
|
@ -151,13 +151,14 @@ public class TestingUtilities extends BaseTestingUtilities {
|
||||||
String result = compareXml(f1, f2);
|
String result = compareXml(f1, f2);
|
||||||
if (result != null && SHOW_DIFF) {
|
if (result != null && SHOW_DIFF) {
|
||||||
String diff = Utilities.path(System.getenv("ProgramFiles"), "WinMerge", "WinMergeU.exe");
|
String diff = Utilities.path(System.getenv("ProgramFiles"), "WinMerge", "WinMergeU.exe");
|
||||||
List<String> command = new ArrayList<String>();
|
if (new File(diff).exists()) {
|
||||||
command.add("\"" + diff + "\" \"" + f1 + "\" \"" + f2 + "\"");
|
List<String> command = new ArrayList<String>();
|
||||||
|
command.add("\"" + diff + "\" \"" + f1 + "\" \"" + f2 + "\"");
|
||||||
ProcessBuilder builder = new ProcessBuilder(command);
|
|
||||||
builder.directory(new CSFile("c:\\temp"));
|
|
||||||
builder.start();
|
|
||||||
|
|
||||||
|
ProcessBuilder builder = new ProcessBuilder(command);
|
||||||
|
builder.directory(new CSFile("c:\\temp"));
|
||||||
|
builder.start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -171,7 +172,7 @@ public class TestingUtilities extends BaseTestingUtilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String compareElements(String path, Element e1, Element e2) {
|
private static String compareElements(String path, Element e1, Element e2) {
|
||||||
if (!e1.getNamespaceURI().equals(e2.getNamespaceURI()))
|
if (!namespacesMatch(e1.getNamespaceURI(), e2.getNamespaceURI()))
|
||||||
return "Namespaces differ at " + path + ": " + e1.getNamespaceURI() + "/" + e2.getNamespaceURI();
|
return "Namespaces differ at " + path + ": " + e1.getNamespaceURI() + "/" + e2.getNamespaceURI();
|
||||||
if (!e1.getLocalName().equals(e2.getLocalName()))
|
if (!e1.getLocalName().equals(e2.getLocalName()))
|
||||||
return "Names differ at " + path + ": " + e1.getLocalName() + "/" + e2.getLocalName();
|
return "Names differ at " + path + ": " + e1.getLocalName() + "/" + e2.getLocalName();
|
||||||
|
@ -209,6 +210,10 @@ public class TestingUtilities extends BaseTestingUtilities {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean namespacesMatch(String ns1, String ns2) {
|
||||||
|
return ns1 == null ? ns2 == null : ns1.equals(ns2);
|
||||||
|
}
|
||||||
|
|
||||||
private static Object normalise(String text) {
|
private static Object normalise(String text) {
|
||||||
String result = text.trim().replace('\r', ' ').replace('\n', ' ').replace('\t', ' ');
|
String result = text.trim().replace('\r', ' ').replace('\n', ' ').replace('\t', ' ');
|
||||||
while (result.contains(" "))
|
while (result.contains(" "))
|
||||||
|
|
|
@ -5539,7 +5539,7 @@ public class FHIRPathEngine {
|
||||||
throw makeException(expr, I18nConstants.FHIRPATH_DISCRIMINATOR_BAD_NAME, expr.getName());
|
throw makeException(expr, I18nConstants.FHIRPATH_DISCRIMINATOR_BAD_NAME, expr.getName());
|
||||||
}
|
}
|
||||||
} else if (expr.getKind() == Kind.Group) {
|
} else if (expr.getKind() == Kind.Group) {
|
||||||
throw makeException(expr, I18nConstants.FHIRPATH_DISCRIMINATOR_BAD_SYNTAX_GROUP);
|
throw makeException(expr, I18nConstants.FHIRPATH_DISCRIMINATOR_BAD_SYNTAX_GROUP, expr.toString());
|
||||||
} else if (expr.getKind() == Kind.Constant) {
|
} else if (expr.getKind() == Kind.Constant) {
|
||||||
throw makeException(expr, I18nConstants.FHIRPATH_DISCRIMINATOR_BAD_SYNTAX_CONST);
|
throw makeException(expr, I18nConstants.FHIRPATH_DISCRIMINATOR_BAD_SYNTAX_CONST);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ public class IGHelper {
|
||||||
public static final String EXT_MAPPING_CSV = ToolingExtensions.EXT_IGP_MAPPING_CSV;
|
public static final String EXT_MAPPING_CSV = ToolingExtensions.EXT_IGP_MAPPING_CSV;
|
||||||
public static final String EXT_BUNDLE = ToolingExtensions.EXT_IGP_BUNDLE;
|
public static final String EXT_BUNDLE = ToolingExtensions.EXT_IGP_BUNDLE;
|
||||||
public static final String EXT_RESOURCE_INFO = ToolingExtensions.EXT_IGP_RESOURCE_INFO;
|
public static final String EXT_RESOURCE_INFO = ToolingExtensions.EXT_IGP_RESOURCE_INFO;
|
||||||
|
public static final String EXT_CONTAINED_RESOURCE_INFO = ToolingExtensions.EXT_IGP_CONTAINED_RESOURCE_INFO;
|
||||||
public static final String EXT_PRIVATE_BASE = ToolingExtensions.EXT_PRIVATE_BASE;
|
public static final String EXT_PRIVATE_BASE = ToolingExtensions.EXT_PRIVATE_BASE;
|
||||||
|
|
||||||
public static String readStringParameter(ImplementationGuideDefinitionComponent ig, String name) {
|
public static String readStringParameter(ImplementationGuideDefinitionComponent ig, String name) {
|
||||||
|
|
|
@ -276,7 +276,7 @@ public class NPMPackageGenerator {
|
||||||
return "hl7.fhir.r3.core";
|
return "hl7.fhir.r3.core";
|
||||||
if (v.startsWith("4.0"))
|
if (v.startsWith("4.0"))
|
||||||
return "hl7.fhir.r4.core";
|
return "hl7.fhir.r4.core";
|
||||||
if (v.startsWith("4.1"))
|
if (v.startsWith("4.1") || v.startsWith("4.3"))
|
||||||
return "hl7.fhir.r4b.core";
|
return "hl7.fhir.r4b.core";
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,6 +230,7 @@ public class QuestionnaireBuilder {
|
||||||
questionnaire.setPublisher(profile.getPublisher());
|
questionnaire.setPublisher(profile.getPublisher());
|
||||||
Questionnaire.QuestionnaireItemComponent item = new Questionnaire.QuestionnaireItemComponent();
|
Questionnaire.QuestionnaireItemComponent item = new Questionnaire.QuestionnaireItemComponent();
|
||||||
questionnaire.addItem(item);
|
questionnaire.addItem(item);
|
||||||
|
item.setLinkId("meta");
|
||||||
item.getCode().addAll(profile.getKeyword());
|
item.getCode().addAll(profile.getKeyword());
|
||||||
questionnaire.setId(nextId("qs"));
|
questionnaire.setId(nextId("qs"));
|
||||||
}
|
}
|
||||||
|
@ -241,6 +242,7 @@ public class QuestionnaireBuilder {
|
||||||
response.setStatus(QuestionnaireResponseStatus.INPROGRESS);
|
response.setStatus(QuestionnaireResponseStatus.INPROGRESS);
|
||||||
QuestionnaireResponse.QuestionnaireResponseItemComponent item = new QuestionnaireResponse.QuestionnaireResponseItemComponent();
|
QuestionnaireResponse.QuestionnaireResponseItemComponent item = new QuestionnaireResponse.QuestionnaireResponseItemComponent();
|
||||||
response.addItem(item);
|
response.addItem(item);
|
||||||
|
item.setLinkId("meta");
|
||||||
item.setUserData("object", resource);
|
item.setUserData("object", resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,9 +262,10 @@ public class QuestionnaireBuilder {
|
||||||
display.setType(QuestionnaireItemType.DISPLAY);
|
display.setType(QuestionnaireItemType.DISPLAY);
|
||||||
display.setText(element.getComment());
|
display.setText(element.getComment());
|
||||||
group.addItem(display);
|
group.addItem(display);
|
||||||
|
display.setLinkId(element.getId()+"-display");
|
||||||
}
|
}
|
||||||
group.setType(QuestionnaireItemType.GROUP);
|
group.setType(QuestionnaireItemType.GROUP);
|
||||||
ToolingExtensions.addFlyOver(group, element.getDefinition());
|
ToolingExtensions.addFlyOver(group, element.getDefinition(), element.getId()+"-flyover");
|
||||||
group.setRequired(element.getMin() > 0);
|
group.setRequired(element.getMin() > 0);
|
||||||
if (element.getMin() > 0)
|
if (element.getMin() > 0)
|
||||||
ToolingExtensions.addMin(group, element.getMin());
|
ToolingExtensions.addMin(group, element.getMin());
|
||||||
|
@ -284,10 +287,11 @@ public class QuestionnaireBuilder {
|
||||||
nparents.addAll(parents);
|
nparents.addAll(parents);
|
||||||
nparents.add(child);
|
nparents.add(child);
|
||||||
QuestionnaireItemComponent childGroup = group.addItem();
|
QuestionnaireItemComponent childGroup = group.addItem();
|
||||||
|
childGroup.setLinkId(child.getId()+"-grp");
|
||||||
childGroup.setType(QuestionnaireItemType.GROUP);
|
childGroup.setType(QuestionnaireItemType.GROUP);
|
||||||
|
|
||||||
List<QuestionnaireResponse.QuestionnaireResponseItemComponent> nResponse = new ArrayList<QuestionnaireResponse.QuestionnaireResponseItemComponent>();
|
List<QuestionnaireResponse.QuestionnaireResponseItemComponent> nResponse = new ArrayList<QuestionnaireResponse.QuestionnaireResponseItemComponent>();
|
||||||
processExisting(child.getPath(), answerGroups, nResponse);
|
processExisting(child.getPath(), answerGroups, childGroup, nResponse);
|
||||||
// if the element has a type, we add a question. else we add a group on the basis that
|
// if the element has a type, we add a question. else we add a group on the basis that
|
||||||
// it will have children of its own
|
// it will have children of its own
|
||||||
if (child.getType().isEmpty() || isAbstractType(child.getType()))
|
if (child.getType().isEmpty() || isAbstractType(child.getType()))
|
||||||
|
@ -334,13 +338,14 @@ public class QuestionnaireBuilder {
|
||||||
return path.substring(path.lastIndexOf('.')+1);
|
return path.substring(path.lastIndexOf('.')+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processExisting(String path, List<QuestionnaireResponse.QuestionnaireResponseItemComponent> answerGroups, List<QuestionnaireResponse.QuestionnaireResponseItemComponent> nResponse) throws FHIRException {
|
private void processExisting(String path, List<QuestionnaireResponse.QuestionnaireResponseItemComponent> answerGroups, QuestionnaireItemComponent item, List<QuestionnaireResponse.QuestionnaireResponseItemComponent> nResponse) throws FHIRException {
|
||||||
// processing existing data
|
// processing existing data
|
||||||
for (QuestionnaireResponse.QuestionnaireResponseItemComponent ag : answerGroups) {
|
for (QuestionnaireResponse.QuestionnaireResponseItemComponent ag : answerGroups) {
|
||||||
List<Base> children = ((Element) ag.getUserData("object")).listChildrenByName(tail(path));
|
List<Base> children = ((Element) ag.getUserData("object")).listChildrenByName(tail(path));
|
||||||
for (Base child : children) {
|
for (Base child : children) {
|
||||||
if (child != null) {
|
if (child != null) {
|
||||||
QuestionnaireResponse.QuestionnaireResponseItemComponent ans = ag.addItem();
|
QuestionnaireResponse.QuestionnaireResponseItemComponent ans = ag.addItem();
|
||||||
|
ag.setLinkId(item.getLinkId());
|
||||||
ans.setUserData("object", child);
|
ans.setUserData("object", child);
|
||||||
nResponse.add(ans);
|
nResponse.add(ans);
|
||||||
}
|
}
|
||||||
|
@ -366,9 +371,9 @@ public class QuestionnaireBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Utilities.noString(element.getComment()))
|
if (!Utilities.noString(element.getComment()))
|
||||||
ToolingExtensions.addFlyOver(group, element.getDefinition()+" "+element.getComment());
|
ToolingExtensions.addFlyOver(group, element.getDefinition()+" "+element.getComment(), group.getLinkId()+"-flyover");
|
||||||
else
|
else
|
||||||
ToolingExtensions.addFlyOver(group, element.getDefinition());
|
ToolingExtensions.addFlyOver(group, element.getDefinition(), group.getLinkId()+"-flyover");
|
||||||
|
|
||||||
if (element.getType().size() > 1 || element.getType().get(0).getWorkingCode().equals("*")) {
|
if (element.getType().size() > 1 || element.getType().get(0).getWorkingCode().equals("*")) {
|
||||||
List<TypeRefComponent> types = expandTypeList(element.getType());
|
List<TypeRefComponent> types = expandTypeList(element.getType());
|
||||||
|
|
|
@ -69,7 +69,9 @@ import java.util.Map;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.fhir.ucum.Utilities;
|
import org.fhir.ucum.Utilities;
|
||||||
import org.hl7.fhir.exceptions.FHIRException;
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
|
import org.hl7.fhir.r5.model.Base;
|
||||||
import org.hl7.fhir.r5.model.BooleanType;
|
import org.hl7.fhir.r5.model.BooleanType;
|
||||||
|
import org.hl7.fhir.r5.model.CanonicalResource;
|
||||||
import org.hl7.fhir.r5.model.CanonicalType;
|
import org.hl7.fhir.r5.model.CanonicalType;
|
||||||
import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent;
|
import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent;
|
||||||
import org.hl7.fhir.r5.model.CodeType;
|
import org.hl7.fhir.r5.model.CodeType;
|
||||||
|
@ -89,6 +91,7 @@ import org.hl7.fhir.r5.model.IntegerType;
|
||||||
import org.hl7.fhir.r5.model.MarkdownType;
|
import org.hl7.fhir.r5.model.MarkdownType;
|
||||||
import org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent;
|
import org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent;
|
||||||
import org.hl7.fhir.r5.model.PrimitiveType;
|
import org.hl7.fhir.r5.model.PrimitiveType;
|
||||||
|
import org.hl7.fhir.r5.model.Property;
|
||||||
import org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent;
|
import org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent;
|
||||||
import org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType;
|
import org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType;
|
||||||
import org.hl7.fhir.r5.model.StringType;
|
import org.hl7.fhir.r5.model.StringType;
|
||||||
|
@ -166,6 +169,7 @@ public class ToolingExtensions {
|
||||||
public static final String EXT_IGP_MAPPING_CSV = "http://hl7.org/fhir/StructureDefinition/igpublisher-mapping-csv";
|
public static final String EXT_IGP_MAPPING_CSV = "http://hl7.org/fhir/StructureDefinition/igpublisher-mapping-csv";
|
||||||
public static final String EXT_IGP_BUNDLE = "http://hl7.org/fhir/StructureDefinition/igpublisher-bundle";
|
public static final String EXT_IGP_BUNDLE = "http://hl7.org/fhir/StructureDefinition/igpublisher-bundle";
|
||||||
public static final String EXT_IGP_RESOURCE_INFO = "http://hl7.org/fhir/tools/StructureDefinition/resource-information";
|
public static final String EXT_IGP_RESOURCE_INFO = "http://hl7.org/fhir/tools/StructureDefinition/resource-information";
|
||||||
|
public static final String EXT_IGP_CONTAINED_RESOURCE_INFO = "http://hl7.org/fhir/tools/StructureDefinition/contained-resource-information";
|
||||||
public static final String EXT_IGP_LOADVERSION = "http://hl7.org/fhir/StructureDefinition/igpublisher-loadversion";
|
public static final String EXT_IGP_LOADVERSION = "http://hl7.org/fhir/StructureDefinition/igpublisher-loadversion";
|
||||||
public static final String EXT_MAX_VALUESET = "http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet";
|
public static final String EXT_MAX_VALUESET = "http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet";
|
||||||
public static final String EXT_MIN_VALUESET = "http://hl7.org/fhir/StructureDefinition/elementdefinition-minValueSet";
|
public static final String EXT_MIN_VALUESET = "http://hl7.org/fhir/StructureDefinition/elementdefinition-minValueSet";
|
||||||
|
@ -182,7 +186,6 @@ public class ToolingExtensions {
|
||||||
public static final String EXT_XML_TYPE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-xml-type";
|
public static final String EXT_XML_TYPE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-xml-type";
|
||||||
public static final String EXT_RENDERED_VALUE = "http://hl7.org/fhir/StructureDefinition/rendered-value";
|
public static final String EXT_RENDERED_VALUE = "http://hl7.org/fhir/StructureDefinition/rendered-value";
|
||||||
public static final String EXT_OLD_CONCEPTMAP_EQUIVALENCE = "http://hl7.org/fhir/1.0/StructureDefinition/extension-ConceptMap.element.target.equivalence";
|
public static final String EXT_OLD_CONCEPTMAP_EQUIVALENCE = "http://hl7.org/fhir/1.0/StructureDefinition/extension-ConceptMap.element.target.equivalence";
|
||||||
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_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_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_TRANSLATABLE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-translatable";
|
||||||
|
@ -192,6 +195,9 @@ public class ToolingExtensions {
|
||||||
public static final String EXT_XML_NAME = "http://hl7.org/fhir/StructureDefinition/elementdefinition-xml-name";
|
public static final String EXT_XML_NAME = "http://hl7.org/fhir/StructureDefinition/elementdefinition-xml-name";
|
||||||
public static final String EXT_BINDING_STYLE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-binding-style";
|
public static final String EXT_BINDING_STYLE = "http://hl7.org/fhir/StructureDefinition/elementdefinition-binding-style";
|
||||||
public static final String EXT_BINARY_FORMAT = "http://hl7.org/fhir/StructureDefinition/implementationguide-resource-format";
|
public static final String EXT_BINARY_FORMAT = "http://hl7.org/fhir/StructureDefinition/implementationguide-resource-format";
|
||||||
|
public static final String EXT_TARGET_ID = "http://hl7.org/fhir/StructureDefinition/targetElement";
|
||||||
|
public static final String EXT_TARGET_PATH = "http://hl7.org/fhir/StructureDefinition/targetPath";
|
||||||
|
public static final String EXT_VALUESET_SYSTEM = "http://hl7.org/fhir/StructureDefinition/valueset-system";
|
||||||
|
|
||||||
// specific extension helpers
|
// specific extension helpers
|
||||||
|
|
||||||
|
@ -462,11 +468,12 @@ public class ToolingExtensions {
|
||||||
// return findBooleanExtension(c, EXT_DEPRECATED);
|
// return findBooleanExtension(c, EXT_DEPRECATED);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public static void addFlyOver(QuestionnaireItemComponent item, String text){
|
public static void addFlyOver(QuestionnaireItemComponent item, String text, String linkId){
|
||||||
if (!StringUtils.isBlank(text)) {
|
if (!StringUtils.isBlank(text)) {
|
||||||
QuestionnaireItemComponent display = item.addItem();
|
QuestionnaireItemComponent display = item.addItem();
|
||||||
display.setType(QuestionnaireItemType.DISPLAY);
|
display.setType(QuestionnaireItemType.DISPLAY);
|
||||||
display.setText(text);
|
display.setText(text);
|
||||||
|
display.setLinkId(linkId);
|
||||||
display.getExtension().add(Factory.newExtension(EXT_CONTROL, Factory.newCodeableConcept("flyover", "http://hl7.org/fhir/questionnaire-item-control", "Fly-over"), true));
|
display.getExtension().add(Factory.newExtension(EXT_CONTROL, Factory.newCodeableConcept("flyover", "http://hl7.org/fhir/questionnaire-item-control", "Fly-over"), true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -900,5 +907,25 @@ public class ToolingExtensions {
|
||||||
dr.getExtension().add(Factory.newExtension(url, new UriType(value), true));
|
dr.getExtension().add(Factory.newExtension(url, new UriType(value), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean usesExtension(String url, Base base) {
|
||||||
|
if ("Extension".equals(base.fhirType())) {
|
||||||
|
Property p = base.getNamedProperty("url");
|
||||||
|
for (Base b : p.getValues()) {
|
||||||
|
if (url.equals(b.primitiveValue())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Property p : base.children() ) {
|
||||||
|
for (Base v : p.getValues()) {
|
||||||
|
if (usesExtension(url, v)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -35,6 +35,8 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hl7.fhir.utilities.Utilities;
|
import org.hl7.fhir.utilities.Utilities;
|
||||||
|
import org.hl7.fhir.utilities.VersionUtilities;
|
||||||
|
import org.hl7.fhir.utilities.VersionUtilities.VersionURLInfo;
|
||||||
|
|
||||||
|
|
||||||
public class TypesUtilities {
|
public class TypesUtilities {
|
||||||
|
@ -111,7 +113,7 @@ public class TypesUtilities {
|
||||||
res.add(new WildcardInformation("id", TypeClassification.PRIMITIVE));
|
res.add(new WildcardInformation("id", TypeClassification.PRIMITIVE));
|
||||||
res.add(new WildcardInformation("instant", TypeClassification.PRIMITIVE));
|
res.add(new WildcardInformation("instant", TypeClassification.PRIMITIVE));
|
||||||
res.add(new WildcardInformation("integer", TypeClassification.PRIMITIVE));
|
res.add(new WildcardInformation("integer", TypeClassification.PRIMITIVE));
|
||||||
if (!version.startsWith("4.1")) {
|
if (!VersionUtilities.isR4BVer(version)) {
|
||||||
res.add(new WildcardInformation("integer64", TypeClassification.PRIMITIVE));
|
res.add(new WildcardInformation("integer64", TypeClassification.PRIMITIVE));
|
||||||
}
|
}
|
||||||
res.add(new WildcardInformation("markdown", TypeClassification.PRIMITIVE));
|
res.add(new WildcardInformation("markdown", TypeClassification.PRIMITIVE));
|
||||||
|
@ -130,6 +132,7 @@ public class TypesUtilities {
|
||||||
res.add(new WildcardInformation("Annotation", TypeClassification.DATATYPE));
|
res.add(new WildcardInformation("Annotation", TypeClassification.DATATYPE));
|
||||||
res.add(new WildcardInformation("Attachment", TypeClassification.DATATYPE));
|
res.add(new WildcardInformation("Attachment", TypeClassification.DATATYPE));
|
||||||
res.add(new WildcardInformation("CodeableConcept", TypeClassification.DATATYPE));
|
res.add(new WildcardInformation("CodeableConcept", TypeClassification.DATATYPE));
|
||||||
|
res.add(new WildcardInformation("CodeableReference", TypeClassification.DATATYPE));
|
||||||
res.add(new WildcardInformation("Coding", TypeClassification.DATATYPE));
|
res.add(new WildcardInformation("Coding", TypeClassification.DATATYPE));
|
||||||
res.add(new WildcardInformation("ContactPoint", TypeClassification.DATATYPE));
|
res.add(new WildcardInformation("ContactPoint", TypeClassification.DATATYPE));
|
||||||
res.add(new WildcardInformation("Count", TypeClassification.DATATYPE));
|
res.add(new WildcardInformation("Count", TypeClassification.DATATYPE));
|
||||||
|
@ -142,6 +145,7 @@ public class TypesUtilities {
|
||||||
res.add(new WildcardInformation("Quantity", TypeClassification.DATATYPE));
|
res.add(new WildcardInformation("Quantity", TypeClassification.DATATYPE));
|
||||||
res.add(new WildcardInformation("Range", TypeClassification.DATATYPE));
|
res.add(new WildcardInformation("Range", TypeClassification.DATATYPE));
|
||||||
res.add(new WildcardInformation("Ratio", TypeClassification.DATATYPE));
|
res.add(new WildcardInformation("Ratio", TypeClassification.DATATYPE));
|
||||||
|
res.add(new WildcardInformation("RatioRange", TypeClassification.DATATYPE));
|
||||||
res.add(new WildcardInformation("Reference", " - a reference to another resource", TypeClassification.DATATYPE));
|
res.add(new WildcardInformation("Reference", " - a reference to another resource", TypeClassification.DATATYPE));
|
||||||
res.add(new WildcardInformation("SampledData", TypeClassification.DATATYPE));
|
res.add(new WildcardInformation("SampledData", TypeClassification.DATATYPE));
|
||||||
res.add(new WildcardInformation("Signature", TypeClassification.DATATYPE));
|
res.add(new WildcardInformation("Signature", TypeClassification.DATATYPE));
|
||||||
|
|
|
@ -40,7 +40,15 @@ public class XVerExtensionManager {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isR5(String url) {
|
||||||
|
String v = url.substring(20, 23);
|
||||||
|
return "5.0".equals(v);
|
||||||
|
}
|
||||||
|
|
||||||
public XVerExtensionStatus status(String url) throws FHIRException {
|
public XVerExtensionStatus status(String url) throws FHIRException {
|
||||||
|
if (url.length() < 24) {
|
||||||
|
return XVerExtensionStatus.Invalid;
|
||||||
|
}
|
||||||
String v = url.substring(20, 23);
|
String v = url.substring(20, 23);
|
||||||
if ("5.0".equals(v)) {
|
if ("5.0".equals(v)) {
|
||||||
v = "4.6"; // for now
|
v = "4.6"; // for now
|
||||||
|
@ -125,6 +133,11 @@ public class XVerExtensionManager {
|
||||||
} else {
|
} else {
|
||||||
throw new FHIRException("Internal error - attempt to define extension for "+url+" when it is invalid");
|
throw new FHIRException("Internal error - attempt to define extension for "+url+" when it is invalid");
|
||||||
}
|
}
|
||||||
|
if (path.has("modifier") && path.get("modifier").getAsBoolean()) {
|
||||||
|
ElementDefinition baseDef = new ElementDefinition("Extension");
|
||||||
|
sd.getDifferential().getElement().add(0, baseDef);
|
||||||
|
baseDef.setIsModifier(true);
|
||||||
|
}
|
||||||
return sd;
|
return sd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import okhttp3.Headers;
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.logging.HttpLoggingInterceptor;
|
|
||||||
import org.hl7.fhir.r5.model.Bundle;
|
import org.hl7.fhir.r5.model.Bundle;
|
||||||
import org.hl7.fhir.r5.model.Resource;
|
import org.hl7.fhir.r5.model.Resource;
|
||||||
import org.hl7.fhir.r5.utils.client.EFhirClientException;
|
import org.hl7.fhir.r5.utils.client.EFhirClientException;
|
||||||
|
|
|
@ -2,8 +2,8 @@ package org.hl7.fhir.r5.utils.client.network;
|
||||||
|
|
||||||
import okhttp3.*;
|
import okhttp3.*;
|
||||||
import org.hl7.fhir.utilities.ToolingClientLogger;
|
import org.hl7.fhir.utilities.ToolingClientLogger;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -22,9 +22,8 @@ public class FhirLoggingInterceptor implements Interceptor {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
@Override
|
||||||
public Response intercept(@NotNull Interceptor.Chain chain) throws IOException {
|
public Response intercept(@Nonnull Interceptor.Chain chain) throws IOException {
|
||||||
// Log Request
|
// Log Request
|
||||||
Request request = chain.request();
|
Request request = chain.request();
|
||||||
logger.logRequest(request.method(), request.url().toString(), new ArrayList<>(request.headers().names()),
|
logger.logRequest(request.method(), request.url().toString(), new ArrayList<>(request.headers().names()),
|
||||||
|
|
|
@ -35,8 +35,8 @@ public class RetryInterceptor implements Interceptor {
|
||||||
try {
|
try {
|
||||||
// If we are retrying a failed request that failed due to a bad response from the server, we must close it first
|
// If we are retrying a failed request that failed due to a bad response from the server, we must close it first
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
System.out.println("Previous " + chain.request().method() + " attempt returned HTTP<" + (response.code())
|
// System.out.println("Previous " + chain.request().method() + " attempt returned HTTP<" + (response.code())
|
||||||
+ "> from url -> " + chain.request().url() + ".");
|
// + "> from url -> " + chain.request().url() + ".");
|
||||||
response.close();
|
response.close();
|
||||||
}
|
}
|
||||||
// System.out.println(chain.request().method() + " attempt <" + (retryCounter + 1) + "> to url -> " + chain.request().url());
|
// System.out.println(chain.request().method() + " attempt <" + (retryCounter + 1) + "> to url -> " + chain.request().url());
|
||||||
|
|
|
@ -9,7 +9,7 @@ import org.hl7.fhir.r5.model.Resource;
|
||||||
import org.hl7.fhir.r5.model.TypeDetails;
|
import org.hl7.fhir.r5.model.TypeDetails;
|
||||||
import org.hl7.fhir.r5.model.ValueSet;
|
import org.hl7.fhir.r5.model.ValueSet;
|
||||||
import org.hl7.fhir.r5.utils.FHIRPathEngine;
|
import org.hl7.fhir.r5.utils.FHIRPathEngine;
|
||||||
import org.hl7.fhir.r5.utils.IResourceValidator;
|
import org.hl7.fhir.r5.utils.validation.IResourceValidator;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package org.hl7.fhir.r5.utils.validation;
|
||||||
|
|
||||||
|
public class BundleValidationRule {
|
||||||
|
private String rule;
|
||||||
|
private String profile;
|
||||||
|
private boolean checked;
|
||||||
|
|
||||||
|
public BundleValidationRule(String rule, String profile) {
|
||||||
|
super();
|
||||||
|
this.rule = rule;
|
||||||
|
this.profile = profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRule() {
|
||||||
|
return rule;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProfile() {
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isChecked() {
|
||||||
|
return checked;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChecked(boolean checked) {
|
||||||
|
this.checked = checked;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package org.hl7.fhir.r5.utils;
|
package org.hl7.fhir.r5.utils.validation;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2011+, HL7, Inc.
|
Copyright (c) 2011+, HL7, Inc.
|
||||||
|
@ -30,26 +30,18 @@ package org.hl7.fhir.r5.utils;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
|
import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat;
|
||||||
|
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||||
|
import org.hl7.fhir.r5.utils.validation.constants.BestPracticeWarningLevel;
|
||||||
|
import org.hl7.fhir.r5.utils.validation.constants.CheckDisplayOption;
|
||||||
|
import org.hl7.fhir.r5.utils.validation.constants.IdStatus;
|
||||||
|
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import org.hl7.fhir.exceptions.DefinitionException;
|
|
||||||
import org.hl7.fhir.exceptions.FHIRException;
|
|
||||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
|
||||||
import org.hl7.fhir.r5.elementmodel.Element;
|
|
||||||
import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat;
|
|
||||||
import org.hl7.fhir.r5.model.CanonicalResource;
|
|
||||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
|
||||||
import org.hl7.fhir.r5.utils.IResourceValidator.BundleValidationRule;
|
|
||||||
import org.hl7.fhir.utilities.Utilities;
|
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface to the instance validator. This takes a resource, in one of many forms, and
|
* Interface to the instance validator. This takes a resource, in one of many forms, and
|
||||||
|
@ -60,124 +52,21 @@ import com.google.gson.JsonObject;
|
||||||
*/
|
*/
|
||||||
public interface IResourceValidator {
|
public interface IResourceValidator {
|
||||||
|
|
||||||
public class BundleValidationRule {
|
|
||||||
private String rule;
|
|
||||||
private String profile;
|
|
||||||
private boolean checked;
|
|
||||||
|
|
||||||
public BundleValidationRule(String rule, String profile) {
|
|
||||||
super();
|
|
||||||
this.rule = rule;
|
|
||||||
this.profile = profile;
|
|
||||||
}
|
|
||||||
public String getRule() {
|
|
||||||
return rule;
|
|
||||||
}
|
|
||||||
public String getProfile() {
|
|
||||||
return profile;
|
|
||||||
}
|
|
||||||
public boolean isChecked() {
|
|
||||||
return checked;
|
|
||||||
}
|
|
||||||
public void setChecked(boolean checked) {
|
|
||||||
this.checked = checked;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ReferenceValidationPolicy {
|
|
||||||
IGNORE, CHECK_TYPE_IF_EXISTS, CHECK_EXISTS, CHECK_EXISTS_AND_TYPE, CHECK_VALID;
|
|
||||||
|
|
||||||
public boolean checkExists() {
|
|
||||||
return this == CHECK_EXISTS_AND_TYPE || this == CHECK_EXISTS || this == CHECK_VALID || this == CHECK_TYPE_IF_EXISTS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkType() {
|
|
||||||
return this == CHECK_TYPE_IF_EXISTS || this == CHECK_EXISTS_AND_TYPE || this == CHECK_VALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkValid() {
|
|
||||||
return this == CHECK_VALID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IValidationProfileUsageTracker {
|
|
||||||
void recordProfileUsage(StructureDefinition profile, Object appContext, Element element);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public interface IValidatorResourceFetcher {
|
|
||||||
|
|
||||||
Element fetch(IResourceValidator validator, Object appContext, String url) throws FHIRFormatError, DefinitionException, FHIRException, IOException;
|
|
||||||
ReferenceValidationPolicy validationPolicy(IResourceValidator validator, Object appContext, String path, String url);
|
|
||||||
boolean resolveURL(IResourceValidator validator, Object appContext, String path, String url, String type) throws IOException, FHIRException;
|
|
||||||
|
|
||||||
byte[] fetchRaw(IResourceValidator validator, String url) throws MalformedURLException, IOException; // for attachment checking
|
|
||||||
|
|
||||||
IValidatorResourceFetcher setLocale(Locale locale);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* this is used when the validator encounters a reference to a structure definition, value set or code system at some random URL reference
|
|
||||||
* while validating.
|
|
||||||
*
|
|
||||||
* Added in v5.2.2. return null to leave functionality as it was before then.
|
|
||||||
*
|
|
||||||
* @param primitiveValue
|
|
||||||
* @return an R5 version of the resource
|
|
||||||
* @throws URISyntaxException
|
|
||||||
*/
|
|
||||||
CanonicalResource fetchCanonicalResource(IResourceValidator validator, String url) throws URISyntaxException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether to try calling fetchCanonicalResource for this reference (not whether it will succeed - just throw an exception from fetchCanonicalResource if it doesn't resolve. This is a policy thing.
|
|
||||||
*
|
|
||||||
* Added in v5.2.2. return false to leave functionality as it was before then.
|
|
||||||
*
|
|
||||||
* @param url
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
boolean fetchesCanonicalResource(IResourceValidator validator, String url);
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum BestPracticeWarningLevel {
|
|
||||||
Ignore,
|
|
||||||
Hint,
|
|
||||||
Warning,
|
|
||||||
Error
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum CheckDisplayOption {
|
|
||||||
Ignore,
|
|
||||||
Check,
|
|
||||||
CheckCaseAndSpace,
|
|
||||||
CheckCase,
|
|
||||||
CheckSpace
|
|
||||||
}
|
|
||||||
|
|
||||||
enum IdStatus {
|
|
||||||
OPTIONAL, REQUIRED, PROHIBITED
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* how much to check displays for coded elements
|
* how much to check displays for coded elements
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
CheckDisplayOption getCheckDisplay();
|
CheckDisplayOption getCheckDisplay();
|
||||||
void setCheckDisplay(CheckDisplayOption checkDisplay);
|
void setCheckDisplay(CheckDisplayOption checkDisplay);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* whether the resource must have an id or not (depends on context)
|
* whether the resource must have an id or not (depends on context)
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
IdStatus getResourceIdRule();
|
IdStatus getResourceIdRule();
|
||||||
void setResourceIdRule(IdStatus resourceIdRule);
|
void setResourceIdRule(IdStatus resourceIdRule);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* whether the validator should enforce best practice guidelines
|
* whether the validator should enforce best practice guidelines
|
||||||
* as defined by various HL7 committees
|
* as defined by various HL7 committees
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
BestPracticeWarningLevel getBestPracticeWarningLevel();
|
BestPracticeWarningLevel getBestPracticeWarningLevel();
|
||||||
IResourceValidator setBestPracticeWarningLevel(BestPracticeWarningLevel value);
|
IResourceValidator setBestPracticeWarningLevel(BestPracticeWarningLevel value);
|
||||||
|
@ -185,48 +74,46 @@ public interface IResourceValidator {
|
||||||
IValidatorResourceFetcher getFetcher();
|
IValidatorResourceFetcher getFetcher();
|
||||||
IResourceValidator setFetcher(IValidatorResourceFetcher value);
|
IResourceValidator setFetcher(IValidatorResourceFetcher value);
|
||||||
|
|
||||||
|
IValidationPolicyAdvisor getPolicyAdvisor();
|
||||||
|
IResourceValidator setPolicyAdvisor(IValidationPolicyAdvisor advisor);
|
||||||
|
|
||||||
IValidationProfileUsageTracker getTracker();
|
IValidationProfileUsageTracker getTracker();
|
||||||
IResourceValidator setTracker(IValidationProfileUsageTracker value);
|
IResourceValidator setTracker(IValidationProfileUsageTracker value);
|
||||||
|
|
||||||
boolean isNoBindingMsgSuppressed();
|
boolean isNoBindingMsgSuppressed();
|
||||||
IResourceValidator setNoBindingMsgSuppressed(boolean noBindingMsgSuppressed);
|
IResourceValidator setNoBindingMsgSuppressed(boolean noBindingMsgSuppressed);
|
||||||
|
|
||||||
public boolean isNoInvariantChecks();
|
boolean isNoInvariantChecks();
|
||||||
public IResourceValidator setNoInvariantChecks(boolean value) ;
|
IResourceValidator setNoInvariantChecks(boolean value) ;
|
||||||
|
|
||||||
public boolean isWantInvariantInMessage();
|
boolean isWantInvariantInMessage();
|
||||||
public IResourceValidator setWantInvariantInMessage(boolean wantInvariantInMessage);
|
IResourceValidator setWantInvariantInMessage(boolean wantInvariantInMessage);
|
||||||
|
|
||||||
public boolean isNoTerminologyChecks();
|
boolean isNoTerminologyChecks();
|
||||||
public IResourceValidator setNoTerminologyChecks(boolean noTerminologyChecks);
|
IResourceValidator setNoTerminologyChecks(boolean noTerminologyChecks);
|
||||||
|
|
||||||
public boolean isNoExtensibleWarnings();
|
boolean isNoExtensibleWarnings();
|
||||||
public IResourceValidator setNoExtensibleWarnings(boolean noExtensibleWarnings);
|
IResourceValidator setNoExtensibleWarnings(boolean noExtensibleWarnings);
|
||||||
|
|
||||||
public boolean isNoUnicodeBiDiControlChars();
|
boolean isNoUnicodeBiDiControlChars();
|
||||||
public void setNoUnicodeBiDiControlChars(boolean noUnicodeBiDiControlChars);
|
void setNoUnicodeBiDiControlChars(boolean noUnicodeBiDiControlChars);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether being unable to resolve a profile in found in Resource.meta.profile or ElementDefinition.type.profile or targetProfile is an error or just a warning
|
* Whether being unable to resolve a profile in found in Resource.meta.profile or ElementDefinition.type.profile or targetProfile is an error or just a warning
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public boolean isErrorForUnknownProfiles();
|
boolean isErrorForUnknownProfiles();
|
||||||
public void setErrorForUnknownProfiles(boolean errorForUnknownProfiles);
|
void setErrorForUnknownProfiles(boolean errorForUnknownProfiles);
|
||||||
|
|
||||||
public boolean isShowMessagesFromReferences();
|
boolean isShowMessagesFromReferences();
|
||||||
public void setShowMessagesFromReferences(boolean value);
|
void setShowMessagesFromReferences(boolean value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this is used internally in the publishing stack to ensure that everything is water tight, but
|
* this is used internally in the publishing stack to ensure that everything is water tight, but
|
||||||
* this check is not necessary or appropriate at run time when the validator is hosted in HAPI
|
* this check is not necessary or appropriate at run time when the validator is hosted in HAPI
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isWantCheckSnapshotUnchanged();
|
boolean isWantCheckSnapshotUnchanged();
|
||||||
public void setWantCheckSnapshotUnchanged(boolean wantCheckSnapshotUnchanged);
|
void setWantCheckSnapshotUnchanged(boolean wantCheckSnapshotUnchanged);
|
||||||
|
|
||||||
//FIXME: don't need that, gets never used?
|
|
||||||
// public String getValidationLanguage();
|
|
||||||
// public void setValidationLanguage(String value);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It's common to see references such as Patient/234234 - these usually mean a reference to a Patient resource.
|
* It's common to see references such as Patient/234234 - these usually mean a reference to a Patient resource.
|
||||||
|
@ -235,27 +122,28 @@ public interface IResourceValidator {
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isAssumeValidRestReferences();
|
boolean isAssumeValidRestReferences();
|
||||||
public void setAssumeValidRestReferences(boolean value);
|
void setAssumeValidRestReferences(boolean value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* if this is true, the validator will accept extensions and references to example.org and acme.com as
|
* if this is true, the validator will accept extensions and references to example.org and acme.com as
|
||||||
* valid, on the basis that they are understood to be references to content that could exist in priniple but can't in practice
|
* valid, on the basis that they are understood to be references to content that could exist in priniple but can't in practice
|
||||||
*/
|
*/
|
||||||
public boolean isAllowExamples();
|
boolean isAllowExamples();
|
||||||
public void setAllowExamples(boolean value) ;
|
void setAllowExamples(boolean value) ;
|
||||||
|
|
||||||
|
boolean isNoCheckAggregation();
|
||||||
|
void setNoCheckAggregation(boolean value);
|
||||||
|
|
||||||
public boolean isNoCheckAggregation();
|
|
||||||
public void setNoCheckAggregation(boolean value);
|
|
||||||
/**
|
/**
|
||||||
* CrumbTrail - whether the validator creates hints to
|
* CrumbTrail - whether the validator creates hints to
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isCrumbTrails();
|
boolean isCrumbTrails();
|
||||||
public void setCrumbTrails(boolean crumbTrails);
|
void setCrumbTrails(boolean crumbTrails);
|
||||||
|
|
||||||
public boolean isValidateValueSetCodesOnTxServer();
|
boolean isValidateValueSetCodesOnTxServer();
|
||||||
public void setValidateValueSetCodesOnTxServer(boolean value);
|
void setValidateValueSetCodesOnTxServer(boolean value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bundle validation rules allow for requesting particular entries in a bundle get validated against particular profiles
|
* Bundle validation rules allow for requesting particular entries in a bundle get validated against particular profiles
|
||||||
|
@ -264,7 +152,7 @@ public interface IResourceValidator {
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<BundleValidationRule> getBundleValidationRules();
|
List<BundleValidationRule> getBundleValidationRules();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate suite
|
* Validate suite
|
|
@ -0,0 +1,82 @@
|
||||||
|
package org.hl7.fhir.r5.utils.validation;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hl7.fhir.r5.elementmodel.Element;
|
||||||
|
import org.hl7.fhir.r5.model.ElementDefinition;
|
||||||
|
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||||
|
import org.hl7.fhir.r5.model.ValueSet;
|
||||||
|
import org.hl7.fhir.r5.utils.validation.constants.ContainedReferenceValidationPolicy;
|
||||||
|
import org.hl7.fhir.r5.utils.validation.constants.ReferenceValidationPolicy;
|
||||||
|
import org.hl7.fhir.r5.utils.validation.constants.CodedContentValidationPolicy;
|
||||||
|
import org.hl7.fhir.r5.utils.validation.constants.BindingKind;
|
||||||
|
|
||||||
|
public interface IValidationPolicyAdvisor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param validator
|
||||||
|
* @param appContext What was originally provided from the app for it's context
|
||||||
|
* @param path Path that led us to this resource.
|
||||||
|
* @param url Url of the profile the container resource is being validated against.
|
||||||
|
* @return {@link ReferenceValidationPolicy}
|
||||||
|
*/
|
||||||
|
ReferenceValidationPolicy policyForReference(IResourceValidator validator,
|
||||||
|
Object appContext,
|
||||||
|
String path,
|
||||||
|
String url);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* //TODO pass through the actual containing Element as opposed to the type, id
|
||||||
|
* @param validator
|
||||||
|
* @param appContext What was originally provided from the app for it's context
|
||||||
|
* @param containerType Type of the resources that contains the resource being validated
|
||||||
|
* @param containerId Id of the resources that contains the resource being validated
|
||||||
|
* @param containingResourceType Type of the resource that will be validated (BUNDLE_ENTRY, BUNDLE_OUTCOME, CONTAINED_RESOURCE, PARAMETER)
|
||||||
|
* @param path Path that led us to this resource.
|
||||||
|
* @param url Url of the profile the container resource is being validated against.
|
||||||
|
* @return {@link ReferenceValidationPolicy}
|
||||||
|
*/
|
||||||
|
ContainedReferenceValidationPolicy policyForContained(IResourceValidator validator,
|
||||||
|
Object appContext,
|
||||||
|
String containerType,
|
||||||
|
String containerId,
|
||||||
|
Element.SpecialElement containingResourceType,
|
||||||
|
String path,
|
||||||
|
String url);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called before validating a concept in an instance against the terminology sub-system
|
||||||
|
*
|
||||||
|
* There's two reasons to use this policy advisor feature:
|
||||||
|
* - save time by not calling the terminology server for validation that don't bring value to the context calling the validation
|
||||||
|
* - suppressing known issues from being listed as a problem
|
||||||
|
*
|
||||||
|
* Note that the terminology subsystem has two parts: a mini-terminology server running inside the
|
||||||
|
* validator, and then calling out to an external terminology service (usually tx.fhir.org, though you
|
||||||
|
* run your own local copy of this - see https://confluence.hl7.org/display/FHIR/Running+your+own+copy+of+tx.fhir.org).
|
||||||
|
* You can't tell which subsystem will handle the terminology validation directly from the content provided here which
|
||||||
|
* subsystem will be called - you'll haev to investigate based on your set up. (matters, since it makes a huge performance
|
||||||
|
* difference, though it also depends on caching, and the impact of caching is also not known at this point)
|
||||||
|
*
|
||||||
|
* @param validator
|
||||||
|
* @param appContext What was originally provided from the app for it's context
|
||||||
|
* @param stackPath The current path for the stack. Note that the because of cross-references and FHIRPath conformsTo() statements, the stack can wind through the content unpredictably.
|
||||||
|
* @param definition the definition being validated against (might be useful: ElementDefinition.base.path, ElementDefinition.type, ElementDefinition.binding
|
||||||
|
* @param structure The structure definition that contains the element definition being validated against (may be from the base spec, may be from a profile)
|
||||||
|
* @param kind The part of the binding being validated
|
||||||
|
* @param valueSet The value set for the binding part that's being validated
|
||||||
|
* @param systems A list of canonical URls (including versions if known) of the systems in the instance that's being validated. Note that if a plain code is being validated, then there'll be no known system when this is called (systems will be empty, not null)
|
||||||
|
* @return {@link CodedContentValidationPolicy}
|
||||||
|
*/
|
||||||
|
CodedContentValidationPolicy policyForCodedContent(IResourceValidator validator,
|
||||||
|
Object appContext,
|
||||||
|
String stackPath,
|
||||||
|
ElementDefinition definition,
|
||||||
|
StructureDefinition structure,
|
||||||
|
BindingKind kind,
|
||||||
|
ValueSet valueSet,
|
||||||
|
List<String> systems);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package org.hl7.fhir.r5.utils.validation;
|
||||||
|
|
||||||
|
import org.hl7.fhir.r5.elementmodel.Element;
|
||||||
|
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||||
|
|
||||||
|
public interface IValidationProfileUsageTracker {
|
||||||
|
void recordProfileUsage(StructureDefinition profile, Object appContext, Element element);
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package org.hl7.fhir.r5.utils.validation;
|
||||||
|
|
||||||
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
|
import org.hl7.fhir.r5.elementmodel.Element;
|
||||||
|
import org.hl7.fhir.r5.model.CanonicalResource;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public interface IValidatorResourceFetcher {
|
||||||
|
|
||||||
|
Element fetch(IResourceValidator validator, Object appContext, String url) throws FHIRException, IOException;
|
||||||
|
|
||||||
|
boolean resolveURL(IResourceValidator validator, Object appContext, String path, String url, String type) throws IOException, FHIRException;
|
||||||
|
|
||||||
|
byte[] fetchRaw(IResourceValidator validator, String url) throws IOException; // for attachment checking
|
||||||
|
|
||||||
|
IValidatorResourceFetcher setLocale(Locale locale);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this is used when the validator encounters a reference to a structure definition, value set or code system at some random URL reference
|
||||||
|
* while validating.
|
||||||
|
* <p>
|
||||||
|
* Added in v5.2.2. return null to leave functionality as it was before then.
|
||||||
|
*
|
||||||
|
* @return an R5 version of the resource
|
||||||
|
* @throws URISyntaxException
|
||||||
|
*/
|
||||||
|
CanonicalResource fetchCanonicalResource(IResourceValidator validator, String url) throws URISyntaxException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to try calling fetchCanonicalResource for this reference (not whether it will succeed - just throw an exception from fetchCanonicalResource if it doesn't resolve. This is a policy thing.
|
||||||
|
* <p>
|
||||||
|
* Added in v5.2.2. return false to leave functionality as it was before then.
|
||||||
|
*
|
||||||
|
* @param url
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean fetchesCanonicalResource(IResourceValidator validator, String url);
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
package org.hl7.fhir.r5.utils.validation;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hl7.fhir.exceptions.FHIRException;
|
||||||
|
import org.hl7.fhir.r5.elementmodel.Element;
|
||||||
|
import org.hl7.fhir.r5.model.DomainResource;
|
||||||
|
import org.hl7.fhir.r5.model.Questionnaire;
|
||||||
|
import org.hl7.fhir.r5.model.Resource;
|
||||||
|
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||||
|
|
||||||
|
public class ValidationContextCarrier {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* When the validator is calling validateCode, it typically has a partially loaded resource that may provide
|
||||||
|
* additional resources that are relevant to the validation. This is a handle back into the validator context
|
||||||
|
* to ask for the resource to be fully loaded if it becomes relevant. Note that the resource may fail to load
|
||||||
|
* (e.g. if it's part of what's being validated) and if it does, the validator will record the validation
|
||||||
|
* issues before throwing an error
|
||||||
|
*
|
||||||
|
* This is a reference back int
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface IValidationContextResourceLoader {
|
||||||
|
public Resource loadContainedResource(List<ValidationMessage> errors, String path, Element resource, String id, Class<? extends Resource> class1) throws FHIRException;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of resources that provide context - typically, a container resource, and a bundle resource.
|
||||||
|
* iterate these in order looking for contained resources
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static class ValidationContextResourceProxy {
|
||||||
|
|
||||||
|
// either a resource
|
||||||
|
private Resource resource;
|
||||||
|
|
||||||
|
|
||||||
|
// or an element and a loader
|
||||||
|
private Element element;
|
||||||
|
private IValidationContextResourceLoader loader;
|
||||||
|
private List<ValidationMessage> errors;
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
public ValidationContextResourceProxy(Resource resource) {
|
||||||
|
this.resource = resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ValidationContextResourceProxy(List<ValidationMessage> errors, String path, Element element, IValidationContextResourceLoader loader) {
|
||||||
|
this.errors = errors;
|
||||||
|
this.path = path;
|
||||||
|
this.element = element;
|
||||||
|
this.loader = loader;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Resource loadContainedResource(String id, Class<? extends Resource> class1) throws FHIRException {
|
||||||
|
if (resource == null) {
|
||||||
|
Resource res = loader.loadContainedResource(errors, path, element, id, class1);
|
||||||
|
return res;
|
||||||
|
} else {
|
||||||
|
if (resource instanceof DomainResource) {
|
||||||
|
for (Resource r : ((DomainResource) resource).getContained()) {
|
||||||
|
if (r.getId().equals(id)) {
|
||||||
|
if (class1.isInstance(r))
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ValidationContextResourceProxy> resources = new ArrayList<>();
|
||||||
|
|
||||||
|
public List<ValidationContextResourceProxy> getResources() {
|
||||||
|
return resources;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package org.hl7.fhir.r5.utils.validation.constants;
|
||||||
|
|
||||||
|
public enum BestPracticeWarningLevel {
|
||||||
|
Ignore,
|
||||||
|
Hint,
|
||||||
|
Warning,
|
||||||
|
Error
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package org.hl7.fhir.r5.utils.validation.constants;
|
||||||
|
|
||||||
|
public enum BindingKind {
|
||||||
|
/**
|
||||||
|
* The primary binding e.g. ElementDefinition.binding.valueSet
|
||||||
|
*/
|
||||||
|
PRIMARY,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The max value set
|
||||||
|
*/
|
||||||
|
MAX_VS;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package org.hl7.fhir.r5.utils.validation.constants;
|
||||||
|
|
||||||
|
public enum CheckDisplayOption {
|
||||||
|
Ignore,
|
||||||
|
Check,
|
||||||
|
CheckCaseAndSpace,
|
||||||
|
CheckCase,
|
||||||
|
CheckSpace
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package org.hl7.fhir.r5.utils.validation.constants;
|
||||||
|
|
||||||
|
public enum CodedContentValidationPolicy {
|
||||||
|
/**
|
||||||
|
* don't validate the code
|
||||||
|
*/
|
||||||
|
IGNORE,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* validate the code against the underlying code systems
|
||||||
|
*/
|
||||||
|
CODE,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* validate the code against the value set too.
|
||||||
|
* Note that this isn't much faster than just validating the code since
|
||||||
|
* the expensive part is hitting the terminology server (if necessary)
|
||||||
|
* and that has to be done for the code part too
|
||||||
|
*/
|
||||||
|
VALUESET //
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package org.hl7.fhir.r5.utils.validation.constants;
|
||||||
|
|
||||||
|
public enum ContainedReferenceValidationPolicy {
|
||||||
|
IGNORE,
|
||||||
|
CHECK_TYPE,
|
||||||
|
CHECK_VALID;
|
||||||
|
|
||||||
|
public boolean ignore() {
|
||||||
|
return this == IGNORE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkType() {
|
||||||
|
return this == CHECK_TYPE || this == CHECK_VALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkValid() {
|
||||||
|
return this == CHECK_VALID;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package org.hl7.fhir.r5.utils.validation.constants;
|
||||||
|
|
||||||
|
public enum IdStatus {
|
||||||
|
OPTIONAL,
|
||||||
|
REQUIRED,
|
||||||
|
PROHIBITED
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package org.hl7.fhir.r5.utils.validation.constants;
|
||||||
|
|
||||||
|
public enum ReferenceValidationPolicy {
|
||||||
|
IGNORE,
|
||||||
|
CHECK_TYPE_IF_EXISTS,
|
||||||
|
CHECK_EXISTS,
|
||||||
|
CHECK_EXISTS_AND_TYPE,
|
||||||
|
CHECK_VALID;
|
||||||
|
|
||||||
|
public boolean ignore() {
|
||||||
|
return this == IGNORE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkExists() {
|
||||||
|
return this == CHECK_EXISTS_AND_TYPE || this == CHECK_EXISTS || this == CHECK_VALID || this == CHECK_TYPE_IF_EXISTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkType() {
|
||||||
|
return this == CHECK_TYPE_IF_EXISTS || this == CHECK_EXISTS_AND_TYPE || this == CHECK_VALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkValid() {
|
||||||
|
return this == CHECK_VALID;
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue