<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="profile-Provenance" />
  <url value="https://bpcs.exchange/fhir/StructureDefinition/profile-Provenance" />
  <name value="Provenance" />
  <title value="Provenance Profile" />
  <status value="active" />
  <experimental value="false" />
  <description value="Allows information about who is responsible for creating, updating, and/or marking as 'inactive' a given version of a record." />
  <fhirVersion value="5.0.0" />
  <mapping>
    <identity value="BPCS" />
    <name value="Internal BPCS API" />
  </mapping>
  <mapping>
    <identity value="BPCS" />
    <name value="Internal BPCS API" />
  </mapping>
  <kind value="resource" />
  <abstract value="false" />
  <type value="Provenance" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Provenance" />
  <derivation value="constraint" />
  <differential>
    <element id="Provenance.id">
      <path value="Provenance.id" />
      <comment value="This should be a simple integer (typically just '1' unless a recipient has multiple actions (e.g. update + inactivate)" />
      <mustSupport value="true" />
    </element>
    <element id="Provenance.target">
      <extension url="http://hl7.org/fhir/StructureDefinition/designNote">
        <valueMarkdown value="These create recusion problems when generating snapshot, and aren't technically necessary.         targetProfile https://bpcs.exchange/fhir/StructureDefinition/profile-Patient-search         targetProfile https://bpcs.exchange/fhir/StructureDefinition/profile-Group-search   targetProfile https://bpcs.exchange/fhir/StructureDefinition/profile-Coverage-family" />
      </extension>
      <path value="Provenance.target" />
      <max value="1" />
      <type>
        <code value="Reference" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/profile-Reference-rest" />
        <aggregation value="contained" />
        <versioning value="specific" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Provenance.target.reference">
      <path value="Provenance.target.reference" />
      <comment value="Point to the containing record" />
      <patternString value="#" />
    </element>
    <element id="Provenance.occurred[x]">
      <path value="Provenance.occurred[x]" />
      <short value="effModDt/recEffDate" />
      <definition value="This date is the first day that the data on the record is in effect." />
      <comment value="This could represent when the 1st (i.e. CREATE) record was added or any subsequent (i.e. UPDATE) records that were added." />
      <type>
        <code value="dateTime" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="recCreateTimestamp, recUpdateTimestamp, or recInactiveTimestamp (or CustomTimestamps - whichever is present)" />
      </mapping>
    </element>
    <element id="Provenance.activity">
      <path value="Provenance.activity" />
      <comment value="Inactivate maps to DELETE" />
      <min value="1" />
      <type>
        <code value="CodeableConcept" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/profile-CodeableConcept-simple" />
      </type>
      <mustSupport value="true" />
      <binding>
        <strength value="required" />
        <valueSet value="https://bpcs.exchange/fhir/ValueSet/vs-history-record-activity" />
      </binding>
    </element>
    <element id="Provenance.agent">
      <path value="Provenance.agent" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Provenance.agent.who">
      <path value="Provenance.agent.who" />
      <short value="Creating/Updating user" />
      <mustSupport value="true" />
    </element>
    <element id="Provenance.agent.who.identifier">
      <path value="Provenance.agent.who.identifier" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Provenance.agent.who.identifier.system">
      <path value="Provenance.agent.who.identifier.system" />
      <min value="1" />
      <patternUri value="https://bpcs.exchange/fhir/NamingSystem/userids" />
      <mustSupport value="true" />
    </element>
    <element id="Provenance.agent.who.identifier.value">
      <path value="Provenance.agent.who.identifier.value" />
      <min value="1" />
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="recCreateUserId, recUpdateUserId, or recInactiveUserId" />
      </mapping>
    </element>
  </differential>
</StructureDefinition>