TimLuq / schematron-runner

2 stars 3 forks source link

CCDA Validation #1

Open wreiske opened 5 years ago

wreiske commented 5 years ago

Hey Tim,

I've been working on a Browserify version of schematron-runner (to run validation 100% in a browser). It seems to be running with a few minor issues (line numbers and xml didn't show up). I fixed the xml output to show, but I haven't tried getting the line numbers working. Made some modifications to allow for using a file object in the browser instead of relying on fs.

screen shot 2018-12-27 at 10 05 47 am

I'm running into some issues with CCDA validation. I know this project wasn't designed for it, but I'm hoping there may be some easy code changes to add support for it. Here are the problems I'm currently running into (when ran from the command line, NodeJS on OSX):

  1. Everything is showing as "passed", even though there are missing or renamed elements in the XML. If I modify the XML to try and create an error for something schematron showed as "passed", it will just remove it from the "passed" object and it won't be added to errors, warnings, etc. It just dissapears from the output.

Example: The following test checks to see if an element contains a templateId and a root of "2.16.840.1.113883.10.20.22.4.24". CCDA.sch

<sch:rule id="r-urn-oid-2.16.840.1.113883.10.20.22.4.24-errors" context="cda:participantRole[cda:templateId[@root='2.16.840.1.113883.10.20.22.4.24']]">
  <sch:extends rule="r-urn-oid-2.16.840.1.113883.10.20.22.4.24-errors-abstract" />
  <sch:assert id="a-81-7495" test="count(cda:templateId[@root='2.16.840.1.113883.10.20.22.4.24'])=1">SHALL contain exactly one [1..1] templateId (CONF:81-7495) such that it SHALL contain exactly one [1..1] @root="2.16.840.1.113883.10.20.22.4.24" (CONF:81-10493).</sch:assert>
</sch:rule>

When schematron-runner is executed on the following xml, it shows in the "passed" object. xdrtest1.xml

 <templateId root="2.16.840.1.113883.10.20.22.4.24"/>

Changing it to the following removes it from the "passed" object, but it does not add it to the "errors" object.

<templateId root="2.16.840.1.113883.10.20.22.4.55"/>

Also, there is a test in the SCR that looks like this:

<sch:assert id="a-1198-15974" test="not(cda:subject/cda:relatedSubject/cda:subject) or cda:subject/cda:relatedSubject/cda:subject[count(cda:administrativeGenderCode)=1]">The subject, if present, SHALL contain exactly one [1..1] administrativeGenderCode (CONF:1198-15974).</sch:assert>

When renaming all of the "administrativeGenderCode" elements in the XML to "administrativeGenderCodeBAD", schematron-runner doesn't show them as errors.

I've attached both the SCR and the XML we are testing with. Maybe I am doing something wrong?

ccda-test.zip

Thanks, Will

jddamore commented 5 years ago

@wreiske We're using the former (native JavaScript) package that this schematron-runner was based on (called cda-schematron here: https://www.npmjs.com/package/cda-schematron

I didn't check everything, but I did validate that the administrativeGenderCodeBAD issue is picked up with that package. May want to try that one out.