use of org.hl7.fhir.r4b.utils.FHIRPathEngine in project org.hl7.fhir.core by hapifhir.
the class XmlParserTests method setUp.
@BeforeAll
public static void setUp() throws Exception {
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
context = TestingUtilities.getWorkerContext(pcm.loadPackage("hl7.fhir.r4.core", "4.0.1"));
fp = new FHIRPathEngine(context);
context.loadFromFile(TestingUtilities.loadTestResourceStream("validator", "cda", "any.xml"), "any.xml", null);
context.loadFromFile(TestingUtilities.loadTestResourceStream("validator", "cda", "ii.xml"), "ii.xml", null);
context.loadFromFile(TestingUtilities.loadTestResourceStream("validator", "cda", "cd.xml"), "cd.xml", null);
context.loadFromFile(TestingUtilities.loadTestResourceStream("validator", "cda", "ce.xml"), "ce.xml", null);
context.loadFromFile(TestingUtilities.loadTestResourceStream("validator", "cda", "ed.xml"), "ed.xml", null);
context.loadFromFile(TestingUtilities.loadTestResourceStream("validator", "cda", "st.xml"), "st.xml", null);
context.loadFromFile(TestingUtilities.loadTestResourceStream("validator", "cda", "cda.xml"), "cda.xml", null);
for (StructureDefinition sd : context.getStructures()) {
if (!sd.hasSnapshot()) {
System.out.println("generate snapshot for " + sd.getUrl());
context.generateSnapshot(sd, true);
}
}
}
use of org.hl7.fhir.r4b.utils.FHIRPathEngine in project org.hl7.fhir.core by hapifhir.
the class ValidationEngine method validate.
// testing entry point
public OperationOutcome validate(FhirFormat format, InputStream stream, List<String> profiles) throws FHIRException, IOException, EOperationOutcome {
List<ValidationMessage> messages = new ArrayList<ValidationMessage>();
InstanceValidator validator = getValidator(format);
validator.validate(null, messages, stream, format, asSdList(profiles));
return ValidatorUtils.messagesToOutcome(messages, context, fhirPathEngine);
}
use of org.hl7.fhir.r4b.utils.FHIRPathEngine in project org.hl7.fhir.core by hapifhir.
the class ValidationEngine method initContext.
protected void initContext(TimeTracker tt) throws IOException {
context.setCanNoTS(true);
context.setCacheId(UUID.randomUUID().toString());
// because of Forge
context.setAllowLoadingDuplicates(true);
context.setExpansionProfile(makeExpProfile());
if (tt != null) {
context.setClock(tt);
}
NpmPackage npmX = getPcm().loadPackage(CommonPackages.ID_XVER, CommonPackages.VER_XVER);
context.loadFromPackage(npmX, null);
this.fhirPathEngine = new FHIRPathEngine(context);
}
use of org.hl7.fhir.r4b.utils.FHIRPathEngine in project org.hl7.fhir.core by hapifhir.
the class ValidationEngine method evaluateFhirPath.
public String evaluateFhirPath(String source, String expression) throws FHIRException, IOException {
Content cnt = igLoader.loadContent(source, "validate", false);
FHIRPathEngine fpe = this.getValidator(null).getFHIRPathEngine();
Element e = Manager.parseSingle(context, new ByteArrayInputStream(cnt.focus), cnt.cntType);
ExpressionNode exp = fpe.parse(expression);
return fpe.evaluateToString(new ValidatorHostContext(context, e), e, e, e, exp);
}
use of org.hl7.fhir.r4b.utils.FHIRPathEngine in project org.hl7.fhir.core by hapifhir.
the class ValidationEngine method validate.
public OperationOutcome validate(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 ValidatorUtils.messagesToOutcome(messages, context, fhirPathEngine);
}
Aggregations