<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="profile-error-response" />
  <url value="http://pharmacyeclaims.ca/FHIR/v1.0/StructureDefinition/profile-error-response" />
  <name value="ErrorClaimResponse" />
  <title value="Claim Response with Errors" />
  <status value="draft" />
  <description value="A claim response that has errors and therefore cannot be fully adjudicated" />
  <purpose value="A claim response that has errors and therefore cannot be fully adjudicated" />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="ClaimResponse" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/ClaimResponse" />
  <derivation value="constraint" />
  <differential>
    <element id="ClaimResponse">
      <path value="ClaimResponse" />
      <comment value="Usage Note:  This profile is used when a calim or reversal has been rejected due to errors.&#xD;&#xA;CPHA Mapping:   Response Status E.05.03 = R &quot;R=rejected claim/reversal&quot; where errors are detected" />
    </element>
    <element id="ClaimResponse.meta">
      <path value="ClaimResponse.meta" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.meta.profile">
      <path value="ClaimResponse.meta.profile" />
      <max value="1" />
      <fixedCanonical value="http://pharmacyeclaims.ca/FHIR/v1.0/StructureDefinition/profile-error-response" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.identifier">
      <path value="ClaimResponse.identifier" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="assigner.identifier.type.coding.system" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <comment value="Usage Note:    There are two identifiers; the Reference number which maps to CPHA and a response identifier which is not restricted    Both are assigned by the processor.    Minimally, one identifier must be present for the Reference number (limited to 9N).   The additional identifier must also be specified, without limitation and will eventually replace the Reference number as it will be unlimited.&#xD;&#xA;&#xD;&#xA;CPHA Map:  Reference Number E.04.03&#xD;&#xA;Usage Note:  this is optional in CPHA" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.identifier.system">
      <path value="ClaimResponse.identifier.system" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.identifier.value">
      <path value="ClaimResponse.identifier.value" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.identifier:ReferenceNumber">
      <path value="ClaimResponse.identifier" />
      <sliceName value="ReferenceNumber" />
      <comment value="Usage Note: This is an internal reference number assigned to each claim by the processor.    This must be present on all claim response&#xD;&#xA;CPHA Mapping: Reference Number  E.04.03  9N" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.identifier:ReferenceNumber.system">
      <path value="ClaimResponse.identifier.system" />
      <max value="0" />
    </element>
    <element id="ClaimResponse.identifier:ReferenceNumber.value">
      <path value="ClaimResponse.identifier.value" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.identifier:ResponseIdentifier">
      <path value="ClaimResponse.identifier" />
      <sliceName value="ResponseIdentifier" />
      <comment value="Usage Note:   A GUID may be used as this number must be unique.  The system may be assigned by the adjudicaiton system to identify the unique namespace." />
      <min value="1" />
      <max value="1" />
    </element>
    <element id="ClaimResponse.identifier:ResponseIdentifier.system">
      <path value="ClaimResponse.identifier.system" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.identifier:ResponseIdentifier.value">
      <path value="ClaimResponse.identifier.value" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.status">
      <path value="ClaimResponse.status" />
      <fixedCode value="active" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.type">
      <path value="ClaimResponse.type" />
      <fixedCodeableConcept>
        <text value="pharmacy" />
      </fixedCodeableConcept>
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.type.coding">
      <path value="ClaimResponse.type.coding" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.type.coding.code">
      <path value="ClaimResponse.type.coding.code" />
      <min value="1" />
      <fixedCode value="pharmacy" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.use">
      <path value="ClaimResponse.use" />
      <fixedCode value="claim" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.patient">
      <path value="ClaimResponse.patient" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://pharmacyeclaims.ca/FHIR/v1.0/StructureDefinition/profile-patient" />
        <aggregation value="bundled" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.created">
      <path value="ClaimResponse.created" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.insurer">
      <path value="ClaimResponse.insurer" />
      <comment value="Usage Note:   This conveys the identifer for the insurer&#xD;&#xA;CPHA Mapping:  IIN ( Issuer Identification Number)    A.01.01&#xD;&#xA;&#xD;&#xA;References SHALL be a reference to an actual FHIR resource, and SHALL be resolveable (allowing for access control, temporary unavailability, etc.). Resolution can be either by retrieval from the URL, or, where applicable by resource type, by treating an absolute reference as a canonical URL and looking it up in a local registry/repository." />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.insurer.identifier">
      <path value="ClaimResponse.insurer.identifier" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.request">
      <path value="ClaimResponse.request" />
      <comment value="Usage:  This is the number assigned, by the provider, to the request to which this response applies.   This includes both the main identifier as well as the trace number for backward compatibility.&#xD;&#xA;CPHA Map:   Trace Number E.02.03 6N, maps to display&#xD;&#xA;&#xD;&#xA;&#xD;&#xA;References SHALL be a reference to an actual FHIR resource, and SHALL be resolveable (allowing for access control, temporary unavailability, etc.). Resolution can be either by retrieval from the URL, or, where applicable by resource type, by treating an absolute reference as a canonical URL and looking it up in a local registry/repository." />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.request.identifier">
      <path value="ClaimResponse.request.identifier" />
      <comment value="CPHA Map:  Trace Number E.02.03 &#xD;&#xA;&#xD;&#xA;When an identifier is provided in place of a reference, any system processing the reference will only be able to resolve the identifier to a reference if it understands the business context in which the identifier is used. Sometimes this is global (e.g. a national identifier) but often it is not. For this reason, none of the useful mechanisms described for working with references (e.g. chaining, includes) are possible, nor should servers be expected to be able resolve the reference. Servers may accept an identifier based reference untouched, resolve it, and/or reject it - see CapabilityStatement.rest.resource.referencePolicy. &#xA;&#xA;When both an identifier and a literal reference are provided, the literal reference is preferred. Applications processing the resource are allowed - but not required - to check that the identifier matches the literal reference&#xA;&#xA;Applications converting a logical reference to a literal reference may choose to leave the logical reference present, or remove it.&#xA;&#xA;Reference is intended to point to a structure that can potentially be expressed as a FHIR resource, though there is no need for it to exist as an actual FHIR resource instance - except in as much as an application wishes to actual find the target of the reference. The content referred to be the identifier must meet the logical constraints implied by any limitations on what resource types are permitted for the reference.  For example, it would not be legitimate to send the identifier for a drug prescription if the type were Reference(Observation|DiagnosticReport).  One of the use-cases for Reference.identifier is the situation where no FHIR representation exists (where the type is Reference (Any)." />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.request.identifier.system">
      <path value="ClaimResponse.request.identifier.system" />
      <min value="1" />
      <fixedUri value="http://pharmacyeclaims.ca/FHIR/CPHA-identifier/trace-number" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.request.identifier.value">
      <path value="ClaimResponse.request.identifier.value" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.request.display">
      <path value="ClaimResponse.request.display" />
      <comment value="Usage Note:  This will be the Claim.identifier (slice Claim-identifier) from the request message.   Note:  the additional identifier from the request ( Trace number ) will be conveyed in the display element.&#xD;&#xA;CPHA MAP:   &#xD;&#xA;&#xD;&#xA;This is generally not the same as the Resource.text of the referenced resource.  The purpose is to identify what's being referenced, not to fully describe it." />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.outcome">
      <path value="ClaimResponse.outcome" />
      <fixedCode value="error" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.disposition">
      <path value="ClaimResponse.disposition" />
      <comment value="CPHA Map:   Response Status E.05.03&#xD;&#xA;This indicates the status of the claim response which is a value of &quot;R&quot; = Rejected claim/reversal&#xD;&#xA;&#xD;&#xA;Set value = Single letter of A or B or C, etc.. as follows:&#xD;&#xA;&#xD;&#xA;A=accepted as transmitted - no adjustments&#xD;&#xA;B=accepted with Rx price adjustment&#xD;&#xA;C=claim captured for batch processing&#xD;&#xA;D=pay cardholder claim accepted&#xD;&#xA;R=rejected claim/reversal&#xD;&#xA;V=reversal acceptedNote that FHIR strings SHALL NOT exceed 1MB in size" />
      <min value="1" />
      <fixedString value="R" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.item">
      <path value="ClaimResponse.item" />
      <comment value="Note:  This is not permitted; used as a differentiator in the FHIR profiles." />
      <max value="0" />
    </element>
    <element id="ClaimResponse.processNote">
      <path value="ClaimResponse.processNote" />
      <comment value="Usage:  Detailed response information which may be returned with errors.&#xD;&#xA;&#xD;&#xA;Conformance Rule:   A maximum of 1000 characters may be returned for each note&#xD;&#xA;Conformance Rule:   A maximum of 10 notes can be returned; this allows for a given note to be returned in both english and french and therefore allows up to 20 instances.    &#xD;&#xA;Conformance Rule:   Where possible adjudicators must return both english and french as this allows the vendor to display the note in the language of the user.&#xD;&#xA;Conformance Rule:    Vendors must co-relate french and english notes by assigning the same processNote.number&#xD;&#xA;Conformance Rule:   When the adjudicator does not know whether a note is french or english, the language.text must contain a value of &quot;unknown&quot;.&#xD;&#xA;&#xD;&#xA;CPHA Map:  Message Data Lines 1,2,3  E.20.03, E.21.03, E.22.03  A/N40" />
      <max value="20" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.processNote.text">
      <path value="ClaimResponse.processNote.text" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.error">
      <path value="ClaimResponse.error" />
      <comment value="Usage Note:   A new code set has been created which contains a subset of the CPHA Response Codes.  This logically separates errors from other types of response codes.   TBD&#xD;&#xA;CPHA Map:  Response Codes E.06.03&#xD;&#xA;&#xD;&#xA;If the request contains errors then an error element should be provided and no adjudication related sections (item, addItem, or payment) should be present." />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.error.code">
      <path value="ClaimResponse.error.code" />
      <mustSupport value="true" />
      <binding>
        <strength value="extensible" />
        <valueSet value="http://pharmacyeclaims.ca/FHIR/ValueSet/error-code" />
      </binding>
    </element>
    <element id="ClaimResponse.error.code.coding">
      <path value="ClaimResponse.error.code.coding" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.error.code.coding.system">
      <path value="ClaimResponse.error.code.coding.system" />
      <min value="1" />
      <fixedUri value="http://pharmacyeclaims.ca/FHIR/CodeSystem/error-code" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.error.code.coding.code">
      <path value="ClaimResponse.error.code.coding.code" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="ClaimResponse.error.code.text">
      <path value="ClaimResponse.error.code.text" />
      <mustSupport value="true" />
    </element>
  </differential>
</StructureDefinition>