<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="User" />
  <url value="http://hl7.org/fhir/StructureDefinition/User" />
  <version value="0.1" />
  <name value="User" />
  <status value="draft" />
  <publisher value="Synapxe" />
  <copyright value="Copyright (C) 2024 Synapxe" />
  <fhirVersion value="5.0.0" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="User" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/DomainResource" />
  <derivation value="specialization" />
  <differential>
    <element id="User">
      <path value="User" />
      <constraint>
        <key value="dom-3" />
        <severity value="error" />
        <human value="If the resource is contained in another resource, it SHALL be referred to from elsewhere in the resource or SHALL refer to the containing resource" />
        <expression value="contained.where(((id.exists() and ('#'+id in (%resource.descendants().reference | %resource.descendants().as(canonical) | %resource.descendants().as(uri) | %resource.descendants().as(url)))) or descendants().where(reference = '#').exists() or descendants().where(as(canonical) = '#').exists() or descendants().where(as(uri) = '#').exists()).not()).trace('unmatched', id).empty()" />
      </constraint>
      <constraint>
        <key value="email-format" />
        <severity value="error" />
        <human value="If system is 'email', the value must be a valid email address." />
        <expression value="email.matches('^\\S+@\\S+\\.\\S{2,}$')" />
      </constraint>
    </element>
    <element id="User.name">
      <path value="User.name" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="string" />
      </type>
      <isModifier value="false" />
    </element>
    <element id="User.email">
      <path value="User.email" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="string" />
      </type>
      <isModifier value="false" />
    </element>
    <element id="User.status">
      <path value="User.status" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="string" />
      </type>
      <isModifier value="false" />
      <binding>
        <strength value="required" />
        <valueSet value="https://fhir.synapxe.sg/ValueSet/user-status" />
      </binding>
    </element>
    <element id="User.location">
      <path value="User.location" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="string" />
      </type>
      <isModifier value="false" />
    </element>
    <element id="User.lastLoginOn">
      <path value="User.lastLoginOn" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="BackboneElement" />
      </type>
      <isModifier value="false" />
    </element>
    <element id="User.preference">
      <path value="User.preference" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="string" />
      </type>
      <isModifier value="false" />
    </element>
    <element id="User.preferredRole">
      <path value="User.preferredRole" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Role" />
      </type>
      <isModifier value="false" />
    </element>
    <element id="User.role">
      <path value="User.role" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Role" />
      </type>
      <isModifier value="false" />
    </element>
    <element id="User.createdBy">
      <path value="User.createdBy" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="string" />
      </type>
      <isModifier value="false" />
    </element>
    <element id="User.creationDateTime">
      <path value="User.creationDateTime" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="BackboneElement" />
      </type>
      <isModifier value="false" />
    </element>
    <element id="User.modifiedBy">
      <path value="User.modifiedBy" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="string" />
      </type>
      <isModifier value="false" />
    </element>
    <element id="User.isDeleted">
      <path value="User.isDeleted" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="boolean" />
      </type>
      <isModifier value="false" />
    </element>
    <element id="User.modificationDateTime">
      <path value="User.modificationDateTime" />
      <min value="1" />
      <max value="1" />
      <type>
        <code value="BackboneElement" />
      </type>
      <isModifier value="false" />
    </element>
  </differential>
</StructureDefinition>