<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="//www.nemsis.org/media/nemsis_v3/master/Schematron/utilities/html/schematronHtml.xsl"?>
<sch:schema
	xmlns:sch="http://purl.oclc.org/dsdl/schematron"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	queryBinding="xslt2" id="EMSDataSet"
	schemaVersion="3.4.0.170111_20220302"
	see="http://www.nemsis.org/v3/downloads/schematron.html">

<sch:title>NEMSIS State of Illinois ISO Schematron file for EMSDataSet</sch:title>

<sch:ns prefix="nem" uri="http://www.nemsis.org"/>
<sch:ns prefix="xsi" uri="http://www.w3.org/2001/XMLSchema-instance"/>

<!-- "Initialize" variables used by nemsisDiagnostic. -->
<sch:let name="nemsisElements" value="()"/>
<sch:let name="nemsisElementsMissing" value="''"/>
<sch:let name="nemsisElementsMissingContext" value="()"/>

<sch:let name="AllowedEMSSystemNumbers" value="'0121','0139','0165','0175','0215','0218','0219','0237','0238','0242','0243','0253','0254','0256','0257','0279','0316','0320','0327','0360','0425','0432','0451','0473','0476','0481','0526','0530','0562','0623','0633','0644','0663','0671','0704','0710','0712','0729','0746','0777','0805','0828','0849','0859','0906','0907','0909','0948','0961','0980','1002','1011','1014','1072','1082','1103','1108','1113','1178','1241','1255','1275'" />
<sch:let name="PatientEncountered" value="'4212013','4212015','4212017','4212019','4212021','4212023','4212025','4212027','4212029','4212031','4212033','4212035','4212037'" />
<sch:let name="PatientTreated" value="'4212017','4212019','4212027','4212029','4212031','4212033','4212035','4212037'" />
<sch:let name="PatientTransported" value="'4212013','4212017','4212023','4212033'" />
<sch:let name="Assist" value="'4212001','4212003','4212005','4212041'" />
<sch:let name="NoPatientContact" value="'4212007','4212009','4212011','4212039','4212043'" />
<sch:let name="NoTransportPatientContact" value="'4212015','4212019','4212021','4212025','4212027','4212029','4212031','4212035','4212037'" />
<sch:let name="OrganTransport" value="'4212043'" />


<!-- ************** PATTERNS ***************** -->

<sch:pattern id="p5">
  <sch:title>dAgency.01 Rules</sch:title>
  <sch:rule id="r5" context="nem:eResponse.01">
    <sch:let name="nemsisElements" value="." />
    <sch:assert id="Rule_5" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test=". = ../../../../nem:DemographicGroup/nem:dAgency.01">
      EMS Agency Number (eResponse.01) must unconditionally equal EMS Agency Unique State ID (dAgency.01).
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p6">
  <sch:title>dAgency.02 Rules</sch:title>
  <sch:rule id="r6" context="nem:eResponse.01">
    <sch:let name="nemsisElements" value="." />
    <sch:assert id="Rule_6" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test=". = ../../../../nem:DemographicGroup/nem:dAgency.02">
      EMS Agency Number (eResponse.01) must unconditionally equal EMS Agency Number (dAgency.02).
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p7">
  <sch:title>dAgency.04 Rules</sch:title>
  <sch:rule id="r7" context="nem:DemographicGroup/nem:dAgency.04">
    <sch:let name="nemsisElements" value="." />
    <sch:assert id="Rule_7" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test=". = '17'">
      EMS Agency State (dAgency.04) must unconditionally equal '17', the state FIPS code for Illinois.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p8">
  <sch:title>eResponse.01 Rules</sch:title>
  <sch:rule id="r8" context="nem:eResponse.01">
    <sch:let name="nemsisElements" value="." />
    <sch:assert id="Rule_8" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="number(.)>=1000 and number(.)&lt;=9999">
      EMS Agency Number (eResponse.01) must be a four-digit numeric string in the range of 1000-9999.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p9">
  <sch:title>eResponse.08 Rules</sch:title>
  <sch:rule id="r9"
            context="nem:eResponse.08">
    <sch:let  name="nemsisElements"  value="."  />
    <sch:report id="Rule_10"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". = '2208013' and count(../nem:eResponse.08) &gt; 1">
      When Types of Dispatch Delay (eResponse.08) includes 'None/No Delay'
      there cannot also be other Dispatch Delay Types.
    </sch:report>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p11">
  <sch:title>eResponse.09 Rules</sch:title>
  <sch:rule id="r11"
            context="nem:eResponse.09">
    <sch:let  name="nemsisElements"  value="."  />
    <sch:report id="Rule_11"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". = '' and ../../nem:eTimes/nem:eTimes.05 != ''">
      Type of Response Delay (eResponse.09) must equal a valid value
      other than a Not Value when En Route Date/Time (eTimes.05) is
      specified.
    </sch:report>
    <sch:report id="Rule_12"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". = '2209011' and count(../nem:eResponse.09) &gt; 1">
      When Types of Response Delay (eResponse.09) includes 'None/No Delay'
      there cannot also be other Response Delay Types.
    </sch:report>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p13">
  <sch:title>eResponse.10 Rules</sch:title>
  <sch:rule id="r13"
            context="nem:eResponse.10">
    <sch:let  name="nemsisElements"  value="."  />
            
    <sch:assert id="Rule_13"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="@NV = '7701001' or ../../nem:eDisposition/nem:eDisposition.12 != '4212007'">
      Type of Scene Delay (eResponse.10) must equal 'Not Applicable'
      when Incident/Patient Disposition (eDisposition.12) equals
      'Canceled (Prior to Arrival At Scene)'.
    </sch:assert>
    
    <sch:report id="Rule_14"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". = '' and ../../nem:eTimes/nem:eTimes.06 != ''">
      Type of Scene Delay (eResponse.10) must equal a valid value
      other than a Not Value when Arrived on Scene (eTimes.06) is
      specified.
    </sch:report>
    
    <sch:report id="Rule_15"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". = '2210017' and count(../nem:eResponse.10) &gt; 1">
      When Types of Scene Delay (eResponse.10) includes 'None/No Delay'
      there cannot also be other Scene Delay Types.
    </sch:report>
    
  </sch:rule>
</sch:pattern>

<sch:pattern id="p16">
  <sch:title>eResponse.11 Rules</sch:title>
  <sch:rule id="r16"
            context="nem:eResponse.11">
    <sch:let  name="nemsisElements"  value="."  />
    
    <sch:assert id="Rule_16"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="@NV = '7701001' or ../../nem:eDisposition/nem:eDisposition.12 = ($PatientTransported,$OrganTransport)">
      Type of Transport Delay (eResponse.11) must equal 'Not Applicable'
      when Incident/Patient Disposition (eDisposition.12) does not equal
      a value from either the 'Patient Transported' or the 'Organ Transport'
      Disposition Group.
    </sch:assert>
    
    <sch:report id="Rule_17"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". = '' and ../../nem:eTimes/nem:eTimes.11 != ''">
      Type of Transport Delay (eResponse.11) must equal a valid value
      other than a Not Value when Patient Arrived at Destination Date/Time 
      (eTimes.11) is specified.
    </sch:report>
    
    <sch:report id="Rule_18"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". = '2211011' and count(../nem:eResponse.11) &gt; 1">
      When Types of Transport Delay (eResponse.11) includes 'None/No Delay'
      there cannot also be other Transport Delay Types.
    </sch:report>
    
  </sch:rule>
</sch:pattern>

<sch:pattern id="p19-20">
  <sch:title>eResponse.12 Rules</sch:title>
  <sch:rule id="r19-20"
            context="nem:eResponse.12">
    <sch:let  name="nemsisElements"  value="."  />
    
            
    <sch:report id="Rule_19"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". = '' and ../../nem:eTimes/nem:eTimes.06 != ''">
      Type of Turn-Around Delay (eResponse.12) must equal a valid value 
      other than a Not Value when Unit Arrived on Scene Date/Time (eTimes.06)
      is specified.
    </sch:report>
    
    <sch:report id="Rule_20"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". = '2212015' and count(../nem:eResponse.12) &gt; 1">
      When Types of Turn-Around Delay (eResponse.12) includes 'None/No Delay'
      there cannot also be other Turn-Around Delay Types.
    </sch:report>
    
  </sch:rule>
</sch:pattern>

<sch:pattern id="p26">
  <sch:title>Crew Required</sch:title>
  <sch:rule id="r26"
            context="nem:PatientCareReport">
    <sch:let name="nemsisElementsMissing" value="'eCrew.01'"/>
  
    <sch:assert id="Rule_26"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="descendant::nem:eCrew.01[normalize-space(.) != '']">
      A MINIMUM of one state EMS licensure ID number must
      be entered into each run report.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p28">
  <sch:title>Dispatch Time Order</sch:title>

  <sch:rule id="r28.1"
            context="nem:eTimes.03[. != '' and ../nem:eTimes.02 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.02)"  />
    
    <sch:assert id="Rule_28_1"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". &gt;= ../nem:eTimes.02">
      Unit Notified by Dispatch Date/Time (eTimes.03) must be greater
      than or equal to Dispatch Notified Date/Time (eTimes.02).
    </sch:assert>
  </sch:rule>

  <sch:rule id="r28.2"
            context="nem:eTimes.03[. != '' and ../nem:eTimes.01 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.01)"  />
    
    <sch:assert id="Rule_28_2"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". &gt;= ../nem:eTimes.01">
      Unit Notified by Dispatch Date/Time (eTimes.03) must be greater
      than or equal to PSAP Call Date/Time (eTimes.01).
    </sch:assert>
  </sch:rule>

</sch:pattern>


