<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="profile-message-header-response" />
  <url value="http://pharmacyeclaims.ca/FHIR/v1.0/StructureDefinition/profile-message-header-response" />
  <name value="MessageHeaderResponse" />
  <title value="Message Header Response" />
  <status value="draft" />
  <description value="MessageHeaderResponse" />
  <purpose value="MessageHeaderResponse" />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="MessageHeader" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/MessageHeader" />
  <derivation value="constraint" />
  <differential>
    <element id="MessageHeader.id">
      <path value="MessageHeader.id" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="MessageHeader.meta">
      <path value="MessageHeader.meta" />
      <mustSupport value="true" />
    </element>
    <element id="MessageHeader.meta.tag">
      <path value="MessageHeader.meta.tag" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="system" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="MessageHeader.meta.tag.system">
      <path value="MessageHeader.meta.tag.system" />
      <mustSupport value="true" />
    </element>
    <element id="MessageHeader.meta.tag.code">
      <path value="MessageHeader.meta.tag.code" />
      <mustSupport value="true" />
    </element>
    <element id="MessageHeader.event[x]">
      <path value="MessageHeader.event[x]" />
      <comment value="Usage Note::   The event code will identify the transaction type being processed&#xD;&#xA;processed.   &#xD;&#xA;Set value = 51= Response to a dispense claim&#xD;&#xA;Set value = 52 - Response to professional services claim&#xD;&#xA;Set value = 61= Response to request for reversal &#xD;&#xA;Set value = 80 = Response for Daily Totals&#xD;&#xA;Set value = 81 = Response Adjudication Summary&#xD;&#xA;&#xD;&#xA;CPHA Mapping: Transaction Code  A.03.03.     &#xD;&#xA;&#xD;&#xA;The time of the event will be found in the focus resource. The time of the message will be found in [Bundle.timestamp](bundle-definitions.html#Bundle.timestamp)." />
      <type>
        <code value="Coding" />
      </type>
      <mustSupport value="true" />
      <binding>
        <strength value="preferred" />
        <valueSet value="http://pharmacyeclaims.ca/fhir/valueset-message-events" />
      </binding>
    </element>
    <element id="MessageHeader.event[x].system">
      <path value="MessageHeader.event[x].system" />
      <comment value="Usage:   A fixed value of http://pharmacyeclaims.ca/fhir/CodeSystem/message-events-response&#xD;&#xA;CPHA Mapping:  None &#xD;&#xA;The URI may be an OID (urn:oid:...) or a UUID (urn:uuid:...).  OIDs and UUIDs SHALL be references to the HL7 OID registry. Otherwise, the URI should come from HL7's list of FHIR defined special URIs or it should reference to some definition that establishes the system clearly and unambiguously." />
      <min value="1" />
      <fixedUri value="http://pharmacyeclaims.ca/fhir/CodeSystem/message-events" />
      <mustSupport value="true" />
    </element>
    <element id="MessageHeader.event[x].code">
      <path value="MessageHeader.event[x].code" />
      <comment value="Usage:  The response value will be one of:&#xD;&#xA;51 - Response to Pay Provider or Pay Cardholder Claim for Dispensed Medication&#xD;&#xA;52 - Response to Professional Services Claim&#xD;&#xA;61 - Response to Reversal Request&#xD;&#xA;80 - Response to Daily Totals&#xD;&#xA;81 - Response to Adjudication DetailsNote that FHIR strings SHALL NOT exceed 1MB in size" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="MessageHeader.destination">
      <path value="MessageHeader.destination" />
      <comment value="Usage Note:   For responses, the destination is the sending Pharmacy&#xD;&#xA;&#xD;&#xA;There SHOULD be at least one destination, but in some circumstances, the source system is unaware of any particular destination system." />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="MessageHeader.destination.target">
      <path value="MessageHeader.destination.target" />
      <mustSupport value="true" />
    </element>
    <element id="MessageHeader.destination.target.identifier">
      <path value="MessageHeader.destination.target.identifier" />
      <comment value="Usage:  An optional identifier used to specify the target network&#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)." />
      <mustSupport value="true" />
    </element>
    <element id="MessageHeader.destination.endpoint">
      <path value="MessageHeader.destination.endpoint" />
      <comment value="Usage Note:   Endpoint for the network routing to the Pharmacy.   Normally this is the source endpoint from the request message.&#xD;&#xA;&#xD;&#xA;The id may be a non-resolvable URI for systems that do not use standard network-based addresses." />
      <mustSupport value="true" />
    </element>
    <element id="MessageHeader.destination.receiver">
      <path value="MessageHeader.destination.receiver" />
      <mustSupport value="true" />
    </element>
    <element id="MessageHeader.destination.receiver.identifier">
      <path value="MessageHeader.destination.receiver.identifier" />
      <comment value="Usage Note:   This should be treated as mandatory for backward compatibility&#xD;&#xA;CPHA Mapping:  Provider Software ID   A.04.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)." />
      <mustSupport value="true" />
    </element>
    <element id="MessageHeader.destination.receiver.display">
      <path value="MessageHeader.destination.receiver.display" />
      <comment value="Usage:   This should be treated as mandatory for backward compatibility&#xD;&#xA;CPHA Map:  Provider Software Version A.05.03&#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="MessageHeader.source">
      <path value="MessageHeader.source" />
      <comment value="Usage Note:   This is the endpoint of the Adjudicator;  values will be set by each system.    This may vary across environments (test/production)." />
      <mustSupport value="true" />
    </element>
    <element id="MessageHeader.source.endpoint">
      <path value="MessageHeader.source.endpoint" />
      <mustSupport value="true" />
    </element>
    <element id="MessageHeader.response">
      <path value="MessageHeader.response" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="MessageHeader.response.identifier">
      <path value="MessageHeader.response.identifier" />
      <comment value="Usage Note:  Mandatory as this allows the receiver to link the request and response&#xD;&#xA;&#xD;&#xA;RFC 4122" />
      <mustSupport value="true" />
    </element>
    <element id="MessageHeader.response.code">
      <path value="MessageHeader.response.code" />
      <mustSupport value="true" />
    </element>
    <element id="MessageHeader.response.details">
      <path value="MessageHeader.response.details" />
      <comment value="Usage Note:   If the message has failed, an operation outcome with further details may be included here; will also be referenced as the focus if there is only an Operations Outcome that is returned.&#xD;&#xA;&#xD;&#xA;This SHALL be contained in the bundle. If any of the issues are errors, the response code SHALL be an error." />
      <mustSupport value="true" />
    </element>
    <element id="MessageHeader.response.details.reference">
      <path value="MessageHeader.response.details.reference" />
      <mustSupport value="true" />
    </element>
    <element id="MessageHeader.focus">
      <path value="MessageHeader.focus" />
      <comment value="Usage:  Mandatory when the message has been successfully processed by the receiving application&#xD;&#xA;&#xD;&#xA;The data is defined where the transaction type is defined. The transaction data is always included in the bundle that is the full message.  Only the root resource is specified.  The resources it references should be contained in the bundle but are not also listed here.  Multiple repetitions are allowed to cater for merges and other situations with multiple focal targets." />
      <max value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://pharmacyeclaims.ca/FHIR/v1.0/StructureDefinition/profile-claim-response" />
        <targetProfile value="http://pharmacyeclaims.ca/FHIR/v1.0/StructureDefinition/profile-error-response" />
        <targetProfile value="http://pharmacyeclaims.ca/FHIR/v1.0/StructureDefinition/profile-parameters-reversal-OUT" />
        <targetProfile value="http://pharmacyeclaims.ca/FHIR/v1.0/StructureDefinition/profile-parameters-OUT-AdjudicationDetails" />
        <targetProfile value="http://pharmacyeclaims.ca/FHIR/v1.0/StructureDefinition/profile-parameters-daily-totals-OUT" />
        <aggregation value="bundled" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="MessageHeader.focus.reference">
      <path value="MessageHeader.focus.reference" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
  </differential>
</StructureDefinition>