<StructureDefinition xmlns="http://hl7.org/fhir">
  <url value="https://unicas-fhir.sanidad.gob.es/StructureDefinition/UNICASDocumentReference" />
  <name value="UNICASDocumentReference" />
  <title value="DocumentReference Documento en Base64 ÚNICAS" />
  <status value="draft" />
  <description value="Este profile define las restricciones del recurso DocumentReference para representar un documento clínico en el contexto del caso de uso de ÚNICAS." />
  <fhirVersion value="5.0.0" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="DocumentReference" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/DocumentReference" />
  <derivation value="constraint" />
  <differential>
    <element id="DocumentReference.identifier">
      <path value="DocumentReference.identifier" />
      <short value="Identificador único" />
      <definition value="Business identifiers for the document. Other business identifiers associated with the document, including version independent identifiers." />
      <min value="1" />
    </element>
    <element id="DocumentReference.identifier.system">
      <path value="DocumentReference.identifier.system" />
      <short value="Sistema para identificar el origen" />
      <definition value="Formato: urn:regcess:[CódigoREGCESS]&#xD;&#xA;Debe incluir el código REGCESS después de urn:regcess:" />
      <min value="1" />
      <constraint>
        <key value="regcess-system" />
        <severity value="warning" />
        <human value="system debe comenzar por urn:regcess: seguido del identificador del sistema." />
        <expression value="matches('^urn:regcess:[A-Za-z0-9]+$')" />
      </constraint>
    </element>
    <element id="DocumentReference.identifier.value">
      <path value="DocumentReference.identifier.value" />
      <short value="Identificador interno del sistema para el documento" />
      <definition value="Debe indicar el ID interno del sistema de origen utilizado para el documento." />
      <min value="1" />
    </element>
    <element id="DocumentReference.type">
      <path value="DocumentReference.type" />
      <short value="Tipo de informe/información ÚNICAS" />
      <min value="1" />
      <binding>
        <strength value="extensible" />
        <description value="Value set de Tipos de informes para ÚNICAS" />
        <valueSet value="https://unicas-fhir.sanidad.gob.es/ValueSet/TiposInformesUNICAS" />
      </binding>
    </element>
    <element id="DocumentReference.type.coding.system">
      <path value="DocumentReference.type.coding.system" />
      <short value="URL del refset Documentos del CMDIC | URL del SNOMED CT. Extensión para España del SNS" />
      <definition value="Posible URLs de terminología utilizada para indicar el tipo de informe/información ÚNICAS y su descripción correspondiente:&#xD;&#xA;&#xD;&#xA;- Refset Documentos del CMDIC del SNOMED CT. Extensión para España del SNS: http://snomed.info/sct/900000001000122104?fhir_vs-refset/900000631000122100&#xD;&#xA;- SNOMED CT. Extensión para España del SNS: http://snomed.info/sct/900000001000122104" />
      <min value="1" />
    </element>
    <element id="DocumentReference.type.coding.code">
      <path value="DocumentReference.type.coding.code" />
      <short value="Código del tipo de informe/información ÚNICAS" />
      <min value="1" />
    </element>
    <element id="DocumentReference.type.coding.display">
      <path value="DocumentReference.type.coding.display" />
      <short value="Descripción del tipo de informe/información ÚNICAS" />
      <definition value="Representation defined by the system. A representation of the meaning of the code in the system, following the rules of the system." />
      <min value="1" />
    </element>
    <element id="DocumentReference.subject">
      <path value="DocumentReference.subject" />
      <short value="Referencia al paciente" />
      <definition value="Who/what is the subject of the document. Who or what the document is about. The document can be about a person, (patient or healthcare practitioner), a device (e.g. a machine) or even a group of subjects (such as a document about a herd of farm animals, or a set of patients that share a common exposure)." />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://unicas-fhir.sanidad.gob.es/StructureDefinition/UNICASPatient" />
      </type>
    </element>
    <element id="DocumentReference.subject.reference">
      <path value="DocumentReference.subject.reference" />
      <short value="Referencia recurso FHIR. Identificador de la referencia del recurso FHIR asociado cuando exista/creamos un recurso en el mismo servidor FHIR" />
      <definition value="Formato: [base]/Patient?identifier=[OID registro de número de CIP-SNS]|[Número CIP-SNS]" />
    </element>
    <element id="DocumentReference.subject.type">
      <path value="DocumentReference.subject.type" />
      <short value="Tipo de recurso FHIR" />
      <definition value="Type the reference refers to (e.g. &quot;Patient&quot;) - must be a resource in resources. The expected type of the target of the reference. If both Reference.type and Reference.reference are populated and Reference.reference is a FHIR URL, both SHALL be consistent.&#xD;&#xA;&#xD;&#xA;The type is the Canonical URL of Resource Definition that is the type this reference refers to. References are URLs that are relative to http://hl7.org/fhir/StructureDefinition/ e.g. &quot;Patient&quot; is a reference to http://hl7.org/fhir/StructureDefinition/Patient. Absolute URLs are only allowed for logical models (and can only be used in references in logical models, not resources)." />
      <min value="1" />
    </element>
    <element id="DocumentReference.subject.identifier">
      <path value="DocumentReference.subject.identifier" />
      <short value="Identificador de paciente CIP-SNS. Cuando no tengamos recurso Patient, se debera informar el identificador de paciente mediante CIP-SNS" />
      <definition value="Logical reference, when literal reference is not known. An identifier for the target resource. This is used when there is no way to reference the other resource directly, either because the entity it represents is not available through a FHIR server, or because there is no way for the author of the resource to convert a known identifier to an actual location. There is no requirement that a Reference.identifier point to something that is actually exposed as a FHIR instance, but it SHALL point to a business concept that would be expected to be exposed as a FHIR instance, and that instance would need to be of a FHIR resource type allowed by the reference." />
      <min value="1" />
    </element>
    <element id="DocumentReference.subject.identifier.type">
      <path value="DocumentReference.subject.identifier.type" />
      <short value="Tipos de documentos de identificación para persona ÚNICAS" />
      <definition value="Description of identifier. A coded type for the identifier that can be used to determine which identifier to use for a specific purpose." />
      <binding>
        <strength value="extensible" />
        <description value="Value set de Tipos de documentos de identificación para persona ÚNICAS" />
        <valueSet value="https://unicas-fhir.sanidad.gob.es/ValueSet/TiposDocumentosIdentificacionPersona" />
      </binding>
    </element>
    <element id="DocumentReference.subject.identifier.type.coding.system">
      <path value="DocumentReference.subject.identifier.type.coding.system" />
      <short value="URL del SNOMED CT. Extensión para España del SNS" />
      <definition value="Posible URL de terminología utilizada para indicar el tipo de documentos de identificación y su descripción correspondiente:&#xD;&#xA;&#xD;&#xA;- SNOMED CT. Extensión para España del SNS: http://snomed.info/sct/900000001000122104" />
    </element>
    <element id="DocumentReference.subject.identifier.type.coding.code">
      <path value="DocumentReference.subject.identifier.type.coding.code" />
      <short value="Código del identificador" />
    </element>
    <element id="DocumentReference.subject.identifier.type.coding.display">
      <path value="DocumentReference.subject.identifier.type.coding.display" />
      <short value="Decripción del identificador" />
      <definition value="Representation defined by the system. A representation of the meaning of the code in the system, following the rules of the system." />
    </element>
    <element id="DocumentReference.subject.identifier.system">
      <path value="DocumentReference.subject.identifier.system" />
      <short value="OID registro de número de CIP-SNS" />
      <definition value="The namespace for the identifier value. Establishes the namespace for the value - that is, an absolute URL that describes a set values that are unique." />
    </element>
    <element id="DocumentReference.subject.identifier.value">
      <path value="DocumentReference.subject.identifier.value" />
      <short value="Número CIP-SNS" />
      <definition value="The namespace for the identifier value. Establishes the namespace for the value - that is, an absolute URL that describes a set values that are unique." />
    </element>
    <element id="DocumentReference.subject.display">
      <path value="DocumentReference.subject.display" />
      <short value="Nombre completo del paciente" />
      <definition value="Text alternative for the resource. Plain text narrative that identifies the resource in addition to the resource reference." />
    </element>
    <element id="DocumentReference.context">
      <path value="DocumentReference.context" />
      <short value="Referencia a la interacción clínica" />
      <definition value="Context of the document content. Describes the clinical encounter or type of care that the document content is associated with." />
      <type>
        <code value="Reference" />
        <targetProfile value="https://unicas-fhir.sanidad.gob.es/StructureDefinition/UNICASEncounter" />
      </type>
    </element>
    <element id="DocumentReference.context.reference">
      <path value="DocumentReference.context.reference" />
      <short value="Referencia recurso FHIR" />
      <definition value="Formato: [base]/Encounter?identifier=urn:regcess:[CódigoREGCESS]|[Id interno del sistema para la interacción clínica]" />
    </element>
    <element id="DocumentReference.context.type">
      <path value="DocumentReference.context.type" />
      <short value="Tipo de recurso FHIR" />
      <definition value="Type the reference refers to (e.g. &quot;Patient&quot;) - must be a resource in resources. The expected type of the target of the reference. If both Reference.type and Reference.reference are populated and Reference.reference is a FHIR URL, both SHALL be consistent.&#xD;&#xA;&#xD;&#xA;The type is the Canonical URL of Resource Definition that is the type this reference refers to. References are URLs that are relative to http://hl7.org/fhir/StructureDefinition/ e.g. &quot;Patient&quot; is a reference to http://hl7.org/fhir/StructureDefinition/Patient. Absolute URLs are only allowed for logical models (and can only be used in references in logical models, not resources)." />
    </element>
    <element id="DocumentReference.context.identifier">
      <path value="DocumentReference.context.identifier" />
      <short value="Identificador del recurso FHIR" />
      <definition value="Logical reference, when literal reference is not known. An identifier for the target resource. This is used when there is no way to reference the other resource directly, either because the entity it represents is not available through a FHIR server, or because there is no way for the author of the resource to convert a known identifier to an actual location. There is no requirement that a Reference.identifier point to something that is actually exposed as a FHIR instance, but it SHALL point to a business concept that would be expected to be exposed as a FHIR instance, and that instance would need to be of a FHIR resource type allowed by the reference." />
    </element>
    <element id="DocumentReference.context.identifier.system">
      <path value="DocumentReference.context.identifier.system" />
      <short value="Sistema para identificar el origen" />
      <definition value="Formato: urn:regcess:[CódigoREGCESS]&#xD;&#xA;Debe incluir el código REGCESS después de urn:regcess:" />
    </element>
    <element id="DocumentReference.context.identifier.value">
      <path value="DocumentReference.context.identifier.value" />
      <short value="Identificador interno del sistema para la interacción clínica" />
      <definition value="Debe indicar el ID interno del sistema de origen utilizado para la interacción clínica." />
    </element>
    <element id="DocumentReference.date">
      <path value="DocumentReference.date" />
      <short value="Fecha de publicación del informe/información" />
      <min value="1" />
    </element>
    <element id="DocumentReference.custodian">
      <path value="DocumentReference.custodian" />
      <short value="Referencia a la institución" />
      <definition value="Organization which maintains the document. Identifies the organization or group who is responsible for ongoing maintenance of and access to the document." />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://unicas-fhir.sanidad.gob.es/StructureDefinition/UNICASOrganization" />
      </type>
    </element>
    <element id="DocumentReference.custodian.reference">
      <path value="DocumentReference.custodian.reference" />
      <short value="Referencia recurso FHIR" />
      <definition value="Formato: [base]/Organization?identifier=[OID registro de número de REGCESS]|[Código REGCESS de la institución]" />
    </element>
    <element id="DocumentReference.custodian.type">
      <path value="DocumentReference.custodian.type" />
      <short value="Tipo de recurso FHIR" />
      <definition value="Type the reference refers to (e.g. &quot;Patient&quot;) - must be a resource in resources. The expected type of the target of the reference. If both Reference.type and Reference.reference are populated and Reference.reference is a FHIR URL, both SHALL be consistent.&#xA;&#xA;The type is the Canonical URL of Resource Definition that is the type this reference refers to. References are URLs that are relative to http://hl7.org/fhir/StructureDefinition/ e.g. &quot;Patient&quot; is a reference to http://hl7.org/fhir/StructureDefinition/Patient. Absolute URLs are only allowed for logical models (and can only be used in references in logical models, not resources)." />
      <min value="1" />
    </element>
    <element id="DocumentReference.custodian.identifier">
      <path value="DocumentReference.custodian.identifier" />
      <short value="Identificador de la institución. Cuando no tengamos recurso Organization, se debera informar el identificador de institución mediante código REGCESS" />
      <definition value="Logical reference, when literal reference is not known. An identifier for the target resource. This is used when there is no way to reference the other resource directly, either because the entity it represents is not available through a FHIR server, or because there is no way for the author of the resource to convert a known identifier to an actual location. There is no requirement that a Reference.identifier point to something that is actually exposed as a FHIR instance, but it SHALL point to a business concept that would be expected to be exposed as a FHIR instance, and that instance would need to be of a FHIR resource type allowed by the reference." />
      <min value="1" />
    </element>
    <element id="DocumentReference.custodian.identifier.system">
      <path value="DocumentReference.custodian.identifier.system" />
      <short value="OID registro de número de REGCESS" />
      <definition value="The namespace for the identifier value. Establishes the namespace for the value - that is, an absolute URL that describes a set values that are unique." />
    </element>
    <element id="DocumentReference.custodian.identifier.value">
      <path value="DocumentReference.custodian.identifier.value" />
      <short value="Código REGCESS" />
      <definition value="The value that is unique. The portion of the identifier typically relevant to the user and which is unique within the context of the system." />
    </element>
    <element id="DocumentReference.custodian.display">
      <path value="DocumentReference.custodian.display" />
      <short value="Nombre completo de la institución" />
      <definition value="Text alternative for the resource. Plain text narrative that identifies the resource in addition to the resource reference." />
    </element>
    <element id="DocumentReference.description">
      <path value="DocumentReference.description" />
      <short value="Título del informe/información ÚNICAS" />
      <min value="1" />
    </element>
    <element id="DocumentReference.content">
      <path value="DocumentReference.content" />
      <short value="Contenido del documento codificado en Base64, que puede incluir formatos como PDF o HL7 CDA" />
    </element>
    <element id="DocumentReference.content.attachment.contentType">
      <path value="DocumentReference.content.attachment.contentType" />
      <short value="Tipo de datos (application/pdf | multipart/x-hl7-cda-level-one)" />
      <definition value="Mime type of the content, with charset etc. Identifies the type of the data in the attachment and allows a method to be chosen to interpret or render the data. Includes mime type parameters such as charset where appropriate." />
    </element>
    <element id="DocumentReference.content.attachment.data">
      <path value="DocumentReference.content.attachment.data" />
      <short value="Datos en base64 (Debe indicar un HL7 CDA o un PDF convertido a datos base64)" />
      <definition value="Data inline, base64ed. The actual data of the attachment - a sequence of bytes, base64 encoded." />
    </element>
    <element id="DocumentReference.content.attachment.url">
      <path value="DocumentReference.content.attachment.url" />
      <short value="URL del datos en formato Base64 (recurso Binary)" />
      <definition value="Uri where the data can be found. A location where the data can be accessed." />
      <min value="1" />
    </element>
  </differential>
</StructureDefinition>