<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../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.5.0.211008CP3_IDPH_20221219"
  see="https://nemsis.org/technical-resources/version-3/version-3-schematron/">

  <sch:title>NEMSIS ISO Schematron file for EMSDataSet for the Illinois Department of Public Health</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="()"/>

  <!-- PHASES -->
  <!-- No phases used. -->

  <!-- PATTERNS -->

<sch:pattern id="nemSch_dAgency_r_DemographicGroup">
  <sch:title>DemographicGroup</sch:title>
  <sch:rule id="r_DemographicGroup" context="nem:Header/nem:DemographicGroup">
    <sch:let name="nemsisElements" value="*"/>
    <!-- NOTE: Rule_1 is defined to check against a list of valid IDs, macth pattern instead -->
    <sch:assert id="Rule_1" role="[FATAL]" diagnostics="nemsisDiagnostic"
                test="matches(nem:dAgency.01,'^([0-9]{4})$')">
      EMS Agency Unique State ID (dAgency.01) must contain a valid 4-digit numeric license number issued by IDPH.
    </sch:assert>

    <sch:assert id="Rule_2" role="[FATAL]" diagnostics="nemsisDiagnostic"
                test="nem:dAgency.01 = nem:dAgency.02">
      EMS Agency Number (dAgency.02) must equal EMS Agency Unique State ID (dAgency.01)
    </sch:assert>
  </sch:rule>
</sch:pattern>


<?DSDL_INCLUDE_START includes/pattern_eResponse.xml?>

<sch:pattern id="nemSch_eResponse_r3">
  <sch:title>nemSch_eResponse_r3</sch:title>
  <sch:rule id="r3" context="nem:eResponse.01">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_3" role="[FATAL]" diagnostics="nemsisDiagnostic"
                test=". = ancestor::nem:Header/nem:DemographicGroup/nem:dAgency.01">
      EMS Agency Number (eResponse.01) must equal EMS Agency Unique State ID (dAgency.01)
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eResponse_r4">
  <sch:title>nemSch_eResponse_r4</sch:title>
  <sch:rule id="r4" context="nem:eResponse.08[. = '2208013'][1]">
    <sch:let name="nemsisElements" value="../nem:eResponse.08"/>
    <sch:assert id="Rule_4" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="count(../nem:eResponse.08) = 1">
      When Types of Dispatch Delay (eResponse.08) includes "None/No Delay" there cannot also be other Dispatch Delay
       Types.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eResponse_r6">
  <sch:title>nemSch_eResponse_r6</sch:title>
  <sch:rule id="r6" context="nem:eResponse.09[. = '2209011'][1]">
    <sch:let name="nemsisElements" value="../nem:eResponse.09"/>
    <sch:assert id="Rule_6" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="count(../nem:eResponse.09) = 1">
      When Types of Response Delay (eResponse.09) includes "None/No Delay" there cannot also be other Response Delay
       Types.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eResponse_r9">
  <sch:title>nemSch_eResponse_r9</sch:title>
  <sch:rule id="r9" context="nem:eResponse.10[. = '2210017'][1]">
    <sch:let name="nemsisElements" value="../nem:eResponse.10"/>
    <sch:assert id="Rule_9" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="count(../nem:eResponse.10) = 1">
      When Type of Scene Delay (eResponse.10) includes "None/No Delay" there cannot also be other Scene Delay Types.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eResponse_r12">
  <sch:title>nemSch_eResponse_r12</sch:title>
  <sch:rule id="r12" context="nem:eResponse.11[. = '2211011'][1]">
    <sch:let name="nemsisElements" value="../nem:eResponse.11"/>
    <sch:assert id="Rule_12" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="count(../nem:eResponse.11) = 1">
      When Types of Transport Delay (eResponse.11) includes "None/No Delay" there cannot also be other Transport Delay
       Types.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eResponse_r14">
  <sch:title>nemSch_eResponse_r14</sch:title>
  <sch:rule id="r14" context="nem:eResponse.12[. = '2212015'][1]">
    <sch:let name="nemsisElements" value="../nem:eResponse.12"/>
    <sch:assert id="Rule_14" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="count(../nem:eResponse.12) = 1">
      When Types of Turn-Around Delay (eResponse.12) includes "None/No Delay" there cannot also be other Turn-Around
       Delay Types.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eResponse_r15">
  <sch:title>nemSch_eResponse_r15</sch:title>
  <sch:rule id="r15" context="nem:eResponse.13">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_15" 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>

<sch:pattern id="nemSch_eResponse_r17">
  <sch:title>nemSch_eResponse_r17</sch:title>
  <sch:rule id="r17" context="nem:eResponse.24[. = '2224015']">
    <sch:let name="nemsisElements" value="../nem:eResponse.24"/>
    <sch:assert id="Rule_17" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="not(../nem:eResponse.24 = ('2224017','2224019','2224021','2224023'))">
      When Additional Response Mode Descriptors (eResponse.24) contains 2224015 Lights and Sirens, it cannot contain any
       of the following: 2224017 Lights and No Sirens, 2224019 No Lights or Sirens, 2224021 Initial No Lights or Sirens,
        Upgraded to Lights and Sirens, 2224023 Initial Lights and Sirens, Downgraded to No Lights or Sirens.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eResponse_r18">
  <sch:title>nemSch_eResponse_r18</sch:title>
  <sch:rule id="r18" context="nem:eResponse.24[. = '2224017']">
    <sch:let name="nemsisElements" value="../nem:eResponse.24"/>
    <sch:assert id="Rule_18" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="not(../nem:eResponse.24 = ('2224015','2224019','2224021','2224023'))">
      When Additional Response Mode Descriptors (eResponse.24) contains 2224017 Lights and No Sirens, it cannot contain
       any of the following: 2224015 Lights and Sirens, 2224019 No Lights or Sirens, 2224021 Initial No Lights or
        Sirens, Upgraded to Lights and Sirens, 2224023 Initial Lights and Sirens, Downgraded to No Lights or Sirens.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eResponse_r19">
  <sch:title>nemSch_eResponse_r19</sch:title>
  <sch:rule id="r19" context="nem:eResponse.24[. = '2224019']">
    <sch:let name="nemsisElements" value="../nem:eResponse.24"/>
    <sch:assert id="Rule_19" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="not(../nem:eResponse.24 = ('2224015','2224017','2224021','2224023'))">
      When Additional Response Mode Descriptors (eResponse.24) contains 2224019 No Lights or Sirens, it cannot contain
       any of the following: 2224015 Lights and Sirens, 2224017 Lights and No Sirens, 2224021 Initial No Lights or
        Sirens, Upgraded to Lights and Sirens, 2224023 Initial Lights and Sirens, Downgraded to No Lights or Sirens.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eResponse_r20">
  <sch:title>nemSch_eResponse_r20</sch:title>
  <sch:rule id="r20" context="nem:eResponse.24[. = '2224021']">
    <sch:let name="nemsisElements" value="../nem:eResponse.24"/>
    <sch:assert id="Rule_20" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="not(../nem:eResponse.24 = ('2224015','2224017','2224019','2224023'))">
      When Additional Response Mode Descriptors (eResponse.24) contains 2224021 Initial No Lights or Sirens, Upgraded to
       Lights and Sirens, it cannot contain any of the following: 2224015 Lights and Sirens, 2224017 Lights and No
        Sirens, 2224019 No Lights or Sirens, 2224023 Initial Lights and Sirens, Downgraded to No Lights or Sirens.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eResponse_r21">
  <sch:title>nemSch_eResponse_r21</sch:title>
  <sch:rule id="r21" context="nem:eResponse.24[. = '2224023']">
    <sch:let name="nemsisElements" value="../nem:eResponse.24"/>
    <sch:assert id="Rule_21" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="not(../nem:eResponse.24 = ('2224015','2224017','2224019','2224021'))">
      When Additional Response Mode Descriptors (eResponse.24) contains 2224023 Initial Lights and Sirens, Downgraded to
       No Lights or Sirens, it cannot contain any of the following: 2224015 Lights and Sirens, 2224017 Lights and No
        Sirens, 2224019 No Lights or Sirens, 2224021 Initial No Lights or Sirens, Upgraded to Lights and Sirens.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eResponse_r86">
  <sch:title>nemSch_eResponse_r86</sch:title>
  <sch:rule id="r86" context="nem:eResponse.05[. = ('2205005', '2205007', '2205015', '2205017', '2205019')]">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_86" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eSituation/nem:eSituation.20"
                test="ancestor::nem:PatientCareReport/nem:eSituation/nem:eSituation.20 != ''">
      Reason for Interfacility Transfer/Medical Transport must equal a valid value other than a NV when Type of Service
       Requested (eResponse.05) equals "Other Routine Medical Transport" (2205007) or contains "Transfer" (2205005,
        2205015, 2205017, 2205019).
    </sch:assert>
  </sch:rule>
</sch:pattern>
<?DSDL_INCLUDE_END includes/pattern_eResponse.xml?>


<?DSDL_INCLUDE_START includes/pattern_eTimes.xml?>

<sch:pattern id="nemSch_eTimes_r24">
  <sch:title>nemSch_eTimes_r24</sch:title>
  <sch:rule id="r24" context="nem:eTimes.01[. != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_24" role="[ERROR]" diagnostics="nemsisDiagnostic" 
        subject="../nem:eTimes.03, ." 
        test="not(../nem:eTimes.03) or xs:dateTime(.) &lt;= xs:dateTime(../nem:eTimes.03)">
      When entered, PSAP Call Date/Time (eTimes.01) must be less than or equal to Unit Notified by Dispatch Date/Time
       (eTimes.03).
    </sch:assert>
  </sch:rule>

</sch:pattern>

