<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="profile-PaymentNotice" />
  <url value="https://bpcs.exchange/fhir/StructureDefinition/profile-PaymentNotice" />
  <name value="PaymentNotice" />
  <title value="Payment Notice" />
  <status value="active" />
  <experimental value="false" />
  <description value="A record showing a payment made to a patient" />
  <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="PaymentNotice" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/PaymentNotice" />
  <derivation value="constraint" />
  <differential>
    <element id="PaymentNotice.id">
      <path value="PaymentNotice.id" />
      <comment value="This will be the odbNum followed by the date.  If there are multiple payments to the same odbNum for the same day, add a sequence number to make the payments unique." />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="PaymentNotice.status">
      <path value="PaymentNotice.status" />
      <patternCode value="active" />
    </element>
    <element id="PaymentNotice.created.extension">
      <path value="PaymentNotice.created.extension" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="PaymentNotice.created.extension:dar">
      <path value="PaymentNotice.created.extension" />
      <sliceName value="dar" />
      <min value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://hl7.org/fhir/StructureDefinition/data-absent-reason" />
      </type>
    </element>
    <element id="PaymentNotice.created.extension:dar.url">
      <path value="PaymentNotice.created.extension.url" />
      <fixedUri value="http://hl7.org/fhir/StructureDefinition/data-absent-reason" />
    </element>
    <element id="PaymentNotice.created.extension:dar.value[x]">
      <path value="PaymentNotice.created.extension.value[x]" />
      <slicing>
        <discriminator>
          <type value="type" />
          <path value="$this" />
        </discriminator>
        <ordered value="false" />
        <rules value="open" />
      </slicing>
    </element>
    <element id="PaymentNotice.created.extension:dar.value[x]:dar">
      <path value="PaymentNotice.created.extension.value[x]" />
      <sliceName value="dar" />
      <min value="1" />
    </element>
    <element id="PaymentNotice.paymentDate">
      <path value="PaymentNotice.paymentDate" />
      <min value="1" />
      <type>
        <code value="date" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/profile-date-full" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="PaymentDTO.paymentDate" />
      </mapping>
    </element>
    <element id="PaymentNotice.payee">
      <path value="PaymentNotice.payee" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="PaymentNotice.payee.extension">
      <path value="PaymentNotice.payee.extension" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="PaymentNotice.payee.extension:patient">
      <path value="PaymentNotice.payee.extension" />
      <sliceName value="patient" />
      <min value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://hl7.org/fhir/StructureDefinition/alternate-reference" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="PaymentDTO.odbNum" />
      </mapping>
    </element>
    <element id="PaymentNotice.payee.extension:patient.url">
      <path value="PaymentNotice.payee.extension.url" />
      <fixedUri value="http://hl7.org/fhir/StructureDefinition/alternate-reference" />
    </element>
    <element id="PaymentNotice.payee.extension:patient.value[x]">
      <path value="PaymentNotice.payee.extension.value[x]" />
      <type>
        <code value="Reference" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/profile-Reference-rest" />
        <targetProfile value="https://bpcs.exchange/fhir/StructureDefinition/profile-Patient-search" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="PaymentNotice.payee.display">
      <path value="PaymentNotice.payee.display" />
      <short value="Patient name" />
      <min value="1" />
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="PaymentDTO.name" />
      </mapping>
    </element>
    <element id="PaymentNotice.recipient">
      <path value="PaymentNotice.recipient" />
      <patternReference>
        <display value="BPCS" />
      </patternReference>
    </element>
    <element id="PaymentNotice.amount">
      <path value="PaymentNotice.amount" />
      <type>
        <code value="Money" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/profile-Money-CAD" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="PaymentDTO.amount" />
      </mapping>
    </element>
    <element id="PaymentNotice.paymentStatus">
      <path value="PaymentNotice.paymentStatus" />
      <min value="1" />
      <patternCodeableConcept>
        <coding>
          <system value="http://terminology.hl7.org/CodeSystem/paymentstatus" />
          <code value="paid" />
        </coding>
      </patternCodeableConcept>
    </element>
  </differential>
</StructureDefinition>