<sch:pattern id="p29">
  <sch:title>Arr Scene, No En Route Time</sch:title>
  <sch:rule id="r29"
            context="nem:eTimes.05[. = '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.06)"  />
    
    <sch:assert id="Rule_29"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="../nem:eTimes.06 = ''">
      Unit En Route Date/Time (eTimes.05) must be specified
      when Unit Arrived on Scene Date/Time (eTimes.06) is specified.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p30">
  <sch:title>En Route Time</sch:title>
  <sch:rule id="r30"
            context="nem:eTimes.05[. != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.03)"  />
    
    <sch:assert id="Rule_30"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". &gt;= ../nem:eTimes.03">
      Unit En Route Date/Time (eTimes.05) must be greater than or equal
      to Unit Notified by Dispatch Date/Time (eTimes.03).
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p31">
  <sch:title>No En Route Time</sch:title>
  <sch:rule id="r31"
            context="nem:eTimes.05[. = '']">
    <sch:let  name="nemsisElements"  value="."  />
    
    <sch:assert id="Rule_31"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="ancestor::nem:PatientCareReport//nem:eDisposition.12 = '4212007'">
      Unit En Route Date/Time (eTimes.05) must be specified
      when Incident/Patient Disposition (eDisposition.12) is not equal to
      'Canceled (Prior to Arrival At Scene)'.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p32">
  <sch:title>No Arrive Scene Time</sch:title>
  <sch:rule id="r32"
            context="nem:eTimes.06[. = '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.07)"  />
    
    <sch:assert id="Rule_32"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="../nem:eTimes.07 = ''">
      Unit Arrived on Scene Date/Time (eTimes.06) must be specified
      when Arrived at Patient Date/Time (eTimes.07) is specified.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p33">
  <sch:title>Arrive Scene Time Seq</sch:title>
  <sch:rule id="r33.1"
            context="nem:eTimes.06[. != '' and ../nem:eTimes.05 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.05)"  />
    
    <sch:assert id="Rule_33_1"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". &gt;= ../nem:eTimes.05">
      Unit Arrived on Scene Date/Time (eTimes.06) must be greater than or
      equal to Enroute Date/Time (eTimes.05).
    </sch:assert>
  </sch:rule>
  <sch:rule id="r33.2"
            context="nem:eTimes.06[. != '' and ../nem:eTimes.03 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.03)"  />
    
    <sch:assert id="Rule_33_2"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". &gt;= ../nem:eTimes.03">
      Unit Arrived on Scene Date/Time (eTimes.06) must be greater than or
      equal to Unit Notified by Dispatch Date/Time (eTimes.03).
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p34">
  <sch:title>Not Canceled, No Arrive Scene Time</sch:title>
  <sch:rule id="r34"
            context="nem:eTimes.06[. = '']">
    <sch:let  name="nemsisElements"  value="."  />
    
    <sch:assert id="Rule_34"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="ancestor::nem:PatientCareReport//nem:eDisposition.12 = '4212007'">
      Unit Arrived on Scene Date/Time (eTimes.06) must be specified
       when Incident/Patient Disposition (eDisposition.12) is not equal
      to 'Canceled (Prior to Arrival At Scene)'.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p35">
  <sch:title>No Arrive Scene Time</sch:title>
  <sch:rule id="r35"
            context="nem:eTimes.07[. = '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.09)"  />
    
    <sch:assert id="Rule_35"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="../nem:eTimes.09 = ''">
      Arrived At Patient Date/Time (eTimes.07) must be specified
       when Unit Left Scene Date/Time (eTimes.09) is specified.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p36">
  <sch:title>Arrive Pt Time Seq</sch:title>
  <sch:rule id="r36.1"
            context="nem:eTimes.07[. != '' and ../nem:eTimes.06 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.06)"  />
    
    <sch:assert id="Rule_36_1"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". &gt;= ../nem:eTimes.06">
      Arrived At Patient Date/Time (eTimes.07) must be greater than or
      equal to Unit Arrived on Scene Date/Time (eTimes.06).
    </sch:assert>
  </sch:rule>
  <sch:rule id="r36.2"
            context="nem:eTimes.07[. != '' and ../nem:eTimes.05 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.05)"  />
    
    <sch:assert id="Rule_36_2"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". &gt;= ../nem:eTimes.05">
      Arrived At Patient Date/Time (eTimes.07) must be greater than or
      equal to Enroute Date/Time (eTimes.05).
    </sch:assert>
  </sch:rule>
  <sch:rule id="r36.3"
            context="nem:eTimes.07[. != '' and ../nem:eTimes.03 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.03)"  />
    
    <sch:assert id="Rule_36_3"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". &gt;= ../nem:eTimes.03">
      Arrived At Patient Date/Time (eTimes.07) must be greater than or
      equal to Unit Notified by Dispatch Date/Time (eTimes.03).
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p37">
  <sch:title>No At Pt, but Treat or Assess</sch:title>
  <sch:rule id="r37"
            context="nem:eTimes.07[. = '']">
    <sch:let  name="nemsisElements"  value="(., ../../nem:eExam//*[normalize-space(.) != ''], ../../nem:eHistory//*[normalize-space(.) != ''], ../../nem:eInjury//*[normalize-space(.) != ''], ../../nem:eMedications//*[normalize-space(.) != ''], ../../nem:ePatient//*[normalize-space(.) != ''], ../../nem:eProcedures//*[normalize-space(.) != ''], ../../nem:eVitals//*[normalize-space(.) != ''])"  />
    
    <sch:report id="Rule_37"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="../../nem:eExam//*[normalize-space(.) != ''] or ../../nem:eHistory//*[normalize-space(.) != ''] or ../../nem:eInjury//*[normalize-space(.) != ''] or ../../nem:eMedications//*[normalize-space(.) != ''] or ../../nem:ePatient//*[normalize-space(.) != ''] or ../../nem:eProcedures//*[normalize-space(.) != ''] or ../../nem:eVitals//*[normalize-space(.) != '']">
      Arrived At Patient Date/Time (eTimes.07) must be specified
       when any of the following equals a valid value other than a
      not value:
        -Any eExam element (eExam.&lt;any&gt;)
        -Any eHistory element (eHistory.&lt;any&gt;)
        -Any eInjury element (eInjury.&lt;any&gt;)
        -Any eMedications element (eMedications.&lt;any&gt;)
        -Any ePatient element (ePatient.&lt;any&gt;)
        -Any eProcedures element (eProcedures.&lt;any&gt;)
        -Any eVitals element (eVitals.&lt;any&gt;)
    </sch:report>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p38">
  <sch:title>Pt Contact, No At Pt Time</sch:title>
  <sch:rule id="r38"
            context="nem:eTimes.07[. = '']">
    <sch:let  name="nemsisElements"  value="."  />
    
    <sch:assert id="Rule_38"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="not(../../nem:eDisposition/nem:eDisposition.12[. = ($PatientEncountered)])">
      Arrived At Patient Date/Time (eTimes.07) must be specified
       when Incident Patient Disposition (eDisposition.12) equals a
      value from the 'Patient Encountered' Disposition Group.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p40">
  <sch:title>Arrive Scene Time Seq</sch:title>
  <sch:rule id="r40.0"
            context="nem:eTimes.09[. = '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.11)"  />
    
    <sch:assert id="Rule_40_0"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="../nem:eTimes.11 = ''">
      Unit Left Scene Date/Time (eTimes.09) must be specified
      when Patient Arrived at Destination (eTimes.11) is specified,
      and it must be less than or equal to that value.
    </sch:assert>
  </sch:rule>
  <sch:rule id="r40.1"
            context="nem:eTimes.09[../nem:eTimes.07 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.07)"  />
    
    <sch:assert id="Rule_40_1"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". &gt;= ../nem:eTimes.07">
      Unit Left Scene Date/Time (eTimes.09) must be greater than or
      equal to Arrived at Patient Date/Time (eTimes.07).
    </sch:assert>
  </sch:rule>
  <sch:rule id="r40.2"
            context="nem:eTimes.09[../nem:eTimes.06 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.06)"  />
    
    <sch:assert id="Rule_40_2"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". &gt;= ../nem:eTimes.06">
      Unit Left Scene Date/Time (eTimes.09) must be greater than or
      equal to Unit Arrived on Scene Date/Time (eTimes.06).
    </sch:assert>
  </sch:rule>
  <sch:rule id="r40.3"
            context="nem:eTimes.09[../nem:eTimes.05 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.05)"  />
    
    <sch:assert id="Rule_40_3"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". &gt;= ../nem:eTimes.05">
      Unit Left Scene Date/Time (eTimes.09) must be greater than or
      equal to Enroute Date/Time (eTimes.05).
    </sch:assert>
  </sch:rule>
  <sch:rule id="r40.4"
            context="nem:eTimes.09[../nem:eTimes.03 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.03)"  />
    
    <sch:assert id="Rule_40_4"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". &gt;= ../nem:eTimes.03">
      Unit Left Scene Date/Time (eTimes.09) must be greater than or
      equal to Unit Notified by Dispatch Date/Time (eTimes.03).
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p41">
  <sch:title>Arrive Scene Time Seq</sch:title>
  <sch:rule id="r41.0"
            context="nem:eTimes.11[. = '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.12)"  />
    
    <sch:assert id="Rule_41_0"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="../nem:eTimes.12 = ''">
      Patient Arrived at Destination Date/Time (eTimes.11) must be
      specified when Destination Patient Transfer of Care Date/Time
      (eTimes.12) is specified, and it must be less than or equal to that
      value.
    </sch:assert>
  </sch:rule>
  <sch:rule id="r41.1"
            context="nem:eTimes.11[../nem:eTimes.09 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.09)"  />
    
    <sch:assert id="Rule_41_1"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". &gt;= ../nem:eTimes.09">
      Patient Arrived at Destination Date/Time (eTimes.11) must be greater
      than or equal to Unit Left Scene Date/Time (eTimes.09).
    </sch:assert>
  </sch:rule>
  <sch:rule id="r41.2"
            context="nem:eTimes.11[../nem:eTimes.07 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.07)"  />
    
    <sch:assert id="Rule_41_2"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". &gt;= ../nem:eTimes.07">
      Patient Arrived at Destination Date/Time (eTimes.11) must be greater
      than or equal to Arrived at Patient Date/Time (eTimes.07).
    </sch:assert>
  </sch:rule>
  <sch:rule id="r41.3"
            context="nem:eTimes.11[../nem:eTimes.06 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.06)"  />
    
    <sch:assert id="Rule_41_3"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". &gt;= ../nem:eTimes.06">
      Patient Arrived at Destination Date/Time (eTimes.11) must be greater
      than or equal to Unit Arrived on Scene Date/Time (eTimes.06).
    </sch:assert>
  </sch:rule>
  <sch:rule id="r41.4"
            context="nem:eTimes.11[../nem:eTimes.05 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.05)"  />
    
    <sch:assert id="Rule_41_4"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". &gt;= ../nem:eTimes.05">
      Patient Arrived at Destination Date/Time (eTimes.11) must be greater
      than or equal to Enroute Date/Time (eTimes.05).
    </sch:assert>
  </sch:rule>
  <sch:rule id="r41.5"
            context="nem:eTimes.11[../nem:eTimes.03 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.03)"  />
    
    <sch:assert id="Rule_41_5"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". &gt;= ../nem:eTimes.03">
      Patient Arrived at Destination Date/Time (eTimes.11) must be greater
      than or equal to Unit Notified by Dispatch Date/Time (eTimes.03).
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p42">
  <sch:title>Arrive Scene Time Seq</sch:title>
                                   
  <sch:rule id="r42.1"
            context="nem:eTimes.12[. != '' and ../nem:eTimes.11 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.11)"  />
    
    <sch:assert id="Rule_42_1"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". &gt;= ../nem:eTimes.11">
      Destination Patient Transfer of Care Date/Time (eTimes.12) must be
      greater than or equal to Patient Arrived at Destination Date/Time
      (eTimes.11).
    </sch:assert>
  </sch:rule>
  <sch:rule id="r42.2"
            context="nem:eTimes.12[. != '' and ../nem:eTimes.09 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.09)"  />
    
    <sch:assert id="Rule_42_2"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". &gt;= ../nem:eTimes.09">
      Destination Patient Transfer of Care Date/Time (eTimes.12) must be
      greater than or equal to Unit Left Scene Date/Time (eTimes.09).
    </sch:assert>
  </sch:rule>
  <sch:rule id="r42.3"
            context="nem:eTimes.12[. != '' and ../nem:eTimes.07 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.07)"  />
    
    <sch:assert id="Rule_42_3"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". &gt;= ../nem:eTimes.07">
      Destination Patient Transfer of Care Date/Time (eTimes.12) must be
      greater than or equal to Arrived at Patient Date/Time (eTimes.07).
    </sch:assert>
  </sch:rule>
  <sch:rule id="r42.4"
            context="nem:eTimes.12[. != '' and ../nem:eTimes.06 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.06)"  />
    
    <sch:assert id="Rule_42_4"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". &gt;= ../nem:eTimes.06">
      Destination Patient Transfer of Care Date/Time (eTimes.12) must be
      greater than or equal to Unit Arrived on Scene Date/Time (eTimes.06).
    </sch:assert>
  </sch:rule>
  <sch:rule id="r42.5"
            context="nem:eTimes.12[. != '' and ../nem:eTimes.05 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.05)"  />
    
    <sch:assert id="Rule_42_5"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". &gt;= ../nem:eTimes.05">
      Destination Patient Transfer of Care Date/Time (eTimes.12) must be
      greater than or equal to Enroute Date/Time (eTimes.05).
    </sch:assert>
  </sch:rule>
  <sch:rule id="r42.6"
            context="nem:eTimes.12[. != '' and ../nem:eTimes.03 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eTimes.03)"  />
    
    <sch:assert id="Rule_42_6"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test=". &gt;= ../nem:eTimes.03">
      Destination Patient Transfer of Care Date/Time (eTimes.12) must be
      greater than or equal to Unit Notified by Dispatch Date/Time (eTimes.03).
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p43">
  <sch:title>Dest Xfer of Care blank</sch:title>
  <sch:rule id="r43"
            context="nem:eTimes.12[. = '']">
    <sch:let  name="nemsisElements"  value="."  />
    
    <sch:report id="Rule_43"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="../../nem:eDisposition/nem:eDisposition.12[. = ($PatientTransported)]">
      Destination Patient Transfer of Care Date/Time (eTimes.12) must be
      specified when Incident Patient Disposition (eDisposition.12)
      equals a value from the 'Patient Transported' Disposition Group.
    </sch:report>
  </sch:rule>
</sch:pattern>


<sch:pattern id="p45">
  <sch:title>Pt info on No Pt call</sch:title>
  <sch:rule id="r45"
            context="nem:eDisposition.12[. = $NoPatientContact]">
    <sch:let  name="nemsisElements"  value="(., ../../nem:ePatient/descendant::*[not(@NV = '7701001') and not(child::*)])"  />
    
    <sch:report id="Rule_45"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="../../nem:ePatient/descendant::*[not(@NV = ('7701001','7701003','7701005')) and not(child::*)]">
      All ePatient elements must equal a NOT value or be omitted when Incident/Patient
      Disposition (eDisposition.12) equals a value from the 'No Patient
      Contact' Disposition Group.
    </sch:report>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p46ff">
  <sch:title>Elements Required for Pt Encountered calls</sch:title>
  <sch:rule id="r46ff"
            context="nem:PatientCareReport[nem:eDisposition/nem:eDisposition.12 = $PatientEncountered or nem:eTimes/nem:eTimes.07 != '']">
    <sch:let  name="nemsisElements"  value="(nem:eDisposition/nem:eDisposition.12, nem:eTimes/nem:eTimes.07[. != ''])"  />
    
    <sch:assert id="Rule_46"
                role="[WARNING]"
                diagnostics="nemsisDiagnostic"
                test="nem:ePatient/nem:ePatient.07 != ''">
      Patient's Home County (ePatient.07) should equal a valid value other
      than a Not Value when Incident/Patient Disposition (eDisposition.12)
      equals a value from the 'Patient Encountered' Disposition Group OR
      when Arrived at Patient Date/Time (eTimes.07) is specified.
    </sch:assert>

    <sch:assert id="Rule_48"
                role="[WARNING]"
                diagnostics="nemsisDiagnostic"
                test="nem:ePatient/nem:ePatient.08 != ''">
      Patient's Home State (ePatient.08) should equal a valid value other
      than a Not Value when Incident/Patient Disposition (eDisposition.12)
      equals a value from the 'Patient Encountered' Disposition Group OR
      when Arrived at Patient Date/Time (eTimes.07) is specified.
    </sch:assert>

    <sch:assert id="Rule_50"
                role="[WARNING]"
                diagnostics="nemsisDiagnostic"
                test="nem:ePatient/nem:ePatient.09 != ''">
      Patient's Home ZIP Code (ePatient.09) should equal a valid value other
      than a Not Value when Incident/Patient Disposition (eDisposition.12)
      equals a value from the 'Patient Encountered' Disposition Group OR
      when Arrived at Patient Date/Time (eTimes.07) is specified.
    </sch:assert>

    <sch:assert id="Rule_51"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:ePatient/nem:ePatient.13 != ''">
      Patient's Gender (ePatient.13) must equal a valid value other than
      a Not Value when Incident/Patient Disposition (eDisposition.12) equals
      a value from the 'Patient Encountered' Disposition Group OR when
      Arrived at Patient Date/Time (eTimes.07) is specified.
    </sch:assert>


    <sch:assert id="Rule_52"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="not(nem:ePatient/nem:ePatient.14[@NV = '7701001'])">
      Patient's Race (ePatient.14) cannot equal 'Not Applicable' when
      Incident/Patient Disposition (eDisposition.12) equals a value from
      the 'Patient Encountered' Disposition Group OR when Arrived at Patient
      Date/Time (eTimes.07) is specified.
    </sch:assert>

    <sch:assert id="Rule_54"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:ePatient/nem:ePatient.AgeGroup/nem:ePatient.15[. != ''] or nem:ePatient/nem:ePatient.17[. != '']">
      Patient's Age (ePatient.15) must equal a valid value other than a
      Not Value when Date of Birth (ePatient.17) does not have a valid date
      AND when Incident/Patient Disposition (eDisposition.12) equals a value
      from the 'Patient Encountered' Disposition Group OR Arrived at Patient
      Date/Time (eTimes.07) is specified.
    </sch:assert>

    <sch:assert id="Rule_57"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:ePatient/nem:ePatient.17[. != ''] or nem:ePatient/nem:ePatient.AgeGroup/nem:ePatient.15[. != '']">
      Date of Birth (ePatient.17) must equal a valid date when Patient's
      Age (ePatient.15) does not have a value between 1-120 AND when
      Incident/Patient Disposition (eDisposition.12) equals a value from
      the 'Patient Encountered' Disposition Group OR Arrived at Patient
      Date/Time (eTimes.07) is specified.
    </sch:assert>


  </sch:rule>
</sch:pattern>


<!-- removed 11/16/2016
<sch:pattern id="p58">
  <sch:title>Elements Required for Transported calls</sch:title>
  <sch:rule id="r58"
            context="nem:PatientCareReport[nem:eDisposition/nem:eDisposition.12 = $PatientTransported]">
    <sch:let  name="nemsisElements"  value="nem:ePayment/nem:ePayment.50"  />
    
    
    <sch:assert id="Rule_58"
                role="[WARNING]"
                diagnostics="nemsisDiagnostic"
                test="nem:ePayment/nem:ePayment.50 != ''">
      CMS Service Level (ePayment.50) should equal a valid value other than
      a Not Value when  Incident/Patient Disposition (eDisposition.12) equals
      a value from the 'Patient Transported' Disposition Group.
    </sch:assert>
    
  </sch:rule>
</sch:pattern>
-->

<sch:pattern id="p47">
  <sch:title>Home State Doesn't match County</sch:title>
  <sch:rule id="r47"
            context="nem:ePatient.07[. != '' or ../nem:ePatient.08 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:ePatient.08[. != ''])"  />
    
    <sch:assert id="Rule_47"
                role="[WARNING]"
                diagnostics="nemsisDiagnostic"
                test="../nem:ePatient.08 = substring(.,1,2)">
      The first two digits of Patient's Home County (ePatient.07) must equal
      Patient's Home State (ePatient.08).
    </sch:assert>
  </sch:rule>
</sch:pattern>


<sch:pattern id="p53">
  <sch:title>DOB plus N/A Age</sch:title>
  <sch:rule id="r53"
            context="nem:ePatient.17[. != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:ePatient.AgeGroup/nem:ePatient.15[@NV = '7701001'])"  />
    
    <sch:assert id="Rule_53"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="not(../nem:ePatient.AgeGroup/nem:ePatient.15[@NV = '7701001'])">
      Patient's Age (ePatient.15) cannot equal 'Not Applicable' when Date
      of Birth (ePatient.17) equals a valid date.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p55">
  <sch:title>Age, no Units</sch:title>
  <sch:rule id="r55"
            context="nem:ePatient.15[. != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:ePatient.16[. != ''])"  />
    
    <sch:assert id="Rule_55"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="../nem:ePatient.16 != ''">
      Patient's Age Units (ePatient.16) must equal a valid value other than
      a Not Value when Patient's Age (ePatient.15) has a value between 1-120.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p56">
  <sch:title>Age, no Units</sch:title>
  <sch:rule id="r56"
            context="nem:ePatient.15[. != '']">
    <sch:let  name="nemsisElements"  value="(., ../../nem:ePatient.17[@NV = '7701001'])"  />
    
            
    <sch:report id="Rule_56"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="../../nem:ePatient.17/@NV = '7701001'">
      Date of Birth (ePatient.17) cannot equal 'Not Applicable' when Patient's
      Age (ePatient.15) has a value between 1-120.
    </sch:report>
    
  </sch:rule>
</sch:pattern>

<sch:pattern id="p59ff">
  <sch:title>Requirements when Arrive Scene Time specified</sch:title>
  <sch:rule id="r59ff"
            context="nem:PatientCareReport[nem:eTimes/nem:eTimes.06 != '']">
    <sch:let  name="nemsisElements"  value="(nem:eScene/nem:eScene.01, nem:eScene/nem:eScene.06, nem:eScene/nem:eScene.07, nem:eScene/nem:eScene.09)"  />
    
    <sch:assert id="Rule_59"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eScene/nem:eScene.01 != ''">
      First EMS Unit on Scene (eScene.01) must equal a valid value other
      than a Not Value when Unit Arrived on Scene (eTimes.06) is specified.
    </sch:assert>

    <sch:assert id="Rule_61"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eScene/nem:eScene.06 != ''">
      Number of Patients at Scene (eScene.06) must equal a valid value other
      than a Not Value when Unit Arrived on Scene (eTimes.06) is specified.
    </sch:assert>

    <sch:assert id="Rule_64"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eScene/nem:eScene.07 != ''">
      Mass Casualty Incident (eScene.07) must equal a valid value other
      than a Not Value when Unit Arrived on Scene (eTimes.06) is specified.
    </sch:assert>

    <sch:assert id="Rule_69"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eScene/nem:eScene.09 != ''">
      Incident Location Type (eScene.09) must equal a valid value other
      than a Not Value when Unit Arrived on Scene (eTimes.06) is specified.
    </sch:assert>

  </sch:rule>
