<?xml version="1.0" encoding="UTF-8"?>
<resourceDefinitions xmlns="http://www.hl7.org/fhir" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.hl7.org/fhir definitions.xsd">
  <author>HL7</author>
  <resourceDefinition>
    <name>Message</name>
    <elementDefinitions>
      <elementDefinition>
        <name>Message</name>
        <cardinality>
          <minOccurs>1</minOccurs>
          <maxOccurs>1</maxOccurs>
        </cardinality>
        <conformance>Mandatory</conformance>
        <condition></condition>
        <mustUnderstand>false</mustUnderstand>
        <definition>A message that contains FHIR resources</definition>
        <requirements>Many implementations are not prepared to use REST, and need a message based infrastructure</requirements>
        <rim></rim>
      </elementDefinition>
      <elementDefinition>
        <name>Message.id</name>
        <cardinality>
          <minOccurs>1</minOccurs>
          <maxOccurs>1</maxOccurs>
        </cardinality>
        <conformance>Mandatory</conformance>
        <condition></condition>
        <types>
          <type>id</type>
        </types>
        <mustUnderstand>true</mustUnderstand>
        <definition>Unique Id for this message</definition>
        <requirements>Each message needs a unique identifier so other messages and underlying infrastructure can reference it</requirements>
        <comments>must be unique within a channel, but should be globally unique. UUIDs are recommended</comments>
        <rim></rim>
      </elementDefinition>
      <elementDefinition>
        <name>Message.threadId</name>
        <cardinality>
          <minOccurs>0</minOccurs>
          <maxOccurs>1</maxOccurs>
        </cardinality>
        <conformance>Optional</conformance>
        <condition></condition>
        <types>
          <type>id</type>
        </types>
        <mustUnderstand>false</mustUnderstand>
        <definition>Id of the thread - a series of messages that pertain to the same logical sequence, and are all identified by the same thread identifier</definition>
        <requirements></requirements>
        <rim></rim>
      </elementDefinition>
      <elementDefinition>
        <name>Message.instant</name>
        <cardinality>
          <minOccurs>1</minOccurs>
          <maxOccurs>1</maxOccurs>
        </cardinality>
        <conformance>Mandatory</conformance>
        <condition></condition>
        <types>
          <type>instant</type>
        </types>
        <mustUnderstand>true</mustUnderstand>
        <definition>Instant the message was sent</definition>
        <requirements></requirements>
        <rim></rim>
      </elementDefinition>
      <elementDefinition>
        <name>Message.event</name>
        <cardinality>
          <minOccurs>1</minOccurs>
          <maxOccurs>1</maxOccurs>
        </cardinality>
        <conformance>Mandatory</conformance>
        <condition></condition>
        <types>
          <type>code</type>
        </types>
        <conceptDomain>MessageEvent</conceptDomain>
        <mustUnderstand>true</mustUnderstand>
        <definition>Code that identifies the event this message represents, and connects it with the event definition in the FHIR specification</definition>
        <requirements></requirements>
        <rim></rim>
      </elementDefinition>
      <elementDefinition>
        <name>Message.response</name>
        <cardinality>
          <minOccurs>0</minOccurs>
          <maxOccurs>1</maxOccurs>
        </cardinality>
        <conformance>Optional</conformance>
        <condition></condition>
        <mustUnderstand>true</mustUnderstand>
        <definition>Information about the the message that this message is a response to - if it is a response</definition>
        <requirements></requirements>
        <rim></rim>
      </elementDefinition>
      <elementDefinition>
        <name>Message.response.id</name>
        <cardinality>
          <minOccurs>1</minOccurs>
          <maxOccurs>1</maxOccurs>
        </cardinality>
        <conformance>Mandatory</conformance>
        <condition></condition>
        <types>
          <type>id</type>
        </types>
        <mustUnderstand>true</mustUnderstand>
        <definition>The id of the message that this a response to</definition>
        <requirements></requirements>
        <comments>this message must have the same threadId as the original message (including missing if the original message threadId was missing)</comments>
        <rim></rim>
      </elementDefinition>
      <elementDefinition>
        <name>Message.response.code</name>
        <cardinality>
          <minOccurs>1</minOccurs>
          <maxOccurs>1</maxOccurs>
        </cardinality>
        <conformance>Mandatory</conformance>
        <condition></condition>
        <types>
          <type>code</type>
        </types>
        <conceptDomain>ResponseCode</conceptDomain>
        <mustUnderstand>true</mustUnderstand>
        <definition>Code that identifies the type of response to the message - whether it was successful or not, and whether it should be resent or not</definition>
        <requirements></requirements>
        <comments>This is a generic response to the request message. Specific data for the response will be found in Message.data</comments>
        <rim></rim>
      </elementDefinition>
      <elementDefinition>
        <name>Message.response.duplicate</name>
        <cardinality>
          <minOccurs>1</minOccurs>
          <maxOccurs>1</maxOccurs>
        </cardinality>
        <conformance>Mandatory</conformance>
        <condition></condition>
        <types>
          <type>boolean</type>
        </types>
        <mustUnderstand>true</mustUnderstand>
        <definition>True if this is not the first response, because the request message has been received more than once</definition>
        <requirements></requirements>
        <comments>The request shouldn't be received more than once if reliable message delivery applies, but mostly it doesn't</comments>
        <rim></rim>
      </elementDefinition>
      <elementDefinition>
        <name>Message.source</name>
        <cardinality>
          <minOccurs>1</minOccurs>
          <maxOccurs>1</maxOccurs>
        </cardinality>
        <conformance>Mandatory</conformance>
        <condition></condition>
        <types>
          <type>Resource(Device)</type>
        </types>
        <mustUnderstand>false</mustUnderstand>
        <definition>The source application from which this message originated</definition>
        <requirements></requirements>
        <rim></rim>
      </elementDefinition>
      <elementDefinition>
        <name>Message.destination</name>
        <cardinality>
          <minOccurs>1</minOccurs>
          <maxOccurs>1</maxOccurs>
        </cardinality>
        <conformance>Mandatory</conformance>
        <condition></condition>
        <types>
          <type>Resource(Device)</type>
        </types>
        <mustUnderstand>false</mustUnderstand>
        <definition>The destination application which the message is intended for</definition>
        <requirements></requirements>
        <rim></rim>
      </elementDefinition>
      <elementDefinition>
        <name>Message.enterer</name>
        <cardinality>
          <minOccurs>0</minOccurs>
          <maxOccurs>1</maxOccurs>
        </cardinality>
        <conformance>Optional</conformance>
        <condition></condition>
        <types>
          <type>Resource(Person|Device)</type>
        </types>
        <mustUnderstand>false</mustUnderstand>
        <definition>The person or device that performd the data entry leading to this message. Where there is more than one candidate, pick the most proximal to the message. Can provide other enterers in extensions</definition>
        <requirements>Need to know for audit/traceback requirements</requirements>
        <comments>Usually only for the request, but can be used in a response</comments>
        <rim></rim>
      </elementDefinition>
      <elementDefinition>
        <name>Message.author</name>
        <cardinality>
          <minOccurs>0</minOccurs>
          <maxOccurs>1</maxOccurs>
        </cardinality>
        <conformance>Optional</conformance>
        <condition></condition>
        <types>
          <type>Resource(Person|Device)</type>
        </types>
        <mustUnderstand>false</mustUnderstand>
        <definition>The logical author of the message - the person or device that decided it should happen. Where there is more than one candidate, pick the most proximal to the message. Can provide other enterers in extensions</definition>
        <requirements>Need to know for audit/traceback requirements</requirements>
        <comments>Usually only for the request, but can be used in a response</comments>
        <rim></rim>
      </elementDefinition>
      <elementDefinition>
        <name>Message.responsible</name>
        <cardinality>
          <minOccurs>0</minOccurs>
          <maxOccurs>1</maxOccurs>
        </cardinality>
        <conformance>Optional</conformance>
        <condition></condition>
        <types>
          <type>Resource(Person|Organization)</type>
        </types>
        <mustUnderstand>false</mustUnderstand>
        <definition>The person or organization that accepts overall responsbility for the contents of the message. The implication is that the message event happened under the policies of the responsible party</definition>
        <requirements>Need to know for audit/traceback requirements</requirements>
        <comments>Usually only for the request, but can be used in a response</comments>
        <rim></rim>
      </elementDefinition>
      <elementDefinition>
        <name>Message.effective</name>
        <cardinality>
          <minOccurs>0</minOccurs>
          <maxOccurs>1</maxOccurs>
        </cardinality>
        <conformance>Optional</conformance>
        <condition></condition>
        <types>
          <type>Interval(dateTime)</type>
        </types>
        <mustUnderstand>false</mustUnderstand>
        <definition>The effective time - the real world time of the even that the message represents. Usually this is just a starting time, but some message events also have an end time (do x for period y)</definition>
        <requirements>Need to know for understanding the content of the message</requirements>
        <comments>Usually only for the request, but can be used in a response</comments>
        <rim></rim>
        <todo>Grahame thinks this is not 80/20. Also, that it reall should be domain modeled, not tucked away here</todo>
      </elementDefinition>
      <elementDefinition>
        <name>Message.reason</name>
        <cardinality>
          <minOccurs>0</minOccurs>
          <maxOccurs>1</maxOccurs>
        </cardinality>
        <conformance>Optional</conformance>
        <condition></condition>
        <types>
          <type>CodeableConcept</type>
        </types>
        <conceptDomain>EventReason</conceptDomain>
        <mustUnderstand>false</mustUnderstand>
        <definition>The cause of the event - a reason for why this message is being sent</definition>
        <requirements>Need to be able to track why resources are being changed and report in the audit log / history of the resource</requirements>
        <rim>ControlAct.reasonCode</rim>
      </elementDefinition>
      <elementDefinition>
        <name>Message.data</name>
        <cardinality>
          <minOccurs>0</minOccurs>
          <maxOccurs>1</maxOccurs>
        </cardinality>
        <conformance>Conditional</conformance>
        <condition>Mandatory unless the message is a response, in which case the element is optional</condition>
        <types>
          <type>Resource(Any)</type>
        </types>
        <mustUnderstand>true</mustUnderstand>
        <definition>The actual data of the message - a reference to the focus class of the message. </definition>
        <requirements>Every message event is about actual data, a single resource, that is identified in the definition of the event, and perhaps some or all linked resources</requirements>
        <comments>The data is defined where the transaction type is defined. The transaction data is always aggregated with the transaction resource</comments>
        <rim></rim>
      </elementDefinition>
      <elementDefinition>
        <name>Message.extensions</name>
        <cardinality>
          <minOccurs>0</minOccurs>
          <maxOccurs>1</maxOccurs>
        </cardinality>
        <conformance>Optional</conformance>
        <condition></condition>
        <mustUnderstand>false</mustUnderstand>
        <definition>See Extensions</definition>
        <requirements></requirements>
        <rim></rim>
      </elementDefinition>
      <elementDefinition>
        <name>Message.text</name>
        <cardinality>
          <minOccurs>1</minOccurs>
          <maxOccurs>1</maxOccurs>
        </cardinality>
        <conformance>Mandatory</conformance>
        <condition></condition>
        <types>
          <type>Narrative</type>
        </types>
        <mustUnderstand>false</mustUnderstand>
        <definition> </definition>
        <requirements></requirements>
        <rim></rim>
      </elementDefinition>
    </elementDefinitions>
  </resourceDefinition>
</resourceDefinitions>

