Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
c52d5a71b4
|
@ -1,9 +1,7 @@
|
|||
## Validator Changes
|
||||
|
||||
* Fix FHIRPath type resolution for logical models
|
||||
* Update parsers to record the element format for logical model validation
|
||||
* fix profile matching for CDA logical models
|
||||
* no changes
|
||||
|
||||
## Other code changes
|
||||
|
||||
* Upgrade PackageVisitor for XIG
|
||||
* no changes
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>6.1.11-SNAPSHOT</version>
|
||||
<version>6.1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>6.1.11-SNAPSHOT</version>
|
||||
<version>6.1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>6.1.11-SNAPSHOT</version>
|
||||
<version>6.1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>6.1.11-SNAPSHOT</version>
|
||||
<version>6.1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>6.1.11-SNAPSHOT</version>
|
||||
<version>6.1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -10,22 +10,33 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
import org.hl7.fhir.r4.context.SimpleWorkerContext;
|
||||
import org.hl7.fhir.r4.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r4.formats.JsonParser;
|
||||
<<<<<<< HEAD
|
||||
import org.hl7.fhir.r4.formats.XmlParser;
|
||||
=======
|
||||
>>>>>>> master
|
||||
import org.hl7.fhir.r4.model.Base;
|
||||
import org.hl7.fhir.r4.model.BooleanType;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent;
|
||||
import org.hl7.fhir.r4.model.CapabilityStatement;
|
||||
<<<<<<< HEAD
|
||||
import org.hl7.fhir.r4.model.CodeSystem;
|
||||
=======
|
||||
>>>>>>> master
|
||||
import org.hl7.fhir.r4.model.CodeType;
|
||||
import org.hl7.fhir.r4.model.CodeableConcept;
|
||||
import org.hl7.fhir.r4.model.Coding;
|
||||
import org.hl7.fhir.r4.model.Condition;
|
||||
<<<<<<< HEAD
|
||||
import org.hl7.fhir.r4.model.DateType;
|
||||
import org.hl7.fhir.r4.model.HumanName;
|
||||
import org.hl7.fhir.r4.model.Immunization;
|
||||
import org.hl7.fhir.r4.model.Parameters;
|
||||
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.Period;
|
||||
import org.hl7.fhir.r4.model.Procedure;
|
||||
|
@ -68,8 +79,11 @@ public class CmdLineApp {
|
|||
finished = true;
|
||||
} else if (p.length == 1 && p[0].equals("?")) {
|
||||
genMenu();
|
||||
<<<<<<< HEAD
|
||||
} else if (p.length == 1 && p[0].equals("?tx")) {
|
||||
genMenuTx();
|
||||
=======
|
||||
>>>>>>> master
|
||||
} else if (p.length >= 1 && p[0].equals("c")) {
|
||||
if (p.length == 1) {
|
||||
connectToServer("http://hapi.fhir.org/baseR4");
|
||||
|
@ -115,10 +129,15 @@ public class CmdLineApp {
|
|||
select("Patient", p[1]);
|
||||
} else if (p.length == 3 && p[0].equals("e")) {
|
||||
edit(p[1], p[2]);
|
||||
<<<<<<< HEAD
|
||||
} else if (p.length > 3 && p[0].equals("tx")) {
|
||||
tx(p);
|
||||
} else {
|
||||
tx(p);
|
||||
=======
|
||||
} else {
|
||||
System.out.println("Command unknown or not understood: "+cmd);
|
||||
>>>>>>> master
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error executing command "+p[0]+": "+e.getMessage());
|
||||
|
@ -128,6 +147,7 @@ public class CmdLineApp {
|
|||
System.out.println("Finished!");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
private boolean tx(String[] p) throws IOException {
|
||||
if (p[1].equals("l")) {
|
||||
if (p.length == 4) {
|
||||
|
@ -170,6 +190,9 @@ public class CmdLineApp {
|
|||
}
|
||||
|
||||
private void getImmunizations() throws IOException {
|
||||
=======
|
||||
private void getImmunizations() {
|
||||
>>>>>>> master
|
||||
|
||||
Bundle bnd = client.search("Immunization", "?patient="+currentId);
|
||||
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() {
|
||||
>>>>>>> master
|
||||
|
||||
Bundle bnd = client.search("Procedure", "?patient="+currentId);
|
||||
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() {
|
||||
>>>>>>> master
|
||||
|
||||
Bundle bnd = client.search("Condition", "?patient="+currentId);
|
||||
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 "code" : return new CodeType(value);
|
||||
case "string" : return new StringType(value);
|
||||
<<<<<<< HEAD
|
||||
case "date" : return new DateType(value);
|
||||
=======
|
||||
>>>>>>> master
|
||||
}
|
||||
throw new FHIRException("Unhandled type "+p.getTypeCode());
|
||||
}
|
||||
|
@ -244,7 +278,11 @@ public class CmdLineApp {
|
|||
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) {
|
||||
>>>>>>> master
|
||||
if (type.equals("Patient")) {
|
||||
currentResource = client.fetchResource(Patient.class, id);
|
||||
} else if (type.equals("Immunization")) {
|
||||
|
@ -260,8 +298,12 @@ public class CmdLineApp {
|
|||
System.out.println("Resource = "+currentId+" "+summary(currentResource));
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
private String summary(Resource r) throws IOException {
|
||||
// return new XmlParser().composeString(r);
|
||||
=======
|
||||
private String summary(Resource r) {
|
||||
>>>>>>> master
|
||||
if (r instanceof Patient) {
|
||||
Patient pat = (Patient) r;
|
||||
return pat.getIdBase()+" "+pat.getGender()+" "+pat.getBirthDateElement().asStringValue()+" "+name(pat);
|
||||
|
@ -324,7 +366,11 @@ public class CmdLineApp {
|
|||
return "";
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
private void search(String[] p) throws IOException {
|
||||
=======
|
||||
private void search(String[] p) {
|
||||
>>>>>>> master
|
||||
if (client == null) {
|
||||
throw new FHIRException("Not connected to to a server");
|
||||
}
|
||||
|
@ -332,7 +378,11 @@ public class CmdLineApp {
|
|||
if (p.length > 2) {
|
||||
search = search +"&gender="+p[2];
|
||||
if (p.length > 3) {
|
||||
<<<<<<< HEAD
|
||||
search = search +"&birthdate="+p[3];
|
||||
=======
|
||||
search = search +"&dob="+p[3];
|
||||
>>>>>>> master
|
||||
}
|
||||
}
|
||||
Bundle bnd = client.search("Patient", search);
|
||||
|
@ -368,6 +418,7 @@ public class CmdLineApp {
|
|||
private void connectToServer(String url) throws URISyntaxException {
|
||||
client = new FHIRToolingClient(url, "FHIR-Command-Line-App");
|
||||
CapabilityStatement cs = client.getCapabilitiesStatementQuick();
|
||||
<<<<<<< HEAD
|
||||
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("Connected to "+url+": "+cs.getSoftware().getName()+".");
|
||||
}
|
||||
|
||||
>>>>>>> master
|
||||
private void genMenu() {
|
||||
System.out.println("Simple Client. Commands you can run:");
|
||||
System.out.println(" c {url} - connect to a server");
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>6.1.11-SNAPSHOT</version>
|
||||
<version>6.1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>6.1.11-SNAPSHOT</version>
|
||||
<version>6.1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -50,9 +50,9 @@ public class FmlParser extends ParserBase {
|
|||
ByteArrayInputStream stream = new ByteArrayInputStream(content);
|
||||
String text = TextFile.streamToString(stream);
|
||||
List<ValidatedFragment> result = new ArrayList<>();
|
||||
ValidatedFragment ctxt = new ValidatedFragment("focus", "fml", content);
|
||||
ctxt.setElement(parse(ctxt.getErrors(), text));
|
||||
result.add(ctxt);
|
||||
ValidatedFragment focusFragment = new ValidatedFragment(ValidatedFragment.FOCUS_NAME, "fml", content, false);
|
||||
focusFragment.setElement(parse(focusFragment.getErrors(), text));
|
||||
result.add(focusFragment);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ public class JsonParser extends ParserBase {
|
|||
public List<ValidatedFragment> parse(InputStream inStream) throws IOException, FHIRException {
|
||||
// long start = System.currentTimeMillis();
|
||||
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);
|
||||
|
||||
|
@ -135,17 +135,17 @@ public class JsonParser extends ParserBase {
|
|||
try {
|
||||
obj = org.hl7.fhir.utilities.json.parser.JsonParser.parseObject(source, true, true);
|
||||
} 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 {
|
||||
obj = org.hl7.fhir.utilities.json.parser.JsonParser.parseObject(source, true, true);
|
||||
}
|
||||
|
||||
if (obj != null) {
|
||||
ctxt.setElement(parse(ctxt.getErrors(), obj));
|
||||
focusFragment.setElement(parse(focusFragment.getErrors(), obj));
|
||||
}
|
||||
List<ValidatedFragment> res = new ArrayList<>();
|
||||
res.add(ctxt);
|
||||
res.add(focusFragment);
|
||||
|
||||
// long t =System.currentTimeMillis()-start;
|
||||
// System.out.println("json parser: "+(t)+"ms, "+(content.length/1024)+"kb "+(t == 0 ? "" : " @ "+(content.length / t)+"kb/s"));
|
||||
|
|
|
@ -83,7 +83,7 @@ public class SHCParser extends ParserBase {
|
|||
byte[] content = TextFile.streamToBytes(inStream);
|
||||
ByteArrayInputStream stream = new ByteArrayInputStream(content);
|
||||
List<ValidatedFragment> res = new ArrayList<>();
|
||||
ValidatedFragment shc = new ValidatedFragment("shc", "txt", content);
|
||||
ValidatedFragment shc = new ValidatedFragment("shc", "txt", content, false);
|
||||
res.add(shc);
|
||||
|
||||
String src = TextFile.streamToString(stream).trim();
|
||||
|
@ -121,7 +121,7 @@ public class SHCParser extends ParserBase {
|
|||
return res;
|
||||
}
|
||||
|
||||
ValidatedFragment bnd = new ValidatedFragment("payload", "json", jwt.payloadSrc);
|
||||
ValidatedFragment bnd = new ValidatedFragment("payload", "json", jwt.payloadSrc, true);
|
||||
res.add(bnd);
|
||||
checkNamedProperties(shc.getErrors(), jwt.getPayload(), prefix+"payload", "iss", "nbf", "vc");
|
||||
checkProperty(shc.getErrors(), jwt.getPayload(), prefix+"payload", "iss", true, "String");
|
||||
|
|
|
@ -280,7 +280,7 @@ public class SHLParser extends ParserBase {
|
|||
}
|
||||
|
||||
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);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -2,34 +2,34 @@ package org.hl7.fhir.r5.elementmodel;
|
|||
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of HL7 nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of HL7 nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
@ -83,7 +83,7 @@ public class TurtleParser extends ParserBase {
|
|||
@Override
|
||||
public List<ValidatedFragment> parse(InputStream inStream) throws IOException, FHIRException {
|
||||
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);
|
||||
|
||||
Turtle src = new Turtle();
|
||||
|
@ -91,16 +91,16 @@ public class TurtleParser extends ParserBase {
|
|||
try {
|
||||
src.parse(TextFile.streamToString(stream));
|
||||
} 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;
|
||||
}
|
||||
ctxt.setElement(parse(ctxt.getErrors(), src));
|
||||
focusFragment.setElement(parse(focusFragment.getErrors(), src));
|
||||
} else {
|
||||
src.parse(TextFile.streamToString(stream));
|
||||
ctxt.setElement(parse(ctxt.getErrors(), src));
|
||||
focusFragment.setElement(parse(focusFragment.getErrors(), src));
|
||||
}
|
||||
List<ValidatedFragment> res = new ArrayList<>();
|
||||
res.add(ctxt);
|
||||
res.add(focusFragment);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,63 +3,55 @@ package org.hl7.fhir.r5.elementmodel;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
|
||||
public class ValidatedFragment {
|
||||
|
||||
@Getter
|
||||
private String name;
|
||||
|
||||
@Getter @Setter
|
||||
private String elementPath;
|
||||
|
||||
@Getter
|
||||
private String extension;
|
||||
|
||||
@Getter @Setter
|
||||
private Element element;
|
||||
|
||||
@Getter @Setter
|
||||
private byte[] content;
|
||||
|
||||
@Getter
|
||||
private final boolean isDerivedContent;
|
||||
public final static String FOCUS_NAME = "focus";
|
||||
|
||||
@Getter
|
||||
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();
|
||||
this.name = name;
|
||||
this.element = element;
|
||||
this.content = content;
|
||||
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();
|
||||
this.name = name;
|
||||
this.content = content;
|
||||
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() {
|
||||
return name+"."+extension;
|
||||
}
|
||||
|
||||
public String getElementPath() {
|
||||
return elementPath;
|
||||
}
|
||||
|
||||
public void setElementPath(String elementPath) {
|
||||
this.elementPath = elementPath;
|
||||
}
|
||||
|
||||
public String path() {
|
||||
return elementPath == null ? name : elementPath;
|
||||
}
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
package org.hl7.fhir.r5.elementmodel;
|
||||
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of HL7 nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
/*
|
||||
Copyright (c) 2011+, HL7, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of HL7 nor the names of its contributors may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
@ -465,7 +465,7 @@ public class VerticalBarParser extends ParserBase {
|
|||
while (!reader.isFinished()) // && (getOptions().getSegmentLimit() == 0 || getOptions().getSegmentLimit() > message.getSegments().size()))
|
||||
readSegment(message, reader);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ public class XmlParser extends ParserBase {
|
|||
public List<ValidatedFragment> parse(InputStream inStream) throws FHIRFormatError, DefinitionException, FHIRException, IOException {
|
||||
|
||||
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);
|
||||
Document doc = null;
|
||||
|
@ -138,7 +138,7 @@ public class XmlParser extends ParserBase {
|
|||
// if we can, we'll inspect the header/encoding ourselves
|
||||
|
||||
stream.mark(1024);
|
||||
version = checkHeader(context.getErrors(), stream);
|
||||
version = checkHeader(focusFragment.getErrors(), stream);
|
||||
stream.reset();
|
||||
|
||||
// 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:")) {
|
||||
int line = Utilities.parseInt(extractVal(e.getMessage(), "lineNumber"), 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 {
|
||||
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;
|
||||
}
|
||||
if (doc != null) {
|
||||
context.setElement(parse(context.getErrors(), doc));
|
||||
focusFragment.setElement(parse(focusFragment.getErrors(), doc));
|
||||
}
|
||||
List<ValidatedFragment> res = new ArrayList<>();
|
||||
res.add(context);
|
||||
res.add(focusFragment);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,10 +14,8 @@ import javax.xml.parsers.ParserConfigurationException;
|
|||
import org.fhir.ucum.UcumException;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
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.ResourceFactory;
|
||||
import org.hl7.fhir.r5.sql.SQLOnFhirTestCases.RowSorter;
|
||||
import org.hl7.fhir.r5.test.utils.CompareUtilities;
|
||||
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
||||
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.parser.JsonParser;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
public class SQLOnFhirTestCases {
|
||||
public class SQLOnFhirTests {
|
||||
|
||||
public class TestProvider implements Provider {
|
||||
|
||||
|
@ -110,6 +109,7 @@ public class SQLOnFhirTestCases {
|
|||
@SuppressWarnings("deprecation")
|
||||
@ParameterizedTest(name = "{index}: file {0}")
|
||||
@MethodSource("data")
|
||||
@Disabled
|
||||
public void test(String name, TestDetails test) throws FileNotFoundException, IOException, FHIRException, org.hl7.fhir.exceptions.FHIRException, UcumException {
|
||||
this.details = test;
|
||||
Runner runner = new Runner();
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>6.1.11-SNAPSHOT</version>
|
||||
<version>6.1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>6.1.11-SNAPSHOT</version>
|
||||
<version>6.1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -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_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_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_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})
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>6.1.11-SNAPSHOT</version>
|
||||
<version>6.1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>6.1.11-SNAPSHOT</version>
|
||||
<version>6.1.13-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
|
|
@ -32,12 +32,8 @@ import org.hl7.fhir.r5.context.IWorkerContext;
|
|||
import org.hl7.fhir.r5.context.IWorkerContextManager;
|
||||
import org.hl7.fhir.r5.context.SimpleWorkerContext;
|
||||
import org.hl7.fhir.r5.context.SystemOutLoggingService;
|
||||
import org.hl7.fhir.r5.elementmodel.Element;
|
||||
import org.hl7.fhir.r5.elementmodel.Manager;
|
||||
import org.hl7.fhir.r5.elementmodel.*;
|
||||
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.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r5.formats.JsonParser;
|
||||
|
@ -635,6 +631,13 @@ public class ValidationEngine implements IValidatorResourceFetcher, IValidationP
|
|||
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 {
|
||||
InstanceValidator validator = getValidator(cntType);
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.hl7.fhir.r5.elementmodel.Element;
|
|||
import org.hl7.fhir.r5.elementmodel.LanguageUtils;
|
||||
import org.hl7.fhir.r5.elementmodel.Manager;
|
||||
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.OutputStyle;
|
||||
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.NpmPackage;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
import org.hl7.fhir.validation.IgLoader;
|
||||
import org.hl7.fhir.validation.ValidationEngine;
|
||||
import org.hl7.fhir.validation.ValidationRecord;
|
||||
import org.hl7.fhir.validation.ValidatorUtils;
|
||||
import org.hl7.fhir.validation.*;
|
||||
import org.hl7.fhir.validation.ValidatorUtils.SourceFile;
|
||||
import org.hl7.fhir.validation.cli.model.CliContext;
|
||||
import org.hl7.fhir.validation.cli.model.FileInfo;
|
||||
|
@ -114,13 +112,43 @@ public class ValidationService {
|
|||
|
||||
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<>();
|
||||
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);
|
||||
ValidationOutcome outcome = new ValidationOutcome().setFileInfo(fp);
|
||||
messages.forEach(outcome::addMessage);
|
||||
response.addOutcome(outcome);
|
||||
|
||||
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);
|
||||
} 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());
|
||||
return response;
|
||||
|
|
4
pom.xml
4
pom.xml
|
@ -14,13 +14,13 @@
|
|||
HAPI FHIR
|
||||
-->
|
||||
<artifactId>org.hl7.fhir.core</artifactId>
|
||||
<version>6.1.11-SNAPSHOT</version>
|
||||
<version>6.1.13-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
<guava_version>32.0.1-jre</guava_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>
|
||||
<junit_jupiter_version>5.9.2</junit_jupiter_version>
|
||||
<junit_platform_launcher_version>1.8.2</junit_platform_launcher_version>
|
||||
|
|
Loading…
Reference in New Issue