Merge remote-tracking branch 'origin/master'

This commit is contained in:
Grahame Grieve 2023-10-05 15:22:10 +03:00
commit c52d5a71b4
26 changed files with 222 additions and 145 deletions

View File

@ -1,9 +1,7 @@
## Validator Changes ## Validator Changes
* Fix FHIRPath type resolution for logical models * no changes
* Update parsers to record the element format for logical model validation
* fix profile matching for CDA logical models
## Other code changes ## Other code changes
* Upgrade PackageVisitor for XIG * no changes

View File

@ -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>6.1.11-SNAPSHOT</version> <version>6.1.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -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>6.1.11-SNAPSHOT</version> <version>6.1.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -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>6.1.11-SNAPSHOT</version> <version>6.1.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -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>6.1.11-SNAPSHOT</version> <version>6.1.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -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>6.1.11-SNAPSHOT</version> <version>6.1.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -10,22 +10,33 @@ import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.context.SimpleWorkerContext; import org.hl7.fhir.r4.context.SimpleWorkerContext;
import org.hl7.fhir.r4.formats.IParser.OutputStyle; import org.hl7.fhir.r4.formats.IParser.OutputStyle;
import org.hl7.fhir.r4.formats.JsonParser; import org.hl7.fhir.r4.formats.JsonParser;
<<<<<<< HEAD
import org.hl7.fhir.r4.formats.XmlParser; import org.hl7.fhir.r4.formats.XmlParser;
=======
>>>>>>> master
import org.hl7.fhir.r4.model.Base; import org.hl7.fhir.r4.model.Base;
import org.hl7.fhir.r4.model.BooleanType; import org.hl7.fhir.r4.model.BooleanType;
import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent; import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.r4.model.CapabilityStatement; import org.hl7.fhir.r4.model.CapabilityStatement;
<<<<<<< HEAD
import org.hl7.fhir.r4.model.CodeSystem; import org.hl7.fhir.r4.model.CodeSystem;
=======
>>>>>>> master
import org.hl7.fhir.r4.model.CodeType; import org.hl7.fhir.r4.model.CodeType;
import org.hl7.fhir.r4.model.CodeableConcept; import org.hl7.fhir.r4.model.CodeableConcept;
import org.hl7.fhir.r4.model.Coding; import org.hl7.fhir.r4.model.Coding;
import org.hl7.fhir.r4.model.Condition; import org.hl7.fhir.r4.model.Condition;
<<<<<<< HEAD
import org.hl7.fhir.r4.model.DateType; import org.hl7.fhir.r4.model.DateType;
import org.hl7.fhir.r4.model.HumanName; import org.hl7.fhir.r4.model.HumanName;
import org.hl7.fhir.r4.model.Immunization; import org.hl7.fhir.r4.model.Immunization;
import org.hl7.fhir.r4.model.Parameters; import org.hl7.fhir.r4.model.Parameters;
import org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent; import org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent;
=======
import org.hl7.fhir.r4.model.HumanName;
import org.hl7.fhir.r4.model.Immunization;
>>>>>>> master
import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.Period; import org.hl7.fhir.r4.model.Period;
import org.hl7.fhir.r4.model.Procedure; import org.hl7.fhir.r4.model.Procedure;
@ -68,8 +79,11 @@ public class CmdLineApp {
finished = true; finished = true;
} else if (p.length == 1 && p[0].equals("?")) { } else if (p.length == 1 && p[0].equals("?")) {
genMenu(); genMenu();
<<<<<<< HEAD
} else if (p.length == 1 && p[0].equals("?tx")) { } else if (p.length == 1 && p[0].equals("?tx")) {
genMenuTx(); genMenuTx();
=======
>>>>>>> master
} else if (p.length >= 1 && p[0].equals("c")) { } else if (p.length >= 1 && p[0].equals("c")) {
if (p.length == 1) { if (p.length == 1) {
connectToServer("http://hapi.fhir.org/baseR4"); connectToServer("http://hapi.fhir.org/baseR4");
@ -115,10 +129,15 @@ public class CmdLineApp {
select("Patient", p[1]); select("Patient", p[1]);
} else if (p.length == 3 && p[0].equals("e")) { } else if (p.length == 3 && p[0].equals("e")) {
edit(p[1], p[2]); edit(p[1], p[2]);
<<<<<<< HEAD
} else if (p.length > 3 && p[0].equals("tx")) { } else if (p.length > 3 && p[0].equals("tx")) {
tx(p); tx(p);
} else { } else {
tx(p); tx(p);
=======
} else {
System.out.println("Command unknown or not understood: "+cmd);
>>>>>>> master
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println("Error executing command "+p[0]+": "+e.getMessage()); System.out.println("Error executing command "+p[0]+": "+e.getMessage());
@ -128,6 +147,7 @@ public class CmdLineApp {
System.out.println("Finished!"); System.out.println("Finished!");
} }
<<<<<<< HEAD
private boolean tx(String[] p) throws IOException { private boolean tx(String[] p) throws IOException {
if (p[1].equals("l")) { if (p[1].equals("l")) {
if (p.length == 4) { if (p.length == 4) {
@ -170,6 +190,9 @@ public class CmdLineApp {
} }
private void getImmunizations() throws IOException { private void getImmunizations() throws IOException {
=======
private void getImmunizations() {
>>>>>>> master
Bundle bnd = client.search("Immunization", "?patient="+currentId); Bundle bnd = client.search("Immunization", "?patient="+currentId);
System.out.println(""+bnd.getTotal()+" Immunizations found. Printing "+bnd.getEntry().size()); System.out.println(""+bnd.getTotal()+" Immunizations found. Printing "+bnd.getEntry().size());
@ -180,7 +203,11 @@ public class CmdLineApp {
} }
} }
<<<<<<< HEAD
private void getProcedures() throws IOException { private void getProcedures() throws IOException {
=======
private void getProcedures() {
>>>>>>> master
Bundle bnd = client.search("Procedure", "?patient="+currentId); Bundle bnd = client.search("Procedure", "?patient="+currentId);
System.out.println(""+bnd.getTotal()+" Procedures found. Printing "+bnd.getEntry().size()); System.out.println(""+bnd.getTotal()+" Procedures found. Printing "+bnd.getEntry().size());
@ -191,7 +218,11 @@ public class CmdLineApp {
} }
} }
<<<<<<< HEAD
private void getConditions() throws IOException { private void getConditions() throws IOException {
=======
private void getConditions() {
>>>>>>> master
Bundle bnd = client.search("Condition", "?patient="+currentId); Bundle bnd = client.search("Condition", "?patient="+currentId);
System.out.println(""+bnd.getTotal()+" Conditions found. Printing "+bnd.getEntry().size()); System.out.println(""+bnd.getTotal()+" Conditions found. Printing "+bnd.getEntry().size());
@ -226,7 +257,10 @@ public class CmdLineApp {
case "boolean" : return new BooleanType(value); case "boolean" : return new BooleanType(value);
case "code" : return new CodeType(value); case "code" : return new CodeType(value);
case "string" : return new StringType(value); case "string" : return new StringType(value);
<<<<<<< HEAD
case "date" : return new DateType(value); case "date" : return new DateType(value);
=======
>>>>>>> master
} }
throw new FHIRException("Unhandled type "+p.getTypeCode()); throw new FHIRException("Unhandled type "+p.getTypeCode());
} }
@ -244,7 +278,11 @@ public class CmdLineApp {
System.out.println(new JsonParser().setOutputStyle(OutputStyle.PRETTY).composeString(currentResource)); System.out.println(new JsonParser().setOutputStyle(OutputStyle.PRETTY).composeString(currentResource));
} }
<<<<<<< HEAD
private void select(String type, String id) throws IOException { private void select(String type, String id) throws IOException {
=======
private void select(String type, String id) {
>>>>>>> master
if (type.equals("Patient")) { if (type.equals("Patient")) {
currentResource = client.fetchResource(Patient.class, id); currentResource = client.fetchResource(Patient.class, id);
} else if (type.equals("Immunization")) { } else if (type.equals("Immunization")) {
@ -260,8 +298,12 @@ public class CmdLineApp {
System.out.println("Resource = "+currentId+" "+summary(currentResource)); System.out.println("Resource = "+currentId+" "+summary(currentResource));
} }
<<<<<<< HEAD
private String summary(Resource r) throws IOException { private String summary(Resource r) throws IOException {
// return new XmlParser().composeString(r); // return new XmlParser().composeString(r);
=======
private String summary(Resource r) {
>>>>>>> master
if (r instanceof Patient) { if (r instanceof Patient) {
Patient pat = (Patient) r; Patient pat = (Patient) r;
return pat.getIdBase()+" "+pat.getGender()+" "+pat.getBirthDateElement().asStringValue()+" "+name(pat); return pat.getIdBase()+" "+pat.getGender()+" "+pat.getBirthDateElement().asStringValue()+" "+name(pat);
@ -324,7 +366,11 @@ public class CmdLineApp {
return ""; return "";
} }
<<<<<<< HEAD
private void search(String[] p) throws IOException { private void search(String[] p) throws IOException {
=======
private void search(String[] p) {
>>>>>>> master
if (client == null) { if (client == null) {
throw new FHIRException("Not connected to to a server"); throw new FHIRException("Not connected to to a server");
} }
@ -332,7 +378,11 @@ public class CmdLineApp {
if (p.length > 2) { if (p.length > 2) {
search = search +"&gender="+p[2]; search = search +"&gender="+p[2];
if (p.length > 3) { if (p.length > 3) {
<<<<<<< HEAD
search = search +"&birthdate="+p[3]; search = search +"&birthdate="+p[3];
=======
search = search +"&dob="+p[3];
>>>>>>> master
} }
} }
Bundle bnd = client.search("Patient", search); Bundle bnd = client.search("Patient", search);
@ -368,6 +418,7 @@ public class CmdLineApp {
private void connectToServer(String url) throws URISyntaxException { private void connectToServer(String url) throws URISyntaxException {
client = new FHIRToolingClient(url, "FHIR-Command-Line-App"); client = new FHIRToolingClient(url, "FHIR-Command-Line-App");
CapabilityStatement cs = client.getCapabilitiesStatementQuick(); CapabilityStatement cs = client.getCapabilitiesStatementQuick();
<<<<<<< HEAD
System.out.println("Connected to "+url+": "+cs.getSoftware().getName()+", version "+cs.getFhirVersion().toCode()); System.out.println("Connected to "+url+": "+cs.getSoftware().getName()+", version "+cs.getFhirVersion().toCode());
} }
@ -380,6 +431,11 @@ public class CmdLineApp {
System.out.println(" x - exit"); System.out.println(" x - exit");
} }
=======
System.out.println("Connected to "+url+": "+cs.getSoftware().getName()+".");
}
>>>>>>> master
private void genMenu() { private void genMenu() {
System.out.println("Simple Client. Commands you can run:"); System.out.println("Simple Client. Commands you can run:");
System.out.println(" c {url} - connect to a server"); System.out.println(" c {url} - connect to a server");

View File

@ -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>6.1.11-SNAPSHOT</version> <version>6.1.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -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>6.1.11-SNAPSHOT</version> <version>6.1.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -50,9 +50,9 @@ public class FmlParser extends ParserBase {
ByteArrayInputStream stream = new ByteArrayInputStream(content); ByteArrayInputStream stream = new ByteArrayInputStream(content);
String text = TextFile.streamToString(stream); String text = TextFile.streamToString(stream);
List<ValidatedFragment> result = new ArrayList<>(); List<ValidatedFragment> result = new ArrayList<>();
ValidatedFragment ctxt = new ValidatedFragment("focus", "fml", content); ValidatedFragment focusFragment = new ValidatedFragment(ValidatedFragment.FOCUS_NAME, "fml", content, false);
ctxt.setElement(parse(ctxt.getErrors(), text)); focusFragment.setElement(parse(focusFragment.getErrors(), text));
result.add(ctxt); result.add(focusFragment);
return result; return result;
} }

View File

@ -123,7 +123,7 @@ public class JsonParser extends ParserBase {
public List<ValidatedFragment> parse(InputStream inStream) throws IOException, FHIRException { public List<ValidatedFragment> parse(InputStream inStream) throws IOException, FHIRException {
// long start = System.currentTimeMillis(); // long start = System.currentTimeMillis();
byte[] content = TextFile.streamToBytes(inStream); byte[] content = TextFile.streamToBytes(inStream);
ValidatedFragment ctxt = new ValidatedFragment("focus", "json", content); ValidatedFragment focusFragment = new ValidatedFragment(ValidatedFragment.FOCUS_NAME, "json", content, false);
ByteArrayInputStream stream = new ByteArrayInputStream(content); ByteArrayInputStream stream = new ByteArrayInputStream(content);
@ -135,17 +135,17 @@ public class JsonParser extends ParserBase {
try { try {
obj = org.hl7.fhir.utilities.json.parser.JsonParser.parseObject(source, true, true); obj = org.hl7.fhir.utilities.json.parser.JsonParser.parseObject(source, true, true);
} catch (Exception e) { } catch (Exception e) {
logError(ctxt.getErrors(), ValidationMessage.NO_RULE_DATE, -1, -1,context.formatMessage(I18nConstants.DOCUMENT), IssueType.INVALID, context.formatMessage(I18nConstants.ERROR_PARSING_JSON_, e.getMessage()), IssueSeverity.FATAL); logError(focusFragment.getErrors(), ValidationMessage.NO_RULE_DATE, -1, -1,context.formatMessage(I18nConstants.DOCUMENT), IssueType.INVALID, context.formatMessage(I18nConstants.ERROR_PARSING_JSON_, e.getMessage()), IssueSeverity.FATAL);
} }
} else { } else {
obj = org.hl7.fhir.utilities.json.parser.JsonParser.parseObject(source, true, true); obj = org.hl7.fhir.utilities.json.parser.JsonParser.parseObject(source, true, true);
} }
if (obj != null) { if (obj != null) {
ctxt.setElement(parse(ctxt.getErrors(), obj)); focusFragment.setElement(parse(focusFragment.getErrors(), obj));
} }
List<ValidatedFragment> res = new ArrayList<>(); List<ValidatedFragment> res = new ArrayList<>();
res.add(ctxt); res.add(focusFragment);
// long t =System.currentTimeMillis()-start; // long t =System.currentTimeMillis()-start;
// System.out.println("json parser: "+(t)+"ms, "+(content.length/1024)+"kb "+(t == 0 ? "" : " @ "+(content.length / t)+"kb/s")); // System.out.println("json parser: "+(t)+"ms, "+(content.length/1024)+"kb "+(t == 0 ? "" : " @ "+(content.length / t)+"kb/s"));

View File

@ -83,7 +83,7 @@ public class SHCParser extends ParserBase {
byte[] content = TextFile.streamToBytes(inStream); byte[] content = TextFile.streamToBytes(inStream);
ByteArrayInputStream stream = new ByteArrayInputStream(content); ByteArrayInputStream stream = new ByteArrayInputStream(content);
List<ValidatedFragment> res = new ArrayList<>(); List<ValidatedFragment> res = new ArrayList<>();
ValidatedFragment shc = new ValidatedFragment("shc", "txt", content); ValidatedFragment shc = new ValidatedFragment("shc", "txt", content, false);
res.add(shc); res.add(shc);
String src = TextFile.streamToString(stream).trim(); String src = TextFile.streamToString(stream).trim();
@ -121,7 +121,7 @@ public class SHCParser extends ParserBase {
return res; return res;
} }
ValidatedFragment bnd = new ValidatedFragment("payload", "json", jwt.payloadSrc); ValidatedFragment bnd = new ValidatedFragment("payload", "json", jwt.payloadSrc, true);
res.add(bnd); res.add(bnd);
checkNamedProperties(shc.getErrors(), jwt.getPayload(), prefix+"payload", "iss", "nbf", "vc"); checkNamedProperties(shc.getErrors(), jwt.getPayload(), prefix+"payload", "iss", "nbf", "vc");
checkProperty(shc.getErrors(), jwt.getPayload(), prefix+"payload", "iss", true, "String"); checkProperty(shc.getErrors(), jwt.getPayload(), prefix+"payload", "iss", true, "String");

View File

@ -280,7 +280,7 @@ public class SHLParser extends ParserBase {
} }
private ValidatedFragment addNamedElement(List<ValidatedFragment> res, String name, String type, byte[] content) { private ValidatedFragment addNamedElement(List<ValidatedFragment> res, String name, String type, byte[] content) {
ValidatedFragment result = new ValidatedFragment(name, type, content); ValidatedFragment result = new ValidatedFragment(name, type, content, true);
res.add(result); res.add(result);
return result; return result;
} }

View File

@ -83,7 +83,7 @@ public class TurtleParser extends ParserBase {
@Override @Override
public List<ValidatedFragment> parse(InputStream inStream) throws IOException, FHIRException { public List<ValidatedFragment> parse(InputStream inStream) throws IOException, FHIRException {
byte[] content = TextFile.streamToBytes(inStream); byte[] content = TextFile.streamToBytes(inStream);
ValidatedFragment ctxt = new ValidatedFragment("focus", "ttl", content); ValidatedFragment focusFragment = new ValidatedFragment(ValidatedFragment.FOCUS_NAME, "ttl", content, false);
ByteArrayInputStream stream = new ByteArrayInputStream(content); ByteArrayInputStream stream = new ByteArrayInputStream(content);
Turtle src = new Turtle(); Turtle src = new Turtle();
@ -91,16 +91,16 @@ public class TurtleParser extends ParserBase {
try { try {
src.parse(TextFile.streamToString(stream)); src.parse(TextFile.streamToString(stream));
} catch (Exception e) { } catch (Exception e) {
logError(ctxt.getErrors(), ValidationMessage.NO_RULE_DATE, -1, -1, "(document)", IssueType.INVALID, context.formatMessage(I18nConstants.ERROR_PARSING_TURTLE_, e.getMessage()), IssueSeverity.FATAL); logError(focusFragment.getErrors(), ValidationMessage.NO_RULE_DATE, -1, -1, "(document)", IssueType.INVALID, context.formatMessage(I18nConstants.ERROR_PARSING_TURTLE_, e.getMessage()), IssueSeverity.FATAL);
return null; return null;
} }
ctxt.setElement(parse(ctxt.getErrors(), src)); focusFragment.setElement(parse(focusFragment.getErrors(), src));
} else { } else {
src.parse(TextFile.streamToString(stream)); src.parse(TextFile.streamToString(stream));
ctxt.setElement(parse(ctxt.getErrors(), src)); focusFragment.setElement(parse(focusFragment.getErrors(), src));
} }
List<ValidatedFragment> res = new ArrayList<>(); List<ValidatedFragment> res = new ArrayList<>();
res.add(ctxt); res.add(focusFragment);
return res; return res;
} }

View File

@ -3,63 +3,55 @@ package org.hl7.fhir.r5.elementmodel;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import lombok.Getter;
import lombok.Setter;
import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage;
public class ValidatedFragment { public class ValidatedFragment {
@Getter
private String name; private String name;
@Getter @Setter
private String elementPath; private String elementPath;
@Getter
private String extension; private String extension;
@Getter @Setter
private Element element; private Element element;
@Getter @Setter
private byte[] content; private byte[] content;
@Getter
private final boolean isDerivedContent;
public final static String FOCUS_NAME = "focus";
@Getter
private List<ValidationMessage> errors = new ArrayList<>(); private List<ValidationMessage> errors = new ArrayList<>();
public ValidatedFragment(String name, String extension, Element element, byte[] content) {
public ValidatedFragment(String name, String extension, Element element, byte[] content, boolean isDerivedContent) {
super(); super();
this.name = name; this.name = name;
this.element = element; this.element = element;
this.content = content; this.content = content;
this.extension = extension; this.extension = extension;
this.isDerivedContent = isDerivedContent;
} }
public ValidatedFragment(String name, String extension, byte[] content) { public ValidatedFragment(String name, String extension, byte[] content, boolean isDerivedContent) {
super(); super();
this.name = name; this.name = name;
this.content = content; this.content = content;
this.extension = extension; this.extension = extension;
this.isDerivedContent = isDerivedContent;
} }
public String getName() {
return name;
}
public Element getElement() {
return element;
}
public byte[] getContent() {
return content;
}
public List<ValidationMessage> getErrors() {
return errors;
}
public void setElement(Element element) {
this.element = element;
}
public String getFilename() { public String getFilename() {
return name+"."+extension; return name+"."+extension;
} }
public String getElementPath() {
return elementPath;
}
public void setElementPath(String elementPath) {
this.elementPath = elementPath;
}
public String path() { public String path() {
return elementPath == null ? name : elementPath; return elementPath == null ? name : elementPath;
} }

View File

@ -465,7 +465,7 @@ public class VerticalBarParser extends ParserBase {
while (!reader.isFinished()) // && (getOptions().getSegmentLimit() == 0 || getOptions().getSegmentLimit() > message.getSegments().size())) while (!reader.isFinished()) // && (getOptions().getSegmentLimit() == 0 || getOptions().getSegmentLimit() > message.getSegments().size()))
readSegment(message, reader); readSegment(message, reader);
List<ValidatedFragment> res = new ArrayList<>(); List<ValidatedFragment> res = new ArrayList<>();
res.add(new ValidatedFragment("focus", "hl7", message, content)); res.add(new ValidatedFragment(ValidatedFragment.FOCUS_NAME, "hl7", message, content, false));
return res; return res;
} }

View File

@ -118,7 +118,7 @@ public class XmlParser extends ParserBase {
public List<ValidatedFragment> parse(InputStream inStream) throws FHIRFormatError, DefinitionException, FHIRException, IOException { public List<ValidatedFragment> parse(InputStream inStream) throws FHIRFormatError, DefinitionException, FHIRException, IOException {
byte[] content = TextFile.streamToBytes(inStream); byte[] content = TextFile.streamToBytes(inStream);
ValidatedFragment context = new ValidatedFragment("focus", "xml", content); ValidatedFragment focusFragment = new ValidatedFragment(ValidatedFragment.FOCUS_NAME, "xml", content, false);
ByteArrayInputStream stream = new ByteArrayInputStream(content); ByteArrayInputStream stream = new ByteArrayInputStream(content);
Document doc = null; Document doc = null;
@ -138,7 +138,7 @@ public class XmlParser extends ParserBase {
// if we can, we'll inspect the header/encoding ourselves // if we can, we'll inspect the header/encoding ourselves
stream.mark(1024); stream.mark(1024);
version = checkHeader(context.getErrors(), stream); version = checkHeader(focusFragment.getErrors(), stream);
stream.reset(); stream.reset();
// use a slower parser that keeps location data // use a slower parser that keeps location data
@ -172,17 +172,17 @@ public class XmlParser extends ParserBase {
if (e.getMessage().contains("lineNumber:") && e.getMessage().contains("columnNumber:")) { if (e.getMessage().contains("lineNumber:") && e.getMessage().contains("columnNumber:")) {
int line = Utilities.parseInt(extractVal(e.getMessage(), "lineNumber"), 0); int line = Utilities.parseInt(extractVal(e.getMessage(), "lineNumber"), 0);
int col = Utilities.parseInt(extractVal(e.getMessage(), "columnNumber"), 0); int col = Utilities.parseInt(extractVal(e.getMessage(), "columnNumber"), 0);
logError(context.getErrors(), ValidationMessage.NO_RULE_DATE, line, col, "(xml)", IssueType.INVALID, e.getMessage().substring(e.getMessage().lastIndexOf(";")+1).trim(), IssueSeverity.FATAL); logError(focusFragment.getErrors(), ValidationMessage.NO_RULE_DATE, line, col, "(xml)", IssueType.INVALID, e.getMessage().substring(e.getMessage().lastIndexOf(";")+1).trim(), IssueSeverity.FATAL);
} else { } else {
logError(context.getErrors(), ValidationMessage.NO_RULE_DATE, 0, 0, "(xml)", IssueType.INVALID, e.getMessage(), IssueSeverity.FATAL); logError(focusFragment.getErrors(), ValidationMessage.NO_RULE_DATE, 0, 0, "(xml)", IssueType.INVALID, e.getMessage(), IssueSeverity.FATAL);
} }
doc = null; doc = null;
} }
if (doc != null) { if (doc != null) {
context.setElement(parse(context.getErrors(), doc)); focusFragment.setElement(parse(focusFragment.getErrors(), doc));
} }
List<ValidatedFragment> res = new ArrayList<>(); List<ValidatedFragment> res = new ArrayList<>();
res.add(context); res.add(focusFragment);
return res; return res;
} }

View File

@ -14,10 +14,8 @@ import javax.xml.parsers.ParserConfigurationException;
import org.fhir.ucum.UcumException; import org.fhir.ucum.UcumException;
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.Base;
import org.hl7.fhir.r5.model.Factory;
import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.ResourceFactory; import org.hl7.fhir.r5.model.ResourceFactory;
import org.hl7.fhir.r5.sql.SQLOnFhirTestCases.RowSorter;
import org.hl7.fhir.r5.test.utils.CompareUtilities; import org.hl7.fhir.r5.test.utils.CompareUtilities;
import org.hl7.fhir.r5.test.utils.TestingUtilities; import org.hl7.fhir.r5.test.utils.TestingUtilities;
import org.hl7.fhir.r5.utils.sql.Provider; import org.hl7.fhir.r5.utils.sql.Provider;
@ -28,12 +26,13 @@ import org.hl7.fhir.utilities.json.model.JsonElement;
import org.hl7.fhir.utilities.json.model.JsonObject; import org.hl7.fhir.utilities.json.model.JsonObject;
import org.hl7.fhir.utilities.json.parser.JsonParser; import org.hl7.fhir.utilities.json.parser.JsonParser;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.MethodSource;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
public class SQLOnFhirTestCases { public class SQLOnFhirTests {
public class TestProvider implements Provider { public class TestProvider implements Provider {
@ -110,6 +109,7 @@ public class SQLOnFhirTestCases {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@ParameterizedTest(name = "{index}: file {0}") @ParameterizedTest(name = "{index}: file {0}")
@MethodSource("data") @MethodSource("data")
@Disabled
public void test(String name, TestDetails test) throws FileNotFoundException, IOException, FHIRException, org.hl7.fhir.exceptions.FHIRException, UcumException { public void test(String name, TestDetails test) throws FileNotFoundException, IOException, FHIRException, org.hl7.fhir.exceptions.FHIRException, UcumException {
this.details = test; this.details = test;
Runner runner = new Runner(); Runner runner = new Runner();

View File

@ -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>6.1.11-SNAPSHOT</version> <version>6.1.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -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>6.1.11-SNAPSHOT</version> <version>6.1.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -249,7 +249,7 @@ Validation_VAL_Profile_MultipleMatches_other = Found multiple matching profiles
Validation_VAL_Profile_NoDefinition = No definition found for resource type ''{0}'' Validation_VAL_Profile_NoDefinition = No definition found for resource type ''{0}''
Validation_VAL_Profile_NoMatch = Unable to find a match for the specified profile among choices: {0} Validation_VAL_Profile_NoMatch = Unable to find a match for the specified profile among choices: {0}
Validation_VAL_Profile_NoSnapshot = StructureDefinition {0} has no snapshot - validation is against the snapshot, so it must be provided Validation_VAL_Profile_NoSnapshot = StructureDefinition {0} has no snapshot - validation is against the snapshot, so it must be provided
Validation_VAL_Profile_NoType = The type of element {0} is not known - it couild not be determined from the information available. Valid types at this point are {1} Validation_VAL_Profile_NoType = The type of element {0} is not known - it could not be determined from the information available. Valid types at this point are {1}
Validation_VAL_Profile_NotAllowed = This element is not allowed by the profile {0} Validation_VAL_Profile_NotAllowed = This element is not allowed by the profile {0}
Validation_VAL_Profile_NotSlice = This element does not match any known slice {0} and slicing is CLOSED: {1} Validation_VAL_Profile_NotSlice = This element does not match any known slice {0} and slicing is CLOSED: {1}
Validation_VAL_Profile_OutOfOrder = As specified by profile {0}, Element ''{1}'' is out of order (found after {2}) Validation_VAL_Profile_OutOfOrder = As specified by profile {0}, Element ''{1}'' is out of order (found after {2})

View File

@ -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>6.1.11-SNAPSHOT</version> <version>6.1.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -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>6.1.11-SNAPSHOT</version> <version>6.1.13-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -32,12 +32,8 @@ import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.context.IWorkerContextManager; import org.hl7.fhir.r5.context.IWorkerContextManager;
import org.hl7.fhir.r5.context.SimpleWorkerContext; import org.hl7.fhir.r5.context.SimpleWorkerContext;
import org.hl7.fhir.r5.context.SystemOutLoggingService; import org.hl7.fhir.r5.context.SystemOutLoggingService;
import org.hl7.fhir.r5.elementmodel.Element; import org.hl7.fhir.r5.elementmodel.*;
import org.hl7.fhir.r5.elementmodel.Manager;
import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat; import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat;
import org.hl7.fhir.r5.elementmodel.ObjectConverter;
import org.hl7.fhir.r5.elementmodel.ParserBase;
import org.hl7.fhir.r5.elementmodel.SHCParser;
import org.hl7.fhir.r5.formats.FormatUtilities; import org.hl7.fhir.r5.formats.FormatUtilities;
import org.hl7.fhir.r5.formats.IParser.OutputStyle; import org.hl7.fhir.r5.formats.IParser.OutputStyle;
import org.hl7.fhir.r5.formats.JsonParser; import org.hl7.fhir.r5.formats.JsonParser;
@ -635,6 +631,13 @@ public class ValidationEngine implements IValidatorResourceFetcher, IValidationP
return results.getEntryFirstRep().getResource(); return results.getEntryFirstRep().getResource();
} }
public List<ValidatedFragment> validateAsFragments(byte[] source, FhirFormat cntType, List<String> profiles, List<ValidationMessage> messages) throws FHIRException, IOException, EOperationOutcome {
InstanceValidator validator = getValidator(cntType);
validator.validate(null, messages, new ByteArrayInputStream(source), cntType, asSdList(profiles));
return validator.validatedContent;
}
public OperationOutcome validate(byte[] source, FhirFormat cntType, List<String> profiles, List<ValidationMessage> messages) throws FHIRException, IOException, EOperationOutcome { public OperationOutcome validate(byte[] source, FhirFormat cntType, List<String> profiles, List<ValidationMessage> messages) throws FHIRException, IOException, EOperationOutcome {
InstanceValidator validator = getValidator(cntType); InstanceValidator validator = getValidator(cntType);

View File

@ -29,6 +29,7 @@ import org.hl7.fhir.r5.elementmodel.Element;
import org.hl7.fhir.r5.elementmodel.LanguageUtils; import org.hl7.fhir.r5.elementmodel.LanguageUtils;
import org.hl7.fhir.r5.elementmodel.Manager; import org.hl7.fhir.r5.elementmodel.Manager;
import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat; import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat;
import org.hl7.fhir.r5.elementmodel.ValidatedFragment;
import org.hl7.fhir.r5.formats.IParser; import org.hl7.fhir.r5.formats.IParser;
import org.hl7.fhir.r5.formats.IParser.OutputStyle; import org.hl7.fhir.r5.formats.IParser.OutputStyle;
import org.hl7.fhir.r5.model.Bundle; import org.hl7.fhir.r5.model.Bundle;
@ -61,10 +62,7 @@ import org.hl7.fhir.utilities.i18n.XLIFFProducer;
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.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.hl7.fhir.validation.IgLoader; import org.hl7.fhir.validation.*;
import org.hl7.fhir.validation.ValidationEngine;
import org.hl7.fhir.validation.ValidationRecord;
import org.hl7.fhir.validation.ValidatorUtils;
import org.hl7.fhir.validation.ValidatorUtils.SourceFile; import org.hl7.fhir.validation.ValidatorUtils.SourceFile;
import org.hl7.fhir.validation.cli.model.CliContext; import org.hl7.fhir.validation.cli.model.CliContext;
import org.hl7.fhir.validation.cli.model.FileInfo; import org.hl7.fhir.validation.cli.model.FileInfo;
@ -114,13 +112,43 @@ public class ValidationService {
ValidationResponse response = new ValidationResponse().setSessionId(sessionId); ValidationResponse response = new ValidationResponse().setSessionId(sessionId);
for (FileInfo fp : request.getFilesToValidate()) { for (FileInfo fileToValidate : request.getFilesToValidate()) {
if (fileToValidate.getFileType() == null) {
Manager.FhirFormat format = ResourceChecker.checkIsResource(validator.getContext(),
false,
fileToValidate.getFileContent().getBytes(),
fileToValidate.getFileName(),
false);
fileToValidate.setFileType(format.getExtension());
}
List<ValidationMessage> messages = new ArrayList<>(); List<ValidationMessage> messages = new ArrayList<>();
validator.validate(fp.getFileContent().getBytes(), Manager.FhirFormat.getFhirFormat(fp.getFileType()),
List<ValidatedFragment> validatedFragments = validator.validateAsFragments(fileToValidate.getFileContent().getBytes(), Manager.FhirFormat.getFhirFormat(fileToValidate.getFileType()),
request.getCliContext().getProfiles(), messages); request.getCliContext().getProfiles(), messages);
ValidationOutcome outcome = new ValidationOutcome().setFileInfo(fp);
messages.forEach(outcome::addMessage); if (validatedFragments.size() == 1 && !validatedFragments.get(0).isDerivedContent()) {
ValidatedFragment validatedFragment = validatedFragments.get(0);
ValidationOutcome outcome = new ValidationOutcome();
FileInfo fileInfo = new FileInfo(
fileToValidate.getFileName(),
new String(validatedFragment.getContent()),
validatedFragment.getExtension());
outcome.setMessages(validatedFragment.getErrors());
outcome.setFileInfo(fileInfo);
response.addOutcome(outcome); response.addOutcome(outcome);
} else {
for (ValidatedFragment validatedFragment : validatedFragments) {
ValidationOutcome outcome = new ValidationOutcome();
FileInfo fileInfo = new FileInfo(
validatedFragment.getFilename(),
new String(validatedFragment.getContent()),
validatedFragment.getExtension());
outcome.setMessages(validatedFragment.getErrors());
outcome.setFileInfo(fileInfo);
response.addOutcome(outcome);
}
}
} }
System.out.println(" Max Memory: "+Runtime.getRuntime().maxMemory()); System.out.println(" Max Memory: "+Runtime.getRuntime().maxMemory());
return response; return response;

View File

@ -14,13 +14,13 @@
HAPI FHIR HAPI FHIR
--> -->
<artifactId>org.hl7.fhir.core</artifactId> <artifactId>org.hl7.fhir.core</artifactId>
<version>6.1.11-SNAPSHOT</version> <version>6.1.13-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<properties> <properties>
<guava_version>32.0.1-jre</guava_version> <guava_version>32.0.1-jre</guava_version>
<hapi_fhir_version>6.4.1</hapi_fhir_version> <hapi_fhir_version>6.4.1</hapi_fhir_version>
<validator_test_case_version>1.4.7</validator_test_case_version> <validator_test_case_version>1.4.8</validator_test_case_version>
<jackson_version>2.15.2</jackson_version> <jackson_version>2.15.2</jackson_version>
<junit_jupiter_version>5.9.2</junit_jupiter_version> <junit_jupiter_version>5.9.2</junit_jupiter_version>
<junit_platform_launcher_version>1.8.2</junit_platform_launcher_version> <junit_platform_launcher_version>1.8.2</junit_platform_launcher_version>