</sch:pattern>

<sch:pattern id="p60">
  <sch:title>Requirements when Arrive Scene Time specified</sch:title>
  <sch:rule id="r60"
            context="nem:PatientCareReport[nem:eDisposition/nem:eDisposition.12 = ($PatientEncountered)]">
    <sch:let  name="nemsisElements"  value="(nem:eScene/nem:eScene.06, nem:eScene/nem:eScene.07, nem:eArrest/nem:eArrest.01)"  />
    

    <sch:assert id="Rule_60"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eScene/nem:eScene.06 != ''">
      Number of Patients at Scene (eScene.06) must equal a valid value other
      than a Not Value when Incident/Patient Disposition (eDisposition.12)
      equals a value from the 'Patient Encountered' Disposition Group.
    </sch:assert>

    <sch:assert id="Rule_63"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eScene/nem:eScene.07 != ''">
      Mass Casualty Incident (eScene.07) must equal a valid value other
      than a Not Value when Incident/Patient Disposition (eDisposition.12)
      equals a value from the'Patient Encountered' Disposition Group.
    </sch:assert>

    <!-- updated 10/17/2018 to disallow only 'Not Applicable' -->
    <sch:assert id="Rule_106"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="not(nem:eArrest/nem:eArrest.01[@NV = '7701001'])">
      Cardiac Arrest (eArrest.01) must equal a valid value other than 'Not 
      Applicable' when Incident/Patient Disposition (eDisposition.12) contains 
      a value from the 'Patient Encountered' Disposition Group.
    </sch:assert>

  </sch:rule>
</sch:pattern>

<sch:pattern id="p62ff">
  <sch:title>eScene Misc</sch:title>
  <sch:rule id="r62ff"
            context="nem:eScene">
    <sch:let  name="nemsisElements"  value="*"  />
    

    <sch:assert id="Rule_62"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eScene.06 = '2707001' or not(nem:eScene.07 = '9923003')">
      Number of Patients at Scene (eScene.06) must equal 'Multiple' when
      Mass Casualty Incident (eScene.07) equals 'Yes'.
    </sch:assert>

    <sch:assert id="Rule_66"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eScene.08 = '' or nem:eScene.07 = '9923003'">
      Mass Casualty Incident (eScene.07) must equal 'Yes' when Triage
      Classification for MCI Patient (eScene.08) equals a valid value
      other than a Not Value.
    </sch:assert>

    <sch:report id="Rule_68"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="not(nem:eScene.08[@NV = ('7701001','7701003','7701005')]) and ../nem:eDisposition/nem:eDisposition.12[. = ($NoPatientContact)]">
      Triage Classification for MCI Patient (eScene.08) must equal a NOT 
      value when Incident/Patient Disposition (eDisposition.12) equals a
      value from the 'No Patient Contact' Disposition Group.
    </sch:report>

    <sch:report id="Rule_70"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eScene.15/@NV = '7701001' and (../nem:eTimes/nem:eTimes.05 != '')">
      Incident Street Address (eScene.15) cannot equal 'Not Applicable'
      unless Enroute Date/Time (eTimes.05) is not specified.
    </sch:report>

    <sch:report id="Rule_71"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eScene.17/@NV = '7701001' and (../nem:eDisposition/nem:eDisposition.12 != ($NoPatientContact,$OrganTransport) or ../nem:eTimes/nem:eTimes.06 != '')">
      Incident City (eScene.17) cannot equal 'Not Applicable' unless
      Incident/Patient Disposition (eDisposition.12) equals a value from
      either the 'No Patient Contact' or the 'Organ Transport' Disposition
      Group AND Unit Arrived on Scene Date/Time (eTimes.06) is not specified.
    </sch:report>

    <sch:report id="Rule_72"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eScene.18 = '' and (../nem:eDisposition/nem:eDisposition.12 != ($NoPatientContact,$OrganTransport) or ../nem:eTimes/nem:eTimes.06 != '')">
      Incident State (eScene.18) must equal an ANSI Numeric State Code unless
      Incident/Patient Disposition (eDisposition.12) equals a value from
      either the 'No Patient Contact' or the 'Organ Transport' Disposition
      Group AND Unit Arrived on Scene Date/Time (eTimes.06) is not specified.
    </sch:report>

    <sch:report id="Rule_74"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eScene.19 = '' and (../nem:eDisposition/nem:eDisposition.12 != ($NoPatientContact,$OrganTransport) or ../nem:eTimes/nem:eTimes.06 != '')">
      Incident ZIP Code (eScene.19) must equal a US zip code unless
      Incident/Patient Disposition (eDisposition.12) equals a value from
      either the 'No Patient Contact' or the 'Organ Transport' Disposition
      Group AND Unit Arrived on Scene Date/Time (eTimes.06) is not specified.
    </sch:report>

    <sch:report id="Rule_75"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eScene.21 = '' and (../nem:eDisposition/nem:eDisposition.12 != ($NoPatientContact,$OrganTransport) or ../nem:eTimes/nem:eTimes.06 != '')">
      Incident County (eScene.21) must equal an ANSI Numeric County Code
      unless Incident/Patient Disposition (eDisposition.12) equals a value
      from either the 'No Patient Contact' or the 'Organ Transport' Disposition
      Group AND Unit Arrived on Scene Date/Time (eTimes.06) is not specified.
    </sch:report>

  </sch:rule>
</sch:pattern>


<sch:pattern id="p73">
  <sch:title>IL Rule 73</sch:title>
  <sch:rule id="r73"
            context="nem:eScene.21[. != '' or ../nem:eScene.18 != '']">
    <sch:let  name="nemsisElements"  value="(., ../nem:eScene.18[. != ''])"  />
    
    <sch:assert id="Rule_73"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="../nem:eScene.18 = substring(.,1,2)">
      Incident State (eScene.18) must equal the first two digits of Incident
      County (eScene.21).
    </sch:assert>
  </sch:rule>
</sch:pattern>


<sch:pattern id="p77">
  <sch:title>eSituation</sch:title>
  <sch:rule id="r77"
            context="nem:eSituation">
    <sch:let  name="nemsisElements"  value="(*, ../nem:eDisposition/nem:eDisposition.12)"  />
    

    <sch:let name="Outcome" value="../nem:eDisposition/nem:eDisposition.12" />

    <sch:report id="Rule_77"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="$Outcome = ($NoPatientContact) and descendant::*[not(@NV = ('7701001','7701003','7701005')) and not(child::*)]">
      All eSituation elements must equal a NOT value or be omitted when
      Incident/Patient Disposition (eDisposition.12) equals a value from
      the 'No Patient Contact' Disposition Group.
    </sch:report>


    <sch:report id="Rule_78"
                role="[WARNING]"
                diagnostics="nemsisDiagnostic"
                test="(nem:eSituation.01 = '') and ($Outcome = ($PatientTransported)) and (../nem:eResponse/nem:eResponse.ServiceGroup/nem:eResponse.05 = ('2205001','2205003','2205009')) and (nem:eSituation.13 = ('2813001','2813003')) and (substring(nem:eSituation.11,1,3) = 'I21' or substring(nem:eSituation.11,1,3) = 'I63' or (nem:eSituation.12[substring(.,1,3) = 'I21']) or (nem:eSituation.12[substring(.,1,3) = 'I63']))">
      Date/Time of Symptom Onset (eSituation.01) should equal
      a valid value other than a not value when Incident/Patient Disposition
      (eDisposition.12) equals a value from the 'Patient Transported' Disposition
      Group
        AND Type of Service Requested (eResponse.05)equals one of the following
      values:
          '911 Response (Scene)'
          'Intercept'
          'Mutual Aid'
        AND Initial Patient Acuity (eSituation.13) is Critical (Red) OR
       Emergent (Yellow)
        AND Provider's  Impression (eSituation.11 OR eSituation.12) begins
      with
          'I21' (STEMI and NSTEMI myocardial infarction codes) OR
          'I63' (Cerebral Infarction codes)
    </sch:report>
 
 
    <sch:report id="Rule_79"
                role="[WARNING]"
                diagnostics="nemsisDiagnostic"
                test="nem:eSituation.01 = '' and ((../nem:eDisposition/nem:eDisposition.HospitalTeamActivationGroup/nem:eDisposition.24[. != '4224001' and . != '']) or nem:eSituation.09 != '' or nem:eSituation.07 != '' or nem:eSituation.08 != '')">
      Date/Time of Symptom Onset (eSituation.01) should equal
      a valid value other than a Not Value when any of the following conditions
      are met:
        -Destination Team Pre-Arrival Activation (eDisposition.24) equals
      any 'Yes' value;
        -Primary Symptom (eSituation.09) equals an ICD-10-CM Diagnosis Code;
        -Chief Complaint Anatomic Location (eSituation.07) equals a valid
      value other than a Not Value;
        -Chief Complaint Organ System (eSituation.08) equals a valid value
      other than a Not Value.
    </sch:report>

    <sch:assert id="Rule_80"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eSituation.01 &lt;= ../nem:eTimes/nem:eTimes.13">
      Date/Time of Symptom Onset (eSituation.01) must be less
      than or equal to Unit Back in Service Date/Time (eTimes.13)
    </sch:assert>



    <sch:assert id="Rule_81"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eSituation.02 != '' or not($Outcome = ($PatientTreated) and ../nem:eResponse/nem:eResponse.ServiceGroup/nem:eResponse.05 = ('2205001','2205003','2205009'))">
      Possible Injury (eSituation.02) must equal a valid value other than
      a not value when Incident/Patient Disposition (eDisposition.12) equals
      a value from the 'Patient Treated' Disposition Group and Type of Service
      Requested (eResponse.05)  equals any of the following values:
        '911 Response (Scene)'
        'Intercept'
        'Mutual Aid'
    </sch:assert>


    <!-- Rule 82 replaced with 82a, 82b 1/2/2017
    <sch:assert id="Rule_82"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eSituation.02 = '9922005' or not(../nem:eInjury/descendant::*[normalize-space(.) != ''])">
      Possible Injury (eSituation.02) must equal 'Yes' when any eInjury
      element equals a valid value other than a not value.
    </sch:assert>
    -->
    
    <sch:assert id="Rule_82a"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eSituation.02 = '9922005' or not((../nem:eInjury/nem:eInjury.01[normalize-space(.) != '']) or (../nem:eInjury/nem:eInjury.02[normalize-space(.) != '']) or (../nem:eInjury/nem:eInjury.03[normalize-space(.) != '']) or (../nem:eInjury/nem:eInjury.04[normalize-space(.) != '']) or (../nem:eInjury/nem:eInjury.09[normalize-space(.) != '']) or (../nem:eInjury/eInjury.10[normalize-space(.) != '']))">
      Possible Injury (eSituation.02) must equal 'Yes' when any of the following eInjury
      elements equals a valid value other than a not value:
      - eInjury.01 (Cause of Injury)
      - eInjury.02 (Mechanism of Injury)
      - eInjury.03 (Trauma Center Criteria)
      - eInjury.04 (Vehicular, Pedestrian, or Other Injury Risk Factor)
      - eInjury.09 (Height of Fall)
      - eInjury.10 (OSHA Personal Protective Equipment Used)
    </sch:assert>


    <sch:assert id="Rule_82b"
                role="[WARNING]"
                diagnostics="nemsisDiagnostic"
                test="nem:eSituation.02 = '9922005' or not((../nem:eInjury/nem:eInjury.05[normalize-space(.) != '']) or (../nem:eInjury/nem:eInjury.06[normalize-space(.) != '']) or (../nem:eInjury/nem:eInjury.07[normalize-space(.) != '']) or (../nem:eInjury/nem:eInjury.08[normalize-space(.) != '']) or (../nem:eInjury/nem:eInjury.CollisionGroup/descendant::*[normalize-space(.) != '']))">
      Possible Injury (eSituation.02) should equal 'Yes' when any of the following eInjury
      elements equals a valid value other than a not value:
      - eInjury.05 (Main Area of the Vehicle Impacted by the Collision)
      - eInjury.06 (Location of Vehicle in Patient)
      - eInjury.07 (Use of Occupant Safety Equipment)
      - eInjury.08 (Airbag Deployment)
      - eInjury.11 through eInjury.29 (ACN elements)
    </sch:assert>


    <sch:assert id="Rule_83"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eSituation.02 != '' or nem:eSituation.01 = ''">
      Possible Injury (eSituation.02) must equal a valid value other than
      a not value when Date/Time of Symptom Onset (eSituation.01)
      is specified.
    </sch:assert>



    <sch:assert id="Rule_84"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eSituation.02 = '9922005' or ((nem:eSituation.09[. = '' or substring(.,1,3) &lt; 'S00' or substring(.,1,3) &gt; 'T14']) and (nem:eSituation.10[. = '' or substring(.,1,3) &lt; 'S00' or substring(.,1,3) &gt; 'T14']) and (nem:eSituation.11[. = '' or substring(.,1,3) &lt; 'S00' or substring(.,1,3) &gt; 'T14']) and (nem:eSituation.12[. = '' or substring(.,1,3) &lt; 'S00' or substring(.,1,3) &gt; 'T14']))">
      Possible Injury (eSituation.02) must be 'Yes' when any of the following
      elements equals an ICD-10-CM Diagnosis Code in the range S00.XX through
      T14.XX:
          -Primary Symptom (eSituation.09)
          -Secondary Symptom (eSituation.10)
          -Provider's Primary Impression
           (eSituation.11)
          -Provider's Secondary Impression
           (eSituation.12)
    </sch:assert>


    <sch:report id="Rule_85"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eSituation.07 = '' and $Outcome = ($PatientTreated) and ../nem:eResponse/nem:eResponse.ServiceGroup/nem:eResponse.05 = ('2205001','2205003','2205009')">
      Chief Complaint Anatomic Location (eSituation.07) must equal a valid
      value other than a not value when Incident/Patient Disposition (eDisposition.12)
      equals a value from the 'Patient Treated' Disposition Group and Type
      of Service Requested (eResponse.05) equals any of the following values:
        '911 Response (Scene)'
        'Intercept'
        'Mutual Aid'
    </sch:report>



    <sch:report id="Rule_86"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eSituation.08 = '' and $Outcome = ($PatientTreated) and ../nem:eResponse/nem:eResponse.ServiceGroup/nem:eResponse.05 = ('2205001','2205003','2205009')">
      Chief Complaint Organ System (eSituation.08) must equal a valid value
      other than a not value when Incident/Patient Disposition (eDisposition.12)
      equals a value from the 'Patient Treated' Disposition Group and Type
      of Service Requested (eResponse.05) equals any of the following values:
        '911 Response (Scene)'
        'Intercept'
        'Mutual Aid'
    </sch:report>



    <sch:report id="Rule_87"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eSituation.09 = '' and $Outcome = ($PatientTreated) and ../nem:eResponse/nem:eResponse.ServiceGroup/nem:eResponse.05 = ('2205001','2205003','2205009')">
      Primary Symptom (eSituation.09) must equal a valid value other than
      a not value when Incident/Patient Disposition (eDisposition.12) equals
      a value from the 'Patient Treated' Disposition Group and Type of Service
      Requested (eResponse.05) equals any of the following values:
        '911 Response (Scene)'
        'Intercept'
        'Mutual Aid'
    </sch:report>



    <sch:report id="Rule_88"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eSituation.09 = '' and nem:eSituation.10 != ''">
      Primary Symptom (eSituation.09) must equal a valid value other than
      a not value when Other Associated Symptoms (eSituation.10) equals
      a valid value other than a not value.
    </sch:report>




    <sch:report id="Rule_89"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eSituation.10/@NV = '7701001' and $Outcome = ($PatientTreated) and ../nem:eResponse/nem:eResponse.ServiceGroup/nem:eResponse.05 = ('2205001','2205003','2205009')">
      Other Associated Symptoms (eSituation.10) must not equal 'Not Applicable'
      when Incident/Patient Disposition (eDisposition.12) equals a value
      from the 'Patient Treated' Disposition Group and Type of Service Requested
      (eResponse.05) equals any of the following values:
        '911 Response (Scene)'
        'Intercept'
        'Mutual Aid'
    </sch:report>


    <sch:report id="Rule_90"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eSituation.11 ='' and ../nem:eTimes/nem:eTimes.07 != ''">
      Provider's Primary Impression (eSituation.11) must equal a valid value
      other than a not value when Arrived at Patient Date/Time (eTimes.07)
      is specified.
    </sch:report>


    <sch:report id="Rule_91"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eSituation.11 = '' and $Outcome = ($PatientTreated) and ../nem:eResponse/nem:eResponse.ServiceGroup/nem:eResponse.05 = ('2205001','2205003','2205009')">
      Provider's Primary Impression (eSituation.11) must equal a valid value
      other than a not value when Incident/Patient Disposition (eDisposition.12)
      equals a value from the 'Patient Treated' Disposition Group and Type
      of Service Requested (eResponse.05) equals any of the following values:
        '911 Response (Scene)'
        'Intercept'
        'Mutual Aid'
    </sch:report>



    <sch:report id="Rule_92"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eSituation.11 = '' and nem:eSituation.12 != ''">
      Provider's Primary Impression (eSituation.11) must equal a valid value
      other than a not value when Provider's Secondary Impression (eSituation.12)
      equals a valid value other than a Not Value.
    </sch:report>

    <sch:report id="Rule_93"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eSituation.11[@NV = '7701001'] and $Outcome = ($PatientTreated) and ../nem:eResponse/nem:eResponse.ServiceGroup/nem:eResponse.05 = ('2205001','2205003','2205009')">
      Provider's Secondary Impression (eSituation.12) must not equal 'Not
      Applicable' when Incident/Patient Disposition (eDisposition.12) equals
      a value from the 'Patient Treated' Disposition Group and Type of Service
      Requested (eResponse.05) equals any of the following values:
        '911 Response (Scene)'
        'Intercept'
        'Mutual Aid'
    </sch:report>

    <!-- Updated 10/17/2018 to disallow only 'Not Applicable' -->
    <sch:report id="Rule_94"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eSituation.13[@NV = '7701001'] and $Outcome = ($PatientTreated) and ../nem:eResponse/nem:eResponse.ServiceGroup/nem:eResponse.05 = ('2205001','2205003','2205009')">
      Initial Patient Acuity (eSituation.13) must equal a value other than
      'Not Applicable' when Incident/Patient Disposition (eDisposition.12)
      equals a value from the 'Patient Treated' Disposition Group and Type
      of Service Requested (eResponse.05) equals any of the following values:
        '911 Response (Scene)'
        'Intercept'
        'Mutual Aid'
    </sch:report>


    <sch:report id="Rule_95"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="not(nem:eSituation.WorkRelatedGroup/nem:eSituation.14[. != '']) and $Outcome = ($PatientTreated) and ../nem:eResponse/nem:eResponse.ServiceGroup/nem:eResponse.05 = ('2205001','2205003','2205009')">
      Work-Related Illness/Injury (eSituation.14) must equal a valid value
      other than a not value when Incident/Patient Disposition (eDisposition.12)
      equals a value from the 'Patient Treated' Disposition Group and Type
      of Service Requested (eResponse.05) equals any of the following values:
        '911 Response (Scene)'
        'Intercept'
        'Mutual Aid'
    </sch:report>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p96">
  <sch:title>eInjury</sch:title>
  <sch:rule id="r96"
            context="nem:eInjury">
    <sch:let  name="nemsisElements"  value="(*, ../nem:eDisposition/nem:eDisposition.12)"  />
    
    <sch:let name="Outcome" value="../nem:eDisposition/nem:eDisposition.12" />

    <!-- test was changed on 4/28/2017 from 
    $Outcome = ($NoPatientContact) and descendant::*[not(@NV = ('7701001','7701003','7701005')) and not(child::*)]
      
      In conjunction with the national schematron, making sure there are no
      non-empty leaf elements and no elements with PN attributes is 
      equivalent to testing for leaf elements with no NV, but doesn't 
      get tricked into thinking an empty complex element is a leaf 
      element with no NV attribute.
      
    -->
    <sch:report id="Rule_96"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="$Outcome = ($NoPatientContact) and descendant::*[(. != '' and not(child::*)) or (@PN)]">
      All eInjury elements must equal a NOT value when
      Incident/Patient Disposition (eDisposition.12) equals a value from
      the 'No Patient Contact' Disposition Group.
    </sch:report>
                   
    <sch:report id="Rule_97"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="not(nem:eInjury.01[. != '']) and ((nem:eInjury.03 != '') or (nem:eInjury.04 != '') or (nem:eInjury.06 != '') or (nem:eInjury.07 != '') or (nem:eInjury.08 != '') or (../nem:eSituation/nem:eSituation.02 = '9922005') or (../nem:eSituation/nem:eSituation.09[substring(.,1,3) &gt;= 'S00' and substring(.,1,3) &lt;= 'T14']) or (../nem:eSituation/nem:eSituation.10[substring(.,1,3) &gt;= 'S00' and substring(.,1,3) &lt;= 'T14']) or (../nem:eSituation/nem:eSituation.11[substring(.,1,3) &gt;= 'S00' and substring(.,1,3) &lt;= 'T14']) or (../nem:eSituation/nem:eSituation.12[substring(.,1,3) &gt;= 'S00' and substring(.,1,3) &lt;= 'T14']))">
      Cause of Injury (eInjury.01) must equal a valid value other than a
      Not Value when any of the following conditions are met:
      - Trauma Center Criteria (eInjury.03) equals a valid value other than
      a Not Value
      - Vehicular, Pedestrian, or Other Injury Risk Factor (eInjury.04)
      equals a valid value other than a Not Value
      - Location of Patient in Vehicle (eInjury.06) equals a valid value
      other than a Not Value
      - Use of Occupant Safety Equipment (eInjury.07) equals a valid value
      other than a Not Value
      - Airbag Deployment (eInjury.08) equals a valid value other than a
      Not Value
      - Possible Injury (eSituation.02) equals 'Yes'
      - Any of the following elements equals an ICD-10-CM Diagnosis Code
      in the range S00.XX through T14.XX:
          -Primary Symptom (eSituation.09)
          -Secondary Symptom (eSituation.10)
          -Provider's Primary Impression
           (eSituation.11)
          -Provider's Secondary Impression
           (eSituation.12)
    </sch:report>

    <sch:assert id="Rule_100"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="(nem:eInjury.06[. != '']) or not (nem:eInjury.08[. != ''])">
      Location of Patient in Vehicle (eInjury.06) must equal a valid value
      other than a Not Value when Airbag Deployment (eInjury.08) has a value.
    </sch:assert>
    
    <sch:assert id="Rule_101"
                role="[WARNING]"
                diagnostics="nemsisDiagnostic"
                test="nem:eInjury.07 != '' or not(nem:eInjury.08 != '')">
      Use of Occupant Safety Equipment (eInjury.07) must equal a valid value
      other than a Not Value when Airbag Deployment (eInjury.08) has a value.
    </sch:assert>
    
    <sch:assert id="Rule_102"
                role="[WARNING]"
                diagnostics="nemsisDiagnostic"
                test="nem:eInjury.07 != '' or not(nem:eInjury.06)">
      Use of Occupant Safety Equipment (eInjury.07) must equal a valid value
      other than a Not Value when Location of Patient in Vehicle (eInjury.06)
      has a value.
    </sch:assert>
    
    <sch:assert id="Rule_103"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eInjury.08 != '' or not(nem:eInjury.06)">
      Airbag Deployment (eInjury.08) must equal a valid value other than
      a Not Value when Location of Patient in Vehicle (eInjury.06) has a
      value.
    </sch:assert>
  </sch:rule>
