<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="IspmResourceContextReference" />
  <meta>
    <lastUpdated value="2023-02-05T14:41:36.354088+00:00" />
  </meta>
  <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status">
    <valueCode value="normative" />
  </extension>
  <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-normative-version">
    <valueCode value="4.0.0" />
  </extension>
  <url value="http://com.philips.ispm.fhir.r4.profile/StructureDefinition/IspmResourceContextReference" />
  <version value="1.0.1" />
  <name value="IspmResourceContextReference" />
  <status value="draft" />
  <date value="2023-02-09T00:02:53.8161514+00:00" />
  <publisher value="Philips ISPM" />
  <contact>
    <name value="alexey.novikov@philips.com" />
    <telecom>
      <system value="email" />
      <value value="alexey.novikov@philips.com" />
      <use value="work" />
    </telecom>
  </contact>
  <description value="Base StructureDefinition for ISPM Resource Context Reference Type: A reference from one resource to another." />
  <fhirVersion value="4.0.1" />
  <kind value="logical" />
  <abstract value="false" />
  <type value="http://com.philips.ispm.fhir.r4.profile/StructureDefinition/IspmResourceContextReference" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Element" />
  <derivation value="specialization" />
  <differential>
    <element id="IspmResourceContextReference">
      <path value="IspmResourceContextReference" />
      <short value="A reference from one resource to another" />
      <definition value="A reference from one resource to another." />
      <comment value="ISPM References SHALL be a reference to an actual FHIR resource, and SHALL be resolveable (allowing for access control, temporary unavailability, etc.). Resolution can be either by retrieval from the URL, or, where applicable by resource type, by treating an absolute reference as a canonical URL and looking it up in a local registry/repository." />
      <constraint>
        <key value="ele-1" />
        <severity value="error" />
        <human value="All FHIR elements must have a @value or children" />
        <expression value="hasValue() or (children().count() &gt; id.count())" />
        <xpath value="@value|f:*|h:div" />
        <source value="http://hl7.org/fhir/StructureDefinition/Element" />
      </constraint>
      <constraint>
        <key value="ref-1" />
        <severity value="error" />
        <human value="SHALL have a contained resource if a local reference is provided" />
        <expression value="reference.startsWith('#').not() or (reference.substring(1).trace('url') in %rootResource.contained.id.trace('ids'))" />
        <xpath value="not(starts-with(f:reference/@value, '#')) or exists(ancestor::*[self::f:entry or self::f:parameter]/f:resource/f:*/f:contained/f:*[f:id/@value=substring-after(current()/f:reference/@value, '#')]|/*/f:contained/f:*[f:id/@value=substring-after(current()/f:reference/@value, '#')])" />
      </constraint>
    </element>
    <element id="IspmResourceContextReference.reference">
      <path value="IspmResourceContextReference.reference" />
      <short value="Literal reference, Relative, internal or absolute URL" />
      <definition value="A reference to a location at which the other resource is found. The reference may be a relative reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#') refer to contained resources." />
      <comment value="Using absolute URLs provides a stable scalable approach suitable for a cloud/web context, while using relative/logical references provides a flexible approach suitable for use when trading across closed eco-system boundaries.   Absolute URLs do not need to point to a FHIR RESTful server, though this is the preferred approach. If the URL conforms to the structure &quot;/[type]/[id]&quot; then it should be assumed that the reference is to a FHIR RESTful server." />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="string" />
      </type>
      <condition value="ref-1" />
      <condition value="ele-1" />
      <isSummary value="true" />
    </element>
    <element id="IspmResourceContextReference.resourceType">
      <path value="IspmResourceContextReference.resourceType" />
      <short value="ResourceType refers to (e.g. &quot;Practitioner&quot;)" />
      <definition value="The expected type of the target resource of the reference. If both Reference.resourceType and Reference.reference are populated and Reference.reference is a FHIR URL, both SHALL be consistent." />
      <comment value="This element is used to indicate the resource-type of the referenced target. This may be used which ever of the other elements are populated (or not). In some cases, the type of the target may be determined by inspection of the reference (e.g. a RESTful URL) or by resolving the target of the reference; if both the resource-type and a reference is provided, the reference SHALL resolve to a resource of the same type as that specified." />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="string" />
        <profile value="http://hl7.org/fhir/StructureDefinition/string" />
      </type>
      <condition value="ele-1" />
    </element>
  </differential>
</StructureDefinition>