<!--  Medications section: 2.16.840.1.113883.10.20.1.8 -->

<!-- errors -->

<pattern id='p-2.16.840.1.113883.10.20.1.8-errors' see='#p-2.16.840.1.113883.10.20.1.8-errors'>
	<title>Medications section - errors validation phase</title>
	<rule context='*[cda:templateId/@root="2.16.840.1.113883.10.20.1.8"]'>
    <assert test="self::cda:section">The root of a Medications section shall be 'section' in the HL7 namespace.</assert>
    <assert test="cda:text">The Medications section SHALL contain a narrative block.</assert>
    <assert test="cda:code">The medications section SHALL contain Section / code.</assert>
    <assert test="cda:code[@code='10160-0'][@codeSystem='2.16.840.1.113883.6.1']">The value for “Section / code” SHALL be “10160-0” “History of medication use” 2.16.840.1.113883.6.1 LOINC STATIC</assert>
    <assert test="cda:title">The medications section SHALL contain Section / title.</assert>
	</rule>
</pattern>

<!-- warning -->

<pattern id='p-2.16.840.1.113883.10.20.1.8-warning' see='#p-2.16.840.1.113883.10.20.1.8-warning'>
	<title>Medications section - warning validation phase</title>
	<rule context='*[cda:templateId/@root="2.16.840.1.113883.10.20.1.8"]'>
	<assert test="descendant::*[cda:templateId/@root='2.16.840.1.113883.10.20.1.24' or cda:templateId/@root='2.16.840.1.113883.10.20.1.34' ]">The Medications section  SHOULD include one or more medication activities (templateId 2.16.840.1.113883.10.20.1.24) and/or supply activities (templateId 2.16.840.1.113883.10.20.1.34)</assert>
	<assert test="contains(translate(cda:title,'QWERTYUIOPASDFGHJKLZXCVBNM','qwertyuiopasdfghjklzxcvbnm'),'medication')">Section / title SHOULD be valued with a case-insensitive language-insensitive text string containing “medication”.</assert>
	</rule>
</pattern>

<!-- manual -->

<pattern id='p-2.16.840.1.113883.10.20.1.8-manual' see='#p-2.16.840.1.113883.10.20.1.8-manual'>
	<title>Medications section - manual validation phase</title>
	<rule context='*[cda:templateId/@root="2.16.840.1.113883.10.20.1.8"]'>
	<report test='.'></report>
	</rule>
</pattern>