</sch:pattern>
    
<sch:pattern id="p104">
  <sch:title>eArrest</sch:title>
  <sch:rule id="r104"
            context="nem:eArrest">
    <sch:let  name="nemsisElements"  value="*"  />
    

    <sch:assert id="Rule_104"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eArrest.01 = ('3001003','3001005') or not(nem:eArrest.14 != '')">
      Cardiac Arrest (eArrest.01) must equal a valid value other than 'No'
      or a Not Value when Date/Time of Cardiac Arrest (eArrest.14) is specified.
    </sch:assert>

    <sch:assert id="Rule_105"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eArrest.01 = ('3001003','3001005') or not((nem:eArrest.02|nem:eArrest.03|nem:eArrest.04|nem:eArrest.05|nem:eArrest.07|nem:eArrest.11|nem:eArrest.12|nem:eArrest.17|nem:eArrest.18) != '')">
      Cardiac Arrest (eArrest.01) must equal 'Yes, After EMS Arrival' or
      'Yes, Prior to EMS Arrival' when any of the following elements equals
      a value other than a Not Value:
        - Cardiac Arrest Etiology (eArrest.02)
        - Resuscitation Attempted By EMS (eArrest.03)
        - Arrest Witnessed By (eArrest.04)
        - CPR Care Provided Prior to EMS Arrival (eArrest.05)
        - AED Use Prior to EMS Arrival (eArrest.07)
        - First monitored Arrest Rhythm of the Patient (eArrest.11)
        - Any Return of Spontaneous Circulation (eArrest.12)
        - Cardiac Rhythm on Arrival at Destination (eArrest.17)
        - End of EMS Cardiac Arrest Event (eArrest.18)
    </sch:assert>

    <sch:assert id="Rule_107"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="not(nem:eArrest.01 = ('3001003','3001005')) or nem:eArrest.02 != ''">
      Cardiac Arrest Etiology (eArrest.02) must equal a valid value other
      than a Not Value when Cardiac Arrest (eArrest.01) has a value of 'Yes,
      After EMS Arrival' or 'Yes, Prior to EMS Arrival'.
    </sch:assert>

    <sch:report id="Rule_108"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eArrest.03 = '3003009' and nem:eArrest.03 = ('3003001','3003003','3003005')">
      Resuscitation Attempted by EMS (eArrest.03) cannot contain 'Not Attempted-DNR
      Orders' and one of the following values in the same record:
      'Attempted Defibrillation'
      'Attempted Ventilation'
      'Initiated Chest Compressions'
    </sch:report>

    <sch:report id="Rule_109"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eArrest.03 = '3003011' and nem:eArrest.03 = ('3003001','3003003','3003005')">
      Resuscitation Attempted by EMS (eArrest.03) cannot contain 'Not 
      Attempted-Signs of Circulation' and one of the following values in the 
      same record:
      'Attempted Defibrillation'
      'Attempted Ventilation'
      'Initiated Chest Compressions'
    </sch:report>

    <sch:report id="Rule_110"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eArrest.03 = '3003007' and nem:eArrest.03 = ('3003001','3003003','3003005')">
      Resuscitation Attempted by EMS (eArrest.03) cannot contain a value
      of 'Not Attempted-Considered Futile' and one of the following values
      in the same record:
      'Attempted Defibrillation'
      'Attempted Ventilation'
      'Initiated Chest Compressions'
    </sch:report>

    <sch:assert id="Rule_111"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eArrest.03 = '3003003' or not(nem:eArrest.09 = ('3009013','3009015','3009017','3009019'))">
      Resuscitation Attempted by EMS (eArrest.03) must include 'Attempted
      Ventilation' when Type of CPR (eArrest.09) equals one of the following:
      'Ventilation-Bag Valve Mask'
      'Ventilation-Impedance Threshold Device'
      'Ventilation-Mouth to Mouth'
      'Ventilation-Pocket Mask'.
    </sch:assert>

    <sch:assert id="Rule_112"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="(nem:eArrest.03 = '3003005') or not(nem:eArrest.09[. = ('3009001','3009003','3009005','3009007','3009009','3009011')])">
      Resuscitation Attempted by EMS (eArrest.03) must include 'Initiated
      Chest Compressions' when Type of CPR Provided (eArrest.09) equals
      one of the following:
      'Compressions-Continuous'
      'Compressions-External Band Type Device'
      'Compressions-External Plunger Type Device'
      'Compressions-External Thumper Type Device'
      'Compressions-Intermittent with Ventilation'
      'Compressions-Other Device (Not Listed)'.
    </sch:assert>

    <sch:assert id="Rule_113"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eArrest.03 != '' or not(nem:eArrest.01 = ('3001003','3001005'))">
      Resuscitation Attempted by EMS (eArrest.03) must equal a valid value
      other than a Not Value when Cardiac Arrest (eArrest.01) has a value
      of 'Yes, After EMS Arrival' or 'Yes, Prior to EMS Arrival'.
    </sch:assert>

    <sch:assert id="Rule_114"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eArrest.04 != '' or not(nem:eArrest.01 = ('3001003','3001005'))">
      Arrest Witness By (eArrest.04) must equal at least one valid value
      other than a Not Value when Cardiac Arrest (eArrest.01) has a value
      of 'Yes, After EMS Arrival' or 'Yes, Prior to EMS Arrival'.
    </sch:assert>

    <sch:report id="Rule_115"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eArrest.04 = '3004001' and nem:eArrest.04 != '3004001'">
      When Arrest Witnessed By (eArrest.04) equals 'Not Witnessed' it must
      not also equal any other value.
    </sch:report>

    <sch:assert id="Rule_116"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eArrest.05 != '' or not(nem:eArrest.01 = '3001003')">
      CPR Care Provided Prior to EMS Arrival (eArrest.05) must equal a valid
      value other than a Not Value when Cardiac Arrest (eArrest.01) has
      a value of 'Yes, Prior to EMS Arrival'.
    </sch:assert>

    <sch:assert id="Rule_117"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eArrest.06[. != ''] or not(nem:eArrest.05 = '9923003')">
      Who Provided CPR Prior to EMS Arrival (eArrest.06) must equal a valid
      value other than a Not Value when CPR Care Provided Prior to EMS Arrival
      (eArrest.05) has a value of 'Yes'.
    </sch:assert>

    <sch:assert id="Rule_118"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="not(nem:eArrest.01 = '3001003') or nem:eArrest.07 != ''">
      AED Use Prior to EMS Arrival (eArrest.07) must equal a valid value
      other than a Not Value when Cardiac Arrest (eArrest.01) has a value
      of 'Yes, Prior to EMS Arrival'.
    </sch:assert>

    <sch:assert id="Rule_119"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eArrest.08 != '' or not(nem:eArrest.07 = ('3007003','3007005'))">
      Who Used AED Prior to EMS Arrival (eArrest.08) must equal a valid
      value other than a Not Value when AED Use Prior to EMS Arrival (eArrest.07)
      has a value of 'Yes'.
    </sch:assert>

    <sch:assert id="Rule_120"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eArrest.09 = ('3009001','3009003','3009005','3009007','3009009','3009011') or not(nem:eArrest.03 = '3003005')">
      Type of CPR Provided (eArrest.09) must include a 'Compressions' value
      when Resuscitation Attempted by EMS  (eArrest.03) includes 'Initiated
      Chest Compressions'.
    </sch:assert>

    <sch:assert id="Rule_121"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eArrest.09 = ('3009013','3009015','3009017','3009019') or not(nem:eArrest.03 = '3003003')">
      Type of CPR Provided (eArrest.09) should include a 'Ventilation' value
      when Resuscitation Attempted (eArrest.03) by EMS includes 'Attempted
      Ventilation'.
    </sch:assert>

    <sch:assert id="Rule_123"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="not(nem:eArrest.03 = ('3003001','3003005')) or nem:eArrest.12 != ''">
      Any Return of Spontaneous Circulation (eArrest.12) must equal a valid
      value other than a Not Value when Resuscitation Attempted by EMS (eArrest.03)
      equals any of the following:
       'Attempted Defibrillation'
       'Initiated Chest Compressions'
    </sch:assert>

    <sch:report id="Rule_124"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eArrest.12[. = '3012001' or @NV != ''] and nem:eArrest.12[. != '3012001' and .!= '']">
      When Any Return of Spontaneous Circulation (eArrest.12) inclides No or a Not
      value, it must not also include any other value.
    </sch:report>

    <sch:assert id="Rule_125"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="not(nem:eArrest.14/@NV = '7701001') or not(nem:eArrest.01 = ('3001003','3001005'))">
      Date/Time of Cardiac Arrest (eArrest.14) cannot equal 'Not Applicable'
      when Cardiac Arrest (eArrest.01) has a value of 'Yes, After EMS Arrival'
      or 'Yes, Prior to EMS Arrival'.
    </sch:assert>

    <!-- removed 11/7/2016, to be reconsidered when sw to 3.4 is made
    
    <sch:assert id="Rule_126"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="not(nem:eArrest.03 = ('3003001','3003003','3003005')) or nem:eArrest.16 != ''">
      Reason CPR/Resuscitation Discontinued (eArrest.16) must equal a valid
      value other than a Not Value when Resuscitation Attempted by EMS (eArrest.03)
      equals any of the following:
       'Attempted Defibrillation'
       'Initiated Chest Compressions'
       'Attempted Ventilation'
    </sch:assert>

    <sch:assert id="Rule_127"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="not(../nem:eDisposition/nem:eDisposition.12 = ('4212017','4212019')) or nem:eArrest.16 != ''">
      Reason CPR/Resuscitation Discontinued (eArrest.16) must equal a valid
      value other than a Not Value when Incident/Patient Disposition (eDisposition.12)
      equals one of the two 'Patient Dead at Scene-Resuscitation Attempted'
      values.
    </sch:assert>
    
    -->
    
    <sch:report id="Rule_128"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eArrest.01 = ('3001003','3001005') and ../nem:eDisposition/nem:eDisposition.12 = ($PatientTransported) and not(nem:eArrest.17 != '')">
      Cardiac Rhythm on Arrival at Destination (eArrest.17) must equal a
      valid value other than a Not Value when Cardiac Arrest (eArrest.01)
      has a value of 'Yes, After EMS Arrival' or 'Yes, Prior to EMS Arrival'
       AND Incident/Patient Disposition (eDisposition.12) equals a value
      from the 'Patient Transported' disposition group.
    </sch:report>

    <sch:assert id="Rule_129"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eArrest.18 != '' or not(nem:eArrest.01 = ('3001003','3001005'))">
      End of EMS Cardiac Arrest Event (eArrest.18) must equal a valid value
      other than a Not Value when Cardiac Arrest (eArrest.01) has a value
      of 'Yes, After EMS Arrival' or 'Yes, Prior to EMS Arrival'.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p130">
  <sch:title>eHistory</sch:title>
  <sch:rule id="r130"
            context="nem:eHistory">
    <sch:let  name="nemsisElements"  value="(*, ../nem:eDisposition/nem:eDisposition.12, ../nem:eTimes/nem:eTimes.07[. != ''])"  />

    <!-- test changed on 4/28/2017 from:
      "../nem:eDisposition/nem:eDisposition.12 = ($NoPatientContact) and descendant::*[not(@NV = ('7701001','7701003','7701005')) and not(child::*)]"
      
      In conjunction with the national schematron, making sure there are no
      non-empty leaf elements and no elements with PN attributes is 
      equivalent to testing for leaf elements with no NV, but doesn't 
      get tricked into thinking an empty complex element is a leaf 
      element with no NV attribute.
      
    -->

    <sch:report id="Rule_130"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="../nem:eDisposition/nem:eDisposition.12 = ($NoPatientContact) and descendant::*[(. != '' and not(child::*)) or (@PN)]">
      All eHistory elements must equal a NOT value or be omitted when
      Incident/Patient Disposition (eDisposition.12) equals a value from
      the 'No Patient Contact' Disposition Group.
    </sch:report>

    <sch:assert id="Rule_131"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eHistory.01 != '' or not(../nem:eTimes/nem:eTimes.07 != '')">
      Barriers to Patient Care (eHistory.01) must equal a valid value other
      than a Not Value when Arrived at Patient Date/Time (eTimes.07) is
      specified.
    </sch:assert>

    <sch:report id="Rule_132"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eHistory.01 = '3101009' and nem:eHistory.01 != '3101009'">
      When Barriers to Patient Care (eHistory.01) equals 'None noted' there
      must not be any other values selected.
    </sch:report>

    <sch:assert id="Rule_133"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="(nem:eHistory.08[. != '' or @PN != '']) or not(../nem:eDisposition/nem:eDisposition.12[. = ($PatientTreated)])">
      Medical/Surgical History (eHistory.08) must equal either a Pertinent 
      Negative or another valid value other than a Not Value when Disposition
      (eDisposition.12) equals a value from the 'Patient Treated' Disposition 
      Group.
    </sch:assert>

    <sch:report id="Rule_134"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="((../nem:eTimes/nem:eTimes.07 != '') or (../nem:eDisposition/nem:eDisposition.12[. = ($PatientEncountered)])) and not(nem:eHistory.17[@PN != '' or . != ''])">
      Alcohol/Drug Use Indicators (eHistory.17) must equal either a pertinent
      negative or another valid value other than a Not value when 
      Incident/Patient Disposition (eDisposition.12) equals a value from the 
      'Patient Encountered' Disposition Group OR when Arrived at 
      Patient Date/Time (eTimes.07) is specified.
    </sch:report>
  </sch:rule>