<sch:pattern id="nemSch_eTimes_r_eTimes03">
  <sch:title>nemSch_eTimes_r_eTimes03</sch:title>
  <sch:rule id="r_eTimes03" context="nem:eTimes.03">
    <sch:let name="nemsisElements" value="."/>

    <sch:assert id="Rule_22" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eDispatch/nem:eDispatch.02"
                test="ancestor::nem:PatientCareReport/nem:eDispatch/nem:eDispatch.02 != ''">
      EMD Performed (eDispatch.02) must equal a valid value if Unit Notified by Dispatch Date/Time (eTimes.03) contains
       a time.
    </sch:assert>

    <sch:assert id="Rule_23" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="count(ancestor::nem:PatientCareReport/nem:eCrew/nem:eCrew.CrewGroup/nem:eCrew.01) &gt; 1">
      A MINIMUM of two state EMS licensure ID numbers must be entered for each run report if Unit Notified by Dispatch
       Date/Time (eTimes.03) contains a time. However, IDs for all licensed crewmembers should be entered.
    </sch:assert>

    <sch:assert id="Rule_25" role="[ERROR]" diagnostics="nemsisDiagnostic" 
        subject="., ../nem:eTimes.01, ../nem:eTimes.02" 
        test="(not(../nem:eTimes.01) or ../nem:eTimes.01 = '' or xs:dateTime(.) &gt;= xs:dateTime(../nem:eTimes.01))
               and (not(../nem:eTimes.02) or xs:dateTime(.) &gt;= xs:dateTime(../nem:eTimes.02))">
      Unit Notified by Dispatch Date/Time (eTimes.03) must be greater than or equal to Dispatch Notified Date/Time
       (eTimes.02) and PSAP Call Date/Time (eTimes.01).
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eTimes_r_eTimes05">
  <sch:title>nemSch_eTimes_r_eTimes05</sch:title>
  <sch:rule id="r_eTimes05" context="nem:eTimes.05[. != '']">
    <sch:let name="nemsisElements" value="."/>

    <sch:assert id="Rule_5" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eResponse/nem:eResponse.09"                
                test="ancestor::nem:PatientCareReport/nem:eResponse/nem:eResponse.09 != ''">
      Type of Response Delay (eResponse.09) must equal a valid value other than a NV when En Route Date/Time (eTimes.05)
       is specified.
    </sch:assert>

    <sch:assert id="Rule_16" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eResponse/nem:eResponse.24"                
                test="ancestor::nem:PatientCareReport/nem:eResponse/nem:eResponse.24 != ''">
      Additional Response Mode Descriptors (eResponse.24) must equal a valid value other than a NV when Unit En Route
       Date/Time (eTimes.05) contains a time.
    </sch:assert>

    <sch:assert id="Rule_27" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eTimes.03"
                test="not(../nem:eTimes.03) or xs:dateTime(.) &gt;= xs:dateTime(../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="nemSch_eTimes_r_eTimes06">
  <sch:title>nemSch_eTimes_r_eTimes06</sch:title>
  <sch:rule id="r_eTimes06" context="nem:eTimes.06[. != '']">
    <sch:let name="nemsisElements" value="."/>

    <sch:assert id="Rule_8" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eResponse/nem:eResponse.10"
                test="ancestor::nem:PatientCareReport/nem:eResponse/nem:eResponse.10 != ''">
      Type of Scene Delay (eResponse.10) must equal a valid value other than a NV when Arrived on Scene (eTimes.06) is
       specified.
    </sch:assert>

    <sch:assert id="Rule_13" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eResponse/nem:eResponse.12"
                test="ancestor::nem:PatientCareReport/nem:eResponse/nem:eResponse.12 != ''">
      Type of Turn-Around Delay (eResponse.12) must equal a valid value other than a NV when Unit Arrived on Scene
       Date/Time (eTimes.06) is specified.
    </sch:assert>

    <sch:assert id="Rule_26" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eTimes.05"
                test="../nem:eTimes.05 != ''">
      Unit En Route Date/Time (eTimes.05) must be specified when Unit Arrived on Scene Date/Time (eTimes.06) is
       specified.
    </sch:assert>

    <sch:assert id="Rule_31" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eTimes.05"
                test="not(../nem:eTimes.05) or ../nem:eTimes.05 = '' or xs:dateTime(.) &gt;= xs:dateTime(../nem:eTimes.05)">
      Unit Arrived on Scene Date Time (eTimes.06) must be greater than or equal to Unit En Route Date/Time (eTimes.05).
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eTimes_r_eTimes07">
  <sch:title>nemSch_eTimes_r_eTimes07</sch:title>
  <sch:rule id="r_eTimes07" context="nem:eTimes.07[. != '']">
    <sch:let name="nemsisElements" value="."/>

    <sch:assert id="Rule_30" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eTimes.06"
                test="../nem:eTimes.06 != ''">
      Unit Arrived on Scene Date/Time (eTimes.06) must be specified when Arrived at Patient Date/Time (eTimes.07)
       contains a time.
    </sch:assert>

    <sch:assert id="Rule_33" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eTimes.06"
                test="not(../nem:eTimes.06) or ../nem:eTimes.06 = '' or xs:dateTime(.) &gt;= xs:dateTime(../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:assert id="Rule_112" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eHistory/nem:eHistory.01"
                test="ancestor::nem:PatientCareReport/nem:eHistory/nem:eHistory.01 != ''">
      Barriers to Patient Care (eHistory.01) must equal a valid value other than a NV when Arrived at Patient Date/Time
       (eTimes.07) is specified.
    </sch:assert>

  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eTimes_r34">
  <sch:title>nemSch_eTimes_r34</sch:title>
  <sch:rule id="r34" context="nem:PatientCareReport/nem:eTimes">
    <sch:let name="nemsisElements" value="*"/>
    <sch:assert id="Rule_34" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="nem:eTimes.07 != '' or (not(nem:eTimes.08) and not(nem:eTimes.09))">
      Arrived At Patient Date/Time (eTimes.07) must be specified when either Transfer of EMS Patient Care Date/Time
       (eTimes.08) or Unit Left Scene Date/Time (eTimes.09) contains a time.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eTimes_r36">
  <sch:title>nemSch_eTimes_r36</sch:title>
  <sch:rule id="r36" context="nem:eTimes.08[. != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_36" role="[WARNING]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eTimes.07"
                test="not(../nem:eTimes.07) or ../nem:eTimes.07 = '' or xs:dateTime(.) &gt; xs:dateTime(../nem:eTimes.07)">
      Transfer of EMS Patient Care Date/Time (eTimes.08) must be greater than Arrived at Patient Date/Time (eTimes.07).
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eTimes_r38">
  <sch:title>nemSch_eTimes_r38</sch:title>
  <sch:rule id="r38" context="nem:eTimes.09[. != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_38" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eTimes.07"
                test="not(../nem:eTimes.07) or ../nem:eTimes.07 = '' or xs:dateTime(.) &gt;= xs:dateTime(../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:pattern>

<sch:pattern id="nemSch_eTimes_r_eTimes11">
  <sch:title>nemSch_eTimes_r_eTimes11</sch:title>
  <sch:rule id="r_eTimes11" context="nem:eTimes.11[. != '']">
    <sch:let name="nemsisElements" value="."/>

    <sch:assert id="Rule_11" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eResponse/nem:eResponse.11"
                test="ancestor::nem:PatientCareReport/nem:eResponse/nem:eResponse.11 != ''">
      Type of Transport Delay (eResponse.11) must equal a valid value other than a NV when Patient Arrived at
       Destination Date/Time (eTimes.11) is specified.
    </sch:assert>

    <sch:assert id="Rule_39" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eTimes.09"
                test="../nem:eTimes.09 != ''">
      Unit Left Scene Date/Time (eTimes.09) must be specified when Patient Arrived at Destination (eTimes.11) contains a
       time.
    </sch:assert>

    <sch:assert id="Rule_41" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="../nem:eTimes.09, ."
                test="not(../nem:eTimes.09) or ../nem:eTimes.09 = '' or xs:dateTime(.) &gt;= xs:dateTime(../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:assert id="Rule_43" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="../nem:eTimes.12 != ''">
      Destination Patient Transfer of Care Date/Time (eTimes.12) must be specified when Patient Arrived at Destination
       Date/Time (eTimes.11) contains a time.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eTimes_r_eTimes12">
  <sch:title>nemSch_eTimes_r_eTimes12</sch:title>
  <sch:rule id="r_eTimes12" context="nem:eTimes.12[. != '']">
    <sch:let name="nemsisElements" value="."/>

    <sch:assert id="Rule_42" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="../nem:eTimes.11 != ''">
      Patient Arrived at Destination Date/Time (eTimes.11) must be specified when Destination Patient Transfer of Care
       Date/Time (eTimes.12) contains a time.
    </sch:assert>

    <sch:assert id="Rule_44" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="../nem:eTimes.11, ."
                test="not(../nem:eTimes.11) or ../nem:eTimes.11 = '' or xs:dateTime(.) &gt;= xs:dateTime(../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:pattern>

<sch:pattern id="nemSch_eTimes_r45">
  <sch:title>nemSch_eTimes_r45</sch:title>
  <sch:rule id="r45" context="nem:eTimes.13">
    <sch:let name="nemsisElements" value="."/>

    <sch:assert id="r45_eTimes03" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="../nem:eTimes.03, ."
                test="not(../nem:eTimes.03) or xs:dateTime(.) &gt; xs:dateTime(../nem:eTimes.03)">
      Unit Back in Service Date/Time (eTimes.13) must be greater than Unit Notified by Dispatch Date/Time (eTimes.03).
    </sch:assert>

    <sch:assert id="r45_eTimes05" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="../nem:eTimes.05, ."
                test="not(../nem:eTimes.05) or ../nem:eTimes.05 = '' or xs:dateTime(.) &gt; xs:dateTime(../nem:eTimes.05)">
      Unit Back in Service Date/Time (eTimes.13) must be greater than Unit En Route Date/Time (eTimes.05).
    </sch:assert>

    <sch:assert id="r45_eTimes06" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="../nem:eTimes.06, ."
                test="not(../nem:eTimes.06) or ../nem:eTimes.06 = '' or xs:dateTime(.) &gt; xs:dateTime(../nem:eTimes.06)">
      Unit Back in Service Date/Time (eTimes.13) must be greater than Unit Arrived on Scene Date/Time (eTimes.06).
    </sch:assert>

    <sch:assert id="r45_eTimes07" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="../nem:eTimes.07, ."
                test="not(../nem:eTimes.07) or ../nem:eTimes.07 = '' or xs:dateTime(.) &gt; xs:dateTime(../nem:eTimes.07)">
      Unit Back in Service Date/Time (eTimes.13) must be greater than Arrived at Patient Date/Time (eTimes.07).
    </sch:assert>

    <sch:assert id="r45_eTimes12" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="../nem:eTimes.12, ."
                test="not(../nem:eTimes.12) or ../nem:eTimes.12 = '' or xs:dateTime(.) &gt; xs:dateTime(../nem:eTimes.12)">
      Unit Back in Service Date/Time (eTimes.13) must be greater than Destination Patient Transfer of Care Date/Time
       (eTimes.12).
    </sch:assert>
  </sch:rule>
</sch:pattern>
<?DSDL_INCLUDE_END includes/pattern_eTimes.xml?>


<?DSDL_INCLUDE_START includes/pattern_ePatient.xml?>

