<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="ObservationSocialHistoryPSAB" />
  <url value="https://www.alberta.ca/fhir/psab/StructureDefinition/ObservationSocialHistoryPSAB" />
  <version value="1.2.0" />
  <name value="ObservationSocialHistoryPSAB" />
  <title value="Observation-SocialHistory (PS-AB)" />
  <status value="draft" />
  <description value="This profile defines a set of constraints to the FHIR Observation (Social History) resource for use in Alberta Patient Summaries (PS-AB). It re-profiles the PS-CA Social History (General) profile and refines constraints applied to the Observation (Social History) resource when used in the PS-AB Composition profile." />
  <fhirVersion value="4.0.1" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="Observation" />
  <baseDefinition value="http://fhir.infoway-inforoute.ca/io/psca/StructureDefinition/observation-socialhistory-ca-ps" />
  <derivation value="constraint" />
  <differential>
    <element id="Observation">
      <path value="Observation" />
      <comment value="Observation (Social History) resources included in Alberta Patient Summary Document Bundles have rules that certain attributes are not to be contained in Observation (Social History) resource. These are mechanically enforced through invariants at the PS-AB Bundle level." />
    </element>
    <element id="Observation.category:social-history">
      <path value="Observation.category" />
      <sliceName value="social-history" />
      <sliceIsConstraining value="true" />
    </element>
    <element id="Observation.category:social-history.coding">
      <path value="Observation.category.coding" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.category:social-history.coding.system">
      <path value="Observation.category.coding.system" />
      <comment value="Fixed system value of 'http://terminology.hl7.org/CodeSystem/observation-category'" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.category:social-history.coding.code">
      <path value="Observation.category.coding.code" />
      <comment value="Fixed code value of 'social-history'" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.code.text">
      <path value="Observation.code.text" />
      <comment value="Text string describing the risk factor or type of observation" />
      <min value="1" />
    </element>
    <element id="Observation.subject">
      <path value="Observation.subject" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://www.alberta.ca/fhir/psab/StructureDefinition/PatientPSAB" />
      </type>
    </element>
    <element id="Observation.effective[x]">
      <path value="Observation.effective[x]" />
      <slicing>
        <discriminator>
          <type value="type" />
          <path value="$this" />
        </discriminator>
        <ordered value="false" />
        <rules value="open" />
      </slicing>
      <comment value="Required for each lifestyle factor submitted. YYYY-MM-DD format. Partial dates (YYYY only or YYYY-MM only) are accepted." />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Observation.effective[x]:effectiveDateTime">
      <path value="Observation.effective[x]" />
      <sliceName value="effectiveDateTime" />
      <comment value="YYYY-MM-DDThh:mm:ss[+|-]ZZ:ZZ  e.g.,: 1980-05-31T12:23:12-05:00" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="dateTime" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Observation.performer">
      <path value="Observation.performer" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://www.alberta.ca/fhir/psab/StructureDefinition/PractitionerPSAB" />
        <targetProfile value="https://www.alberta.ca/fhir/psab/StructureDefinition/PractitionerRolePSAB" />
        <targetProfile value="https://www.alberta.ca/fhir/psab/StructureDefinition/PatientPSAB" />
      </type>
    </element>
    <element id="Observation.value[x]">
      <path value="Observation.value[x]" />
      <slicing>
        <discriminator>
          <type value="type" />
          <path value="$this" />
        </discriminator>
        <ordered value="false" />
        <rules value="open" />
      </slicing>
      <min value="1" />
    </element>
    <element id="Observation.value[x]:valueString">
      <path value="Observation.value[x]" />
      <sliceName value="valueString" />
      <comment value="If value is populated (desired over note), it is expected to be populated in string format" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="string" />
      </type>
      <mustSupport value="true" />
    </element>
    <element id="Observation.note">
      <path value="Observation.note" />
      <short value="Lifestyle Risk Factor Notes" />
    </element>
  </differential>
</StructureDefinition>