</sch:pattern>



<sch:pattern id="p135">
  <sch:title>eVitals</sch:title>
  
  <sch:rule id="r135"
            context="nem:eVitals.VitalGroup">
    <sch:let  name="nemsisElements"  value="(*, ../../nem:eDisposition/nem:eDisposition.12, ../../nem:eTimes/nem:eTimes.07[. != ''], ../../nem:eTimes/nem:eTimes.13[. != ''])"  />
    
            
    <sch:report id="Rule_135"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="../../nem:eDisposition/nem:eDisposition.12 = ($NoPatientContact) and descendant::*[not(@NV = ('7701001','7701003','7701005')) and not(child::*)]">
      All eVitals elements must equal a NOT value when
      Incident/Patient Disposition (eDisposition.12) equals a value from
      the 'No Patient Contact' Disposition Group.
    </sch:report>

    <sch:assert id="Rule_136"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eVitals.01 &gt;= ../../nem:eTimes/nem:eTimes.07 or not(nem:eVitals.02 = '9923001')">
      Date/Time Vital Signs Taken (eVitals.01) must be greater than or equal
      to Arrived at Patient Date/Time (eTimes.07) when Obtained Prior
      to this Units EMS Care (eVitals.02) equals 'No'.
    </sch:assert>

    <sch:assert id="Rule_137"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eVitals.01 &lt;= ../../nem:eTimes/nem:eTimes.13">
      Date/Time Vital Signs Taken (eVitals.01) must be less than or equal
      to Unit Back in Service Date/Time (eTimes.13).
    </sch:assert>


    <sch:report id="Rule_138"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="(nem:eVitals.01[. = '']) and (nem:eVitals.02[. = '9923001']) and (descendant::nem:eVitals.03[(. != '') and (not(@PN != ''))]|descendant::nem:eVitals.04[(. != '') and (not(@PN != ''))]|descendant::nem:eVitals.05[(. != '') and (not(@PN != ''))]|descendant::nem:eVitals.06[(. != '') and (not(@PN != ''))]|descendant::nem:eVitals.07[(. != '') and (not(@PN != ''))]|descendant::nem:eVitals.08[(. != '') and (not(@PN != ''))]|descendant::nem:eVitals.09[(. != '') and (not(@PN != ''))]|descendant::nem:eVitals.10[(. != '') and (not(@PN != ''))]|descendant::nem:eVitals.11[(. != '') and (not(@PN != ''))]|nem:eVitals.12[(. != '') and (not(@PN != ''))]|nem:eVitals.13[(. != '') and (not(@PN != ''))]|nem:eVitals.14[(. != '') and (not(@PN != ''))]|nem:eVitals.15[(. != '') and (not(@PN != ''))]|nem:eVitals.16[(. != '') and (not(@PN != ''))]|nem:eVitals.17[(. != '') and (not(@PN != ''))]|nem:eVitals.18[(. != '') and (not(@PN != ''))])">
      Date/Time Vitals Signs Taken (eVitals.01) must be specified
      when Obtained Prior to this Unit's EMS Care (eVitals.02) has value
      of 'No' and any eVitals element in the range eVitals.3 through eVitals.33
      equals a valid value other than a not value and does not have a Pertinent
      Negative.
    </sch:report>

    <sch:assert id="Rule_139"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eVitals.01 &lt;= ../../nem:eTimes/nem:eTimes.07 or not(nem:eVitals.02 = '9923003')">
      Date/Time Vitals Signs Taken (eVitals.01) must not be later than
      Arrived at Patient Date/Time (eTimes.07) when Obtained Prior to 
      this Unit's EMS Care (eVitals.02) is 'Yes'.
    </sch:assert>

    <sch:assert id="Rule_140"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eVitals.02 != ''or not(descendant::*[normalize-space(.) != ''])">
      Obtained Prior to this Unit's EMS Care (eVitals.02) must equal 'Yes'
      or 'No' when any other eVitals element equals a valid value other
      than a not value.
    </sch:assert>

    <sch:assert id="Rule_154"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eVitals.GlasgowScoreGroup/nem:eVitals.19 != '' or not(nem:eVitals.GlasgowScoreGroup/nem:eVitals.23 != '' and nem:eVitals.02 = '9923001')">
      Glasgow Coma Score-Eye (eVitals.19) must equal an integer ranging from
      1 to 4 when Total Glasgow Coma Score (eVitals.23) equals a value in the
      range 3-15, inclusive, and Obtained Prior to this Units EMS Care (eVital.02) = 'No'.
    </sch:assert>

    <sch:assert id="Rule_155"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eVitals.GlasgowScoreGroup/nem:eVitals.20 != '' or not(nem:eVitals.GlasgowScoreGroup/nem:eVitals.23 != '' and nem:eVitals.02 = '9923001')">
      Glasgow Coma Score-Verbal (eVitals.20) must equal an integer ranging
      from 1 to 5 when Total Glasgow Coma Score (eVitals.23) equals a value
      in the range 3-15, inclusive, and Obtained Prior to this Units EMS Care (eVital.02) = 'No'.
    </sch:assert>

    <sch:assert id="Rule_156"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eVitals.GlasgowScoreGroup/nem:eVitals.21 != '' or not(nem:eVitals.GlasgowScoreGroup/nem:eVitals.23 != '' and nem:eVitals.02 = '9923001')">
      Glasgow Coma Score-Motor (eVitals.21) must equal an integer ranging
      from 1 to 6 when Total Glasgow Coma Score (eVitals.23) equals a value
      in the range 3-15, inclusive, and Obtained Prior to this Units EMS Care (eVital.02) = 'No'.
    </sch:assert>

    <sch:assert id="Rule_157"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eVitals.GlasgowScoreGroup/nem:eVitals.22 != '' or not(nem:eVitals.GlasgowScoreGroup/nem:eVitals.23 != '' and nem:eVitals.02 = '9923001')">
      Glasgow Coma Score-Qualifier (eVitals.22) must equal a valid value
      other than a Not Value when Total Glasgow Coma Score (eVitals.23)
      equals a value in the range 3-15, inclusive, and Obtained Prior to this Units EMS Care (eVital.02) = 'No'.
    </sch:assert>

    <sch:assert id="Rule_158"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="not(nem:eVitals.GlasgowScoreGroup/nem:eVitals.22 = '3322003' and nem:eVitals.GlasgowScoreGroup/nem:eVitals.22 != '3322003')">
      Glasgow Coma Score-Qualifier (eVitals.22) should not include any other
      values when it includes 'Initial GCS has legitimate values without
      interventions such as intubation and sedation'.
    </sch:assert>

    <sch:assert id="Rule_159"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="not(nem:eVitals.GlasgowScoreGroup/nem:eVitals.19 != '') or not(nem:eVitals.GlasgowScoreGroup/nem:eVitals.20 != '') or not(nem:eVitals.GlasgowScoreGroup/nem:eVitals.21 != '') or ((nem:eVitals.GlasgowScoreGroup/nem:eVitals.23 != '') and (nem:eVitals.GlasgowScoreGroup/nem:eVitals.23 = nem:eVitals.GlasgowScoreGroup/nem:eVitals.19 + nem:eVitals.GlasgowScoreGroup/nem:eVitals.20 + nem:eVitals.GlasgowScoreGroup/nem:eVitals.21))"> 
      Total Glasgow Coma Score (eVitals.23) must equal the sum of Glasgow
      Coma Score-Eye (eVitals.19), Glasgow Coma Score-Verbal (eVitals.20),
      and Glasgow Coma Score-Motor (eVitals.21) when all three contain a
      score.
    </sch:assert>

    <sch:report id="Rule_160"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eVitals.PainScaleGroup/nem:eVitals.27/@NV = '7701001' and nem:eVitals.PainScaleGroup/nem:eVitals.28 != ''">
      Pain Score (eVitals.27) cannot equal 'Not Applicable' when Pain Scale
      Type (eVitals.28) has a value.
    </sch:report>
    

    <sch:assert id="Rule_161"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="(nem:eVitals.StrokeScaleGroup/nem:eVitals.29[. != '' or @PN != '']) or not(nem:eVitals.StrokeScaleGroup/nem:eVitals.30 != '')">
      Stroke Scale Score (eVitals.29) must equal either a Pertinent Negative
      or another valid value other than a Not Value when Stroke Scale Type
      (eVitals.30) equals a valid value other than a Not Value.
    </sch:assert>

    <sch:assert id="Rule_162"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eVitals.StrokeScaleGroup/nem:eVitals.30 != '' or not(nem:eVitals.StrokeScaleGroup/nem:eVitals.29[. != '' and not(@PN != '')])">
      Stroke Scale Type (eVitals.30) must equal a valid value other than
      a Not Value when Stroke Scale Score (eVitals.29) equals a value other
      than a Not Value and does not contain a Pertinent Negative.
    </sch:assert>

  </sch:rule>


  <sch:rule id="r141"
            context="nem:eVitals.CardiacRhythmGroup">
    <sch:let  name="nemsisElements"  value="*"  />
    
    
    <!--        
    <sch:assert id="Rule_141"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eVitals.03 != '' or not(nem:eVitals.04 != '')">
      Cardiac Rhythm/ Electrocardiography (ECG) (eVitals.03) must equal
      a valid value other than a not value when  ECG Type (eVitals.04) equals
      a valid value other than a not value.
    </sch:assert>
    -->
    
    <sch:assert id="Rule_142"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="(nem:eVitals.03[. != '' or @PN != '']) or not(nem:eVitals.05 != '')">
      Cardiac Rhythm/Electrocardiography (ECG) (eVitals.03) must equal either
      a Pertinent Negative or another valid value other than a Not Value when
      Method of ECG Interpretation (eVitals.05) equals a valid value other
      than a Not value.
    </sch:assert>

    <!--
    <sch:assert id="Rule_143"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="not(nem:eVitals.04[@NV = '7701001']) or not(nem:eVitals.03[. != '' and not(@PN != '')])">
      ECG Type (eVitals.04) cannot equal 'Not Applicable' when Cardiac 
      Rhythm/Electrocardiography (ECG) (eVitals.03) equals a valid value other
      than a not value and does not have a Pertinent Negative.
    </sch:assert>
    -->
    
    <sch:assert id="Rule_144"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="not(nem:eVitals.05[@NV = '7701001']) or not(nem:eVitals.03[. != '' and not(@PN != '')])">
      Method of ECG Interpretation (eVitals.05) cannot equal 'Not Applicable'
      when Cardiac Rhythm/Electrocardiography (ECG) (eVitals.03) equals
      a valid value other than a not value and does not have a Pertinent
      Negative.
    </sch:assert>
  </sch:rule>


  <sch:rule id="r146"
            context="nem:eVitals.BloodPressureGroup">
    <sch:let  name="nemsisElements"  value="*"  />
    

    <sch:assert id="Rule_146"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eVitals.06[. != '' or @PN != ''] or not(nem:eVitals.08 != '')">
      SBP (Systolic Blood Pressure) (eVitals.06) must equal an integer in
      the 0-500 range, inclusive, or a Pertinent Negative when Method of
      Blood Pressure Measurement (eVitals.08) equals a valid value other
      than a not value.
    </sch:assert>

    <sch:assert id="Rule_147"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eVitals.06[. != ''] or not(nem:eVitals.07 != '')">
      SBP (Systolic Blood Pressure) (eVitals.06) must equal an integer in
      the 0-500 range, inclusive, when DBP (Diastolic
      Blood Pressure) (eVitals.07) equals 'P', 'p', or an integer in the 0-500
      range, inclusive.
    </sch:assert>

    <sch:assert id="Rule_149"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eVitals.07[. != '' or @PN != ''] or not(nem:eVitals.08[. != '' and . != '3308003'])">
      DBP (Diastolic Blood Pressure) (eVitals.07) must equal 'P', 'p', or an
      integer in the 0-500 range, inclusive, or a Pertinent Negative when Method
      of Blood Pressure Measurement (eVitals.08) equals a valid value other
      than a not value. Exception: DBP may equal "Not Applicable" when Method of
      Blood Pressure Measurement (eVitals.08) equals "Doppler".
    </sch:assert>

    <sch:assert id="Rule_150"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eVitals.07[. != '' or @PN != ''] or not(nem:eVitals.06[. != '' ]) or nem:eVitals.08 = '3308003'">
      DBP (Diastolic Blood Pressure) (eVitals.07) must equal 'P', 'p', or an integer
      in the 0-500 range, inclusive, or a Pertinent Negative when SBP (Systolic
      Blood Pressure) (eVitals.06) equals an integer in the 0-500 range,
      inclusive. Exception: DBP may equal "Not Applicable" when Method of Blood
      Pressure Measurement (eVitals.08) equals "Doppler".
    </sch:assert>

    <sch:assert id="Rule_151"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eVitals.08 != '' or not(nem:eVitals.06 != '' or nem:eVitals.07 != '')">
      Method of Blood Pressure Measurement (eVitals.08) must equal a valid
      value other than a Not Value when either SBP (Systolic Blood Pressure)
      (eVitals.06) or DBP (Diastolic Blood Pressure) (eVitals.07) equals 'P', 'p',
      or an integer in the 0-500 range, inclusive.
    </sch:assert>

  </sch:rule>
