mirror of
https://github.com/hapifhir/org.hl7.fhir.core.git
synced 2025-02-08 13:54:44 +00:00
Merge branch 'master' of https://github.com/hapifhir/org.hl7.fhir.core into STU3-template-issue
This commit is contained in:
commit
d307ea7184
@ -4,4 +4,5 @@
|
|||||||
|
|
||||||
## Other code changes
|
## Other code changes
|
||||||
|
|
||||||
* no changes
|
* Ignore META-INF contents from other dependencies while building Validator jar
|
||||||
|
* Fix to r5 TestingUtilities to allow NarrativeGenerationTests to pass.
|
||||||
|
@ -239,7 +239,7 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
|
|||||||
|
|
||||||
public SimpleWorkerContext fromPackage(NpmPackage pi, IContextResourceLoader loader) throws IOException, FHIRException {
|
public SimpleWorkerContext fromPackage(NpmPackage pi, IContextResourceLoader loader) throws IOException, FHIRException {
|
||||||
SimpleWorkerContext context = getSimpleWorkerContextInstance();
|
SimpleWorkerContext context = getSimpleWorkerContextInstance();
|
||||||
context.setAllowLoadingDuplicates(true);
|
context.setAllowLoadingDuplicates(allowLoadingDuplicates);
|
||||||
context.version = pi.getNpm().get("version").getAsString();
|
context.version = pi.getNpm().get("version").getAsString();
|
||||||
context.loadFromPackage(pi, loader);
|
context.loadFromPackage(pi, loader);
|
||||||
context.finishLoading();
|
context.finishLoading();
|
||||||
|
@ -11570,6 +11570,10 @@ When pattern[x] is used to constrain a complex object, it means that each proper
|
|||||||
return getType().size() == 1 && Utilities.existsInList(getType().get(0).getCode(), "Element", "BackboneElement");
|
return getType().size() == 1 && Utilities.existsInList(getType().get(0).getCode(), "Element", "BackboneElement");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean prohibited() {
|
||||||
|
return "0".equals(getMax());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// end addition
|
// end addition
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import org.hl7.fhir.r5.context.IWorkerContext;
|
|||||||
import org.hl7.fhir.r5.context.IWorkerContext.ValidationResult;
|
import org.hl7.fhir.r5.context.IWorkerContext.ValidationResult;
|
||||||
import org.hl7.fhir.r5.model.Address;
|
import org.hl7.fhir.r5.model.Address;
|
||||||
import org.hl7.fhir.r5.model.Annotation;
|
import org.hl7.fhir.r5.model.Annotation;
|
||||||
|
import org.hl7.fhir.r5.model.BackboneType;
|
||||||
import org.hl7.fhir.r5.model.Base;
|
import org.hl7.fhir.r5.model.Base;
|
||||||
import org.hl7.fhir.r5.model.BaseDateTimeType;
|
import org.hl7.fhir.r5.model.BaseDateTimeType;
|
||||||
import org.hl7.fhir.r5.model.CanonicalResource;
|
import org.hl7.fhir.r5.model.CanonicalResource;
|
||||||
@ -48,6 +49,7 @@ 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.DateType;
|
import org.hl7.fhir.r5.model.DateType;
|
||||||
|
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.Expression;
|
||||||
import org.hl7.fhir.r5.model.Extension;
|
import org.hl7.fhir.r5.model.Extension;
|
||||||
@ -357,8 +359,138 @@ public class DataRenderer extends Renderer {
|
|||||||
return value.primitiveValue();
|
return value.primitiveValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -- 6. General purpose extension rendering ----------------------------------------------
|
||||||
|
|
||||||
// -- 5. Data type Rendering ----------------------------------------------
|
public boolean hasRenderableExtensions(DataType element) {
|
||||||
|
for (Extension ext : element.getExtension()) {
|
||||||
|
if (canRender(ext)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasRenderableExtensions(BackboneType element) {
|
||||||
|
for (Extension ext : element.getExtension()) {
|
||||||
|
if (canRender(ext)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return element.hasModifierExtension();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getExtensionLabel(Extension ext) {
|
||||||
|
StructureDefinition sd = context.getWorker().fetchResource(StructureDefinition.class, ext.getUrl());
|
||||||
|
if (sd != null && ext.getValue().isPrimitive() && sd.hasSnapshot()) {
|
||||||
|
for (ElementDefinition ed : sd.getSnapshot().getElement()) {
|
||||||
|
if (Utilities.existsInList(ed.getPath(), "Extension", "Extension.value[x]") && ed.hasLabel()) {
|
||||||
|
return ed.getLabel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canRender(Extension ext) {
|
||||||
|
return getExtensionLabel(ext) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void renderExtensionsInList(XhtmlNode ul, DataType element) throws FHIRFormatError, DefinitionException, IOException {
|
||||||
|
for (Extension ext : element.getExtension()) {
|
||||||
|
if (canRender(ext)) {
|
||||||
|
String lbl = getExtensionLabel(ext);
|
||||||
|
XhtmlNode li = ul.li();
|
||||||
|
li.tx(lbl);
|
||||||
|
li.tx(": ");
|
||||||
|
render(li, ext.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void renderExtensionsInList(XhtmlNode ul, BackboneType element) throws FHIRFormatError, DefinitionException, IOException {
|
||||||
|
for (Extension ext : element.getModifierExtension()) {
|
||||||
|
if (canRender(ext)) {
|
||||||
|
String lbl = getExtensionLabel(ext);
|
||||||
|
XhtmlNode li = ul.li();
|
||||||
|
li = li.b();
|
||||||
|
li.tx(lbl);
|
||||||
|
li.tx(": ");
|
||||||
|
render(li, ext.getValue());
|
||||||
|
} else {
|
||||||
|
// somehow have to do better than this
|
||||||
|
XhtmlNode li = ul.li();
|
||||||
|
li.b().tx("WARNING: Unrenderable Modifier Extension!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Extension ext : element.getExtension()) {
|
||||||
|
if (canRender(ext)) {
|
||||||
|
String lbl = getExtensionLabel(ext);
|
||||||
|
XhtmlNode li = ul.li();
|
||||||
|
li.tx(lbl);
|
||||||
|
li.tx(": ");
|
||||||
|
render(li, ext.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void renderExtensionsInText(XhtmlNode div, DataType element, String sep) throws FHIRFormatError, DefinitionException, IOException {
|
||||||
|
boolean first = true;
|
||||||
|
for (Extension ext : element.getExtension()) {
|
||||||
|
if (canRender(ext)) {
|
||||||
|
if (first) {
|
||||||
|
first = false;
|
||||||
|
} else {
|
||||||
|
div.tx(sep);
|
||||||
|
div.tx(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
String lbl = getExtensionLabel(ext);
|
||||||
|
div.tx(lbl);
|
||||||
|
div.tx(": ");
|
||||||
|
render(div, ext.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void renderExtensionsInList(XhtmlNode div, BackboneType element, String sep) throws FHIRFormatError, DefinitionException, IOException {
|
||||||
|
boolean first = true;
|
||||||
|
for (Extension ext : element.getModifierExtension()) {
|
||||||
|
if (first) {
|
||||||
|
first = false;
|
||||||
|
} else {
|
||||||
|
div.tx(sep);
|
||||||
|
div.tx(" ");
|
||||||
|
}
|
||||||
|
if (canRender(ext)) {
|
||||||
|
String lbl = getExtensionLabel(ext);
|
||||||
|
XhtmlNode b = div.b();
|
||||||
|
b.tx(lbl);
|
||||||
|
b.tx(": ");
|
||||||
|
render(div, ext.getValue());
|
||||||
|
} else {
|
||||||
|
// somehow have to do better than this
|
||||||
|
div.b().tx("WARNING: Unrenderable Modifier Extension!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Extension ext : element.getExtension()) {
|
||||||
|
if (canRender(ext)) {
|
||||||
|
if (first) {
|
||||||
|
first = false;
|
||||||
|
} else {
|
||||||
|
div.tx(sep);
|
||||||
|
div.tx(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
String lbl = getExtensionLabel(ext);
|
||||||
|
div.tx(lbl);
|
||||||
|
div.tx(": ");
|
||||||
|
render(div, ext.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// -- 6. Data type Rendering ----------------------------------------------
|
||||||
|
|
||||||
public static String display(IWorkerContext context, DataType type) {
|
public static String display(IWorkerContext context, DataType type) {
|
||||||
return new DataRenderer(new RenderingContext(context, null, null, "http://hl7.org/fhir/R4", "", null, ResourceRendererMode.END_USER)).display(type);
|
return new DataRenderer(new RenderingContext(context, null, null, "http://hl7.org/fhir/R4", "", null, ResourceRendererMode.END_USER)).display(type);
|
||||||
@ -866,11 +998,11 @@ public class DataRenderer extends Renderer {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renderCodeableConcept(XhtmlNode x, CodeableConcept cc) {
|
protected void renderCodeableConcept(XhtmlNode x, CodeableConcept cc) throws FHIRFormatError, DefinitionException, IOException {
|
||||||
renderCodeableConcept(x, cc, false);
|
renderCodeableConcept(x, cc, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renderCodeableReference(XhtmlNode x, CodeableReference e, boolean showCodeDetails) {
|
protected void renderCodeableReference(XhtmlNode x, CodeableReference e, boolean showCodeDetails) throws FHIRFormatError, DefinitionException, IOException {
|
||||||
if (e.hasConcept()) {
|
if (e.hasConcept()) {
|
||||||
renderCodeableConcept(x, e.getConcept(), showCodeDetails);
|
renderCodeableConcept(x, e.getConcept(), showCodeDetails);
|
||||||
}
|
}
|
||||||
@ -879,7 +1011,7 @@ public class DataRenderer extends Renderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renderCodeableConcept(XhtmlNode x, CodeableConcept cc, boolean showCodeDetails) {
|
protected void renderCodeableConcept(XhtmlNode x, CodeableConcept cc, boolean showCodeDetails) throws FHIRFormatError, DefinitionException, IOException {
|
||||||
if (cc.isEmpty()) {
|
if (cc.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -935,6 +1067,12 @@ public class DataRenderer extends Renderer {
|
|||||||
sp.tx(" \""+c.getDisplay()+"\"");
|
sp.tx(" \""+c.getDisplay()+"\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (hasRenderableExtensions(cc)) {
|
||||||
|
if (!first) {
|
||||||
|
sp.tx("; ");
|
||||||
|
}
|
||||||
|
renderExtensionsInText(sp, cc, ";");
|
||||||
|
}
|
||||||
sp.tx(")");
|
sp.tx(")");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -75,11 +75,23 @@ public class TestingUtilities extends BaseTestingUtilities {
|
|||||||
|
|
||||||
static public Map<String, IWorkerContext> fcontexts;
|
static public Map<String, IWorkerContext> fcontexts;
|
||||||
|
|
||||||
public static IWorkerContext context() {
|
final static public String DEFAULT_CONTEXT_VERSION = "4.0.1";
|
||||||
return context("4.0.1");
|
|
||||||
|
/** Get an existing instantiation of a WorkerContext if available
|
||||||
|
*
|
||||||
|
* This uses the DEFAULT_CONTEXT_VERSION
|
||||||
|
* */
|
||||||
|
public static IWorkerContext getSharedWorkerContext() {
|
||||||
|
return getSharedWorkerContext(DEFAULT_CONTEXT_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IWorkerContext context(String version) {
|
/**
|
||||||
|
* Get an existing instantiation of a WorkerContext if available
|
||||||
|
*
|
||||||
|
* @param version FHIR Version to get context for
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static IWorkerContext getSharedWorkerContext(String version) {
|
||||||
if ("4.5.0".equals(version)) {
|
if ("4.5.0".equals(version)) {
|
||||||
version = "4.4.0"; // temporary work around
|
version = "4.4.0"; // temporary work around
|
||||||
}
|
}
|
||||||
@ -89,33 +101,35 @@ public class TestingUtilities extends BaseTestingUtilities {
|
|||||||
fcontexts = new HashMap<>();
|
fcontexts = new HashMap<>();
|
||||||
}
|
}
|
||||||
if (!fcontexts.containsKey(v)) {
|
if (!fcontexts.containsKey(v)) {
|
||||||
FilesystemPackageCacheManager pcm;
|
IWorkerContext fcontext = getWorkerContext(version);
|
||||||
try {
|
|
||||||
pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
|
|
||||||
IWorkerContext fcontext = getWorkerContext(pcm.loadPackage(VersionUtilities.packageForVersion(version), version));
|
|
||||||
fcontext.setUcumService(new UcumEssenceService(TestingUtilities.loadTestResourceStream("ucum", "ucum-essence.xml")));
|
|
||||||
fcontext.setExpansionProfile(new Parameters());
|
|
||||||
// ((SimpleWorkerContext) fcontext).connectToTSServer(new TerminologyClientR5("http://tx.fhir.org/r4"), null);
|
|
||||||
fcontexts.put(v, fcontext);
|
fcontexts.put(v, fcontext);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new Error(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return fcontexts.get(v);
|
return fcontexts.get(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IWorkerContext getWorkerContext(String version) {
|
||||||
|
FilesystemPackageCacheManager pcm;
|
||||||
|
try {
|
||||||
|
pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
|
||||||
|
IWorkerContext fcontext = getWorkerContext(pcm.loadPackage(VersionUtilities.packageForVersion(version), version));
|
||||||
|
fcontext.setUcumService(new UcumEssenceService(TestingUtilities.loadTestResourceStream("ucum", "ucum-essence.xml")));
|
||||||
|
fcontext.setExpansionProfile(new Parameters());
|
||||||
|
return fcontext;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new Error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static SimpleWorkerContext getWorkerContext(NpmPackage npmPackage) throws Exception {
|
public static SimpleWorkerContext getWorkerContext(NpmPackage npmPackage) throws Exception {
|
||||||
SimpleWorkerContext swc = new SimpleWorkerContext.SimpleWorkerContextBuilder().withUserAgent(TestConstants.USER_AGENT).withTerminologyCachePath(TestConstants.TX_CACHE).fromPackage(npmPackage);
|
SimpleWorkerContext swc = new SimpleWorkerContext.SimpleWorkerContextBuilder().withAllowLoadingDuplicates(true).withUserAgent(TestConstants.USER_AGENT).withTerminologyCachePath(TestConstants.TX_CACHE).fromPackage(npmPackage);
|
||||||
TerminologyCache.setCacheErrors(true);
|
TerminologyCache.setCacheErrors(true);
|
||||||
swc.setAllowLoadingDuplicates(true);
|
|
||||||
return swc;
|
return swc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SimpleWorkerContext getWorkerContext(NpmPackage npmPackage, IWorkerContext.IContextResourceLoader loader) throws Exception {
|
public static SimpleWorkerContext getWorkerContext(NpmPackage npmPackage, IWorkerContext.IContextResourceLoader loader) throws Exception {
|
||||||
SimpleWorkerContext swc = new SimpleWorkerContext.SimpleWorkerContextBuilder().withUserAgent(TestConstants.USER_AGENT).withTerminologyCachePath(TestConstants.TX_CACHE).fromPackage(npmPackage, loader);
|
SimpleWorkerContext swc = new SimpleWorkerContext.SimpleWorkerContextBuilder().withAllowLoadingDuplicates(true).withUserAgent(TestConstants.USER_AGENT).withTerminologyCachePath(TestConstants.TX_CACHE).fromPackage(npmPackage, loader);
|
||||||
TerminologyCache.setCacheErrors(true);
|
TerminologyCache.setCacheErrors(true);
|
||||||
swc.setAllowLoadingDuplicates(true);
|
|
||||||
return swc;
|
return swc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,12 +123,12 @@ public class XVerExtensionManager {
|
|||||||
populateTypes(path, val, verSource, verTarget);
|
populateTypes(path, val, verSource, verTarget);
|
||||||
} else if (path.has("elements")) {
|
} else if (path.has("elements")) {
|
||||||
for (JsonElement i : path.getAsJsonArray("elements")) {
|
for (JsonElement i : path.getAsJsonArray("elements")) {
|
||||||
String s = i.getAsString();
|
String s = i.getAsString().replace("[x]", "");
|
||||||
sd.getDifferential().addElement().setPath("Extension.extension").setSliceName(s);
|
sd.getDifferential().addElement().setPath("Extension.extension").setSliceName(s);
|
||||||
sd.getDifferential().addElement().setPath("Extension.extension.extension").setMax("0");
|
sd.getDifferential().addElement().setPath("Extension.extension.extension").setMax("0");
|
||||||
sd.getDifferential().addElement().setPath("Extension.extension.url").setFixed(new UriType(s));
|
sd.getDifferential().addElement().setPath("Extension.extension.url").setFixed(new UriType(s));
|
||||||
ElementDefinition val = sd.getDifferential().addElement().setPath("Extension.extension.value[x]").setMin(1);
|
ElementDefinition val = sd.getDifferential().addElement().setPath("Extension.extension.value[x]").setMin(1);
|
||||||
JsonObject elt = root.getAsJsonObject(e+"."+s);
|
JsonObject elt = root.getAsJsonObject(e+"."+i.getAsString());
|
||||||
if (!elt.has("types")) {
|
if (!elt.has("types")) {
|
||||||
throw new FHIRException("Internal error - nested elements not supported yet");
|
throw new FHIRException("Internal error - nested elements not supported yet");
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ public class CDARoundTripTests {
|
|||||||
value.setValue("öé");
|
value.setValue("öé");
|
||||||
|
|
||||||
ByteArrayOutputStream baosXml = new ByteArrayOutputStream();
|
ByteArrayOutputStream baosXml = new ByteArrayOutputStream();
|
||||||
Manager.compose(TestingUtilities.context(), xml, baosXml, FhirFormat.XML, OutputStyle.PRETTY, null);
|
Manager.compose(TestingUtilities.getSharedWorkerContext(), xml, baosXml, FhirFormat.XML, OutputStyle.PRETTY, null);
|
||||||
String cdaSerialised = baosXml.toString("UTF-8");
|
String cdaSerialised = baosXml.toString("UTF-8");
|
||||||
Assertions.assertTrue(cdaSerialised.indexOf("öé") > 0);
|
Assertions.assertTrue(cdaSerialised.indexOf("öé") > 0);
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ public class FHIRPathTests {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ValueSet resolveValueSet(Object appContext, String url) {
|
public ValueSet resolveValueSet(Object appContext, String url) {
|
||||||
return TestingUtilities.context().fetchResource(ValueSet.class, url);
|
return TestingUtilities.getSharedWorkerContext().fetchResource(ValueSet.class, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ public class FHIRPathTests {
|
|||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setUp() {
|
public static void setUp() {
|
||||||
fp = new FHIRPathEngine(TestingUtilities.context());
|
fp = new FHIRPathEngine(TestingUtilities.getSharedWorkerContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Stream<Arguments> data() throws ParserConfigurationException, SAXException, IOException {
|
public static Stream<Arguments> data() throws ParserConfigurationException, SAXException, IOException {
|
||||||
|
@ -65,7 +65,7 @@ public class GraphQLEngineTests implements IGraphQLStorageServices {
|
|||||||
stream = TestingUtilities.loadTestResourceStream("r5", parts[0].toLowerCase()+"-"+parts[1].toLowerCase()+".xml");
|
stream = TestingUtilities.loadTestResourceStream("r5", parts[0].toLowerCase()+"-"+parts[1].toLowerCase()+".xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphQLEngine gql = new GraphQLEngine(TestingUtilities.context());
|
GraphQLEngine gql = new GraphQLEngine(TestingUtilities.getSharedWorkerContext());
|
||||||
gql.setServices(this);
|
gql.setServices(this);
|
||||||
if (stream != null)
|
if (stream != null)
|
||||||
gql.setFocus(new XmlParser().parse(stream));
|
gql.setFocus(new XmlParser().parse(stream));
|
||||||
|
@ -37,7 +37,7 @@ public class LiquidEngineTests implements ILiquidEngineIncludeResolver {
|
|||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
engine = new LiquidEngine(TestingUtilities.context(), null);
|
engine = new LiquidEngine(TestingUtilities.getSharedWorkerContext(), null);
|
||||||
engine.setIncludeResolver(this);
|
engine.setIncludeResolver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ public class NarrativeGenerationTests {
|
|||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setUp() {
|
public static void setUp() {
|
||||||
context = TestingUtilities.context();
|
context = TestingUtilities.getSharedWorkerContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest(name = "{index}: file {0}")
|
@ParameterizedTest(name = "{index}: file {0}")
|
||||||
|
@ -34,7 +34,7 @@ public class NarrativeGeneratorTests {
|
|||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setUp() throws FHIRException {
|
public static void setUp() throws FHIRException {
|
||||||
rc = new RenderingContext(TestingUtilities.context(), null, null, "http://hl7.org/fhir", "", null, ResourceRendererMode.END_USER);
|
rc = new RenderingContext(TestingUtilities.getSharedWorkerContext(), null, null, "http://hl7.org/fhir", "", null, ResourceRendererMode.END_USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -32,7 +32,7 @@ public class OpenApiGeneratorTest {
|
|||||||
public void run(InputStream sfn, String dfn) throws IOException, FHIRFormatError, FileNotFoundException {
|
public void run(InputStream sfn, String dfn) throws IOException, FHIRFormatError, FileNotFoundException {
|
||||||
CapabilityStatement cs = (CapabilityStatement) new JsonParser().parse(sfn);
|
CapabilityStatement cs = (CapabilityStatement) new JsonParser().parse(sfn);
|
||||||
Writer oa = new Writer(new FileOutputStream(dfn));
|
Writer oa = new Writer(new FileOutputStream(dfn));
|
||||||
OpenApiGenerator gen = new OpenApiGenerator(TestingUtilities.context(), cs, oa);
|
OpenApiGenerator gen = new OpenApiGenerator(TestingUtilities.getSharedWorkerContext(), cs, oa);
|
||||||
gen.generate("test-lic", "http://spdx.org/licenses/test-lic.html");
|
gen.generate("test-lic", "http://spdx.org/licenses/test-lic.html");
|
||||||
oa.commit();
|
oa.commit();
|
||||||
}
|
}
|
||||||
|
@ -29,13 +29,13 @@ public class ProfileUtilitiesTests {
|
|||||||
public void testSimple() throws FHIRException {
|
public void testSimple() throws FHIRException {
|
||||||
|
|
||||||
StructureDefinition focus = new StructureDefinition();
|
StructureDefinition focus = new StructureDefinition();
|
||||||
StructureDefinition base = TestingUtilities.context().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Patient").copy();
|
StructureDefinition base = TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Patient").copy();
|
||||||
focus.setUrl(Utilities.makeUuidUrn());
|
focus.setUrl(Utilities.makeUuidUrn());
|
||||||
focus.setBaseDefinition(base.getUrl());
|
focus.setBaseDefinition(base.getUrl());
|
||||||
focus.setType("Patient");
|
focus.setType("Patient");
|
||||||
focus.setDerivation(TypeDerivationRule.CONSTRAINT);
|
focus.setDerivation(TypeDerivationRule.CONSTRAINT);
|
||||||
List<ValidationMessage> messages = new ArrayList<>();
|
List<ValidationMessage> messages = new ArrayList<>();
|
||||||
new ProfileUtilities(TestingUtilities.context(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://test.org/test", "Simple Test");
|
new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://test.org/test", "Simple Test");
|
||||||
|
|
||||||
boolean ok = base.getSnapshot().getElement().size() == focus.getSnapshot().getElement().size();
|
boolean ok = base.getSnapshot().getElement().size() == focus.getSnapshot().getElement().size();
|
||||||
for (int i = 0; i < base.getSnapshot().getElement().size(); i++) {
|
for (int i = 0; i < base.getSnapshot().getElement().size(); i++) {
|
||||||
@ -70,13 +70,13 @@ public class ProfileUtilitiesTests {
|
|||||||
// */
|
// */
|
||||||
@Test
|
@Test
|
||||||
public void testSimple2() {
|
public void testSimple2() {
|
||||||
StructureDefinition base = TestingUtilities.context().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/ValueSet").copy();
|
StructureDefinition base = TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/ValueSet").copy();
|
||||||
StructureDefinition focus = base.copy();
|
StructureDefinition focus = base.copy();
|
||||||
focus.setUrl(Utilities.makeUuidUrn());
|
focus.setUrl(Utilities.makeUuidUrn());
|
||||||
focus.setSnapshot(null);
|
focus.setSnapshot(null);
|
||||||
focus.setDifferential(null);
|
focus.setDifferential(null);
|
||||||
List<ValidationMessage> messages = new ArrayList<>();
|
List<ValidationMessage> messages = new ArrayList<>();
|
||||||
new ProfileUtilities(TestingUtilities.context(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://test.org", "Simple Test");
|
new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://test.org", "Simple Test");
|
||||||
|
|
||||||
boolean ok = base.getSnapshot().getElement().size() == focus.getSnapshot().getElement().size();
|
boolean ok = base.getSnapshot().getElement().size() == focus.getSnapshot().getElement().size();
|
||||||
for (int i = 0; i < base.getSnapshot().getElement().size(); i++) {
|
for (int i = 0; i < base.getSnapshot().getElement().size(); i++) {
|
||||||
@ -110,7 +110,7 @@ public class ProfileUtilitiesTests {
|
|||||||
@Test
|
@Test
|
||||||
void testCardinalityChange() {
|
void testCardinalityChange() {
|
||||||
StructureDefinition focus = new StructureDefinition();
|
StructureDefinition focus = new StructureDefinition();
|
||||||
StructureDefinition base = TestingUtilities.context().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Patient").copy();
|
StructureDefinition base = TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Patient").copy();
|
||||||
focus.setUrl(Utilities.makeUuidUrn());
|
focus.setUrl(Utilities.makeUuidUrn());
|
||||||
focus.setBaseDefinition(base.getUrl());
|
focus.setBaseDefinition(base.getUrl());
|
||||||
focus.setType(base.getType());
|
focus.setType(base.getType());
|
||||||
@ -119,7 +119,7 @@ public class ProfileUtilitiesTests {
|
|||||||
id.setPath("Patient.identifier");
|
id.setPath("Patient.identifier");
|
||||||
id.setMin(1);
|
id.setMin(1);
|
||||||
List<ValidationMessage> messages = new ArrayList<>();
|
List<ValidationMessage> messages = new ArrayList<>();
|
||||||
new ProfileUtilities(TestingUtilities.context(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://test.org", "Simple Test");
|
new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://test.org", "Simple Test");
|
||||||
|
|
||||||
boolean ok = base.getSnapshot().getElement().size() == focus.getSnapshot().getElement().size();
|
boolean ok = base.getSnapshot().getElement().size() == focus.getSnapshot().getElement().size();
|
||||||
for (int i = 0; i < base.getSnapshot().getElement().size(); i++) {
|
for (int i = 0; i < base.getSnapshot().getElement().size(); i++) {
|
||||||
@ -155,7 +155,7 @@ public class ProfileUtilitiesTests {
|
|||||||
void testMinValueChange() {
|
void testMinValueChange() {
|
||||||
// Given
|
// Given
|
||||||
StructureDefinition focus = new StructureDefinition();
|
StructureDefinition focus = new StructureDefinition();
|
||||||
StructureDefinition base = TestingUtilities.context().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Appointment").copy();
|
StructureDefinition base = TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Appointment").copy();
|
||||||
focus.setUrl(Utilities.makeUuidUrn());
|
focus.setUrl(Utilities.makeUuidUrn());
|
||||||
focus.setBaseDefinition(base.getUrl());
|
focus.setBaseDefinition(base.getUrl());
|
||||||
focus.setType(base.getType());
|
focus.setType(base.getType());
|
||||||
@ -165,7 +165,7 @@ public class ProfileUtilitiesTests {
|
|||||||
id.setMinValue(new IntegerType(1));
|
id.setMinValue(new IntegerType(1));
|
||||||
List<ValidationMessage> messages = new ArrayList<>();
|
List<ValidationMessage> messages = new ArrayList<>();
|
||||||
// When
|
// When
|
||||||
new ProfileUtilities(TestingUtilities.context(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://test.org", "Simple Test");
|
new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://test.org", "Simple Test");
|
||||||
// Then
|
// Then
|
||||||
boolean ok = base.getSnapshot().getElement().size() == focus.getSnapshot().getElement().size();
|
boolean ok = base.getSnapshot().getElement().size() == focus.getSnapshot().getElement().size();
|
||||||
for (int i = 0; i < base.getSnapshot().getElement().size(); i++) {
|
for (int i = 0; i < base.getSnapshot().getElement().size(); i++) {
|
||||||
@ -202,7 +202,7 @@ public class ProfileUtilitiesTests {
|
|||||||
void testMaxValueChange() {
|
void testMaxValueChange() {
|
||||||
// Given
|
// Given
|
||||||
StructureDefinition focus = new StructureDefinition();
|
StructureDefinition focus = new StructureDefinition();
|
||||||
StructureDefinition base = TestingUtilities.context().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Appointment").copy();
|
StructureDefinition base = TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Appointment").copy();
|
||||||
focus.setUrl(Utilities.makeUuidUrn());
|
focus.setUrl(Utilities.makeUuidUrn());
|
||||||
focus.setBaseDefinition(base.getUrl());
|
focus.setBaseDefinition(base.getUrl());
|
||||||
focus.setType(base.getType());
|
focus.setType(base.getType());
|
||||||
@ -212,7 +212,7 @@ public class ProfileUtilitiesTests {
|
|||||||
id.setMaxValue(new IntegerType(1));
|
id.setMaxValue(new IntegerType(1));
|
||||||
List<ValidationMessage> messages = new ArrayList<>();
|
List<ValidationMessage> messages = new ArrayList<>();
|
||||||
// When
|
// When
|
||||||
new ProfileUtilities(TestingUtilities.context(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://test.org", "Simple Test");
|
new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), messages, null).generateSnapshot(base, focus, focus.getUrl(), "http://test.org", "Simple Test");
|
||||||
// Then
|
// Then
|
||||||
boolean ok = base.getSnapshot().getElement().size() == focus.getSnapshot().getElement().size();
|
boolean ok = base.getSnapshot().getElement().size() == focus.getSnapshot().getElement().size();
|
||||||
for (int i = 0; i < base.getSnapshot().getElement().size(); i++) {
|
for (int i = 0; i < base.getSnapshot().getElement().size(); i++) {
|
||||||
|
@ -33,7 +33,7 @@ public class ResourceRoundTripTests {
|
|||||||
@Test
|
@Test
|
||||||
public void test() throws IOException, FHIRException, EOperationOutcome {
|
public void test() throws IOException, FHIRException, EOperationOutcome {
|
||||||
DomainResource res = (DomainResource) new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", "unicode.xml"));
|
DomainResource res = (DomainResource) new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", "unicode.xml"));
|
||||||
RenderingContext rc = new RenderingContext(TestingUtilities.context(), null, null, "http://hl7.org/fhir", "", null, ResourceRendererMode.END_USER);
|
RenderingContext rc = new RenderingContext(TestingUtilities.getSharedWorkerContext(), null, null, "http://hl7.org/fhir", "", null, ResourceRendererMode.END_USER);
|
||||||
RendererFactory.factory(res, rc).render(res);
|
RendererFactory.factory(res, rc).render(res);
|
||||||
IOUtils.copy(TestingUtilities.loadTestResourceStream("r5", "unicode.xml"), new FileOutputStream(TestingUtilities.tempFile("gen", "unicode.xml")));
|
IOUtils.copy(TestingUtilities.loadTestResourceStream("r5", "unicode.xml"), new FileOutputStream(TestingUtilities.tempFile("gen", "unicode.xml")));
|
||||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(TestingUtilities.tempFile("gen", "unicode.out.xml")), res);
|
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(TestingUtilities.tempFile("gen", "unicode.out.xml")), res);
|
||||||
@ -64,7 +64,7 @@ public class ResourceRoundTripTests {
|
|||||||
* verify that umlaut like äö etc are not encoded in UTF-8 in attributes
|
* verify that umlaut like äö etc are not encoded in UTF-8 in attributes
|
||||||
*/
|
*/
|
||||||
public void testSerializeUmlaut() throws IOException {
|
public void testSerializeUmlaut() throws IOException {
|
||||||
Element xml = Manager.parseSingle(TestingUtilities.context(), TestingUtilities.loadTestResourceStream("r5", "unicode.xml"),
|
Element xml = Manager.parseSingle(TestingUtilities.getSharedWorkerContext(), TestingUtilities.loadTestResourceStream("r5", "unicode.xml"),
|
||||||
FhirFormat.XML);
|
FhirFormat.XML);
|
||||||
List<Element> concept = xml.getChildrenByName("concept");
|
List<Element> concept = xml.getChildrenByName("concept");
|
||||||
assertTrue(concept!=null && concept.size()==1);
|
assertTrue(concept!=null && concept.size()==1);
|
||||||
@ -72,7 +72,7 @@ public class ResourceRoundTripTests {
|
|||||||
assertTrue(code!=null && code.size()==1);
|
assertTrue(code!=null && code.size()==1);
|
||||||
code.get(0).setValue("ö");
|
code.get(0).setValue("ö");
|
||||||
ByteArrayOutputStream baosXml = new ByteArrayOutputStream();
|
ByteArrayOutputStream baosXml = new ByteArrayOutputStream();
|
||||||
Manager.compose(TestingUtilities.context(), xml, baosXml, FhirFormat.XML, OutputStyle.PRETTY, null);
|
Manager.compose(TestingUtilities.getSharedWorkerContext(), xml, baosXml, FhirFormat.XML, OutputStyle.PRETTY, null);
|
||||||
String cdaSerialised = baosXml.toString("UTF-8");
|
String cdaSerialised = baosXml.toString("UTF-8");
|
||||||
assertTrue(cdaSerialised.indexOf("ö")>0);
|
assertTrue(cdaSerialised.indexOf("ö")>0);
|
||||||
}
|
}
|
||||||
|
@ -18,12 +18,12 @@ import org.junit.jupiter.api.Test;
|
|||||||
public class ShexGeneratorTests {
|
public class ShexGeneratorTests {
|
||||||
|
|
||||||
private void doTest(String name) throws FileNotFoundException, IOException, FHIRException, UcumException {
|
private void doTest(String name) throws FileNotFoundException, IOException, FHIRException, UcumException {
|
||||||
StructureDefinition sd = TestingUtilities.context().fetchResource(StructureDefinition.class, ProfileUtilities.sdNs(name, null));
|
StructureDefinition sd = TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, ProfileUtilities.sdNs(name, null));
|
||||||
if (sd == null) {
|
if (sd == null) {
|
||||||
throw new FHIRException("StructuredDefinition for " + name + "was null");
|
throw new FHIRException("StructuredDefinition for " + name + "was null");
|
||||||
}
|
}
|
||||||
Path outPath = FileSystems.getDefault().getPath(System.getProperty("java.io.tmpdir"), name.toLowerCase() + ".shex");
|
Path outPath = FileSystems.getDefault().getPath(System.getProperty("java.io.tmpdir"), name.toLowerCase() + ".shex");
|
||||||
TextFile.stringToFile(new ShExGenerator(TestingUtilities.context()).generate(HTMLLinkPolicy.NONE, sd), outPath.toString());
|
TextFile.stringToFile(new ShExGenerator(TestingUtilities.getSharedWorkerContext()).generate(HTMLLinkPolicy.NONE, sd), outPath.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -211,13 +211,13 @@ public class SnapShotGenerationTests {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDatatype(String name) {
|
public boolean isDatatype(String name) {
|
||||||
StructureDefinition sd = TestingUtilities.context().fetchTypeDefinition(name);
|
StructureDefinition sd = TestingUtilities.getSharedWorkerContext().fetchTypeDefinition(name);
|
||||||
return (sd != null) && (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION) && (sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE || sd.getKind() == StructureDefinitionKind.COMPLEXTYPE);
|
return (sd != null) && (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION) && (sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE || sd.getKind() == StructureDefinitionKind.COMPLEXTYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isResource(String typeSimple) {
|
public boolean isResource(String typeSimple) {
|
||||||
StructureDefinition sd = TestingUtilities.context().fetchTypeDefinition(typeSimple);
|
StructureDefinition sd = TestingUtilities.getSharedWorkerContext().fetchTypeDefinition(typeSimple);
|
||||||
return (sd != null) && (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION) && (sd.getKind() == StructureDefinitionKind.RESOURCE);
|
return (sd != null) && (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION) && (sd.getKind() == StructureDefinitionKind.RESOURCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +249,7 @@ public class SnapShotGenerationTests {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLinkForProfile(StructureDefinition profile, String url) {
|
public String getLinkForProfile(StructureDefinition profile, String url) {
|
||||||
StructureDefinition sd = TestingUtilities.context().fetchResource(StructureDefinition.class, url);
|
StructureDefinition sd = TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, url);
|
||||||
if (sd == null)
|
if (sd == null)
|
||||||
return url + "|" + url;
|
return url + "|" + url;
|
||||||
else
|
else
|
||||||
@ -275,15 +275,15 @@ public class SnapShotGenerationTests {
|
|||||||
public Resource fetchFixture(String id) {
|
public Resource fetchFixture(String id) {
|
||||||
TestFetchMode mode = TestFetchMode.INPUT;
|
TestFetchMode mode = TestFetchMode.INPUT;
|
||||||
if (id.equals("patient"))
|
if (id.equals("patient"))
|
||||||
return TestingUtilities.context().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Patient");
|
return TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Patient");
|
||||||
if (id.equals("valueset"))
|
if (id.equals("valueset"))
|
||||||
return TestingUtilities.context().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/ValueSet");
|
return TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/ValueSet");
|
||||||
if (id.equals("organization"))
|
if (id.equals("organization"))
|
||||||
return TestingUtilities.context().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Organization");
|
return TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Organization");
|
||||||
if (id.equals("operationoutcome"))
|
if (id.equals("operationoutcome"))
|
||||||
return TestingUtilities.context().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/OperationOutcome");
|
return TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/OperationOutcome");
|
||||||
if (id.equals("parameters"))
|
if (id.equals("parameters"))
|
||||||
return TestingUtilities.context().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Parameters");
|
return TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/Parameters");
|
||||||
|
|
||||||
if (id.contains("-")) {
|
if (id.contains("-")) {
|
||||||
String[] p = id.split("\\-");
|
String[] p = id.split("\\-");
|
||||||
@ -339,7 +339,7 @@ public class SnapShotGenerationTests {
|
|||||||
@Override
|
@Override
|
||||||
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters) throws PathEngineException {
|
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters) throws PathEngineException {
|
||||||
if ("fixture".equals(functionName))
|
if ("fixture".equals(functionName))
|
||||||
return new TypeDetails(CollectionStatus.SINGLETON, TestingUtilities.context().getResourceNamesAsSet());
|
return new TypeDetails(CollectionStatus.SINGLETON, TestingUtilities.getSharedWorkerContext().getResourceNamesAsSet());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,7 +366,7 @@ public class SnapShotGenerationTests {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
|
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
|
||||||
IResourceValidator val = TestingUtilities.context().newValidator();
|
IResourceValidator val = TestingUtilities.getSharedWorkerContext().newValidator();
|
||||||
List<ValidationMessage> valerrors = new ArrayList<ValidationMessage>();
|
List<ValidationMessage> valerrors = new ArrayList<ValidationMessage>();
|
||||||
if (item instanceof Resource) {
|
if (item instanceof Resource) {
|
||||||
val.validate(appContext, valerrors, (Resource) item, url);
|
val.validate(appContext, valerrors, (Resource) item, url);
|
||||||
@ -404,7 +404,7 @@ public class SnapShotGenerationTests {
|
|||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setUp() {
|
public static void setUp() {
|
||||||
fp = new FHIRPathEngine(TestingUtilities.context());
|
fp = new FHIRPathEngine(TestingUtilities.getSharedWorkerContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Stream<Arguments> data() throws ParserConfigurationException, IOException, FHIRFormatError, SAXException {
|
public static Stream<Arguments> data() throws ParserConfigurationException, IOException, FHIRFormatError, SAXException {
|
||||||
@ -462,7 +462,7 @@ public class SnapShotGenerationTests {
|
|||||||
private void testSort(TestDetails test, SnapShotGenerationTestsContext context) throws DefinitionException, FHIRException, IOException {
|
private void testSort(TestDetails test, SnapShotGenerationTestsContext context) throws DefinitionException, FHIRException, IOException {
|
||||||
StructureDefinition base = getSD(test.getSource().getBaseDefinition(), context);
|
StructureDefinition base = getSD(test.getSource().getBaseDefinition(), context);
|
||||||
test.setOutput(test.getSource().copy());
|
test.setOutput(test.getSource().copy());
|
||||||
ProfileUtilities pu = new ProfileUtilities(TestingUtilities.context(), null, null);
|
ProfileUtilities pu = new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), null, null);
|
||||||
pu.setIds(test.getSource(), false);
|
pu.setIds(test.getSource(), false);
|
||||||
List<String> errors = new ArrayList<String>();
|
List<String> errors = new ArrayList<String>();
|
||||||
pu.sortDifferential(base, test.getOutput(), test.getOutput().getUrl(), errors, false);
|
pu.sortDifferential(base, test.getOutput(), test.getOutput().getUrl(), errors, false);
|
||||||
@ -476,17 +476,17 @@ public class SnapShotGenerationTests {
|
|||||||
private void testGen(boolean fail, TestDetails test, SnapShotGenerationTestsContext context) throws Exception {
|
private void testGen(boolean fail, TestDetails test, SnapShotGenerationTestsContext context) throws Exception {
|
||||||
if (!Utilities.noString(test.register)) {
|
if (!Utilities.noString(test.register)) {
|
||||||
List<ValidationMessage> messages = new ArrayList<ValidationMessage>();
|
List<ValidationMessage> messages = new ArrayList<ValidationMessage>();
|
||||||
ProfileUtilities pu = new ProfileUtilities(TestingUtilities.context(), messages, null);
|
ProfileUtilities pu = new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), messages, null);
|
||||||
pu.setNewSlicingProcessing(true);
|
pu.setNewSlicingProcessing(true);
|
||||||
for (StructureDefinition sd : test.included) {
|
for (StructureDefinition sd : test.included) {
|
||||||
pu.setIds(sd, false);
|
pu.setIds(sd, false);
|
||||||
}
|
}
|
||||||
for (StructureDefinition sd : test.included) {
|
for (StructureDefinition sd : test.included) {
|
||||||
if (!TestingUtilities.context().hasResource(StructureDefinition.class, sd.getUrl())) {
|
if (!TestingUtilities.getSharedWorkerContext().hasResource(StructureDefinition.class, sd.getUrl())) {
|
||||||
TestingUtilities.context().cacheResource(sd);
|
TestingUtilities.getSharedWorkerContext().cacheResource(sd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
StructureDefinition base = TestingUtilities.context().fetchResource(StructureDefinition.class, test.included.get(0).getBaseDefinition());
|
StructureDefinition base = TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, test.included.get(0).getBaseDefinition());
|
||||||
if (base != null) {
|
if (base != null) {
|
||||||
pu.generateSnapshot(base, test.included.get(0), test.included.get(0).getUrl(), "http://test.org/profile", test.included.get(0).getName());
|
pu.generateSnapshot(base, test.included.get(0), test.included.get(0).getUrl(), "http://test.org/profile", test.included.get(0).getName());
|
||||||
}
|
}
|
||||||
@ -505,16 +505,16 @@ public class SnapShotGenerationTests {
|
|||||||
throw new Exception("URL mismatch on base: " + base.getUrl() + " wanting " + test.getSource().getBaseDefinition());
|
throw new Exception("URL mismatch on base: " + base.getUrl() + " wanting " + test.getSource().getBaseDefinition());
|
||||||
|
|
||||||
StructureDefinition output = test.getSource().copy();
|
StructureDefinition output = test.getSource().copy();
|
||||||
ProfileUtilities pu = new ProfileUtilities(TestingUtilities.context(), messages, new TestPKP());
|
ProfileUtilities pu = new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), messages, new TestPKP());
|
||||||
pu.setNewSlicingProcessing(test.isNewSliceProcessing());
|
pu.setNewSlicingProcessing(test.isNewSliceProcessing());
|
||||||
pu.setThrowException(false);
|
pu.setThrowException(false);
|
||||||
pu.setDebug(test.isDebug());
|
pu.setDebug(test.isDebug());
|
||||||
pu.setIds(test.getSource(), false);
|
pu.setIds(test.getSource(), false);
|
||||||
if (!TestingUtilities.context().hasPackage(CommonPackages.ID_XVER, CommonPackages.VER_XVER)) {
|
if (!TestingUtilities.getSharedWorkerContext().hasPackage(CommonPackages.ID_XVER, CommonPackages.VER_XVER)) {
|
||||||
NpmPackage npm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION).loadPackage(CommonPackages.ID_XVER, CommonPackages.VER_XVER);
|
NpmPackage npm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION).loadPackage(CommonPackages.ID_XVER, CommonPackages.VER_XVER);
|
||||||
TestingUtilities.context().loadFromPackage(npm, new TestPackageLoader(new String[]{"StructureDefinition"}), new String[]{"StructureDefinition"});
|
TestingUtilities.getSharedWorkerContext().loadFromPackage(npm, new TestPackageLoader(new String[]{"StructureDefinition"}), new String[]{"StructureDefinition"});
|
||||||
}
|
}
|
||||||
pu.setXver(new XVerExtensionManager(TestingUtilities.context()));
|
pu.setXver(new XVerExtensionManager(TestingUtilities.getSharedWorkerContext()));
|
||||||
if (test.isSort()) {
|
if (test.isSort()) {
|
||||||
List<String> errors = new ArrayList<String>();
|
List<String> errors = new ArrayList<String>();
|
||||||
int lastCount = output.getDifferential().getElement().size();
|
int lastCount = output.getDifferential().getElement().size();
|
||||||
@ -539,14 +539,14 @@ public class SnapShotGenerationTests {
|
|||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
if (output.getDifferential().hasElement()) {
|
if (output.getDifferential().hasElement()) {
|
||||||
RenderingContext rc = new RenderingContext(TestingUtilities.context(), null, null, "http://hl7.org/fhir", "", null, ResourceRendererMode.END_USER);
|
RenderingContext rc = new RenderingContext(TestingUtilities.getSharedWorkerContext(), null, null, "http://hl7.org/fhir", "", null, ResourceRendererMode.END_USER);
|
||||||
rc.setDestDir(Utilities.path("[tmp]", "snapshot"));
|
rc.setDestDir(Utilities.path("[tmp]", "snapshot"));
|
||||||
rc.setProfileUtilities(new ProfileUtilities(TestingUtilities.context(), null, new TestPKP()));
|
rc.setProfileUtilities(new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), null, new TestPKP()));
|
||||||
RendererFactory.factory(output, rc).render(output);
|
RendererFactory.factory(output, rc).render(output);
|
||||||
}
|
}
|
||||||
if (!fail) {
|
if (!fail) {
|
||||||
test.output = output;
|
test.output = output;
|
||||||
TestingUtilities.context().cacheResource(output);
|
TestingUtilities.getSharedWorkerContext().cacheResource(output);
|
||||||
File dst = new File(TestingUtilities.tempFile("snapshot", test.getId() + "-expected.xml"));
|
File dst = new File(TestingUtilities.tempFile("snapshot", test.getId() + "-expected.xml"));
|
||||||
if (dst.exists())
|
if (dst.exists())
|
||||||
dst.delete();
|
dst.delete();
|
||||||
@ -563,14 +563,14 @@ public class SnapShotGenerationTests {
|
|||||||
private StructureDefinition getSD(String url, SnapShotGenerationTestsContext context) throws DefinitionException, FHIRException, IOException {
|
private StructureDefinition getSD(String url, SnapShotGenerationTestsContext context) throws DefinitionException, FHIRException, IOException {
|
||||||
StructureDefinition sd = context.getByUrl(url);
|
StructureDefinition sd = context.getByUrl(url);
|
||||||
if (sd == null) {
|
if (sd == null) {
|
||||||
sd = TestingUtilities.context().fetchResource(StructureDefinition.class, url);
|
sd = TestingUtilities.getSharedWorkerContext().fetchResource(StructureDefinition.class, url);
|
||||||
}
|
}
|
||||||
if (sd == null) {
|
if (sd == null) {
|
||||||
throw new DefinitionException("Unable to find profile "+url);
|
throw new DefinitionException("Unable to find profile "+url);
|
||||||
}
|
}
|
||||||
if (!sd.hasSnapshot()) {
|
if (!sd.hasSnapshot()) {
|
||||||
StructureDefinition base = getSD(sd.getBaseDefinition(), context);
|
StructureDefinition base = getSD(sd.getBaseDefinition(), context);
|
||||||
ProfileUtilities pu = new ProfileUtilities(TestingUtilities.context(), messages, new TestPKP());
|
ProfileUtilities pu = new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), messages, new TestPKP());
|
||||||
pu.setNewSlicingProcessing(true);
|
pu.setNewSlicingProcessing(true);
|
||||||
List<String> errors = new ArrayList<String>();
|
List<String> errors = new ArrayList<String>();
|
||||||
pu.sortDifferential(base, sd, url, errors, false);
|
pu.sortDifferential(base, sd, url, errors, false);
|
||||||
|
@ -24,6 +24,7 @@ import org.hl7.fhir.r5.renderers.utils.RenderingContext.ITypeParser;
|
|||||||
import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
|
import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
|
||||||
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
||||||
import org.hl7.fhir.utilities.TextFile;
|
import org.hl7.fhir.utilities.TextFile;
|
||||||
|
import org.hl7.fhir.utilities.VersionUtilities;
|
||||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
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.ToolsVersion;
|
import org.hl7.fhir.utilities.npm.ToolsVersion;
|
||||||
@ -104,8 +105,11 @@ public class VocabTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void setUp() throws FileNotFoundException, FHIRException, IOException {
|
public static void setUp() throws FHIRException, IOException {
|
||||||
context = TestingUtilities.context();
|
/* Do NOT get a shared worker context from Testing Utilities or else the terminology package loaded below
|
||||||
|
will appear in tests where it causes failures.
|
||||||
|
*/
|
||||||
|
context = TestingUtilities.getWorkerContext(VersionUtilities.getMajMin(TestingUtilities.DEFAULT_CONTEXT_VERSION));
|
||||||
if (!context.hasPackage("hl7.terminology", null)) {
|
if (!context.hasPackage("hl7.terminology", null)) {
|
||||||
|
|
||||||
NpmPackage utg = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION).loadPackage("hl7.terminology");
|
NpmPackage utg = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION).loadPackage("hl7.terminology");
|
||||||
|
@ -86,9 +86,9 @@ public class ResourceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Element testEM() throws Exception {
|
public Element testEM() throws Exception {
|
||||||
Element resource = Manager.parseSingle(TestingUtilities.context(), new FileInputStream(source), isJson() ? FhirFormat.JSON : FhirFormat.XML);
|
Element resource = Manager.parseSingle(TestingUtilities.getSharedWorkerContext(), new FileInputStream(source), isJson() ? FhirFormat.JSON : FhirFormat.XML);
|
||||||
Manager.compose(TestingUtilities.context(), resource, new FileOutputStream(source.getAbsoluteFile()+".out.json"), FhirFormat.JSON, OutputStyle.PRETTY, null);
|
Manager.compose(TestingUtilities.getSharedWorkerContext(), resource, new FileOutputStream(source.getAbsoluteFile()+".out.json"), FhirFormat.JSON, OutputStyle.PRETTY, null);
|
||||||
Manager.compose(TestingUtilities.context(), resource, new FileOutputStream(source.getAbsoluteFile()+".out.json"), FhirFormat.XML, OutputStyle.PRETTY, null);
|
Manager.compose(TestingUtilities.getSharedWorkerContext(), resource, new FileOutputStream(source.getAbsoluteFile()+".out.json"), FhirFormat.XML, OutputStyle.PRETTY, null);
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ import java.io.ByteArrayInputStream;
|
|||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -82,10 +81,10 @@ public class PackageClient {
|
|||||||
if (versions != null) {
|
if (versions != null) {
|
||||||
for (String v : sorted(versions.keySet())) {
|
for (String v : sorted(versions.keySet())) {
|
||||||
JsonObject obj = versions.getAsJsonObject(v);
|
JsonObject obj = versions.getAsJsonObject(v);
|
||||||
res.add(new PackageInfo(JSONUtil.str(obj, "name"),
|
res.add(new PackageInfo(JSONUtil.str(obj, "Name", "name"),
|
||||||
JSONUtil.str(obj, "version"),
|
JSONUtil.str(obj, "Version", "version"),
|
||||||
JSONUtil.str(obj, "FhirVersion"),
|
JSONUtil.str(obj, "FhirVersion", "fhirVersion"),
|
||||||
JSONUtil.str(obj, "description"),
|
JSONUtil.str(obj, "Description", "description"),
|
||||||
JSONUtil.str(obj, "url"),
|
JSONUtil.str(obj, "url"),
|
||||||
JSONUtil.str(obj, "canonical"),
|
JSONUtil.str(obj, "canonical"),
|
||||||
address));
|
address));
|
||||||
@ -192,42 +191,51 @@ public class PackageClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected PackageInfo getPackageInfoFromJSON(JsonObject o, String name, String canonical, String fhirVersion) {
|
||||||
|
String id = JSONUtil.str(o, "npm-name");
|
||||||
|
String pname = JSONUtil.str(o, "name");
|
||||||
|
String pcanonical = JSONUtil.str(o, "canonical");
|
||||||
|
String description = JSONUtil.str(o, "description");
|
||||||
|
boolean ok = true;
|
||||||
|
if (ok && !Utilities.noString(name)) {
|
||||||
|
ok = (pname != null && pname.contains(name)) || (description != null && description.contains(name)) || (id != null && id.contains(name));
|
||||||
|
}
|
||||||
|
if (ok && !Utilities.noString(canonical)) {
|
||||||
|
ok = pcanonical.contains(canonical);
|
||||||
|
}
|
||||||
|
String version = null;
|
||||||
|
String fVersion = null;
|
||||||
|
String url = null;
|
||||||
|
|
||||||
|
if (ok) {
|
||||||
|
// if we can find something...
|
||||||
|
for (JsonObject e : JSONUtil.objects(o, "editions")) {
|
||||||
|
if (fhirVersion == null || fhirVersion.equals(JSONUtil.str(e, "fhir-version"))) {
|
||||||
|
String v = JSONUtil.str(e, "ig-version");
|
||||||
|
if (version == null || VersionUtilities.isThisOrLater(version, v)) {
|
||||||
|
version = v;
|
||||||
|
fVersion = e.getAsJsonArray("fhir-version").get(0).getAsString();
|
||||||
|
url = JSONUtil.str(e, "url");
|
||||||
|
|
||||||
|
String npmPackage = JSONUtil.str(e, "package");
|
||||||
|
if (npmPackage != null && id == null) {
|
||||||
|
id = npmPackage.substring(0, npmPackage.indexOf("#"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new PackageInfo(id, version, fVersion, description, url, pcanonical, address);
|
||||||
|
}
|
||||||
|
|
||||||
public List<PackageInfo> listFromRegistry(String name, String canonical, String fhirVersion) throws IOException {
|
public List<PackageInfo> listFromRegistry(String name, String canonical, String fhirVersion) throws IOException {
|
||||||
List<PackageInfo> result = new ArrayList<>();
|
List<PackageInfo> result = new ArrayList<>();
|
||||||
JsonObject packages = JsonTrackingParser.fetchJson("https://raw.githubusercontent.com/FHIR/ig-registry/master/fhir-ig-list.json?nocache=" + System.currentTimeMillis());
|
JsonObject packages = JsonTrackingParser.fetchJson("https://raw.githubusercontent.com/FHIR/ig-registry/master/fhir-ig-list.json?nocache=" + System.currentTimeMillis());
|
||||||
for (JsonObject o : JSONUtil.objects(packages, "guides")) {
|
for (JsonObject o : JSONUtil.objects(packages, "guides")) {
|
||||||
if (o.has("canonical")) {
|
if (o.has("canonical")) {
|
||||||
String id = JSONUtil.str(o, "npm-name");
|
final PackageInfo packageInfo = getPackageInfoFromJSON(o, name, canonical, fhirVersion);
|
||||||
String pname = JSONUtil.str(o, "name");
|
if (packageInfo.getVersion() != null) {
|
||||||
String pcanonical = JSONUtil.str(o, "canonical");
|
result.add(packageInfo);
|
||||||
String description = JSONUtil.str(o, "description");
|
|
||||||
boolean ok = true;
|
|
||||||
if (ok && !Utilities.noString(name)) {
|
|
||||||
ok = (pname != null && pname.contains(name)) || (description != null && description.contains(name)) || (id != null && id.contains(name));
|
|
||||||
}
|
|
||||||
if (ok && !Utilities.noString(canonical)) {
|
|
||||||
ok = pcanonical.contains(canonical);
|
|
||||||
}
|
|
||||||
String version = null;
|
|
||||||
String fVersion = null;
|
|
||||||
String url = null;
|
|
||||||
|
|
||||||
if (ok) {
|
|
||||||
// if we can find something...
|
|
||||||
for (JsonObject e : JSONUtil.objects(o, "editions")) {
|
|
||||||
if (fhirVersion == null || fhirVersion.equals(JSONUtil.str(e, "fhir-version"))) {
|
|
||||||
String v = JSONUtil.str(e, "ig-version");
|
|
||||||
if (version == null || VersionUtilities.isThisOrLater(version, v)) {
|
|
||||||
version = v;
|
|
||||||
fVersion = e.getAsJsonArray("fhir-version").get(0).getAsString();
|
|
||||||
url = JSONUtil.str(e, "url");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (version != null) {
|
|
||||||
result.add(new PackageInfo(id, version, fVersion, description, url, pcanonical, address));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -403,6 +403,11 @@ public class HierarchicalTableGenerator extends TranslatingUtilities {
|
|||||||
pieces.add(p);
|
pieces.add(p);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
public Piece addText(String text) {
|
||||||
|
Piece p = new Piece(null, text, null);
|
||||||
|
pieces.add(p);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
public String text() {
|
public String text() {
|
||||||
StringBuilder b = new StringBuilder();
|
StringBuilder b = new StringBuilder();
|
||||||
for (Piece p : pieces)
|
for (Piece p : pieces)
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
package org.hl7.fhir.utilities.npm;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
public class PackageClientTest {
|
||||||
|
|
||||||
|
PackageClient packageClient = new PackageClient(PackageClient.PRIMARY_SERVER);
|
||||||
|
|
||||||
|
private void assertExpectedFields(final PackageInfo packageInfo) {
|
||||||
|
assertEquals("dummy.package", packageInfo.getId());
|
||||||
|
assertEquals("1.2.3", packageInfo.getVersion());
|
||||||
|
assertEquals("4.5.6", packageInfo.getFhirVersion());
|
||||||
|
assertEquals("Dummy description",
|
||||||
|
packageInfo.getDescription());
|
||||||
|
assertEquals("https://d.e.f", packageInfo.getUrl());
|
||||||
|
assertEquals("https://a.b.c", packageInfo.getCanonical());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("test getting package from JSON works")
|
||||||
|
public void getPackageInfoFromJSONTest() throws java.io.IOException{
|
||||||
|
final JsonObject jsonObject = new Gson().fromJson(Files.newBufferedReader(Paths.get("src", "test", "resources", "npm", "PackageClient-baseTestCase.json")), JsonObject.class);
|
||||||
|
final PackageInfo packageInfo = packageClient.getPackageInfoFromJSON(jsonObject, null, null, null);
|
||||||
|
|
||||||
|
assertExpectedFields(packageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("test getting package from JSON works")
|
||||||
|
public void getPackageInfoWithIdFromJSONTest() throws java.io.IOException {
|
||||||
|
final JsonObject jsonObject = new Gson().fromJson(Files.newBufferedReader(Paths.get("src", "test", "resources", "npm", "PackageClient-testCaseWithId.json")), JsonObject.class);
|
||||||
|
final PackageInfo packageInfo = packageClient.getPackageInfoFromJSON(jsonObject, null, null, null);
|
||||||
|
|
||||||
|
assertExpectedFields(packageInfo);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"name": "Pan-Canadian Patient Summary",
|
||||||
|
"description": "Dummy description",
|
||||||
|
"canonical": "https://a.b.c",
|
||||||
|
"editions": [
|
||||||
|
{
|
||||||
|
"name": "Dummy name",
|
||||||
|
"ig-version": "1.2.3",
|
||||||
|
"package": "dummy.package#1.2.3",
|
||||||
|
"fhir-version": [
|
||||||
|
"4.5.6"
|
||||||
|
],
|
||||||
|
"url": "https://d.e.f"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"name": "Pan-Canadian Patient Summary",
|
||||||
|
"description": "Dummy description",
|
||||||
|
"canonical": "https://a.b.c",
|
||||||
|
"npm-name": "dummy.package",
|
||||||
|
"editions": [
|
||||||
|
{
|
||||||
|
"name": "Dummy name",
|
||||||
|
"ig-version": "1.2.3",
|
||||||
|
"package": "not.a.dummy.package#1.2.3",
|
||||||
|
"fhir-version": [
|
||||||
|
"4.5.6"
|
||||||
|
],
|
||||||
|
"url": "https://d.e.f"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -76,7 +76,7 @@
|
|||||||
<goal>unpack-dependencies</goal>
|
<goal>unpack-dependencies</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<excludes>**/module-info.class,META-INF/*.SF,META-INF/*.DSA,META-INF/*.RSA</excludes>
|
<excludes>**/module-info.class,META-INF/*</excludes>
|
||||||
<outputDirectory>${project.build.directory}/classes</outputDirectory>
|
<outputDirectory>${project.build.directory}/classes</outputDirectory>
|
||||||
<overWriteReleases>false</overWriteReleases>
|
<overWriteReleases>false</overWriteReleases>
|
||||||
<overWriteSnapshots>true</overWriteSnapshots>
|
<overWriteSnapshots>true</overWriteSnapshots>
|
||||||
|
@ -108,7 +108,7 @@ public class ComparisonTests {
|
|||||||
|
|
||||||
if (context == null) {
|
if (context == null) {
|
||||||
System.out.println("---- Load R5 ----------------------------------------------------------------");
|
System.out.println("---- Load R5 ----------------------------------------------------------------");
|
||||||
context = TestingUtilities.context();
|
context = TestingUtilities.getSharedWorkerContext();
|
||||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
|
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
|
||||||
NpmPackage npm = pcm.loadPackage("hl7.fhir.us.core#3.1.0");
|
NpmPackage npm = pcm.loadPackage("hl7.fhir.us.core#3.1.0");
|
||||||
BaseWorkerContext bc = (BaseWorkerContext) context;
|
BaseWorkerContext bc = (BaseWorkerContext) context;
|
||||||
|
@ -522,9 +522,9 @@ public class SnapShotGenerationXTests {
|
|||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
if (output.getDifferential().hasElement()) {
|
if (output.getDifferential().hasElement()) {
|
||||||
RenderingContext rc = new RenderingContext(TestingUtilities.context(), null, null, "http://hl7.org/fhir", "", null, ResourceRendererMode.END_USER);
|
RenderingContext rc = new RenderingContext(TestingUtilities.getSharedWorkerContext(), null, null, "http://hl7.org/fhir", "", null, ResourceRendererMode.END_USER);
|
||||||
rc.setDestDir(makeTempDir());
|
rc.setDestDir(makeTempDir());
|
||||||
rc.setProfileUtilities(new ProfileUtilities(TestingUtilities.context(), null, new TestPKP()));
|
rc.setProfileUtilities(new ProfileUtilities(TestingUtilities.getSharedWorkerContext(), null, new TestPKP()));
|
||||||
RendererFactory.factory(output, rc).render(output);
|
RendererFactory.factory(output, rc).render(output);
|
||||||
}
|
}
|
||||||
if (!fail) {
|
if (!fail) {
|
||||||
|
@ -350,9 +350,9 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe
|
|||||||
|
|
||||||
public StructureDefinition loadProfile(String filename, String contents, List<ValidationMessage> messages) throws IOException, FHIRFormatError, FileNotFoundException, FHIRException, DefinitionException {
|
public StructureDefinition loadProfile(String filename, String contents, List<ValidationMessage> messages) throws IOException, FHIRFormatError, FileNotFoundException, FHIRException, DefinitionException {
|
||||||
StructureDefinition sd = (StructureDefinition) loadResource(filename, contents);
|
StructureDefinition sd = (StructureDefinition) loadResource(filename, contents);
|
||||||
ProfileUtilities pu = new ProfileUtilities(TestingUtilities.context(version), messages, null);
|
ProfileUtilities pu = new ProfileUtilities(TestingUtilities.getSharedWorkerContext(version), messages, null);
|
||||||
if (!sd.hasSnapshot()) {
|
if (!sd.hasSnapshot()) {
|
||||||
StructureDefinition base = TestingUtilities.context(version).fetchResource(StructureDefinition.class, sd.getBaseDefinition());
|
StructureDefinition base = TestingUtilities.getSharedWorkerContext(version).fetchResource(StructureDefinition.class, sd.getBaseDefinition());
|
||||||
pu.generateSnapshot(base, sd, sd.getUrl(), null, sd.getTitle());
|
pu.generateSnapshot(base, sd, sd.getUrl(), null, sd.getTitle());
|
||||||
// (debugging) new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", sd.getId()+".xml")), sd);
|
// (debugging) new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", sd.getId()+".xml")), sd);
|
||||||
}
|
}
|
||||||
@ -360,7 +360,7 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe
|
|||||||
if (r instanceof StructureDefinition) {
|
if (r instanceof StructureDefinition) {
|
||||||
StructureDefinition childSd = (StructureDefinition) r;
|
StructureDefinition childSd = (StructureDefinition) r;
|
||||||
if (!childSd.hasSnapshot()) {
|
if (!childSd.hasSnapshot()) {
|
||||||
StructureDefinition base = TestingUtilities.context(version).fetchResource(StructureDefinition.class, childSd.getBaseDefinition());
|
StructureDefinition base = TestingUtilities.getSharedWorkerContext(version).fetchResource(StructureDefinition.class, childSd.getBaseDefinition());
|
||||||
pu.generateSnapshot(base, childSd, childSd.getUrl(), null, childSd.getTitle());
|
pu.generateSnapshot(base, childSd, childSd.getUrl(), null, childSd.getTitle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -427,7 +427,7 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!TestingUtilities.context(version).isNoTerminologyServer() || !focus.has("tx-dependent")) {
|
if (!TestingUtilities.getSharedWorkerContext(version).isNoTerminologyServer() || !focus.has("tx-dependent")) {
|
||||||
Assert.assertEquals("Test " + name + (profile == null ? "" : " profile: "+ profile) + ": Expected " + Integer.toString(java.get("errorCount").getAsInt()) + " errors, but found " + Integer.toString(ec) + ".", java.get("errorCount").getAsInt(), ec);
|
Assert.assertEquals("Test " + name + (profile == null ? "" : " profile: "+ profile) + ": Expected " + Integer.toString(java.get("errorCount").getAsInt()) + " errors, but found " + Integer.toString(ec) + ".", java.get("errorCount").getAsInt(), ec);
|
||||||
if (java.has("warningCount")) {
|
if (java.has("warningCount")) {
|
||||||
Assert.assertEquals( "Test " + name + (profile == null ? "" : " profile: "+ profile) + ": Expected " + Integer.toString(java.get("warningCount").getAsInt()) + " warnings, but found " + Integer.toString(wc) + ".", java.get("warningCount").getAsInt(), wc);
|
Assert.assertEquals( "Test " + name + (profile == null ? "" : " profile: "+ profile) + ": Expected " + Integer.toString(java.get("warningCount").getAsInt()) + " warnings, but found " + Integer.toString(wc) + ".", java.get("warningCount").getAsInt(), wc);
|
||||||
@ -501,18 +501,18 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe
|
|||||||
public Element fetch(IResourceValidator validator, Object appContext, String url) throws FHIRFormatError, DefinitionException, IOException, FHIRException {
|
public Element fetch(IResourceValidator validator, Object appContext, String url) throws FHIRFormatError, DefinitionException, IOException, FHIRException {
|
||||||
Element res = null;
|
Element res = null;
|
||||||
if (url.equals("Patient/test")) {
|
if (url.equals("Patient/test")) {
|
||||||
res = new ObjectConverter(TestingUtilities.context(version)).convert(new Patient());
|
res = new ObjectConverter(TestingUtilities.getSharedWorkerContext(version)).convert(new Patient());
|
||||||
} else if (TestingUtilities.findTestResource("validator", url.replace("/", "-").toLowerCase() + ".json")) {
|
} else if (TestingUtilities.findTestResource("validator", url.replace("/", "-").toLowerCase() + ".json")) {
|
||||||
res = Manager.makeParser(TestingUtilities.context(version), FhirFormat.JSON).parseSingle(TestingUtilities.loadTestResourceStream("validator", url.replace("/", "-").toLowerCase() + ".json"));
|
res = Manager.makeParser(TestingUtilities.getSharedWorkerContext(version), FhirFormat.JSON).parseSingle(TestingUtilities.loadTestResourceStream("validator", url.replace("/", "-").toLowerCase() + ".json"));
|
||||||
} else if (TestingUtilities.findTestResource("validator", url.replace("/", "-").toLowerCase() + ".xml")) {
|
} else if (TestingUtilities.findTestResource("validator", url.replace("/", "-").toLowerCase() + ".xml")) {
|
||||||
res = Manager.makeParser(TestingUtilities.context(version), FhirFormat.XML).parseSingle(TestingUtilities.loadTestResourceStream("validator", url.replace("/", "-").toLowerCase() + ".xml"));
|
res = Manager.makeParser(TestingUtilities.getSharedWorkerContext(version), FhirFormat.XML).parseSingle(TestingUtilities.loadTestResourceStream("validator", url.replace("/", "-").toLowerCase() + ".xml"));
|
||||||
}
|
}
|
||||||
if (res == null && url.contains("/")) {
|
if (res == null && url.contains("/")) {
|
||||||
String tail = url.substring(url.indexOf("/") + 1);
|
String tail = url.substring(url.indexOf("/") + 1);
|
||||||
if (TestingUtilities.findTestResource("validator", tail.replace("/", "-").toLowerCase() + ".json")) {
|
if (TestingUtilities.findTestResource("validator", tail.replace("/", "-").toLowerCase() + ".json")) {
|
||||||
res = Manager.makeParser(TestingUtilities.context(version), FhirFormat.JSON).parseSingle(TestingUtilities.loadTestResourceStream("validator", tail.replace("/", "-").toLowerCase() + ".json"));
|
res = Manager.makeParser(TestingUtilities.getSharedWorkerContext(version), FhirFormat.JSON).parseSingle(TestingUtilities.loadTestResourceStream("validator", tail.replace("/", "-").toLowerCase() + ".json"));
|
||||||
} else if (TestingUtilities.findTestResource("validator", tail.replace("/", "-").toLowerCase() + ".xml")) {
|
} else if (TestingUtilities.findTestResource("validator", tail.replace("/", "-").toLowerCase() + ".xml")) {
|
||||||
res = Manager.makeParser(TestingUtilities.context(version), FhirFormat.XML).parseSingle(TestingUtilities.loadTestResourceStream("validator", tail.replace("/", "-").toLowerCase() + ".xml"));
|
res = Manager.makeParser(TestingUtilities.getSharedWorkerContext(version), FhirFormat.XML).parseSingle(TestingUtilities.loadTestResourceStream("validator", tail.replace("/", "-").toLowerCase() + ".xml"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
@ -558,7 +558,7 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
|
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
|
||||||
IResourceValidator val = TestingUtilities.context(version).newValidator();
|
IResourceValidator val = TestingUtilities.getSharedWorkerContext(version).newValidator();
|
||||||
List<ValidationMessage> valerrors = new ArrayList<ValidationMessage>();
|
List<ValidationMessage> valerrors = new ArrayList<ValidationMessage>();
|
||||||
if (item instanceof Resource) {
|
if (item instanceof Resource) {
|
||||||
val.validate(appContext, valerrors, (Resource) item, url);
|
val.validate(appContext, valerrors, (Resource) item, url);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user