<StructureDefinition xmlns="http://hl7.org/fhir" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://hl7.org/fhir ../../input-cache/schemas/R5/fhir-single.xsd">
  <id value="profile-Consent" />
  <url value="https://bpcs.exchange/fhir/StructureDefinition/profile-Consent" />
  <name value="Consent" />
  <title value="Consent" />
  <status value="active" />
  <experimental value="false" />
  <description value="A record of a recipient's consent (or consent refusal) with respect to automatic income retrieval from CRA" />
  <fhirVersion value="5.0.0" />
  <mapping>
    <identity value="BPCS" />
    <name value="Internal BPCS API" />
  </mapping>
  <kind value="resource" />
  <abstract value="false" />
  <type value="Consent" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Consent" />
  <derivation value="constraint" />
  <differential>
    <element id="Consent.id">
      <path value="Consent.id" />
      <comment value="This will be the [applicationId] + '.' + [odbNum]" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Consent.status">
      <path value="Consent.status" />
      <patternCode value="active" />
    </element>
    <element id="Consent.subject">
      <path value="Consent.subject" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/profile-Reference-rest" />
        <targetProfile value="https://bpcs.exchange/fhir/StructureDefinition/profile-Patient-create" />
      </type>
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="ODB number of containing Recipient" />
      </mapping>
    </element>
    <element id="Consent.date">
      <path value="Consent.date" />
      <min value="1" />
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="ConsentDTO.recordedDate" />
      </mapping>
    </element>
    <element id="Consent.grantor">
      <path value="Consent.grantor" />
      <short value="consenter" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <profile value="https://bpcs.exchange/fhir/StructureDefinition/profile-Reference-rest" />
        <targetProfile value="https://bpcs.exchange/fhir/StructureDefinition/profile-RelatedPerson-consenter" />
        <aggregation value="contained" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Consent.grantee">
      <path value="Consent.grantee" />
      <short value="consenter" />
      <min value="1" />
      <max value="1" />
      <patternReference>
        <reference value="Organization/bpcs" />
      </patternReference>
      <mustSupport value="true" />
    </element>
    <element id="Consent.policyBasis">
      <path value="Consent.policyBasis" />
      <short value="Type of consent" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Consent.policyBasis.url">
      <path value="Consent.policyBasis.url" />
      <short value="CRA income permission" />
      <definition value="A URL that indicates that the identified recipient has authorized the BPCS program to receive income information direct from CRA" />
      <min value="1" />
      <patternUrl value="https://bpcs.exchange/fhir/index.html#CRAConsent" />
      <mustSupport value="true" />
    </element>
    <element id="Consent.decision">
      <path value="Consent.decision" />
      <min value="1" />
      <mustSupport value="true" />
      <mapping>
        <identity value="BPCS" />
        <map value="ConsentDTO.status" />
      </mapping>
    </element>
  </differential>
</StructureDefinition>