</sch:pattern>


<sch:pattern id="p163">
  <sch:title>eExam</sch:title>
  <sch:rule id="r163"
            context="nem:eExam">
    <sch:let  name="nemsisElements"  value="(descendant::*[not(@NV = '7701001') and not(child::*)], ../nem:eDisposition/nem:eDisposition.12)"  />
    
            
    <sch:report id="Rule_163"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="../nem:eDisposition/nem:eDisposition.12 = ($NoPatientContact) and descendant::*[not(@NV = ('7701001','7701003','7701005')) and not(child::*)]">
      All eExam elements must equal a NOT value when  Incident/Patient
      Disposition (eDisposition.12) equals a value from the 'No Patient
      Contact' Disposition Group.
    </sch:report>

  </sch:rule>


  <sch:rule id="r164"
            context="nem:PatientCareReport">
    <sch:let  name="nemsisElements"  value="nem:eExam/nem:eExam.01"  />
    

    <sch:assert id="Rule_164"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eExam[nem:eExam.01[. != '']] or (not(nem:eDisposition/nem:eDisposition.12[. = ($PatientTreated)]))">
      Estimated Body Weight in Kilograms (eExam.01) must equal a valid value
      other than a Not Value or 'Unable to Complete' when Incident/Patient
      Disposition (eDisposition.12) equals a value from the 'Patient
      Treated' Disposition Group.
    </sch:assert>
    
  </sch:rule>            
  
</sch:pattern>

<sch:pattern id="p166">
  <sch:title>eProtocols.ProtocolGroup</sch:title>
  <sch:rule id="r166"
            context="nem:eProtocols.ProtocolGroup">
    <sch:let  name="nemsisElements"  value="*"  />
    
            
    <sch:report id="Rule_166"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="(not(nem:eProtocols.01[. != ''])) and (../../nem:eDisposition/nem:eDisposition.12[. = ($PatientTreated)])">
      Protocols Used (eProtocols.01) must equal a valid value other than
      a Not Value when Incident/Patient Disposition (eDisposition.12) equals
      a value from the 'Patient Treated' Disposition Group.
    </sch:report>

    <sch:assert id="Rule_167"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eProtocols.02 != '' or not(nem:eProtocols.01 != '')">
      Protocol Age Category (eProtocols.02) must equal a valid value other
      than a Not Value when Protocols Used (eProtocols.01) equals a valid
      value other than a Not Value.
    </sch:assert>

  </sch:rule>
</sch:pattern>


<sch:pattern id="p168">
  <sch:title>eMedications.MedicationGroup</sch:title>
  <sch:rule id="r168"
            context="nem:eMedications.MedicationGroup">
    <sch:let  name="nemsisElements"  value="(*, ../../nem:eDisposition/nem:eDisposition.12)"  />
    

    <sch:let name="AdminPrior" value="(nem:eMedications.02 = '9923003')" />
    <sch:let name="NotAdminPrior" value="(nem:eMedications.02 = '9923001')" />
    
    <sch:report id="Rule_168"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="../../nem:eDisposition/nem:eDisposition.12 = ($NoPatientContact) and descendant::*[not(@NV = ('7701001','7701003','7701005')) and not(child::*)]">
      All eMedications elements must equal a NOT value when  Incident/Patient
      Disposition (eDisposition.12) equals a value from the 'No Patient
      Contact' Disposition Group.
    </sch:report>

    <sch:report id="Rule_169"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="(not(nem:eMedications.01[. != ''])) and (nem:eMedications.03[. != '']) and (not (nem:eMedications.03[@PN != ''])) and (nem:eMedications.02[. = '9923001'])">
      Date/time Medication Administered (eMedications.01) must equal a valid
      value other than a Not Value when Medication Given (eMedication.03) has
      a valid value other than a Not Value (without a Pertinent Negative)
      and Medication Administered Prior to this Unit's EMS Care
      (eMedications.02) has a value of "No".
    </sch:report>

    <sch:assert id="Rule_170"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eMedications.01 &gt;= ../../nem:eTimes/nem:eTimes.07 or not($NotAdminPrior)">
      Date/Time Medication Administered (eMedications.01) must be greater
      than or equal to Arrived at Patient Date/Time (eTimes.07) when Medication
      Administered Prior to this Unit's EMS Care (eMedications.02) has a
      value of 'No'.
    </sch:assert>

    <sch:assert id="Rule_171"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eMedications.01 &lt;= ../../nem:eTimes/nem:eTimes.13">
      Date/Time Medication Administered (eMedications.01) must be less than
      or equal to Unit Back in Service Date/Time (eTimes.13).
    </sch:assert>

    <sch:assert id="Rule_172"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eMedications.01 &lt;= ../../nem:eTimes/nem:eTimes.07 or not($AdminPrior)">
      If provided, Date/Time Medication Administered (eMedications.01) must 
      be less than or equal to Arrived at Patient Date/Time (eTimes.07) when 
      Medication Administered Prior to this Unit's EMS Care (eMedications.02) 
      equals 'Yes'.
    </sch:assert>

    <sch:assert id="Rule_173"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eMedications.02 != '' or not(nem:eMedications.03[. != '' and not(@PN != '')])">
      Medication Administered Prior to this Unit's EMS Care (eMedications.02)
      must equal a valid value other than a Not Value when Medication Given
      (eMedications.03) has an RX Norm value and does not have a Pertinent
      Negative.
    </sch:assert>

    <sch:assert id="Rule_174"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eMedications.03 != '' or not(nem:eMedications.02 != '')">
      Medication Given (eMedications.03) must include an RX Norm value when
      Medication Administered Prior to this Unit's EMS Care (eMedications.02)
      has a value.
    </sch:assert>

    <sch:assert id="Rule_175"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eMedications.03 != '' or not(nem:eMedications.11 != '')">
      Medication Given (eMedications.03) must include an RX Norm value when
      Medication Authorization (eMedications.11) has a value.
    </sch:assert>

    <sch:assert id="Rule_176"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eMedications.03 != '' or not(nem:eMedications.08 != '')">
      Medication Given (eMedications.03) must include an RX Norm value
      when Medication Complication (eMedications.08) has a value.
    </sch:assert>

    <sch:assert id="Rule_177"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eMedications.03 != '' or not(nem:eMedications.DosageGroup/nem:eMedications.05 != '')">
      Medication Given (eMedications.03) must include an RX Norm value when
      Medication Dosage (eMedications.05) has a value.
    </sch:assert>

    <sch:assert id="Rule_178"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eMedications.03 != '' or not(nem:eMedications.DosageGroup/nem:eMedications.06 != '')">
      Medication Given (eMedications.03) must include an RX Norm value when
      Medication Dosage Units (eMedications.06) has a value.
    </sch:assert>

    <sch:assert id="Rule_179"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eMedications.03 != '' or not(nem:eMedications.07 != '')">
      Medication Given (eMedications.03) must include an RX Norm value when
      Response to Medication (eMedications.07) has a value.
    </sch:assert>

    <sch:assert id="Rule_180"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eMedications.03 != '' or not(nem:eMedications.10 != '')">
      Medication Given (eMedications.03) must include an RX Norm value when
      Role/Type of Person Administering Medication (eMedications.10) has
      a value.
    </sch:assert>

    <sch:assert id="Rule_181"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eMedications.04 != '' or not(nem:eMedications.03[. != '' and not(@PN != '')])">
      Medication Administered Route (eMedications.04) cannot be left blank
      when Medication Given (eMedications.03) has an RX Norm value and no
      Pertinent Negatives.
    </sch:assert>

    <sch:assert id="Rule_182"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eMedications.DosageGroup/nem:eMedications.05 != '' or not(nem:eMedications.03[. != '' and not(@PN != '')])">
      Medication Dosage (eMedications.05)  must equal a valid value other
      than a Not Value when Medication Given (eMedications.03) has an RX
      Norm value and no Pertinent Negatives.
    </sch:assert>

    <sch:assert id="Rule_183"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eMedications.DosageGroup/nem:eMedications.06 != '' or not(nem:eMedications.DosageGroup/nem:eMedications.05 != '')">
      Medication Dosage Units (eMedications.06)  must equal a valid value
      other than a Not Value when Medication Dosage (eMedications.05) equals
      a valid value other than a Not Value.
    </sch:assert>

    <sch:assert id="Rule_184"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eMedications.07 != '' or not(nem:eMedications.03[. != '' and not(@PN != '')]) or $AdminPrior">
      Response to Medication (eMedications.07)  must equal a valid value
      other than a Not Value when Medication Given (eMedications.03) has
      an RX Norm value and no Pertinent Negatives. Exception:  May be nill
      or equal "Not Recorded" if Medication Administered Prior to this Units
      EMS Care (eMedications.02) = "Yes".
    </sch:assert>

    <sch:assert id="Rule_185"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="not(nem:eMedications.08[@NV = '7701001']) or not(nem:eMedications.03[. != '' and not(@PN != '')]) or $AdminPrior">
      Medication Complication (eMedications.08) cannot equal 'Not Applicable'
      when Medication Given (eMedications.03) has an RX Norm value and no
      Pertinent Negatives. Exception:  May be nill or equal "Not Recorded" if
      Medication Administered Prior to this Units EMS Care (eMedications.02) =
      "Yes".
    </sch:assert>

    <sch:report id="Rule_186"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eMedications.08 = '3708031' and count(nem:eMedications.08) &gt; 1">
      When Medication Complication (eMedications.08) equals 'None' there
      must not be any other values selected.
    </sch:report>

    <sch:assert id="Rule_187"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eMedications.10 != '' or not(nem:eMedications.03[. != '' and not(@PN != '')]) or $AdminPrior">
      Role/Type of Person Administering Medication (eMedications.10)  must
      equal a valid value other than a Not Value when Medication Given (eMedications.03)
      has an RX Norm value and no Pertinent Negatives. Exception:  May be nill
      or equal "Not Recorded" if Medication Administered Prior to this Units
      EMS Care (eMedications.02) = "Yes".
    </sch:assert>

    <sch:assert id="Rule_189"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eMedications.11 != '' or not(nem:eMedications.03[. != '' and not(@PN != '')]) or $AdminPrior">
      Medication Authorization (eMedications.11)  must equal a valid value
      other than a Not Value when Medication Given (eMedications.03) has
      an RX Norm value and no Pertinent Negatives. Exception:  May be nill or
      equal "Not Recorded" if Medication Administered Prior to this Units EMS
      Care (eMedications.02) = "Yes".
    </sch:assert>

  </sch:rule>
</sch:pattern>

