<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="gap-provenance-profile" />
  <url value="http://akinox.com/fhir/StructureDefinition/gap-provenance-profile" />
  <version value="1.0.0" />
  <name value="GapProvenance" />
  <title value="GAP Provenance Profile" />
  <status value="draft" />
  <description value="A FHIR Provenance profile for GAP requests to track who initiated the request. This resource is optional (0..1 cardinality in the Bundle) and used when the source system can provide initiator information." />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="Provenance" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Provenance" />
  <derivation value="constraint" />
  <differential>
    <element id="Provenance">
      <path value="Provenance" />
      <constraint>
        <key value="gap-provenance-agent-author" />
        <severity value="error" />
        <human value="Agent type must be 'author' to indicate who initiated the request." />
        <expression value="agent.type.coding.where(system='http://terminology.hl7.org/CodeSystem/provenance-participant-type' and code='author').exists()" />
        <source value="http://akinox.com/fhir/StructureDefinition/gap-provenance-profile" />
      </constraint>
    </element>
    <element id="Provenance.target">
      <path value="Provenance.target" />
      <max value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Task" />
      </type>
    </element>
    <element id="Provenance.agent">
      <path value="Provenance.agent" />
      <max value="1" />
    </element>
    <element id="Provenance.agent.type">
      <path value="Provenance.agent.type" />
      <min value="1" />
      <binding>
        <strength value="required" />
        <valueSet value="http://hl7.org/fhir/ValueSet/provenance-participant-type" />
      </binding>
    </element>
    <element id="Provenance.agent.who">
      <path value="Provenance.agent.who" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Patient" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/RelatedPerson" />
      </type>
    </element>
  </differential>
</StructureDefinition>