<sch:pattern id="nemSch_ePatient_r51">
  <sch:title>nemSch_ePatient_r51</sch:title>
  <sch:rule id="r51" context="nem:ePatient.07[. != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_51" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:ePatient.08"
                test="starts-with(., ../nem:ePatient.08)">
      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="nemSch_ePatient_r56">
  <sch:title>nemSch_ePatient_r56</sch:title>
  <sch:rule id="r56" context="nem:ePatient.15[. = '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_56" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:ePatient.17, ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.27"
                test="../nem:ePatient.17 = '' or ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.27 != '4227001'">
      Patient's Age (ePatient.15) must equal a valid value other than a NV when Date of Birth (ePatient.17) does not
       have a valid date AND (when Unit Disposition (eDisposition.27) equals 4227001 "Patient Contact Made".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_ePatient_r57">
  <sch:title>nemSch_ePatient_r57</sch:title>
  <sch:rule id="r57" context="nem:ePatient.16[. = '']">
    <sch:let name="nemsisElements" value="(., ../nem:ePatient.15)"/>
    <sch:assert id="Rule_57" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="../nem:ePatient.15 = ''">
      Patient's Age Units (ePatient.16) must equal a valid value other than a NV when Patient's Age (ePatient.15) is a
       valid value other than a NV.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_ePatient_r58">
  <sch:title>nemSch_ePatient_r58</sch:title>
  <sch:rule id="r58" context="nem:ePatient.17[. = '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_58" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:ePatient.15, ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.27"
                test="../nem:ePatient.15 = '' or ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.27 != '4227001'">
      Date of Birth (ePatient.17) must equal a valid date when Patient's Age (ePatient.15) does not have a valid value
       other than a NV AND when Unit Disposition (eDisposition.27) equals 4227001 "Patient Contact Made".
    </sch:assert>
  </sch:rule>
</sch:pattern>
<?DSDL_INCLUDE_END includes/pattern_ePatient.xml?>


<?DSDL_INCLUDE_START includes/pattern_eScene.xml?>

<sch:pattern id="nemSch_eScene_r_MCI">
  <sch:title>nemSch_eScene_r_MCI</sch:title>
  <sch:rule id="r_MCI" context="nem:eScene.07[. = '9923003']">
    <sch:let name="nemsisElements" value="."/>

    <sch:assert id="Rule_60" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eScene.06"
                test="../nem:eScene.06 = '2707001'">
      Number of Patients at Scene (eScene.06) must equal 2707001 "Multiple" when Mass Casualty Incident (eScene.07)
       equals 9923003 "Yes".
    </sch:assert>

    <sch:assert id="Rule_63" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eScene.08"
                test="../nem:eScene.08 != ''">
      Triage Classification for MCI Patient (eScene.08) must be a valid value other than a NV when Mass Casualty
       Incident (eScene.07) equals 9923003 "Yes".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eScene_r61">
  <sch:title>nemSch_eScene_r61</sch:title>
  <sch:rule id="r61" context="nem:eScene.06[. = '2707001']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_61" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eScene.07"
                test="../nem:eScene.07 = '9923003'">
      Mass Casualty Incident (eScene.07) must equal 9923003 "Yes" when Number of Patients at Scene (eScene.06) equals
       2707001 "Multiple".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eScene_r62">
  <sch:title>nemSch_eScene_r62</sch:title>
  <sch:rule id="r62" context="nem:eScene.08[. != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_62" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eScene.07"
                test="../nem:eScene.07 = '9923003'">
      Mass Casualty Incident (eScene.07) must equal 9923003 "Yes" when Triage Classification for MCI Patient (eScene.08)
       equals a valid value other than a NV.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eScene_r68">
  <sch:title>nemSch_eScene_r68</sch:title>
  <sch:rule id="r68" context="nem:eScene.21[. != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_68" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eScene.18"
                test="starts-with(., ../nem:eScene.18)">
      Incident State (eScene.18) must equal the first two digits of Incident County (eScene.21).
    </sch:assert>
  </sch:rule>
</sch:pattern>
<?DSDL_INCLUDE_END includes/pattern_eScene.xml?>


<?DSDL_INCLUDE_START includes/pattern_eSituation.xml?>

<sch:pattern id="nemSch_eSituation_r71">
  <sch:title>nemSch_eSituation_r71</sch:title>
  <sch:rule id="r71" context="nem:eSituation.01[. != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_71" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.13, ."
                test="not(ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.13)
                      or xs:dateTime(.) &lt;= xs:dateTime(ancestor::nem:PatientCareReport/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:rule>
</sch:pattern>

<sch:pattern id="nemSch_eSituation_r72">
  <sch:title>nemSch_eSituation_r72</sch:title>
  <sch:rule id="r72" context="nem:eSituation.01[. = '' and not(@PN)]">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_72" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.28"
                test="ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.28 != '4228001'">
      Date/Time of Symptom Onset (eSituation.01) must equal a valid value or PN when Patient Evaluation/Care
       (eDisposition.28) equals 4228001 "Patient Evaluated and Care Provided".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eSituation_r73">
  <sch:title>nemSch_eSituation_r73</sch:title>
  <sch:rule id="r73" context="nem:eSituation.02[. = '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_73" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.28"
                test="ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.28 != '4228001'">
      Possible Injury (eSituation.02) must equal a valid value other than a NV when Patient Evaluation/Care
       (eDisposition.28) equals 4228001 "Patient Evaluated and Care Provided".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eSituation_r87">
  <sch:title>nemSch_eSituation_r87</sch:title>
  <sch:rule id="r87" context="nem:eSituation.02[. = '9922005']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_87" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eInjury/nem:eInjury.01,
                         ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.28"
                test="ancestor::nem:PatientCareReport/nem:eInjury/nem:eInjury.01 != ''
                      or ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.28 != '4228001'">
      Cause of Injury must equal a valid value other than a NV when Patient Evaluation/Care (eDisposition.28) equals
       4228001 "Patient Evaluated and Care Provided." and Possible Injury is "Yes".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eSituation_r88-r89">
  <sch:title>nemSch_eSituation_r88-r89</sch:title>
  <sch:rule id="r88-r89" context="nem:eSituation.02[. != '9922005']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_88" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eInjury/nem:eInjury.03"
                test="not (ancestor::nem:PatientCareReport/nem:eInjury/nem:eInjury.03) or
                       ancestor::nem:PatientCareReport/nem:eInjury/nem:eInjury.03 = ''">
      Trauma Triage Criteria (Steps 1 and 2) (eInjury.03) should only be recorded when Possible Injury is "Yes".
    </sch:assert>

    <sch:assert id="Rule_89" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eInjury/nem:eInjury.04"
                test="not (ancestor::nem:PatientCareReport/nem:eInjury/nem:eInjury.04) or
                       ancestor::nem:PatientCareReport/nem:eInjury/nem:eInjury.04 = ''">
      Trauma Triage Criteria (Steps 3 and 4) (eInjury.04) should only be recorded when Possible Injury is "Yes".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eSituation_r74">
  <sch:title>nemSch_eSituation_r74</sch:title>
  <sch:rule id="r74" context="nem:eSituation.03[. = '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_74" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.28"
                test="ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.28 != '4228001'">
      Complaint Type (eSituation.03) must equal a valid value other than a NV when Patient Evaluation/Care
       (eDisposition.28) equals 4228001 "Patient Evaluated and Care Provided".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eSituation_r75">
  <sch:title>nemSch_eSituation_r75</sch:title>
  <sch:rule id="r75" context="nem:eSituation.04[. = '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_75" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eSituation.03"
                test="../nem:eSituation.03 = ''">
      Complaint (eSituation.04) must equal a valid value other than a NV when Complaint Type (eSituation.03) contains a
       valid value other than a NV.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eSituation_r76">
  <sch:title>nemSch_eSituation_r76</sch:title>
  <sch:rule id="r76" context="nem:eSituation.07[. = '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_76" role="[WARNING]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eSituation.03"
                test="../nem:eSituation.03 = ''">
      Chief Complaint Anatomic Location (eSituation.07) must equal a valid value other than a NV when Complaint Type
       (eSituation.03) contains a valid value other than a NV.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eSituation_r77">
  <sch:title>nemSch_eSituation_r77</sch:title>
  <sch:rule id="r77" context="nem:eSituation.08[. = '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_77" role="[WARNING]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eSituation.03"
                test="../nem:eSituation.03 = ''">
      Chief Complaint Organ System (eSituation.08) must equal a valid value other than a NV when Complaint Type
       (eSituation.03) contains a valid value other than a NV.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eSituation_r78">
  <sch:title>nemSch_eSituation_r78</sch:title>
  <sch:rule id="r78" context="nem:eSituation.09[. = '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_78" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.28"
                test="ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.28 != '4228001'">
      Primary Symptom (eSituation.09) must equal a valid value other than a NV when Patient Evaluation/Care
       (eDisposition.28) equals 4228001 "Patient Evaluated and Care Provided".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eSituation_r79">
  <sch:title>nemSch_eSituation_r79</sch:title>
  <sch:rule id="r79" context="nem:eSituation.11[. = '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_79" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.28"
                test="ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.28 != '4228001'">
      Provider's Primary Impression (eSituation.11) must equal a valid value other than a NV when Patient
       Evaluation/Care (eDisposition.28) equals 4228001 "Patient Evaluated and Care Provided".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eSituation_r80">
  <sch:title>nemSch_eSituation_r80</sch:title>
  <sch:rule id="r80" context="nem:eSituation.13[. = '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_80" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.28"
                test="ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.28 != '4228001'">
      Initial Patient Acuity (eSituation.13) must equal a valid value other than a NV when Patient Evaluation/Care
       (eDisposition.28) equals 4228001 "Patient Evaluated and Care Provided".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eSituation_r81">
  <sch:title>nemSch_eSituation_r81</sch:title>
  <sch:rule id="r81" context="nem:eSituation.14[. = '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_81" role="[WARNING]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.28"
                test="ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.28 != '4228001'">
      Work-Related Illness/Injury (eSituation.14) must equal a valid value other than a NV when Patient Evaluation/Care
       (eDisposition.28) equals 4228001 "Patient Evaluated and Care Provided".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eSituation_r82">
  <sch:title>nemSch_eSituation_r82</sch:title>
  <sch:rule id="r82" context="nem:eSituation.18[. != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_82" role="[WARNING]" diagnostics="nemsisDiagnostic"
                subject="ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.03, ."
                test="not(ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.03)
                      or xs:dateTime(.) &lt; xs:dateTime(ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.03)">
      Date/Time Last Known Well (eSituation.18) must be less than Unit Notified by Dispatch Date/Time (eTimes.03).
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eSituation_r83-r84">
  <sch:title>nemSch_eSituation_r83-r84</sch:title>
  <sch:rule id="r83" context="nem:eSituation.18[. = '' and not(@PN)]">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_83" role="[WARNING]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eArrest/nem:eArrest.01,
                         ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.28"
                test="ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.28 != '4228001'
                      or not(ancestor::nem:PatientCareReport/nem:eArrest/nem:eArrest.01 = ('3001003', '3001005'))">
      Date/Time Last Known Well must equal a valid value or PN when Patient Evaluation/Care (eDisposition.28) equals
       4228001 "Patient Evaluated and Care Provided." and Cardiac Arrest is "Yes, ...".
    </sch:assert>

    <sch:assert id="Rule_84" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eVitals/nem:eVitals.VitalGroup/nem:eVitals.StrokeScaleGroup/nem:eVitals.29,
                         ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.28"
                test="ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.28 != '4228001'
                      or not(ancestor::nem:PatientCareReport/nem:eVitals/nem:eVitals.VitalGroup/nem:eVitals.StrokeScaleGroup/nem:eVitals.29 = '3329005')">
      Date/Time Last Known Well must equal a valid value or PN when Patient Evaluation/Care (eDisposition.28) equals
       4228001 "Patient Evaluated and Care Provided" and Stroke Scale Score is "Positive".
    </sch:assert>
  </sch:rule>
</sch:pattern>
<?DSDL_INCLUDE_END includes/pattern_eSituation.xml?>

<?DSDL_INCLUDE_START includes/pattern_eArrest.xml?>

<sch:pattern id="nemSch_eArrest_r_eArrest01">
  <sch:title>nemSch_eArrest_r_eArrest01</sch:title>
  <sch:rule id="r_eArrest01" context="nem:eArrest.01[. = ('3001003', '3001005')]">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_91" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eArrest.02"
                test="../nem:eArrest.02 != ''">
      Cardiac Arrest Etiology (eArrest.02) must equal a valid value other than a NV when Cardiac Arrest (eArrest.01) has
       a value of "Yes, After Any EMS Arrival" or "Yes, Prior to Any EMS Arrival".
    </sch:assert>

    <sch:assert id="Rule_92" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eArrest.03"
                test="../nem:eArrest.03 != ''">
      Resuscitation Attempted by EMS (eArrest.03) must equal a valid value other than a NV when Cardiac Arrest
       (eArrest.01) has a value of "Yes, After Any EMS Arrival" or "Yes, Prior to Any EMS Arrival".
    </sch:assert>

    <sch:assert id="Rule_98" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eArrest.04"
                test="../nem:eArrest.04 != ''">
      Arrest Witness By (eArrest.04) must equal a valid value other than a NV when Cardiac Arrest (eArrest.01) has a
       value of "Yes, After Any EMS Arrival" or "Yes, Prior to Any EMS Arrival".
    </sch:assert>

    <sch:assert id="Rule_105" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eArrest.14"
                test="../nem:eArrest.14 != ''">
      Date/Time of Cardiac Arrest (eArrest.14) must be entered when Cardiac Arrest (eArrest.01) has a value of "Yes,
       After Any EMS Arrival" or "Yes, Prior to Any EMS Arrival".
    </sch:assert>

    <sch:assert id="Rule_107" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eArrest.17, ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.30"
                test="../nem:eArrest.17 != '' 
                      or not(ancestor::nem:PatientCareReport/nem:eDisposition/nem:eDisposition.IncidentDispositionGroup/nem:eDisposition.30 = ('4230001', '4230003'))">
      Cardiac Rhythm on Arrival at Destination (eArrest.17) must equal a valid value other than a NV when Cardiac Arrest
       (eArrest.01) has a value of "Yes, After Any EMS Arrival" or "Yes, Prior to Any EMS Arrival" AND Transport
        Disposition (eDisposition.30) equals a "Transport by This EMS Unit..." value (4230001, 4230003).
    </sch:assert>

    <sch:assert id="Rule_108" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eArrest.18"
                test="../nem:eArrest.18 != ''">
      End of EMS Cardiac Arrest Event (eArrest.18) must equal a valid value other than a NV when Cardiac Arrest
       (eArrest.01) has a value of "Yes, After Any EMS Arrival" or "Yes, Prior to Any EMS Arrival".
    </sch:assert>

  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eArrest_r93">
  <sch:title>nemSch_eArrest_r93</sch:title>
  <sch:rule id="r93" context="nem:eArrest.03[. = '3003009']">
    <sch:let name="nemsisElements" value="../nem:eArrest.03"/>
    <sch:assert id="Rule_93" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="not(../nem:eArrest.03 = ('3003001', '3003003', '3003005'))">
      Resuscitation Attempted by EMS (eArrest.03) cannot contain 3003009 "Not Attempted-DNR Orders" and one of the
       following values in the same record: "Attempted Defibrillation", "Attempted Ventilation",
        "Initiated Chest Compressions".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eArrest_r94">
  <sch:title>nemSch_eArrest_r94</sch:title>
  <sch:rule id="r94" context="nem:eArrest.03[. = '3003011']">
    <sch:let name="nemsisElements" value="../nem:eArrest.03"/>
    <sch:assert id="Rule_94" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="not(../nem:eArrest.03 = ('3003001', '3003003', '3003005'))">
      Resuscitation Attempted by EMS (eArrest.03) cannot contain 3003011 "Not Attempted-Signs of Circulation" and one
       of the following values in the same record: "Attempted Defibrillation", "Attempted Ventilation",
        "Initiated Chest Compressions".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eArrest_r95">
  <sch:title>nemSch_eArrest_r95</sch:title>
  <sch:rule id="r95" context="nem:eArrest.03[. = '3003007']">
    <sch:let name="nemsisElements" value="../nem:eArrest.03"/>
    <sch:assert id="Rule_95" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="not(../nem:eArrest.03 = ('3003001', '3003003', '3003005'))">
      Resuscitation Attempted by EMS (eArrest.03) cannot contain a value of 3003007 "Not Attempted-Considered Futile"
       and one of the following values in the same record: "Attempted Defibrillation", "Attempted Ventilation",
        "Initiated Chest Compressions".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eArrest_r96">
  <sch:title>nemSch_eArrest_r96</sch:title>
  <sch:rule id="r96" context="nem:eArrest.09[. = ('3009013', '3009015', '3009017', '3009019', '3009023', '3009025', '3009027')]">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_96" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eArrest.03"
                test="../nem:eArrest.03 = '3003003'">
      Resuscitation Attempted by EMS (eArrest.03) must include 3003003 "Attempted Ventilation" when Type of CPR Provided
       (eArrest.09) contains "Ventilation..." or "Compressions-Intermittent with Ventilation".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eArrest_r97">
  <sch:title>nemSch_eArrest_r97</sch:title>
  <sch:rule id="r97" context="nem:eArrest.09[. = ('3009001', '3009003', '3009005', '3009007', '3009009', '3009011', '3009021')]">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_97" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eArrest.03"
                test="../nem:eArrest.03 = '3003005'">
      Resuscitation Attempted by EMS (eArrest.03) should contain 3003005 "Initiated Chest Compressions" when Type of CPR
       Provided (eArrest.09) contains "Compressions...".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eArrest_r99">
  <sch:title>nemSch_eArrest_r99</sch:title>
  <sch:rule id="r99" context="nem:eArrest.04[. != ''][1]">
    <sch:let name="nemsisElements" value="../nem:eArrest.04[. != '']"/>
    <sch:assert id="Rule_99" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="not(../nem:eArrest.04 = '3004001') or count(../nem:eArrest.04) = 1">
      When Arrest Witnessed By (eArrest.04) equals 3004001 "Not Witnessed" it must not also equal any other value.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eArrest_r100">
  <sch:title>nemSch_eArrest_r100</sch:title>
  <sch:rule id="r100" context="nem:eArrest.01[. = '3001003']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_100" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eArrest.07"
                test="../nem:eArrest.07 != ''">
      AED Use Prior to EMS Arrival (eArrest.07) must equal a valid value other than a NV when Cardiac Arrest
       (eArrest.01) has a value of 3001003 "Yes, Prior to Any EMS Arrival".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eArrest_r101">
  <sch:title>nemSch_eArrest_r101</sch:title>
  <sch:rule id="r101" context="nem:eArrest.03[. = '3003005']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_101" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eArrest.09"
                test="../nem:eArrest.09 = ('3009001', '3009003', '3009005', '3009007', '3009009', '3009011', '3009021')">
      Type of CPR Provided (eArrest.09) must include a "Compressions" value when Resuscitation Attempted by EMS
       (eArrest.03) includes 3003005 "Initiated Chest Compressions".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eArrest_r102">
  <sch:title>nemSch_eArrest_r102</sch:title>
  <sch:rule id="r102" context="nem:eArrest.03[. = '3003003']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_102" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eArrest.09"
                test="../nem:eArrest.09 = ('3009009', '3009013', '3009015', '3009017', '3009019', '3009023', '3009025', '3009027')">
      Type of CPR Provided (eArrest.09) should include a "Ventilation" value when Resuscitation Attempted (eArrest.03)
       by EMS includes 3003003 "Attempted Ventilation".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eArrest_r103">
  <sch:title>nemSch_eArrest_r103</sch:title>
  <sch:rule id="r103" context="nem:eArrest.01[. = '3001005']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_103" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eArrest.11"
                test="../nem:eArrest.11 != ''">
      First Monitored Arrest Rhythm of the Patient (eArrest.11) must equal a valid value other than a NV when Cardiac
       Arrest (eArrest.01) has a value of 3001005 "Yes, After Any EMS Arrival."
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eArrest_r104">
  <sch:title>nemSch_eArrest_r104</sch:title>
  <sch:rule id="r104" context="nem:eArrest.03[. = ('3003001', '3003003', '3003005')]">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_104" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eArrest.12"
                test="../nem:eArrest.12 != ''">
      Any Return of Spontaneous Circulation (eArrest.12) must equal a valid value other than a NV when Resuscitation
       Attempted by EMS (eArrest.03) equals any of the following: "Attempted Defibrillation", "Attempted Ventilation",
        "Initiated Chest Compressions".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eArrest_r106">
  <sch:title>nemSch_eArrest_r106</sch:title>
  <sch:rule id="r106" context="nem:eArrest.18[. = ('3018003', '3018007', '3018009')]">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_106" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eArrest.16"
                test="../nem:eArrest.16 != ''">
      Reason CPR/Resuscitation Discontinued (eArrest.16) must contain a valid value other than a NV if End of Cardiac
       Arrest Event (eArrest.18) equals "ROSC in the Field," "ROSC in the ED", or "Expired in the Field".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eArrest_r109">
  <sch:title>nemSch_eArrest_r109</sch:title>
  <sch:rule id="r109" context="nem:eArrest.20[. = '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_109" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eArrest.01, ../nem:eArrest.03"
                test="not(../nem:eArrest.03 = '3003005') and not(../nem:eArrest.01 = ('3001003', '3001005'))">
      Who First Initiated CPR (eArrest.20) should equal a valid value other than a NV when Cardiac Arrest (eArrest.01)
       has a value of "Yes, After Any EMS Arrival" or "Yes, Prior to Any EMS Arrival", OR when Resuscitation Attempted
        by EMS (eArrest.03) equals 3003005 "Initiated Chest Compressions".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eArrest_r110">
  <sch:title>nemSch_eArrest_r110</sch:title>
  <sch:rule id="r110" context="nem:eArrest.21[. = '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_110" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eArrest.07, ../nem:eArrest.11"
                test="not(../nem:eArrest.07 = ('3007003', '3007005')) and not(../nem:eArrest.11 = ('3011007', '3011009'))">
      Who First Applied the AED (eArrest.21) should equal a valid value other than a NV when AED Use Prior to EMS
       Arrival (eArrest.07) equals "Yes, Applied without Defibrillation" or "Yes, with Defibrillation" OR when First
        Monitored Arrest Rhythm of the Patient (eArrest.11) equals "Unknown AED Shockable Rhythm" or "Unknown AED
         Non-Shockable Rhythm".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eArrest_r111">
  <sch:title>nemSch_eArrest_r111</sch:title>
  <sch:rule id="r111" context="nem:eArrest.22[. = '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_111" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eArrest.07, ../nem:eArrest.03"
                test="not(../nem:eArrest.03 = '3003001') and not(../nem:eArrest.07 = '3007005')">
      Who First Defibrillated Patient (eArrest.22) should equal a valid value other than a NV when AED Use Prior to EMS
       Arrival (eArrest.07) equals 3007005 "Yes, with Defibrillation" OR when Resuscitation Attempted by EMS
        (eArrest.03) includes 3003001 "Attempted Defibrillation".
    </sch:assert>
  </sch:rule>
</sch:pattern>
<?DSDL_INCLUDE_END includes/pattern_eArrest.xml?>


<?DSDL_INCLUDE_START includes/pattern_eNarrative.xml?>

<sch:pattern id="nemSch_eNarrative_r118">
  <sch:title>nemSch_eNarrative_r118</sch:title>
  <sch:rule id="r118" context="nem:eNarrative">
    <sch:let name="nemsisElements" value="*"/>
    <sch:assert id="Rule_118" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="./nem:eNarrative.01 != ''">
      Patient Care Report Narrative (eNarrative.01) must be entered.
    </sch:assert>
  </sch:rule>
</sch:pattern>
<?DSDL_INCLUDE_END includes/pattern_eNarrative.xml?>


<?DSDL_INCLUDE_START includes/pattern_eVitals.xml?>

<sch:pattern id="nemSch_eVitals_r119">
  <sch:title>nemSch_eVitals_r119</sch:title>
  <sch:rule id="r119" context="nem:eVitals.02[. = '9923001']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_119" role="[ERROR]" diagnostics="nemsisDiagnostic"
                 subject="., ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07, ../nem:eVitals.01"
                 test="not(ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07) or
                       ../nem:eVitals.01 = '' or
                       xs:dateTime(../nem:eVitals.01) &gt;= xs:dateTime(ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07)">
      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:rule>
</sch:pattern>

<sch:pattern id="nemSch_eVitals_r120">
  <sch:title>nemSch_eVitals_r120</sch:title>
  <sch:rule id="r120" context="nem:eVitals.01">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_120" role="[ERROR]" diagnostics="nemsisDiagnostic"
                 subject="., ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.13"
                 test="not(ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.13) or
                       . = '' or
                       xs:dateTime(.) &lt;= xs:dateTime(ancestor::nem:PatientCareReport/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:rule>
</sch:pattern>

<sch:pattern id="nemSch_eVitals_r121">
  <sch:title>nemSch_eVitals_r121</sch:title>
  <sch:rule id="r121" context="nem:eVitals.VitalGroup">
    <sch:let name="nemsisElements" value="*"/>
    <sch:assert id="Rule_121" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="nem:eVitals.01[. != ''] or nem:eVitals.02[. != '9923001'] or not(
                  descendant::nem:eVitals.03[(. != '') and (not(@PN != ''))]|
                  descendant::nem:eVitals.04[(. != '')]|
                  descendant::nem:eVitals.05[(. != '')]|
                  descendant::nem:eVitals.06[(. != '') and (not(@PN != ''))]|
                  descendant::nem:eVitals.07[(. != '') and (not(@PN != ''))]|
                  descendant::nem:eVitals.08[(. != '')]|
                  descendant::nem:eVitals.09[(. != '')]|
                  descendant::nem:eVitals.10[(. != '') and (not(@PN != ''))]|
                  descendant::nem:eVitals.11[(. != '')]|
                  nem:eVitals.12[(. != '') and (not(@PN != ''))]|
                  nem:eVitals.13[(. != '')]|
                  nem:eVitals.14[(. != '') and (not(@PN != ''))]|
                  nem:eVitals.15[(. != '')]|
                  nem:eVitals.16[(. != '') and (not(@PN != ''))]|
                  nem:eVitals.17[(. != '') and (not(@PN != ''))]|
                  nem:eVitals.18[(. != '') and (not(@PN != ''))]|
                  descendant::nem:eVitals.19[(. != '') and (not(@PN != ''))]|
                  descendant::nem:eVitals.20[(. != '') and (not(@PN != ''))]|
                  descendant::nem:eVitals.21[(. != '') and (not(@PN != ''))]|
                  descendant::nem:eVitals.22[(. != '')]|
                  descendant::nem:eVitals.23[(. != '') and (not(@PN != ''))]|
                  descendant::nem:eVitals.24[(. != '') and (not(@PN != ''))]|
                  descendant::nem:eVitals.25[(. != '')]|
                  nem:eVitals.26[(. != '')]|
                  descendant::nem:eVitals.27[(. != '') and (not(@PN != ''))]|
                  descendant::nem:eVitals.28[(. != '')]|
                  descendant::nem:eVitals.29[(. != '') and (not(@PN != ''))]|
                  descendant::nem:eVitals.30[(. != '')]|
                  nem:eVitals.31[(. != '') and (not(@PN != ''))]|
                  nem:eVitals.32[(. != '') and (not(@PN != ''))]|
                  nem:eVitals.33[(. != '') 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.03 through eVitals.33 equals a PN or
        another value other than a NV.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eVitals_r122">
  <sch:title>nemSch_eVitals_r122</sch:title>
  <sch:rule id="r122" context="nem:eVitals.02[. = '9923003']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_122" role="[ERROR]" diagnostics="nemsisDiagnostic"
                 subject="ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07, ., ../nem:eVitals.01"
                 test="../nem:eVitals.01 = '' 
                    or not(ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07) 
                    or ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07 = '' 
                    or xs:dateTime(../nem:eVitals.01) &lt; xs:dateTime(ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07)">
      Date/Time Vitals Signs Taken (eVitals.01) must be blank or less than Arrived at Patient Date/Time (eTimes.07) when
       Obtained Prior to this Unit's EMS Care (eVitals.02) is "Yes".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eVitals_r123">
  <sch:title>nemSch_eVitals_r123</sch:title>
  <sch:rule id="r123" context="nem:eVitals.01[. != '']">
    <sch:let name="nemsisElements" value="../nem:eVitals.01"/>
    <sch:assert id="Rule_123" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eVitals.02"
                test="../nem:eVitals.02 != ''">
      Obtained Prior to this Unit's EMS Care (eVitals.02) must equal a valid value other than a NV when Date/Time Vital
       Signs Taken (eVitals.01) is not blank.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eVitals_r124">
  <sch:title>nemSch_eVitals_r124</sch:title>
  <sch:rule id="r124" context="nem:eVitals.05[. != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_124" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eVitals.03"
                test="../nem:eVitals.03[. != '' or @PN]">
      Cardiac Rhythm/Electrocardiography (ECG) (eVitals.03) must equal a valid value or PN when Method of ECG
       Interpretation (eVitals.05) equals a valid value.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eVitals_r_eVitals03">
  <sch:title>nemSch_eVitals_r_eVitals03</sch:title>
  <sch:rule id="r_eVitals03" context="nem:eVitals.03[. != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_125" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eVitals.04"
                test="../nem:eVitals.04 != ''">
      ECG Type (eVitals.04) must equal a valid value other than a NV when Cardiac Rhythm/Electrocardiography (ECG)
       (eVitals.03) equals a valid value.
    </sch:assert>

    <sch:assert id="Rule_126" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eVitals.05"
                test="../nem:eVitals.05 != ''">
      Method of ECG Interpretation (eVitals.05) must equal a valid value other than a NV when Cardiac
       Rhythm/Electrocardiography (ECG) (eVitals.03) equals a valid value.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eVitals_r_BloodPressureGroup">
  <sch:title>nemSch_eVitals_r_BloodPressureGroup</sch:title>
  <sch:rule id="r_BloodPressureGroup" context="nem:eVitals.BloodPressureGroup">
    <sch:let name="nemsisElements" value="*"/>
    <sch:assert id="Rule_127" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="nem:eVitals.06[. != '' or @PN != ''] or not(nem:eVitals.08 != '')">
      SBP (Systolic Blood Pressure) (eVitals.06) must be a valid value or have a PN when Method of Blood Pressure
       Measurement (eVitals.08) equals a valid value other than a NV.
    </sch:assert>

    <sch:assert id="Rule_128" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="nem:eVitals.06[. != ''] or not(nem:eVitals.07 != '')">
      SBP (Systolic Blood Pressure) (eVitals.06) must be a valid value when DBP (Diastolic Blood Pressure) (eVitals.07)
       equals a valid value other than a NV or PN.
    </sch:assert>

    <sch:assert id="Rule_129" 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 NV when either SBP 
      (Systolic Blood Pressure) (eVitals.06) is not blank or a NV or PN, or DBP (Diastolic Blood Pressure) (eVitals.07)
       is not blank or an NV or PN.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eVitals_r_eVitals23">
  <sch:title>nemSch_eVitals_r_eVitals23</sch:title>
  <sch:rule id="r_eVitals23" context="nem:eVitals.23[. != '']">
   <sch:let name="nemsisElements" value="."/>

   <sch:assert id="Rule_130" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../../nem:eVitals.02, ../nem:eVitals.19"
                test="../../nem:eVitals.02 != '9923001' or ../nem:eVitals.19 != ''">
      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 (eVitals.02)
        = "No".
    </sch:assert>

   <sch:assert id="Rule_131" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../../nem:eVitals.02, ../nem:eVitals.20"
                test="../../nem:eVitals.02 != '9923001' or ../nem:eVitals.20 != ''">
      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 (eVitals.02)
        = "No".
    </sch:assert>

   <sch:assert id="Rule_132" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../../nem:eVitals.02, ../nem:eVitals.21"
                test="../../nem:eVitals.02 != '9923001' or ../nem:eVitals.21 != ''">
      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 (eVitals.02)
        = "No".
    </sch:assert>

   <sch:assert id="Rule_133" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../../nem:eVitals.02, ../nem:eVitals.22"
                test="../../nem:eVitals.02 != '9923001' or ../nem:eVitals.22 != ''">
      Glasgow Coma Score-Qualifier (eVitals.22) must equal a valid value other than a NV when Total Glasgow Coma Score
       (eVitals.23) equals a value in the range 3-15, inclusive, and Obtained Prior to this Units EMS Care (eVitals.02)
        = "No".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eVitals_r134">
  <sch:title>nemSch_eVitals_r134</sch:title>
  <sch:rule id="r134" context="nem:eVitals.22[. = '3322003'][1]">
    <sch:let name="nemsisElements" value="../nem:eVitals.22"/>
    <sch:assert id="Rule_134" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="count(../nem:eVitals.22) = 1">
      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:rule>
</sch:pattern>

<sch:pattern id="nemSch_eVitals_r135">
  <sch:title>nemSch_eVitals_r135</sch:title>
  <sch:rule id="r135" context="nem:eVitals.28[. != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_135" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eVitals.27"
                test="../nem:eVitals.27[. != '']">
      Pain Score (eVitals.27) cannot equal a NV, a PN, or be empty when Pain Scale Type (eVitals.28) has a value other
       than a NV.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eVitals_r136">
  <sch:title>nemSch_eVitals_r136</sch:title>
  <sch:rule id="r136" context="nem:eVitals.27[. != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_136" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eVitals.28"
                test="../nem:eVitals.28[. != '']">
      Pain Scale Type (eVitals.28) cannot equal a NV or be empty when Pain Score (eVitals.27) has a value other than a
       PN or NV.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eVitals_r137">
  <sch:title>nemSch_eVitals_r137</sch:title>
  <sch:rule id="r137" context="nem:eVitals.StrokeScaleGroup">
    <sch:let name="nemsisElements" value="*"/>
    <sch:assert id="Rule_137" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="nem:eVitals.29[. != '' or @PN != ''] or not(nem:eVitals.30 != '')">
      Stroke Scale Score (eVitals.29) must equal either a PN or another valid value other than a NV when Stroke Scale
       Type (eVitals.30) equals a valid value other than a NV.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eVitals_r138">
  <sch:title>nemSch_eVitals_r138</sch:title>
  <sch:rule id="r138" context="nem:PatientCareReport/nem:eVitals">
    <sch:let name="nemsisElements" value="nem:eVitals.VitalGroup"/>
    <sch:assert id="Rule_138" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="not((count(nem:eVitals.VitalGroup/nem:eVitals.StrokeScaleGroup[((nem:eVitals.29 and nem:eVitals.29[. != '' or @PN]))]) &lt; 1) 
                and ((matches(../nem:eSituation/nem:eSituation.11, '^(I63|G45)')) 
                    or count(../nem:eSituation/nem:eSituation.12[matches(text(), '^(I63|G45)')]) != 0))">
      Stroke Scale Score (eVitals.29) must equal a PN or another value other than a NV when Provider Primary Impression
       (eSituation.11) or Secondary Impression (eSituation.12) begins with I63 or G45.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eVitals_r139">
  <sch:title>nemSch_eVitals_r139</sch:title>
  <sch:rule id="r139" context="nem:eVitals.29[. != '' and not(@PN)]">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_139" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eVitals.30"
                test="../nem:eVitals.30 != ''">
      Stroke Scale Type (eVitals.30) must equal a valid value other than a NV when Stroke Scale Score (eVitals.29)
       equals a value other than a NV and does not contain a PN.
    </sch:assert>
  </sch:rule>
</sch:pattern>
<?DSDL_INCLUDE_END includes/pattern_eVitals.xml?>


<?DSDL_INCLUDE_START includes/pattern_eProtocols.xml?>

<sch:pattern id="nemSch_eProtocols_r142">
  <sch:title>nemSch_eProtocols_r142</sch:title>
  <sch:rule id="r142" context="nem:eProtocols.01[. != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_142" role="[WARNING]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eProtocols.02"
                test="../nem:eProtocols.02 != ''">
      Protocol Age Category (eProtocols.02) must contain a valid value when Protocols Used (eProtocol.01) contains a
       valid value.
    </sch:assert>
  </sch:rule>
</sch:pattern>
<?DSDL_INCLUDE_END includes/pattern_eProtocols.xml?>


<?DSDL_INCLUDE_START includes/pattern_eMedications.xml?>

<sch:pattern id="nemSch_eMedications_r146">
  <sch:title>nemSch_eMedications_r146</sch:title>
  <sch:rule id="r146" context="nem:eMedications.01[. != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_146" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.13, ."
                test="not(ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.13) or 
                      xs:dateTime(.) &lt;= xs:dateTime(ancestor::nem:PatientCareReport/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:rule>
</sch:pattern>

<sch:pattern id="nemSch_eMedications_r144">
  <sch:title>nemSch_eMedications_r144</sch:title>
  <sch:rule id="r144" context="nem:eMedications.02[. = '9923001']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_144" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eMedications.01, ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07"
                test="not(ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07) or 
                      ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07 = '' or 
                      (../nem:eMedications.01 != '' and
                       xs:dateTime(../nem:eMedications.01) &gt;= xs:dateTime(ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07))">
      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:rule>
</sch:pattern>

<sch:pattern id="nemSch_eMedications_r145">
  <sch:title>nemSch_eMedications_r145</sch:title>
  <sch:rule id="r145" context="nem:eMedications.02[. = '9923003']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_145" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07, ., ../nem:eMedications.01"
                test="not(ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07) or 
                      ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07 = '' or 
                      (../nem:eMedications.01 != '' and 
                       xs:dateTime(../nem:eMedications.01) &lt; xs:dateTime(ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07))">
      Date/Time Medication Administered (eMedications.01) must be less than Arrived at Patient Date/Time (eTimes.07)
       when Medication Administered Prior to this Unit's EMS Care (eMedications.02) equals "Yes".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eMedications_r148">
  <sch:title>nemSch_eMedications_r148</sch:title>
  <sch:rule id="r148" context="nem:eMedications.02[. != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_148" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eMedications.03"
                test="../nem:eMedications.03 != ''">
      Medication Given (eMedications.03) must have a valid RX Norm or SNOMED-CT value when Medication Administered Prior
       to this Unit's EMS Care (eMedications.02) has a valid value other than a NV.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eMedications_r_MedAdmin">
  <sch:title>nemSch_eMedications_r_MedAdmin</sch:title>
  <sch:rule id="r_MedAdmin" context="nem:eMedications.03[. != '' and not(@PN)]">
    <sch:let name="nemsisElements" value="."/>

    <sch:assert id="Rule_143" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eMedications.01, ../nem:eMedications.02"
                test="not(../nem:eMedications.02 = '9923001') or ../nem:eMedications.01 != ''">
      Date/time Medication Administered (eMedications.01) must equal a valid value other than a NV when Medication Given
       (eMedication.03) has a valid value other than a NV (without a PN) and Medication Administered Prior to this
        Unit's EMS Care (eMedications.02) has a value of "No".
    </sch:assert>

    <sch:assert id="Rule_147" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="../nem:eMedications.02"
                test="../nem:eMedications.02 != ''">
      Medication Administered Prior to this Unit's EMS Care (eMedications.02) must equal a valid value other than a NV
       when Medication Given (eMedications.03) has a value no PNs.
    </sch:assert>

    <sch:assert id="Rule_149" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="../nem:eMedications.04"
                test="../nem:eMedications.04[. != '' or @PN != '']">
      Medication Administered Route (eMedications.04) must equal a valid value other than an NV when Medication Given
       (eMedication.03) has a value and no PNs.
    </sch:assert>

    <sch:assert id="Rule_150" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="../nem:eMedications.DosageGroup/nem:eMedications.05"
                test="../nem:eMedications.DosageGroup/nem:eMedications.05 != ''">
      Medication Dosage (eMedications.05) must equal a valid value other than a NV when Medication Given
       (eMedication.03) has a value and no PNs.
    </sch:assert>

    <sch:assert id="Rule_152" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eMedications.02, ../nem:eMedications.07"
                test="../nem:eMedications.02 = '9923003' or ../nem:eMedications.07 != ''">
      Response to Medication (eMedications.07) must equal a valid value other than a NV when Medication Given
       (eMedication.03) has a value and no PN unless Medication Administered Prior to this Units EMS Care
        (eMedications.02) = "Yes".
    </sch:assert>

    <sch:assert id="Rule_153" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eMedications.02, ../nem:eMedications.08"
                test="../nem:eMedications.02 = '9923003' or ../nem:eMedications.08 != ''">
      Medication Complication (eMedications.08) must equal a valid value other than a NV when Medication Given
       (eMedication.03) has a value and no PN unless Medication Administered Prior to this Units EMS Care
        (eMedications.02) = "Yes".
    </sch:assert>

    <sch:assert id="Rule_155" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eMedications.02, ../nem:eMedications.10"
                test="../nem:eMedications.02 = '9923003' or ../nem:eMedications.10 != ''">
      Role/Type of Person Administering Medication (eMedications.10) must equal a valid value other than an NV when
       Medication Given (eMedication.03) has a value and no PN unless Medication Administered Prior to this Units EMS
        Care (eMedications.02) = "Yes".
    </sch:assert>

    <sch:assert id="Rule_156" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eMedications.02, ../nem:eMedications.11"
                test="../nem:eMedications.02 = '9923003' or ../nem:eMedications.11 != ''">
      Medication Authorization (eMedications.11) must equal a valid value other than an NV when Medication Given
       (eMedication.03) has a value and no PN unless Medication Administered Prior to this Units EMS Care
        (eMedications.02) = "Yes".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eMedications_r151">
  <sch:title>nemSch_eMedications_r151</sch:title>
  <sch:rule id="r151" context="nem:eMedications.05[. != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_151" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="../nem:eMedications.06"
                test="../nem:eMedications.06 != ''">
      Medication Dosage Units (eMedications.06) must equal a valid value other than a NV when Medication Dosage
       (eMedications.05) equals a valid value other than a NV.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eMedications_r154">
  <sch:title>nemSch_eMedications_r154</sch:title>
  <sch:rule id="r154" context="nem:eMedications.08[. = '3708031'][1]">
    <sch:let name="nemsisElements" value="../nem:eMedications.08"/>
    <sch:assert id="Rule_154" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="count(../nem:eMedications.08) = 1">
      When Medication Complication (eMedications.08) equals "None" there must not be any other values selected.
    </sch:assert>
  </sch:rule>
</sch:pattern>
<?DSDL_INCLUDE_END includes/pattern_eMedications.xml?>


<?DSDL_INCLUDE_START includes/pattern_eProcedures.xml?>

<sch:pattern id="nemSch_eProcedures_r_eProcedure01">
  <sch:title>nemSch_eProcedures_r_eProcedure01</sch:title>
  <sch:rule id="r_eProcedure01" context="nem:eProcedures.01[. != '']">
    <sch:let name="nemsisElements" value="."/>

    <sch:assert id="Rule_158" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.13"
                test="not(ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.13) or
                      xs:dateTime(.) &lt;= xs:dateTime(ancestor::nem:PatientCareReport/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_159" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eProcedures.02, ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07"
                test="not(ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07) or
                    ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07 = '' or ../nem:eProcedures.02 = '9923003' or
                    xs:dateTime(.) &gt;= xs:dateTime(ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07)">
      Date/Time Procedure Performed (eProcedures.01) must be greater than or equal to Arrived at Patient Date/Time
       (eTimes.07) unless Procedure Performed Prior to this Unit's EMS Care (eProcedures.02) = "Yes".
    </sch:assert>

    <sch:assert id="Rule_160" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eProcedures.02, ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07"
                test="not(ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07) or
                 ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07 = '' or ../nem:eProcedures.02 != '9923003' or
                 xs:dateTime(.) &lt; xs:dateTime(ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07)">
      Date/Time Procedure Performed (eProcedures.01) must be less than Arrived at Patient Date/Time (eTimes.07) or
       blank when Procedure Performed Prior to this Unit's EMS Care (eProcedures.02) = "Yes".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eProcedures_r162">
  <sch:title>nemSch_eProcedures_r162</sch:title>
  <sch:rule id="r162" context="nem:eProcedures.02[. != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_162" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eProcedures.03"
                test="../nem:eProcedures.03 != ''">
      Procedure (eProcedures.03) must equal a valid value other than a NV when Procedure Performed Prior to this Unit's
       EMS Care (eProcedures.02) has a valid value other than a NV.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eProcedures_r161">
  <sch:title>nemSch_eProcedures_r161</sch:title>
  <sch:rule id="r161" context="nem:eProcedures.03[. != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_161" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eProcedures.02"
                test="../nem:eProcedures.02 != ''">
      Procedure Performed Prior to this Unit's EMS Care (eProcedures.02) must equal a valid value other than a NV when
       Procedure (eProcedures.03) has a valid SNOMED CT Code (with or without a PN).
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eProcedures_r_ProcedurePerformed">
  <sch:title>nemSch_eProcedures_r_ProcedurePerformed</sch:title>
  <sch:rule id="r_ProcedurePerformed" context="nem:eProcedures.03[. != '' and not(@PN)]">
    <sch:let name="nemsisElements" value="."/>

    <sch:assert id="Rule_157" role="[ERROR]" diagnostics="nemsisDiagnostic"
                    subject="., ../nem:eProcedures.01, ../nem:eProcedures.02"
                    test="../nem:eProcedures.02 = '9923003' or ../nem:eProcedures.01 != ''">
          Date/Time Procedure Performed (eProcedures.01) must equal a valid value other than a NV when Procedure
           (eProcedures.03) has a valid SNOMED CT Code and no PN unless Procedure Performed Prior to this Unit's EMS
            Care (eProcedures.02) is "Yes".
    </sch:assert>

    <sch:assert id="Rule_163" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eProcedures.05"
                test="../nem:eProcedures.05 != ''">
      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 PNs.
    </sch:assert>

    <sch:assert id="Rule_164" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eProcedures.06"
                test="../nem:eProcedures.06 != ''">
      Procedure Successful (eProcedures.06) must equal a valid value other than a NV when Procedure (eProcedures.03)
       has a valid SNOMED CT Code and no PNs.
    </sch:assert>

    <sch:assert id="Rule_165" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eProcedures.02, ../nem:eProcedures.07"
                test="../nem:eProcedures.02 = '9923003' or ../nem:eProcedures.07 != ''">
      Procedure Complication (eProcedures.07) must equal a valid value other than a NV when Procedure (eProcedures.03)
       has a valid SNOMED CT Code and no PNs unless Procedure Performed Prior to this Unit's EMS Care (eProcedures.02)
        is "Yes".
    </sch:assert>

    <sch:assert id="Rule_167" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eProcedures.02, ../nem:eProcedures.08"
                test="../nem:eProcedures.02 = '9923003' or ../nem:eProcedures.08 != ''">
      Response to Procedure (eProcedures.08) must equal a valid value other than a NV when Procedure (eProcedures.03)
       has a valid SNOMED CT Code and no PNs unless Procedure Performed Prior to this Unit's EMS Care (eProcedures.02)
        is "Yes".
    </sch:assert>

    <sch:assert id="Rule_168" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eProcedures.02, ../nem:eProcedures.10"
                test="../nem:eProcedures.02 = '9923003' or ../nem:eProcedures.10 != ''">
      Role/Type of Person Performing Procedure (eProcedures.10) must equal a valid value other than a NV when Procedure
       (eProcedures.03) has a valid SNOMED CT Code value and no PNs unless Procedure Performed Prior to this Unit's EMS
        Care (eProcedures.02) is "equal to "Yes".
    </sch:assert>

    <sch:assert id="Rule_169" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eProcedures.02, ../nem:eProcedures.11"
                test="../nem:eProcedures.02 = '9923003' or ../nem:eProcedures.11 != ''">
      Procedure Authorization (eProcedures.11) must equal a valid value other than a NV when Procedure (eProcedures.03)
       has a valid SNOMED CT Code and no PNs unless Procedure Performed Prior to this Unit's EMS Care (eProcedures.02)
        is "Yes".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eProcedures_r166">
  <sch:title>nemSch_eProcedures_r166</sch:title>
  <sch:rule id="r166" context="nem:eProcedures.07[. = '3907033'][1]">
    <sch:let name="nemsisElements" value="../nem:eProcedures.07"/>
    <sch:assert id="Rule_166" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="count(../nem:eProcedures.07) = 1">
      When Procedure Complication (eProcedures.07) equals "None" there must not be any other values selected.
    </sch:assert>
  </sch:rule>
</sch:pattern>
<?DSDL_INCLUDE_END includes/pattern_eProcedures.xml?>


<?DSDL_INCLUDE_START includes/pattern_eDisposition.xml?>

<sch:pattern id="nemSch_eDisposition_r170">
  <sch:title>nemSch_eDisposition_r170</sch:title>
  <sch:rule id="r170" context="nem:eDisposition.DestinationGroup/nem:eDisposition.02[. != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_170" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="../nem:eDisposition.01 != ''">
      Destination/Transferred To, Name (eDisposition.01) must contain a value other than a NV when
       Destination/Transferred To, Code (eDisposition.02) has a valid value other than a NV.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eDisposition_r172">
  <sch:title>nemSch_eDisposition_r172</sch:title>
  <sch:rule id="r172" context="nem:eDisposition.21[. != '4221003' and . != '4221005']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_172" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eDisposition.DestinationGroup/nem:eDisposition.21"
                test="not(../nem:eDisposition.DestinationGroup/nem:eDisposition.02) or 
                      ../nem:eDisposition.DestinationGroup/nem:eDisposition.02/@NV">
      Destination/Transferred to Code (eDisposition.02) must equal a NV or be omitted unless Type of Destination
       (eDisposition.21) equals "Hospital-Emergency Department" or "Hospital-Non-Emergency Department Bed".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eDisposition_r175">
  <sch:title>nemSch_eDisposition_r175</sch:title>
  <sch:rule id="r175" context="nem:eDisposition.06[. != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_175" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eDisposition.05"
                test="starts-with(., ../nem:eDisposition.05)">
      The first two digits of Destination County (eDisposition.06) must equal Destination State (eDisposition.05).
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eDisposition_r179">
  <sch:title>nemSch_eDisposition_r179</sch:title>
  <sch:rule id="r179" context="nem:eDisposition.17[. != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_179" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eDisposition.18"
                test="../nem:eDisposition.18 != ''">
      Additional Transport Mode Descriptors (eDisposition.18) must equal a valid value other than a NV when Transport
       Mode From Scene (eDisposition.17) is not blank or a NV.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eDisposition_r180">
  <sch:title>nemSch_eDisposition_r180</sch:title>
  <sch:rule id="r180" context="nem:eDisposition.18[. = '4218011']">
    <sch:let name="nemsisElements" value="../nem:eDisposition.18"/>
    <sch:assert id="Rule_180" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="not(../nem:eDisposition.18 = ('4218013','4218015','4218017','4218019'))">
      When Additional Transport Mode Descriptors (eDisposition.18) contains 4218011 Lights and Sirens, it cannot contain
       any of the following: 4218013 Lights and No Sirens, 4218015 No Lights or Sirens, 4218017 Initial No Lights or
        Sirens, Upgraded to Lights and Sirens, 4218019 Initial Lights and Sirens, Downgraded to No Lights or Sirens.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eDisposition_r181">
  <sch:title>nemSch_eDisposition_r181</sch:title>
  <sch:rule id="r181" context="nem:eDisposition.18[. = '4218013']">
    <sch:let name="nemsisElements" value="../nem:eDisposition.18"/>
    <sch:assert id="Rule_181" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="not(../nem:eDisposition.18 = ('4218011','4218015','4218017','4218019'))">
      When Additional Transport Mode Descriptors (eDisposition.18) contains 4218013 Lights and No Sirens, it cannot
       contain any of the following: 4218011 Lights and Sirens, 4218015 No Lights or Sirens, 4218017 Initial No Lights
        or Sirens, Upgraded to Lights and Sirens, 4218019 Initial Lights and Sirens, Downgraded to No Lights or Sirens.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eDisposition_r182">
  <sch:title>nemSch_eDisposition_r182</sch:title>
  <sch:rule id="r182" context="nem:eDisposition.18[. = '4218015']">
    <sch:let name="nemsisElements" value="../nem:eDisposition.18"/>
    <sch:assert id="Rule_182" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="not(../nem:eDisposition.18 = ('4218011','4218013','4218017','4218019'))">
      When Additional Transport Mode Descriptors (eDisposition.18) contains 4218015 No Lights or Sirens, it cannot
       contain any of the following: 4218011 Lights and Sirens, 4218013 Lights and No Sirens, 4218017 Initial No Lights
        or Sirens, Upgraded to Lights and Sirens, 4218019 Initial Lights and Sirens, Downgraded to No Lights or Sirens.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eDisposition_r183">
  <sch:title>nemSch_eDisposition_r183</sch:title>
  <sch:rule id="r183" context="nem:eDisposition.18[. = '4218017']">
    <sch:let name="nemsisElements" value="../nem:eDisposition.18"/>
    <sch:assert id="Rule_183" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="not(../nem:eDisposition.18 = ('4218011','4218013','4218015','4218019'))">
      When Additional Transport Mode Descriptors (eDisposition.18) contains 4218017 Initial No Lights or Sirens,
       Upgraded to Lights and Sirens, it cannot contain any of the following: 4218011 Lights and Sirens, 4218013 Lights
        and No Sirens, 4218015 No Lights or Sirens, 4218019 Initial Lights and Sirens, Downgraded to No Lights or
         Sirens.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eDisposition_r184">
  <sch:title>nemSch_eDisposition_r184</sch:title>
  <sch:rule id="r184" context="nem:eDisposition.18[. = '4218019']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_184" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="not(../nem:eDisposition.18 = ('4218011','4218013','4218015','4218017'))">
      When Additional Transport Mode Descriptors (eDisposition.18) contains 4218019 Initial Lights and Sirens,
       Downgraded to No Lights or Sirens, it cannot contain any of the following: 4218011 Lights and Sirens, 4218013
        Lights and No Sirens, 4218015 No Lights or Sirens, 4218017 Initial No Lights or Sirens, Upgraded to Lights and
         Sirens.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eDisposition_r185">
  <sch:title>nemSch_eDisposition_r185</sch:title>
  <sch:rule id="r185" context="nem:eDisposition.28[. = ('4228001', '4228003', '4228005')]">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_185" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:eDisposition/nem:eDisposition.19"
                test="ancestor::nem:eDisposition/nem:eDisposition.19 != ''">
      Final Patient Acuity (eDisposition.19) must equal a valid value other than a NV when Patient Evaluation/Care
       (eDisposition.28) equals any "Patient Evaluated..." value (4228001, 4228003, 4228005).
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eDisposition_r188">
  <sch:title>nemSch_eDisposition_r188</sch:title>
  <sch:rule id="r188" context="nem:eDisposition.21[. = '4221005']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_188" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eDisposition.22"
                test="../nem:eDisposition.22 != ''">
      Hospital Inpatient Destination (eDisposition.22) must equal a valid value other than a NV when Type of Destination
       (eDisposition.21) equals 4221005 "Hospital-Non-Emergency Department Bed".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eDisposition_r_TransportToHospital">
  <sch:title>nemSch_eDisposition_r_TransportToHospital</sch:title>
  <sch:rule id="r_TransportToHospital" context="nem:eDisposition.21[. = ('4221003','4221005')]">
    <sch:let name="nemsisElements" value="."/>
  
    <!-- TODO: r171 does not check against the list of approved IDPH hospital codes in the StateDataSet -->
    <sch:assert id="Rule_171" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eDisposition.DestinationGroup/nem:eDisposition.02"
                test="../nem:eDisposition.DestinationGroup/nem:eDisposition.02[. != '']">
      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 4221003 "Hospital-Emergency
        Department" or 4221005 "Hospital-Non-Emergency Department Bed".
    </sch:assert>
  
    <sch:assert id="Rule_189" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eDisposition.23"
                test="../nem:eDisposition.23 != ''">
      Hospital Capability (eDisposition.23) must equal a valid value other than a NV when Type of Destination
       (eDisposition.21) equals "Hospital-Emergency Department" or "Hospital-Non-Emergency Department Bed".
    </sch:assert>

    <sch:assert id="Rule_196" role="[WARNING]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eOutcome/nem:eOutcome.02"
                test="ancestor::nem:PatientCareReport/nem:eOutcome/nem:eOutcome.02[. != '' or @NV]">
      Hospital Disposition (eOutcome.02) must equal a valid value or NV when Type of Destination (eDisposition.21)
       equals "Hospital-Emergency Department" or "Hospital-Non-Emergency Department Bed".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eDisposition_r195">
  <sch:title>nemSch_eDisposition_r195</sch:title>
  <sch:rule id="r195" context="nem:eDisposition.21[. = '4221003']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_195" role="[WARNING]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eOutcome/nem:eOutcome.01"
                test="ancestor::nem:PatientCareReport/nem:eOutcome/nem:eOutcome.01[. != '' or @NV = '7701003']">
      Emergency Department Disposition (eOutcome.01) must equal a valid value or Not Recorded when Type of Destination
       (eDisposition.21) equals 4221003 Hospital-Emergency Department.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eDisposition_r190">
  <sch:title>nemSch_eDisposition_r190</sch:title>
  <sch:rule id="r190" context="nem:eDisposition.HospitalTeamActivationGroup/nem:eDisposition.25[. != '']">
    <sch:let name="nemsisElements" value="."/>
   <sch:assert id="Rule_190" role="[ERROR]" diagnostics="nemsisDiagnostic"
               test="../nem:eDisposition.24[. != '' and . != '4224001']">
      Destination Team Pre-Arrival Arrival Alert or Activation (eDisposition.24) must equal a valid value other than a
       NV or "No" when Date/Time of Destination Pre-Arrival Arrival Alert or Activation (eDisposition.25) is specified.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eDisposition_r191">
  <sch:title>nemSch_eDisposition_r191</sch:title>
  <sch:rule id="r191" context="nem:eDisposition.HospitalTeamActivationGroup/nem:eDisposition.24[. != '4224001' and . != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_191" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test="../nem:eDisposition.25 != ''">
      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 NV.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eDisposition_r_PatientContactMade">
  <sch:title>nemSch_eDisposition_r_PatientContactMade</sch:title>
  <sch:rule id="r_PatientContactMade" context="nem:eDisposition.27[. = '4227001']">
    <sch:let name="nemsisElements" value="."/>

    <sch:assert id="Rule_32" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07"
                test="ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.07 != ''">
      Arrived At Patient Date/Time (eTimes.07) must be specified when Unit Disposition (eDisposition.27) equals 4227001
       "Patient Contact Made".
    </sch:assert>

    <sch:assert id="Rule_46" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:ePatient/nem:ePatient.PatientNameGroup/nem:ePatient.02"
                test="ancestor::nem:PatientCareReport/nem:ePatient/nem:ePatient.PatientNameGroup/nem:ePatient.02 != ''">
      Last Name (ePatient.02) must equal a valid value other than a NV when Unit Disposition (eDisposition.27) equals
       4227001 "Patient Contact Made".
    </sch:assert>

    <sch:assert id="Rule_47" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:ePatient/nem:ePatient.PatientNameGroup/nem:ePatient.03"
                test="ancestor::nem:PatientCareReport/nem:ePatient/nem:ePatient.PatientNameGroup/nem:ePatient.03 != ''">
      First Name (ePatient.03) must equal a valid value other than a NV when Unit Disposition (eDisposition.27) equals
       4227001 "Patient Contact Made".
    </sch:assert>

    <sch:assert id="Rule_48" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:ePatient/nem:ePatient.05"
                test="ancestor::nem:PatientCareReport/nem:ePatient/nem:ePatient.05 != ''">
      Patient's Home Address (ePatient.05) must equal a valid value other than a NV when Unit Disposition
       (eDisposition.27) equals 4227001 "Patient Contact Made".
    </sch:assert>

    <sch:assert id="Rule_49" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:ePatient/nem:ePatient.06"
                test="ancestor::nem:PatientCareReport/nem:ePatient/nem:ePatient.06 != ''">
      Patient's Home City (ePatient.06) must equal a valid value other than a NV when Unit Disposition (eDisposition.27)
       equals 4227001 "Patient Contact Made".
    </sch:assert>

    <sch:assert id="Rule_50" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:ePatient/nem:ePatient.07"
                test="matches(ancestor::nem:PatientCareReport/nem:ePatient/nem:ePatient.07, '^([0-9]{5})$')">
      Patient's Home County (ePatient.07) must equal a valid value other than a NV when Unit Disposition
       (eDisposition.27) equals 4227001 "Patient Contact Made".
    </sch:assert>

    <sch:assert id="Rule_52" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:ePatient/nem:ePatient.08"
                test="ancestor::nem:PatientCareReport/nem:ePatient/nem:ePatient.08 != ''">
      Patient's Home State (ePatient.08) must equal a valid value other than a NV when Unit Disposition
       (eDisposition.27) equals 4227001 "Patient Contact Made".
    </sch:assert>

    <sch:assert id="Rule_53" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:ePatient/nem:ePatient.09"
                test="matches(ancestor::nem:PatientCareReport/nem:ePatient/nem:ePatient.09,
                 '^([0-9]{5}|[0-9]{5}-[0-9]{4}|[0-9]{5}-[0-9]{5}|[A-Z][0-9][A-Z][0-9][A-Z][0-9])$')">
      Patient's Home ZIP Code (ePatient.09) must equal a valid value other than a NV when Unit Disposition
       (eDisposition.27) equals 4227001 "Patient Contact Made".
    </sch:assert>

    <sch:assert id="Rule_54" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:ePatient/nem:ePatient.13"
                test="ancestor::nem:PatientCareReport/nem:ePatient/nem:ePatient.13 != ''">
      Patient's Gender (ePatient.13) must equal a valid value other than a NV when Unit Disposition (eDisposition.27)
       equals 4227001 "Patient Contact Made".
    </sch:assert>

    <sch:assert id="Rule_55" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:ePatient/nem:ePatient.14"
                test="ancestor::nem:PatientCareReport/nem:ePatient/nem:ePatient.14 != ''">
      Patient's Race (ePatient.14) must equal a valid value other than a NV when Unit Disposition (eDisposition.27)
       equals 4227001 "Patient Contact Made".
    </sch:assert>

    <sch:assert id="Rule_59" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eScene/nem:eScene.06"
                test="ancestor::nem:PatientCareReport/nem:eScene/nem:eScene.06 = ('2707001', '2707005')">
      Number of Patients at Scene (eScene.06) should be "Multiple" or "Single" when Unit Disposition (eDisposition.27)
       equals 4227001 "Patient Contact Made".
    </sch:assert>
    
    <sch:assert id="Rule_113" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eHistory/nem:eHistory.05"
                test="ancestor::nem:PatientCareReport/nem:eHistory/nem:eHistory.05[. != '' or @NV != '']">
      Advance Directives (eHistory.05) must equal a valid value or a NV when Unit Disposition (eDisposition.27) equals
       4227001 "Patient Contact Made".
    </sch:assert>

    <sch:assert id="Rule_114" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eHistory/nem:eHistory.06"
                test="ancestor::nem:PatientCareReport/nem:eHistory/nem:eHistory.06[. != '' or @PN != '']">
      Medication Allergies (eHistory.06) must equal a valid value or a PN when Unit Disposition (eDisposition.27) equals
       4227001 "Patient Contact Made".
    </sch:assert>

    <sch:assert id="Rule_115" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eHistory/nem:eHistory.08"
                test="ancestor::nem:PatientCareReport/nem:eHistory/nem:eHistory.08[. != '' or @PN != '']">
      Medical/Surgical History (eHistory.08) must equal either a PN or another value other than a NV when Unit
       Disposition (eDisposition.27) equals 4227001 "Patient Contact Made".
    </sch:assert>

    <sch:assert id="Rule_116" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eHistory/nem:eHistory.CurrentMedsGroup/nem:eHistory.12"
                test="ancestor::nem:PatientCareReport/nem:eHistory/nem:eHistory.CurrentMedsGroup/nem:eHistory.12[. != '' or @PN != '']">
      Current Medications (eHistory.12) must equal a valid value or a PN when Unit Disposition (eDisposition.27) equals
       4227001 "Patient Contact Made".
    </sch:assert>

    <sch:assert id="Rule_117" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eHistory/nem:eHistory.17"
                test="ancestor::nem:PatientCareReport/nem:eHistory/nem:eHistory.17[. != '' or @PN != '']">
      Alcohol/Drug Use Indicators (eHistory.17) must equal either a PN or another valid value other than a NV when Unit
       Disposition (eDisposition.27) equals 4227001 "Patient Contact Made".
    </sch:assert>

    <sch:assert id="Rule_192" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eDisposition.28"
                test="../nem:eDisposition.28 != ''">
      Patient Evaluation/Care (eDisposition.28) must equal a valid value other than a NV when Unit Disposition
       (eDisposition.27) equals "Patient Contact Made".
    </sch:assert>

    <sch:assert id="Rule_193" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eDisposition.30"
                test="../nem:eDisposition.30 != ''">
      Transport Disposition (eDisposition.30) must equal a valid value other than a NV when Unit Disposition
       (eDisposition.27) equals 4227001 "Patient Contact Made".
    </sch:assert>

  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eDisposition_r_CancelledPriorToArrival">
  <sch:title>nemSch_eDisposition_r_CancelledPriorToArrival</sch:title>
  <sch:rule id="r_CancelledPriorToArrival" context="nem:eDisposition.27[. = '4227005']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_7" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eResponse/nem:eResponse.10"
                test="not(ancestor::nem:PatientCareReport/nem:eResponse/nem:eResponse.10) or
                    ancestor::nem:PatientCareReport/nem:eResponse/nem:eResponse.10[@NV != '']">
      Type of Scene Delay (eResponse.10) must equal a NV or be omitted when Unit Disposition (eDisposition.27) equals
       "Canceled Prior to Arrival At Scene".
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eDisposition_r_NotCancelledPriorToArrival">
  <sch:title>nemSch_eDisposition_r_NotCancelledPriorToArrival</sch:title>
  <sch:rule id="r_NotCancelledPriorToArrival" context="nem:eDisposition.27[not(. = '4227005')]">
    <sch:let name="nemsisElements" value="."/>
    
    <sch:assert id="Rule_28" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.05"
                test="ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.05 != ''">
      Unit En Route Date/Time (eTimes.05) must be specified when Unit Disposition (eDisposition.27) is not equal to
       "Canceled Prior to Arrival At Scene".
    </sch:assert>

    <sch:assert id="Rule_29" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.06"
                test="ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.06 != ''">
      Unit Arrived on Scene Date/Time (eTimes.06) must be specified when Unit Disposition (eDisposition.27) is not equal
       to "Canceled Prior to Arrival At Scene".
    </sch:assert>

    <sch:assert id="Rule_64" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eScene/nem:eScene.09"
                test="ancestor::nem:PatientCareReport/nem:eScene/nem:eScene.09 != ''">
      Incident Location Type (eScene.09) must equal a valid value other than a NV unless Unit Disposition
       (eDisposition.27) equals 4227005 "Cancelled Prior to Arrival at Scene".
    </sch:assert>

    <sch:assert id="Rule_65" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eScene/nem:eScene.15"
                test="ancestor::nem:PatientCareReport/nem:eScene/nem:eScene.15 != ''">
      Incident Street Address (eScene.15) must equal a valid value other than a NV unless Unit Disposition
       (eDisposition.27) equals 4227005 "Cancelled Prior to Arrival at Scene".
    </sch:assert>

    <sch:assert id="Rule_66" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eScene/nem:eScene.17"
                test="ancestor::nem:PatientCareReport/nem:eScene/nem:eScene.17 != ''">
      Incident City (eScene.17) must equal a valid value other than a NV unless Unit Disposition
       (eDisposition.27) equals 4227005 "Cancelled Prior to Arrival at Scene".
    </sch:assert>

    <sch:assert id="Rule_67" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eScene/nem:eScene.18"
               test="matches(ancestor::nem:PatientCareReport/nem:eScene/nem:eScene.18, '^([0-9]{2})$')">
      Incident State (eScene.18) must equal a valid value other than a NV unless Unit Disposition (eDisposition.27)
       equals 4227005 "Cancelled Prior to Arrival at Scene".
    </sch:assert>

    <sch:assert id="Rule_69" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eScene/nem:eScene.19"
                test="matches(ancestor::nem:PatientCareReport/nem:eScene/nem:eScene.19,
                 '^([0-9]{5}|[0-9]{5}-[0-9]{4}|[0-9]{5}-[0-9]{5}|[A-Z][0-9][A-Z][0-9][A-Z][0-9])$')">
      Incident ZIP Code (eScene.19) must equal a five-digit numeric string unless Unit Disposition (eDisposition.27)
       equals 4227005 "Cancelled Prior to Arrival at Scene".
    </sch:assert>

    <sch:assert id="Rule_70" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eScene/nem:eScene.21"
                test="matches(ancestor::nem:PatientCareReport/nem:eScene/nem:eScene.21, '^([0-9]{5})$')">
      Incident County (eScene.21) must equal a five-digit ANSI Numeric County Code unless Unit Disposition
       (eDisposition.27) equals 4227005 "Cancelled Prior to Arrival at Scene."
    </sch:assert>

  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eDisposition_r_PatientEvaluated">
  <sch:title>nemSch_eDisposition_r_PatientEvaluated</sch:title>
  <sch:rule id="r_PatientEvaluated"
            context="nem:eDisposition.28[. = ('4228001', '4228003', '4228005')]">
    <sch:let name="nemsisElements" value="."/>

    <sch:assert id="Rule_140" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eExam/nem:eExam.01"
                test="ancestor::nem:PatientCareReport/nem:eExam/nem:eExam.01[. != '' or @PN]">
      Estimated Body Weight in Kilograms (eExam.01) must equal a valid value other than a NV or "Unable to Complete"
       when Patient Evaluation/Care (eDisposition.28) equals any "Patient Evaluated..." value (4228001, 4228003,
        4228005).
    </sch:assert>

    <sch:assert id="Rule_141" role="[WARNING]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eProtocols/nem:eProtocols.ProtocolGroup/nem:eProtocols.01"
                test="ancestor::nem:PatientCareReport/nem:eProtocols/nem:eProtocols.ProtocolGroup/nem:eProtocols.01[. != '' or @PN]">
      Protocols Used (eProtocols.01) must equal a valid value or a NV when Patient Evaluation/Care (eDisposition.28)
       equals any "Patient Evaluated..." value (4228001, 4228003, 4228005).
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eDisposition_r_PatientEvaluatedWithCare">
  <sch:title>nemSch_eDisposition_r_PatientEvaluatedWithCare</sch:title>
  <sch:rule id="r_PatientEvaluatedWithCare" context="nem:eDisposition.28[. = '4228001']">
    <sch:let name="nemsisElements" value="."/>

    <sch:assert id="Rule_85" role="[WARNING]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eVitals/nem:eVitals.VitalGroup/nem:eVitals.CardiacRhythmGroup/nem:eVitals.03,
                         ancestor::nem:PatientCareReport/nem:eSituation/nem:eSituation.18"
                test="ancestor::nem:PatientCareReport/nem:eSituation/nem:eSituation.18[. != '' or @PN]
                      or not(ancestor::nem:PatientCareReport/nem:eVitals/nem:eVitals.VitalGroup/nem:eVitals.CardiacRhythmGroup/nem:eVitals.03 = ('9901051', '9901053', '9901055', '9901057', '9901058'))">
      Date/Time Last Known Well must equal a valid value or PN when Patient Evaluation/Care (eDisposition.28) equals
       4228001 "Patient Evaluated and Care Provided." and Cardiac Rhythm / Electrocardiography (eVitals.03) contains
        "STEMI".
    </sch:assert>

    <sch:assert id="Rule_90" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eArrest/nem:eArrest.01"
                test="ancestor::nem:PatientCareReport/nem:eArrest/nem:eArrest.01 != ''">
      Cardiac Arrest (eArrest.01) must equal a valid value other than a NV when Patient Evaluation/Care
       (eDisposition.28) equals 4228001 "Patient Evaluated and Care Provided."
    </sch:assert>

    <sch:assert id="Rule_194" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:eDisposition/nem:eDisposition.32"
                test="ancestor::nem:eDisposition/nem:eDisposition.32[. != '' and . != '4232013']">
      Level of Care Provided per Protocols (eDisposition.32) must equal a valid value other than a NV or 4232013 when
       Patient Evaluation/Care (eDisposition.28) equals 4228001 "Patient Evaluated and Care Provided."
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eDisposition_r35">
  <sch:title>nemSch_eDisposition_r35</sch:title>
  <sch:rule id="r35" context="nem:eDisposition.29[. = '4229003']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_35" role="[WARNING]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.08"
                test="ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.08 != ''">
      Transfer of EMS Patient Care Date/Time (eTimes.08) must be specified when Crew Disposition (eDisposition.29)
       equals 4229003 (Initiated Primary Care and Transferred to Another EMS Crew).
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eDisposition_r_TransportedByThisUnit">
  <sch:title>nemSch_eDisposition_r_TransportedByThisUnit</sch:title>
  <sch:rule id="r_TransportedByThisUnit" context="nem:eDisposition.30[. = ('4230001','4230003')]">
    <sch:let name="nemsisElements" value="."/>
    
    <sch:assert id="Rule_37" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.09"
                test="ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.09 != ''">
      Unit Left Scene Date/Time (eTimes.09) must be specified when Transport Disposition (eDisposition.30) is equal to a
       Transport by this Unit value (4230001 or 4230003).
    </sch:assert>

    <sch:assert id="Rule_40" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.11"
                test="ancestor::nem:PatientCareReport/nem:eTimes/nem:eTimes.11 != ''">
      Patient Arrived at Destination Date/Time (eTimes.11) must be specified when Transport Disposition
       (eDisposition.30) is equal to a Transport by this Unit value (4230001 or 4230003).
    </sch:assert>

    <sch:assert id="Rule_173" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:eDisposition/nem:eDisposition.DestinationGroup/nem:eDisposition.05"
                test="matches(ancestor::nem:eDisposition/nem:eDisposition.DestinationGroup/nem:eDisposition.05, '^([0-9]{2})$')">
      Destination State (eDisposition.05) must equal a valid state code when Transport Disposition (eDisposition.30)
       equals a "Transport by This EMS Unit..." value (4230001 or 4230003).
    </sch:assert>

    <sch:assert id="Rule_174" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:eDisposition/nem:eDisposition.DestinationGroup/nem:eDisposition.06"
                test="matches(ancestor::nem:eDisposition/nem:eDisposition.DestinationGroup/nem:eDisposition.06, '^([0-9]{5})$')">
      Destination County (eDisposition.06) must equal a valid county code when Transport Disposition (eDisposition.30)
       equals a "Transport by This EMS Unit..." value (4230001 or 4230003).
    </sch:assert>

    <sch:assert id="Rule_176" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:eDisposition/nem:eDisposition.DestinationGroup/nem:eDisposition.07"
                test="matches(ancestor::nem:eDisposition/nem:eDisposition.DestinationGroup/nem:eDisposition.07,
                 '^([0-9]{5}|[0-9]{5}-[0-9]{4}|[0-9]{5}-[0-9]{5}|[A-Z][0-9][A-Z][0-9][A-Z][0-9])$')">
      Destination ZIP Code (eDisposition.07) must equal a valid US zip code when Transport Disposition (eDisposition.30)
       equals a "Transport by This EMS Unit..." value (4230001 or 4230003).
    </sch:assert>

    <sch:assert id="Rule_177" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:eDisposition/nem:eDisposition.16"
                test="ancestor::nem:eDisposition/nem:eDisposition.16 != ''">
      EMS Transport Method (eDisposition.16) must equal a valid value other than a NV when Transport Disposition
       (eDisposition.30) equals a "Transport by This EMS Unit..." value (4230001 or 4230003).
    </sch:assert>

    <sch:assert id="Rule_178" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:eDisposition/nem:eDisposition.17"
                test="ancestor::nem:eDisposition/nem:eDisposition.17 != ''">
      Transport Mode from Scene (eDisposition.17) must equal a valid value other than a NV when Transport Disposition
       (eDisposition.30) equals a "Transport by This EMS Unit..." value (4230001 or 4230003).
    </sch:assert>

    <sch:assert id="Rule_186" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:eDisposition/nem:eDisposition.20"
                test="ancestor::nem:eDisposition/nem:eDisposition.20 != ''">
      Reason for Choosing Destination (eDisposition.20) must equal a valid value other than a NV when Transport
       Disposition (eDisposition.30) equals a "Transport by This EMS Unit..." value (4230001 or 4230003).
    </sch:assert>

    <sch:assert id="Rule_187" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:eDisposition/nem:eDisposition.21"
                test="ancestor::nem:eDisposition/nem:eDisposition.21 != ''">
      Type of Destination (eDisposition.21) must equal a valid value other than a NV when Transport Disposition
       (eDisposition.30) equals a "Transport by This EMS Unit..." value (4230001 or 4230003).
    </sch:assert>

  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eDisposition_r_NotTransportedByThisUnit">
  <sch:title>nemSch_eDisposition_r_NotTransportedByThisUnit</sch:title>
  <sch:rule id="r_NotTransportedByThisUnit" context="nem:eDisposition.30[. != '4230001' and . != '4230003']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_10" role="[ERROR]" diagnostics="nemsisDiagnostic"
                subject="., ancestor::nem:PatientCareReport/nem:eResponse/nem:eResponse.11"
                test="not(ancestor::nem:PatientCareReport/nem:eResponse/nem:eResponse.11)
                 or ancestor::nem:PatientCareReport/nem:eResponse/nem:eResponse.11[@NV != '']">
      Type of Transport Delay (eResponse.11) must equal a NV or be omitted if Transport Disposition (eDisposition.30) is
       not a "Transport by This EMS Unit…" value.
    </sch:assert>
  </sch:rule>
</sch:pattern>
<?DSDL_INCLUDE_END includes/pattern_eDisposition.xml?>


<?DSDL_INCLUDE_START includes/pattern_eOutcome.xml?>

<sch:pattern id="nemSch_eOutcome_r197">
  <sch:title>nemSch_eOutcome_r197</sch:title>
  <sch:rule id="r197" context="nem:eOutcome.04[. != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_197" role="[WARNING]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eOutcome.03"
                test="../nem:eOutcome.03 != ''">
      External Report ID/Number Type (eOutcome.03) must equal a valid value when External Report ID/Number (eOutcome.04)
       is not blank.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="nemSch_eOutcome_r198">
  <sch:title>nemSch_eOutcome_r198</sch:title>
  <sch:rule id="r198" context="nem:eOutcome.03[. != '']">
    <sch:let name="nemsisElements" value="."/>
    <sch:assert id="Rule_198" role="[WARNING]" diagnostics="nemsisDiagnostic"
                subject="., ../nem:eOutcome.04"
                test="../nem:eOutcome.04 != ''">
      An External Report ID/Number (eOutcome.04) must be entered when External Report ID/Number (eOutcome.03) is not
       blank.
    </sch:assert>
  </sch:rule>
</sch:pattern>
<?DSDL_INCLUDE_END includes/pattern_eOutcome.xml?>


<sch:pattern id="IDPH_system_number_r199">
  <sch:title>IDPH_system_number_r199</sch:title>
  <sch:rule id="r199" 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_199" 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:pattern>

<sch:pattern id="IDPH_system_number_r200">
  <sch:title>IDPH_system_number_r200</sch:title>
  <sch:rule id="r200" 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_200" role="[FATAL]" diagnostics="nemsisDiagnostic"
                test="nem:eCustomResults/nem:eCustomResults.ResultsGroup[matches(nem:eCustomResults.01, '^([0-9]{4})$')
                    and nem:eCustomResults.02 = $EMSSFieldID]">
      A CustomResults.ResultsGroup with a Custom Element ID Referenced (eCustomResults.02) equal to "Illinois EMS System
       Number" and a Custom Data Element Result (eCustomResults.01) consisting of a four digit numeric string must be
        present for each Patient Care Report.
    </sch:assert>
  </sch:rule>
</sch:pattern>

<sch:pattern id="IDPH_system_number_r201">
  <sch:title>IDPH_system_number_r201</sch:title>
  <sch:let name="EMSSFieldID" value="//nem:eCustomConfiguration/nem:eCustomConfiguration.CustomGroup[nem:eCustomConfiguration.01 = 'Illinois EMS System Number']/@CustomElementID"/>

  <sch:rule id="r201" context="nem:PatientCareReport/nem:eCustomResults/nem:eCustomResults.ResultsGroup[nem:eCustomResults.02 = $EMSSFieldID]">
    <sch:let name="nemsisElements" value="."/>
    <sch:let name="nemsisElementsMissing" value="'eCustomResults.01 eCustomResults.02'"/>
    <sch:let name="nemsisElementsMissingContext" value="."/>

    <sch:assert id="Rule_201" role="[ERROR]" diagnostics="nemsisDiagnostic"
                test=".[nem:eCustomResults.01 != ancestor::nem:Header/nem:DemographicGroup/nem:dAgency.01 and 
                        nem:eCustomResults.01 != ancestor::nem:Header/nem:DemographicGroup/nem:dAgency.02 and 
                        nem:eCustomResults.01 != ancestor::nem:Header/nem:PatientCareReport/nem:eResponse/nem:eResponse.AgencyGroup/nem:eResponse.01]">
      When Custom Data Element Title (eCustomConfiguration.01) equals "Illinois EMS System Number", eCustomResults.01
       must not equal any of the following: EMS Agency Unique State ID (dAgency.01), EMS Agency Number (dAgency.02), EMS
        Agency Number (eResponse.01).
    </sch:assert>
  </sch:rule>
</sch:pattern>


  <!-- DIAGNOSTICS -->

  <sch:diagnostics>

    <?DSDL_INCLUDE_START includes/diagnostic_nemsisDiagnostic.xml?><sch:diagnostic id="nemsisDiagnostic">

  <!-- 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::*:StateDataSet/*:sState/*:sState.01"/>
      <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"/>
      <xsl:if test="ancestor-or-self::*[@UUID]">
        <UUID><xsl:value-of select="ancestor-or-self::*[@UUID][1]/@UUID"/></UUID>
      </xsl:if>
    </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><?DSDL_INCLUDE_END includes/diagnostic_nemsisDiagnostic.xml?>

  </sch:diagnostics>

</sch:schema>