<sch:pattern id="p190">
  <sch:title>Procedurees.ProcedureGroup</sch:title>
  <sch:rule id="r190"
            context="nem:eProcedures.ProcedureGroup">
    <sch:let  name="nemsisElements"  value="(*, ../../nem:eDisposition/nem:eDisposition.12)"  />
    

    <sch:let name="DonePrior" value="(nem:eProcedures.02 = '9923003')" />
    <sch:let name="NotDonePrior" value="(nem:eProcedures.02 = '9923001')" />
    
    <sch:report id="Rule_190"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="../../nem:eDisposition/nem:eDisposition.12 = ($NoPatientContact) and descendant::*[not(@NV = ('7701001','7701003','7701005')) and not(child::*)]">
      All eProcedures.ProcedureGroup elements must equal a NOT value when  Incident/Patient
      Disposition (eDisposition.12) equals a value from the 'No Patient
      Contact' Disposition Group.
    </sch:report>

    <sch:assert id="Rule_191"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eProcedures.01 != '' or not(nem:eProcedures.03 != '' and (not(nem:eProcedures.03[@PN != ''])) and $NotDonePrior)">
      Date/Time Procedure Performed (eProcedures.01) must equal a valid value
      other than a Not Value when Procedure (eProcedures.03) has a valid
      SNOMED CT Code (without a Pertinent Negative) and Procedure Performed
      Prior to this Unit's EMS Care (eProcedures.02) is equal to "No".
    </sch:assert>
              
    <sch:assert id="Rule_192"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eProcedures.01 &lt;= ../../nem:eTimes/nem:eTimes.13">
      Date/Time Procedure Performed (eProcedures.01) must be less than or equal
      to Unit Back in Service Date/Time (eTimes.13)
    </sch:assert>

    <sch:assert id="Rule_193"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eProcedures.01 &gt;= ../../nem:eTimes/nem:eTimes.07 or not($NotDonePrior)">
      Date/Time Procedure Performed (eProcedures.01) must greater than or
      equal to Arrived at Patient Date/Time (eTimes.07) when Procedure Performed
      Prior to this Unit's EMS Care (eProcedures.02) is equal to 'No'.
    </sch:assert>

    <sch:assert id="Rule_194"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eProcedures.01 &lt;= ../../nem:eTimes/nem:eTimes.07 or not($DonePrior)">
      If provided, Date/Time Procedure Performed (eProcedures.01) must be less than or
      equal to Arrived at Patient Date/Time (eTimes.07) when Procedure Performed
      Prior to this Unit's EMS Care (eProcedures.02) equals
      'Yes'.
    </sch:assert>

    <sch:assert id="Rule_195"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eProcedures.02 != '' or not(nem:eProcedures.03 != '')">
      Procedure Performed Prior to this Unit's EMS Care (eProcedures.02) must
      equal a valid value other than a Not Value when Procedure
      (eProcedures.03) has a valid SNOMED CT Code (with or without a
      Pertinent Negative).
    </sch:assert>

    <sch:assert id="Rule_196"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eProcedures.03 != '' or not(nem:eProcedures.01 != '')">
      Procedure (eProcedures.03) must equal a valid value other than a Not
      Value when Date/Time Procedure Performed (eProcedures.01) is specified.
    </sch:assert>

    <sch:assert id="Rule_197"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eProcedures.03 != '' or not(nem:eProcedures.05 != '')">
      Procedure (eProcedures.03) must equal a valid value other than a Not
      Value when Number of Procedure Attempts (eProcedures.05) equals an
      integer between 1 and 10, inclusive.
    </sch:assert>

    <sch:assert id="Rule_198"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eProcedures.03 != '' or not(nem:eProcedures.11 != '')">
      Procedure (eProcedures.03) must equal a valid value other than a Not
      Value when Procedure Authorization (eProcedures.11) equals a valid
      value other than a Not Value.
    </sch:assert>

    <sch:assert id="Rule_199"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eProcedures.03 != '' or not(nem:eProcedures.07 != '')">
      Procedure (eProcedures.03) must equal a valid value other than a Not
      Value when Procedure Complication (eProcedures.07) equals a valid
      value other than a Not Value.
    </sch:assert>

    <sch:assert id="Rule_200"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eProcedures.03 != '' or not(nem:eProcedures.09 != '')">
      Procedure (eProcedures.03) must equal a valid value (with or without a
      Pertinent Negative) other than a Not Value when Procedure Crew Member
      ID (eProcedures.09) equals a valid value other than a Not Value.
    </sch:assert>

    <sch:assert id="Rule_201"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eProcedures.03 != '' or not(nem:eProcedures.02 != '')">
      Procedure (eProcedures.03) must equal a valid value other than a Not
      Value when Procedure Performed Prior to this Unit's EMS Care 
      (eProcedures.02) equals a valid value other than a Not Value.
    </sch:assert>

    <sch:assert id="Rule_202"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eProcedures.03 != '' or not(nem:eProcedures.06 != '')">
      Procedure (eProcedures.03) must equal a valid value other than a Not
      Value when Procedure Successful (eProcedures.06) equals a valid value
      other than a Not Value.
    </sch:assert>

    <sch:assert id="Rule_203"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eProcedures.03 != '' or not(nem:eProcedures.08 != '')">
      Procedure (eProcedures.03) must equal a valid value other than a Not
      Value when Response to Procedure (eProcedures.08) equals a valid value
      other than a Not Value.
    </sch:assert>

    <sch:assert id="Rule_204"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eProcedures.03 != '' or not(nem:eProcedures.10 != '')">
      Procedure (eProcedures.03) must equal a valid value other than a Not
      Value when Role/Type of Person Performing the Procedure (eProcedures.10)
      equals a valid value other than a Not Value.
    </sch:assert>

    <sch:assert id="Rule_205"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eProcedures.05 != '' or not(nem:eProcedures.03[. != '' and not(@PN != '')])">
      Number of Procedure Attempts (eProcedures.05) must equal an integer
      between 1 and 10, inclusive, when Procedure (eProcedures.03) has a
      valid SNOMED CT Code and no Pertinent Negatives.
    </sch:assert>

    <sch:assert id="Rule_206"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eProcedures.06 != '' or not(nem:eProcedures.03[. != '' and not(@PN != '')])">
      Procedure Successful (eProcedures.06) must equal a valid value other
      than a Not Value when Procedure (eProcedures.03) has a valid SNOMED
      CT Code and no Pertinent Negatives.
    </sch:assert>

    <sch:assert id="Rule_207"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eProcedures.07 != '' or not(nem:eProcedures.03[. != '' and not(@PN != '')]) or $DonePrior">
      Procedure Complication (eProcedures.07) must equal a valid value other
      than a Not Value when Procedure (eProcedures.03) has a valid SNOMED
      CT Code and no Pertinent Negatives. Exception:  May be nill or equal
      "Not Recorded" if Procedure Performed Prior to this Unit's EMS Care
      (eProcedures.02) = "Yes".
    </sch:assert>

    <sch:report id="Rule_208"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eProcedures.07 = '3907033' and count(nem:eProcedures.07) &gt; 1">
      When Procedure Complication (eProcedures.07) equals 'None' there must
      not be any other values selected.
    </sch:report>

    <sch:assert id="Rule_209"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="not(nem:eProcedures.08[@NV = '7701001']) or not(nem:eProcedures.03[. != '' and not(@PN != '')]) or $DonePrior">
      Response to Procedure (eProcedures.08) cannot equal 'Not Applicable'
      when Procedure (eProcedures.03) has a valid SNOMED CT Code and no
      Pertinent Negatives. Exception:  May be nill or equal "Not Recorded"
      if Procedure Performed Prior to this Unit's EMS Care (eProcedures.02)
      = "Yes".
    </sch:assert>

    <sch:assert id="Rule_210"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eProcedures.10 != '' or not(nem:eProcedures.03[. != '' and not(@PN != '')]) or $DonePrior">
      Role/Type of Person Performing Procedure (eProcedures.10) must equal
      a valid value other than a Not Value when Procedure (eProcedures.03)
      has a valid SNOMED CT Code value and no Pertinent Negatives. Exception:
      May be nill or equal "Not Recorded" if Procedure Performed Prior to this
      Unit's EMS Care (eProcedures.02) = "Yes".
    </sch:assert>

    <sch:assert id="Rule_211"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eProcedures.11 != '' or not(nem:eProcedures.03[. != '' and not(@PN != '')]) or $DonePrior">
      Procedure Authorization (eProcedures.11) must equal a valid value other
      than a Not Value when Procedure (eProcedures.03) has a valid SNOMED
      CT Code and no Pertinent Negatives. Exception:  May be nill or equal
      "Not Recorded" if Procedure Performed Prior to this Unit's EMS Care
      (eProcedures.02) = "Yes".
    </sch:assert>

  </sch:rule>
</sch:pattern>

<sch:pattern id="p212">
  <sch:title>eDisposition.DestinationGroup</sch:title>
  <sch:rule id="r212"
            context="nem:eDisposition.DestinationGroup">
    <sch:let  name="nemsisElements"  value="(*, ../nem:eDisposition.21, ../nem:eDisposition.12)"  />
    
            
    <sch:assert id="Rule_212"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.02 != '' or not(../nem:eDisposition.21 = ('4221003','4221005'))">
      Destination/Transferred to Code (eDisposition.02) must equal a value
      from the supplied list of Illinois hospital destination codes when
      Type of Destination (eDisposition.21) equals either 'Hospital-Emergency
      Department' or 'Hospital-Non-Emergency Department Bed'.
    </sch:assert>

    <sch:assert id="Rule_213"
                role="[WARNING]"
                diagnostics="nemsisDiagnostic"
                test="(nem:eDisposition.02 != '') or (not(../nem:eDisposition.21 = ('4221015','4221017')))">
      Destination/Transferred to Code (eDisposition.02) must contain a value 
      from the supplied list of Illinois EMS agency numbers, if applicable, 
      when Type of Destination (eDisposition.21) equals either 'Other EMS 
      Responder (air)' or 'Other EMS Responder (ground)'.                
    </sch:assert>

    <sch:assert id="Rule_214"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.02[@NV = ('7701001','7701003','7701005') or . = '9995'] or ../nem:eDisposition.21 = ('4221003','4221005','4221015','4221017') or (not (nem:eDisposition.02))">
      Destination/Transferred to Code (eDisposition.02) must equal a Not value
      or '9995' or be omitted unless Type of Destination (eDisposition.21) equals 
      'Hospital-Emergency Department'or 
      'Hospital-Non-Emergency Department Bed' or 
      'Other EMS Responder (air)' or 'Other EMS Responder (ground)'.
    </sch:assert>

    <sch:assert id="Rule_215"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.05 != '' or not(../nem:eDisposition.12 = ($PatientTransported,$OrganTransport)) or ../../nem:eRecord/nem:eRecord.SoftwareApplicationGroup/nem:eRecord.03 = 'EMScan/KeyData'">
      Destination State (eDisposition.05) must equal a valid state code
      when Incident/Patient Disposition (eDisposition.12) equals a value
      from either the 'Patient Transported' or the 'Organ Transport' Disposition
      Group.
    </sch:assert>

    <sch:assert id="Rule_216"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.06 != '' or not(../nem:eDisposition.12 = ($PatientTransported,$OrganTransport)) or ../../nem:eRecord/nem:eRecord.SoftwareApplicationGroup/nem:eRecord.03 = 'EMScan/KeyData'">
      Destination County (eDisposition.06) must equal a valid county code
      when Incident/Patient Disposition (eDisposition.12) equals a value
      from either the 'Patient Transported' or the 'Organ Transport' Disposition
      Group.
    </sch:assert>

    <sch:assert id="Rule_217"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.05 = substring(nem:eDisposition.06,1,2)">
      The first two digits of Destination County (eDisposition.06) must
      equal Destination State (eDisposition.05).
    </sch:assert>

    <sch:assert id="Rule_218"
                role="[WARNING]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.07 != '' or not(../nem:eDisposition.12 = ($PatientTransported,$OrganTransport))">
      Destination ZIP Code (eDisposition.07) should equal a valid US zip code
      when Incident/Patient Disposition (eDisposition.12) equals a value
      from either the 'Patient Transported' or the 'Organ Transport' Disposition
      Group.
    </sch:assert>

  </sch:rule>
</sch:pattern>

<sch:pattern id="p219">
  <sch:title>eDisposition</sch:title>
  <sch:rule id="r219"
            context="nem:eDisposition">
    <sch:let  name="nemsisElements"  value="*"  />
    

    <sch:assert id="Rule_219"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.12 = ($PatientTransported,$OrganTransport) or not(nem:eDisposition.17 != '')">
      Incident/Patient Disposition (eDisposition.12) must have a value from
      the 'Patient Transported' or the 'Organ Transport' Disposition Group
      when Type of Transport Mode from Scene (eDisposition.17) equals a
      valid value other than a Not Value.
    </sch:assert>

    <sch:assert id="Rule_220"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.16[@NV = '7701001'] or nem:eDisposition.12 = ($PatientTransported,$OrganTransport)">
      EMS Transport Method (eDisposition.16) must equal 'Not Applicable'
      when Incident/Patient Disposition (eDisposition.12) does not equal
      a value from either the 'Patient Transported' or the 'Organ Transport'
      Disposition Group.
    </sch:assert>

    <sch:assert id="Rule_221"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.16 != '' or not(nem:eDisposition.12 = ($PatientTransported,$OrganTransport))">
      EMS Transport Method (eDisposition.16) must equal a valid value other
      than a Not Value when Incident/Patient Disposition (eDisposition.12)
      equals a value from either the 'Patient Transported' or the 'Organ Transport'
      Disposition Group.
    </sch:assert>


    <sch:assert id="Rule_222"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.17[@NV = '7701001'] or nem:eDisposition.12 = ($PatientTransported,$OrganTransport)">
      Transport Mode from Scene (eDisposition.17) must equal 'Not Applicable'
      when Incident/Patient Disposition (eDisposition.12) does not equal
      a value from either the 'Patient Transported' or the 'Organ Transport'
      Disposition Group.
    </sch:assert>

    <sch:assert id="Rule_223"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.17 != '' or not(nem:eDisposition.12 = ($PatientTransported,$OrganTransport))">
      Transport Mode from Scene (eDisposition.17) must equal a valid value
      other than a Not Value when Incident/Patient Disposition (eDisposition.12)
      equals a value from either the 'Patient Transported' or the 'Organ Transport'
      Disposition Group.
    </sch:assert>

    <sch:assert id="Rule_224"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.17 != '' or not(nem:eDisposition.18 != '')">
      Transport Mode from Scene (eDisposition.17) must equal a valid value
      other than a Not Value when Additional Transport Mode Descriptors
      (eDisposition.18) equals a valid value other than a Not Value.
    </sch:assert>

<!-- eliminated 10/17/2018
    <sch:assert id="Rule_225"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.17 != '' or not(nem:eDisposition.19 != '')">
      Transport Mode from Scene (eDisposition.17) must equal a valid value
      other than a Not Value when Final Patient Acuity 
      (eDisposition.19) equals a valid value other than a Not Value.
    </sch:assert>
-->

    <sch:assert id="Rule_226"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.17 != '' or not(../nem:eResponse/nem:eResponse.11 != '')">
      Transport Mode from Scene (eDisposition.17) must equal a valid value
      other than a Not Value when Transport Delay (eResponse.11) equals
      a valid value other than a Not Value.
    </sch:assert>

    <sch:report id="Rule_227"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="(nem:eDisposition.18[@NV = '7701001']) and (nem:eDisposition.12 = ($PatientTransported,$OrganTransport))">
      Additional Transport Mode Descriptors (eDisposition.18) cannot equal
      'Not Applicable' when Incident/Patient Disposition (eDisposition.12)
      equals a value from either the 'Patient Transported' or the 'Organ Transport'
      Disposition Group.
    </sch:report>

    <sch:assert id="Rule_228"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.19[@NV = '7701001'] or nem:eDisposition.12 = ($PatientTransported)">
      Final Patient Acuity (eDisposition.19) must equal 'Not
      Applicable' when Incident/Patient Disposition (eDisposition.12) does
      not equal a value from the 'Patient Transported' Disposition Group.
    </sch:assert>

    <sch:assert id="Rule_229"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.19[@NV = '7701003'] or nem:eDisposition.19[. != ''] or not(nem:eDisposition.12[. = ($PatientTransported)])">
      Final Patient Acuity (eDisposition.19) must equal a
      valid value other than 'Not Applicable' when Incident/Patient Disposition
      (eDisposition.12) equals a value from the 'Patient Transported' 
      Disposition Group.
    </sch:assert>

    <sch:assert id="Rule_230"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.20[@NV = '7701001'] or nem:eDisposition.12 = ($PatientTransported,$OrganTransport)">
      Reason for Choosing Destination (eDisposition.20) must equal 'Not
      Applicable' when Incident/Patient Disposition (eDisposition.12) does
      not equal a value from either the 'Patient Transported' or the 'Organ
      Transport' Disposition Group.
    </sch:assert>

    <sch:assert id="Rule_231"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="(nem:eDisposition.20[. != '']) or (not(nem:eDisposition.12[. = ($PatientTransported)]))">
      Reason for Choosing Destination (eDisposition.20) must equal a valid
      value other than a Not Value when Incident/Patient Disposition (eDisposition.12)
      equals a value from the 'Patient Transported' Disposition Group.
    </sch:assert>

    <sch:assert id="Rule_232"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.21[@NV = '7701001'] or nem:eDisposition.12 = ($PatientTransported,$OrganTransport)">
      Type of Destination (eDisposition.21) must equal 'Not Applicable'
      when Incident/Patient Disposition (eDisposition.12) does not equal
      a value from either the 'Patient Transported' or the 'Organ Transported'
      Disposition Group.
    </sch:assert>

    <sch:assert id="Rule_233"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="(nem:eDisposition.21[. != '']) or (not(nem:eDisposition.12[. = ($PatientTransported)]))">
      Type of Destination (eDisposition.21) must equal a valid value other
      than a Not Value when Incident/Patient Disposition (eDisposition.12)
      equals a value from the 'Patient Transported' Disposition Group.
    </sch:assert>

    <sch:assert id="Rule_234"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.22 != '' or not(nem:eDisposition.21 = '4221005')">
      Hospital Inpatient Destination (eDisposition.22) must equal a valid
      value other than a Not Value when Type of Destination (eDisposition.21)
      equals 'Hospital-Non-Emergency Department Bed'.
    </sch:assert>

    <sch:assert id="Rule_235"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.23 != '' or not(nem:eDisposition.21 = ('4221005','4221003'))">
      Hospital Designation (eDisposition.23) must equal a valid value other
      than a Not Value when Type of Destination (eDisposition.21) equals
      'Hospital-Emergency Department' or 'Hospital-Non-Emergency Department
      Bed'.
    </sch:assert>

    <sch:assert id="Rule_236"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.23[@NV = '7701001'] or nem:eDisposition.21 = ('4221003','4221005')">
      Hospital Designation (eDisposition.23) must equal 'Not Applicable'
      when Type of Destination (eDisposition.21) does not equal 'Hospital-Emergency
      Department' or 'Hospital-Non-Emergency Department Bed'.
    </sch:assert>

    <sch:assert id="Rule_237"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.HospitalTeamActivationGroup/nem:eDisposition.24[. != '' and . != '4224001'] or not(nem:eDisposition.HospitalTeamActivationGroup/nem:eDisposition.25 != '')">
      Destination Team Pre-Arrival Arrival Alert or Activation 
      (eDisposition.24) must equal a valid value other than a Not Value or 
      "No" when Date/Time of Destination Pre-Arrival Arrival Alert or 
      Activation (eDisposition.25) is specified.
    </sch:assert>
    
    <!--
    <sch:assert id="Rule_238"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.HospitalTeamActivationGroup/nem:eDisposition.24 != '' or not(nem:eDisposition.12 = ($PatientTransported) and nem:eDisposition.21 = '4221003')">
      Destination Team Pre-Arrival Arrival Alert or Activation 
      (eDisposition.24) must equal a valid value other than a Not Value when 
      Disposition Group is 'Patient Transported' AND Type of Destination 
      (eDisposition.21) equals 'Hospital-Emergency Department'.
    </sch:assert>
    -->
    
    <sch:assert id="Rule_239"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eDisposition.HospitalTeamActivationGroup/nem:eDisposition.25 != '' or not(nem:eDisposition.HospitalTeamActivationGroup/nem:eDisposition.24[. != '4224001' and . != ''])">
      Date/Time of Destination Pre-Arrival Arrival Alert or Activation (eDisposition.25)
      must be specified when Destination Team Pre-Arrival
      Arrival Alert or Activation (eDispositon.24) equals a valid value
      other than 'No' or a Not Value.
    </sch:assert>

  </sch:rule>
</sch:pattern>

<sch:pattern id="p240">
  <sch:title>eOutcome</sch:title>
  <sch:rule id="r240"
            context="nem:eOutcome">
    <sch:let name="nemsisElementsMissing" value="'eOutcome.ExternalDataGroup eOutcome.03 eOutcome.04'"/>
    <sch:let name="nemsisElementsMissingContext" value="."/>
    

    <sch:report id="Rule_240"
                role="[WARNING]"
                diagnostics="nemsisDiagnostic"
                test="not(nem:eOutcome.ExternalDataGroup[nem:eOutcome.03 = '4303009'and nem:eOutcome.04 != '']) and (ancestor::nem:PatientCareReport/nem:eInjury/nem:eInjury.01 = ('V20.9','V29.9','V30.9','V39.9','V40.9','V49.9','V50.9','V59.9','V60.9','V69.9','V70.9','V79.9','V82.9','V86.31','V86.32','V86.34','V86.39','V89.9') or ancestor::nem:PatientCareReport/nem:eInjury/nem:eInjury.04 = ('2904001','2904007','2904009','2904011','2904013','2904015') or ancestor::nem:PatientCareReport/nem:eInjury/nem:eInjury.06 != '' or ancestor::nem:PatientCareReport/nem:eInjury/nem:eInjury.08 != '')">
      An External Data Group (eOutcome.ExternalDataGroup) instance should
      be present with the External Report ID/Number Type (eOutcome.03) element
      equal to 'Law Enforcement Report' (4303009) and the External Report
      ID/Number (eOutcome.04) element not omitted when any of the following
      conditions are met:
      - Cause of Injury (eInjury.01) contains one of the following values:
       V20.9, V29.9, V30.9, V39.9, V40.9, V49.9, V50.9, V59.9, V60.9, V69.9,
      V70.9, V79.9, V82.9, V86.31, V86.32, V86.34, V86.39, V89.9
      - Vehicular, Pedestrian, or Other Injury Risk Factor (eInjury.04)
      contains one of the following values:
         -Auto v. Pedestrian/Bicyclist Thrown, Run Over, or &gt; 20 MPH Impact
         -Crash Death in Same Passenger Compartment
         -Crash Ejection (partial or complete) from vehicle
         -Crash Intrusion, including roof: &gt; 12 in. occupant site; &gt; 18 in. any site
         -Crash Vehicle Telemetry Data (AACN) Consistent with High Risk of Injury
         -Motorcycle Crash &gt; 20 MPH
      - Location of Patient in Vehicle (eInjury.06) equals a valid value
      other than a Not Value
      - Airbag Deployment (eInjury.08) equals a valid value other than a
      Not Value
    </sch:report>
  </sch:rule>
</sch:pattern>

<sch:pattern id="EMSS">
  <sch:title>EMSS</sch:title>
  <sch:rule id="r241.1"
            context="nem:Header">
    <sch:let name="nemsisElementsMissing" value="'eCustomConfiguration.01 eCustomConfiguration.03 eCustomConfiguration.04 eCustomConfiguration.05'"/>
    <sch:let name="nemsisElementsMissingContext" value="."/>
    <sch:assert id="Rule_241_1" role="[FATAL]" diagnostics="nemsisDiagnostic"
                test="nem:eCustomConfiguration//nem:eCustomConfiguration.CustomGroup[nem:eCustomConfiguration.01 = 'Illinois EMS System Number' and nem:eCustomConfiguration.03 = '9902009' and nem:eCustomConfiguration.04 = '9923001' and nem:eCustomConfiguration.05 = '9903001' and @CustomElementID != '']">
      Each Header must have a Custom Data Element configured with Title (eCustomConfiguration.01) equal to the text string 'Illinois EMS System
      Number' and Custom Data Type (eCustomConfiguration.03) equal to 'Text/String' and Custom Data Element Recurrence (eCustomConfiguration.04)
      equal to 'No' and Custom Data Element Usage (eCustomConfiguration.05) equal to 'Mandatory', and having a valid CustomElementID attribute.
    </sch:assert>
  </sch:rule>

  <!--
  <sch:rule id="r241.2"
            context="nem:PatientCareReport">
    <sch:let name="nemsisElementsMissing" value="'eCustomResults.01 eCustomResults.02'"/>
    <sch:let name="nemsisElementsMissingContext" value="."/>
    <sch:let name="EMSSFieldID" value="../nem:eCustomConfiguration//nem:eCustomConfiguration.CustomGroup[nem:eCustomConfiguration.01 = 'Illinois EMS System Number']/@CustomElementID" />

    <sch:assert id="Rule_241_2" role="[FATAL]" diagnostics="nemsisDiagnostic"
                test="nem:eCustomResults/nem:eCustomResults.ResultsGroup[nem:eCustomResults.01 != '' and nem:eCustomResults.02 = $EMSSFieldID]">
      An 'Illinois EMS System Number' Custom Data Element Result (eCustomResults.01) must be present for each Patient Care Report
    </sch:assert>
  </sch:rule>
  -->

  <sch:rule id="r241.3" context="nem:PatientCareReport">
    <sch:let name="nemsisElementsMissing" value="'eCustomResults.01 eCustomResults.02'"/>
    <sch:let name="nemsisElementsMissingContext" value="."/>
    <sch:let name="EMSSFieldID" value="../nem:eCustomConfiguration//nem:eCustomConfiguration.CustomGroup[nem:eCustomConfiguration.01 = 'Illinois EMS System Number']/@CustomElementID" />
    <sch:assert id="Rule_241_3" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="nem:eCustomResults/nem:eCustomResults.ResultsGroup[nem:eCustomResults.01[. = ($AllowedEMSSystemNumbers)] and nem:eCustomResults.02 = $EMSSFieldID]">
      Each Patient Care Report must have an 'Illinois EMS System Number' Custom Data Element Result with a value (eCustomResults.01) that must be one of the following four-digit numeric strings: 0121, 0139, 0165, 0175, 0215, 0218, 0219, 0237, 0238, 0242, 0243, 0253, 0254, 0256, 0257, 0279, 0316, 0320, 0327, 0360, 0425, 0432, 0451, 0473, 0476, 0481, 0526, 0530, 0562, 0623, 0633, 0644, 0663, 0671, 0704, 0710, 0712, 0729, 0746, 0777, 0805, 0828, 0849, 0859, 0906, 0907, 0909, 0948, 0961, 0980, 1002, 1011, 1014, 1072, 1082, 1103, 1108, 1113, 1178, 1241, 1255, 1275.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p242">
  <sch:title>eOther</sch:title>
  <sch:rule id="r242"
            context="nem:eCrew.01[../../../nem:eDisposition/nem:eDisposition.12[. = $PatientEncountered]]">
    <sch:let name="nemsisElementsMissing" value="'eOther.03'"/>
    <sch:let name="nemsisElementsMissingContext" value="./nem:eOther.EMSCrewMemberGroup"/>
    <sch:let  name="CrewID"  value="."  />

    <sch:assert id="Rule_242"
                role="[WARNING]"
                diagnostics="nemsisDiagnostic"
                test="../../../nem:eOther/nem:eOther.EMSCrewMemberGroup[nem:eOther.03 and nem:eOther.04[. = $CrewID]]">
      Personal Protective Equipment Used (eOther.03) should not be omitted
      for any crew member when Incident/Patient Disposition (eDisposition.12)
      equals a value from the 'Patient Encountered' Disposition Group.
    </sch:assert>

  </sch:rule>                
</sch:pattern>

<sch:pattern id="p242-2">
  <sch:title>eOther</sch:title>
  <sch:rule id="r242.2"
            context="nem:eOther.03">
    <sch:let name="nemsisElementsMissing" value="'eOther.04'"/>
    <sch:let name="nemsisElementsMissingContext" value=".."/>

    <sch:assert id="Rule_242_2"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="../nem:eOther.04[. != ''] or ../../../nem:eTimes/nem:eTimes.03[. &lt; '2017-10-01T00:00:00']">
      When Personal Protective Equipment Used (eOther.03) is present, 
      it must be linked to the applicable crewmember via EMS Professional 
      ID (eOther.04)
    </sch:assert>

  </sch:rule>                
</sch:pattern>

<sch:pattern id="p243">
  <sch:title>Work Related Injury or Exposure Required</sch:title>
  <sch:rule id="r243"
            context="nem:eCrew.01[../../../nem:eTimes/nem:eTimes.03[. &gt; '2017-10-01T00:00:00'] and (. != '')]">
    <sch:let  name="nemsisElements"  value="nem:eOther/nem:eOther.EMSCrewMemberGroup/nem:eOther.05"  />
    <sch:let  name="CrewID"  value="."  />
    
    <sch:assert id="Rule_243"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="../../../nem:eOther/nem:eOther.EMSCrewMemberGroup[nem:eOther.05[. != '' or @NV != '7701001'] and nem:eOther.04[. = $CrewID]]">
      A value other than 'Not Applicable' must be present in Suspected 
      EMS Work Related Exposure, Injury or Death element (eOther.05) for 
      each crewmember, and this value must be linked to the applicable 
      crewmember via EMS Professional ID (eOther.04).
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="p244">
  <sch:title>Work Related Injury or Exposure Rules</sch:title>
  <sch:rule id="r244"
            context="nem:eOther.EMSCrewMemberGroup[nem:eOther.05 = '9923003']">
    <sch:let name="nemsisElementsMissing" value="'eOther.06'"/>
    <sch:let name="nemsisElementsMissingContext" value="."/>
    

    <sch:assert id="Rule_244"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eOther.06[. != ''] and (../../nem:eTimes/nem:eTimes.03[. &lt; '2017-10-01T00:00:00'] or nem:eOther.04[. != ''])">
      When Suspected EMS Work Related Exposure, Injury or Death (eOther.05) 
      = 'Yes', A valid value other than a Not value is required in Type of 
      Work-Related Injury, Death or Suspected Exposure (eOther.06), and this 
      value must be linked to the applicable crewmember via EMS Professional 
      ID (eOther.04).
    </sch:assert>
    
  </sch:rule>
</sch:pattern>

<sch:pattern id="p245">
  <sch:title>Crew Information Matches EMSCrewmember Rules</sch:title>
  <sch:rule id="r245.1"
            context="nem:eCrew.01[../../../nem:eTimes/nem:eTimes.03[. &gt; '2017-10-01T00:00:00'] and (. != '')]">
    <sch:let name="nemsisElementsMissing" value="'eOther.06'"/>
    <sch:let name="nemsisElementsMissingContext" value="."/>
    <sch:let  name="CrewID"  value="."  />
    
    <sch:assert id="Rule_245_1"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="../../../nem:eOther/nem:eOther.EMSCrewMemberGroup[nem:eOther.04 = $CrewID]">
      A valid state license number is required in EMS Professional ID 
      (eOther.04) for each crewmember (eCrew.01) and vice-versa.
    </sch:assert>
    
  </sch:rule>

  <sch:rule id="r245.2"
            context="nem:eOther.04[../../../nem:eTimes/nem:eTimes.03[. &gt; '2017-10-01T00:00:00'] and (. != '')]">
    <sch:let name="nemsisElementsMissing" value="'eOther.06'"/>
    <sch:let name="nemsisElementsMissingContext" value="."/>
    <sch:let name="CrewID"  value="."  />
    
    <sch:assert id="Rule_245_2"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="../../../nem:eCrew/nem:eCrew.CrewGroup[nem:eCrew.01 = $CrewID]">
      A valid state license number is required in EMS Professional ID 
      (eOther.04) for each crewmember (eCrew.01) and vice-versa.
    </sch:assert>
    
  </sch:rule>
  
  <sch:rule id="r245.0"
            context="nem:eOther.EMSCrewMemberGroup[nem:eOther.05 = '9923003' and ../../nem:eTimes/nem:eTimes.03[. &lt; '2017-10-01T00:00:00']]">
    <sch:let name="nemsisElementsMissing" value="'eOther.06'"/>
    <sch:let name="nemsisElementsMissingContext" value="."/>
    

    <sch:assert id="Rule_245_0"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="nem:eOther.04[. != '']">
      When Suspected EMS Work Related Exposure, Injury or Death (eOther.05)
      = 'Yes', the Crew Member ID of the affected individal (eOther.04) must
      be provided.
    </sch:assert>
    
  </sch:rule>
</sch:pattern>

<sch:pattern id="p246">
  <sch:title>Unit ID Rules</sch:title>
  <sch:rule id="r246"
            context="nem:eResponse.13">

    <sch:let  name="nemsisElements"  value="."  />
    

    <sch:assert id="Rule_246"
                role="[ERROR]"
                diagnostics="nemsisDiagnostic"
                test="matches(.,'^([0-9]{4}-?)?([0-9]{2}|[Nn][Tt])$')">
      EMS Vehicle Number (eResponse.13) must be a 2-digit number, 'NT', a 
      6-digit number (agency+unit ID) OR a 4-digit number followed by 'NT'. 
      'NT' indicates a non-transport unit (calls for non-transport
      units found in the dataset will be skipped without warning or error).
      An optional hyphen is permitted between the Agency Number (if included)
      and the 2 digit Vehicle ID.
    </sch:assert>
    
  </sch:rule>
</sch:pattern>

<!-- ************ DIAGNOSTICS **************** -->

<sch:diagnostics>
<sch:diagnostic id="nemsisDiagnostic" xmlns:sch="http://purl.oclc.org/dsdl/schematron" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <!-- This is the NEMSIS national diagnostic. It must exist in every NEMSIS Schematron document, 
       and it should be referenced by every assert and report. It provides nationally-
       standardized, structured data to communicate which data elements are of interest in a 
       failed assert or successful report. -->

  <nemsisDiagnostic xmlns="http://www.nemsis.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <!-- Elements that uniquely identify the record where the problem happened. -->

    <record>
      <xsl:copy-of select="ancestor-or-self::*:DemographicReport/*:dAgency/(*:dAgency.01 | *:dAgency.02 | *:dAgency.04)"/>
      <xsl:copy-of select="ancestor-or-self::*:Header/*:DemographicGroup/*"/>
      <xsl:copy-of select="ancestor-or-self::*:PatientCareReport/*:eRecord/*:eRecord.01"/>
    </record>

    <!-- Elements that the user may want to revisit to resolve the problem, along with their values. -->

    <elements>
      <xsl:for-each select="$nemsisElements">
        <xsl:element name="element">
          <xsl:attribute name="location">
            <xsl:apply-templates select="." mode="schematron-get-full-path"/>
          </xsl:attribute>
          <xsl:for-each select ="@*">
            <xsl:attribute name="{name()}">
              <xsl:value-of select="."/>
            </xsl:attribute>
          </xsl:for-each>
          <xsl:if test="not(*)">
            <xsl:value-of select="."/>
          </xsl:if>
        </xsl:element>
      </xsl:for-each>
    </elements>

    <!-- Elements that were missing, that the user may want to visit to resolve the problem. -->

    <elementsMissing>
      <xsl:variable name="default_context" select="."/>
      <xsl:for-each select="tokenize($nemsisElementsMissing, ' ')">
        <xsl:variable name="parent" select="$nemsisElementsMissingContext[contains(local-name(), substring-before(current(), '.'))][1]"/>
        <element>
          <xsl:attribute name="parentLocation">
            <xsl:choose>
              <xsl:when test="$parent">
                <xsl:apply-templates select="$parent" mode="schematron-get-full-path"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:apply-templates select="$default_context" mode="schematron-get-full-path"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:attribute>
          <xsl:attribute name="name">
            <xsl:value-of select="."/>
          </xsl:attribute>
        </element>
      </xsl:for-each>
    </elementsMissing>

  </nemsisDiagnostic>

</sch:diagnostic>
</sch:diagnostics>
</sch:schema>
