{
  "resourceType": "StructureDefinition",
  "url": "https://unicas-fhir.sanidad.gob.es/StructureDefinition/UNICASDocumentReference",
  "name": "UNICASDocumentReference",
  "title": "DocumentReference Documento en Base64 ÚNICAS",
  "status": "draft",
  "description": "Este profile define las restricciones del recurso DocumentReference para representar un documento clínico en el contexto del caso de uso de ÚNICAS.",
  "fhirVersion": "5.0.0",
  "kind": "resource",
  "abstract": false,
  "type": "DocumentReference",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/DocumentReference",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "DocumentReference.identifier",
        "path": "DocumentReference.identifier",
        "short": "Identificador único",
        "definition": "Business identifiers for the document. Other business identifiers associated with the document, including version independent identifiers.",
        "min": 1
      },
      {
        "id": "DocumentReference.identifier.system",
        "path": "DocumentReference.identifier.system",
        "short": "Sistema para identificar el origen",
        "definition": "Formato: urn:regcess:[CódigoREGCESS]\r\nDebe incluir el código REGCESS después de urn:regcess:",
        "min": 1,
        "constraint": [
          {
            "key": "regcess-system",
            "severity": "warning",
            "human": "system debe comenzar por urn:regcess: seguido del identificador del sistema.",
            "expression": "matches('^urn:regcess:[A-Za-z0-9]+$')"
          }
        ]
      },
      {
        "id": "DocumentReference.identifier.value",
        "path": "DocumentReference.identifier.value",
        "short": "Identificador interno del sistema para el documento",
        "definition": "Debe indicar el ID interno del sistema de origen utilizado para el documento.",
        "min": 1
      },
      {
        "id": "DocumentReference.type",
        "path": "DocumentReference.type",
        "short": "Tipo de informe/información ÚNICAS",
        "min": 1,
        "binding": {
          "strength": "extensible",
          "description": "Value set de Tipos de informes para ÚNICAS",
          "valueSet": "https://unicas-fhir.sanidad.gob.es/ValueSet/TiposInformesUNICAS"
        }
      },
      {
        "id": "DocumentReference.type.coding.system",
        "path": "DocumentReference.type.coding.system",
        "short": "URL del refset Documentos del CMDIC | URL del SNOMED CT. Extensión para España del SNS",
        "definition": "Posible URLs de terminología utilizada para indicar el tipo de informe/información ÚNICAS y su descripción correspondiente:\r\n\r\n- Refset Documentos del CMDIC del SNOMED CT. Extensión para España del SNS: http://snomed.info/sct/900000001000122104?fhir_vs-refset/900000631000122100\r\n- SNOMED CT. Extensión para España del SNS: http://snomed.info/sct/900000001000122104",
        "min": 1
      },
      {
        "id": "DocumentReference.type.coding.code",
        "path": "DocumentReference.type.coding.code",
        "short": "Código del tipo de informe/información ÚNICAS",
        "min": 1
      },
      {
        "id": "DocumentReference.type.coding.display",
        "path": "DocumentReference.type.coding.display",
        "short": "Descripción del tipo de informe/información ÚNICAS",
        "definition": "Representation defined by the system. A representation of the meaning of the code in the system, following the rules of the system.",
        "min": 1
      },
      {
        "id": "DocumentReference.subject",
        "path": "DocumentReference.subject",
        "short": "Referencia al paciente",
        "definition": "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": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://unicas-fhir.sanidad.gob.es/StructureDefinition/UNICASPatient"
            ]
          }
        ]
      },
      {
        "id": "DocumentReference.subject.reference",
        "path": "DocumentReference.subject.reference",
        "short": "Referencia recurso FHIR. Identificador de la referencia del recurso FHIR asociado cuando exista/creamos un recurso en el mismo servidor FHIR",
        "definition": "Formato: [base]/Patient?identifier=[OID registro de número de CIP-SNS]|[Número CIP-SNS]"
      },
      {
        "id": "DocumentReference.subject.type",
        "path": "DocumentReference.subject.type",
        "short": "Tipo de recurso FHIR",
        "definition": "Type the reference refers to (e.g. \"Patient\") - 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.\r\n\r\nThe 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. \"Patient\" 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": 1
      },
      {
        "id": "DocumentReference.subject.identifier",
        "path": "DocumentReference.subject.identifier",
        "short": "Identificador de paciente CIP-SNS. Cuando no tengamos recurso Patient, se debera informar el identificador de paciente mediante CIP-SNS",
        "definition": "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": 1
      },
      {
        "id": "DocumentReference.subject.identifier.type",
        "path": "DocumentReference.subject.identifier.type",
        "short": "Tipos de documentos de identificación para persona ÚNICAS",
        "definition": "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": "extensible",
          "description": "Value set de Tipos de documentos de identificación para persona ÚNICAS",
          "valueSet": "https://unicas-fhir.sanidad.gob.es/ValueSet/TiposDocumentosIdentificacionPersona"
        }
      },
      {
        "id": "DocumentReference.subject.identifier.type.coding.system",
        "path": "DocumentReference.subject.identifier.type.coding.system",
        "short": "URL del SNOMED CT. Extensión para España del SNS",
        "definition": "Posible URL de terminología utilizada para indicar el tipo de documentos de identificación y su descripción correspondiente:\r\n\r\n- SNOMED CT. Extensión para España del SNS: http://snomed.info/sct/900000001000122104"
      },
      {
        "id": "DocumentReference.subject.identifier.type.coding.code",
        "path": "DocumentReference.subject.identifier.type.coding.code",
        "short": "Código del identificador"
      },
      {
        "id": "DocumentReference.subject.identifier.type.coding.display",
        "path": "DocumentReference.subject.identifier.type.coding.display",
        "short": "Decripción del identificador",
        "definition": "Representation defined by the system. A representation of the meaning of the code in the system, following the rules of the system."
      },
      {
        "id": "DocumentReference.subject.identifier.system",
        "path": "DocumentReference.subject.identifier.system",
        "short": "OID registro de número de CIP-SNS",
        "definition": "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."
      },
      {
        "id": "DocumentReference.subject.identifier.value",
        "path": "DocumentReference.subject.identifier.value",
        "short": "Número CIP-SNS",
        "definition": "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."
      },
      {
        "id": "DocumentReference.subject.display",
        "path": "DocumentReference.subject.display",
        "short": "Nombre completo del paciente",
        "definition": "Text alternative for the resource. Plain text narrative that identifies the resource in addition to the resource reference."
      },
      {
        "id": "DocumentReference.context",
        "path": "DocumentReference.context",
        "short": "Referencia a la interacción clínica",
        "definition": "Context of the document content. Describes the clinical encounter or type of care that the document content is associated with.",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://unicas-fhir.sanidad.gob.es/StructureDefinition/UNICASEncounter"
            ]
          }
        ]
      },
      {
        "id": "DocumentReference.context.reference",
        "path": "DocumentReference.context.reference",
        "short": "Referencia recurso FHIR",
        "definition": "Formato: [base]/Encounter?identifier=urn:regcess:[CódigoREGCESS]|[Id interno del sistema para la interacción clínica]"
      },
      {
        "id": "DocumentReference.context.type",
        "path": "DocumentReference.context.type",
        "short": "Tipo de recurso FHIR",
        "definition": "Type the reference refers to (e.g. \"Patient\") - 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.\r\n\r\nThe 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. \"Patient\" 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)."
      },
      {
        "id": "DocumentReference.context.identifier",
        "path": "DocumentReference.context.identifier",
        "short": "Identificador del recurso FHIR",
        "definition": "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."
      },
      {
        "id": "DocumentReference.context.identifier.system",
        "path": "DocumentReference.context.identifier.system",
        "short": "Sistema para identificar el origen",
        "definition": "Formato: urn:regcess:[CódigoREGCESS]\r\nDebe incluir el código REGCESS después de urn:regcess:"
      },
      {
        "id": "DocumentReference.context.identifier.value",
        "path": "DocumentReference.context.identifier.value",
        "short": "Identificador interno del sistema para la interacción clínica",
        "definition": "Debe indicar el ID interno del sistema de origen utilizado para la interacción clínica."
      },
      {
        "id": "DocumentReference.date",
        "path": "DocumentReference.date",
        "short": "Fecha de publicación del informe/información",
        "min": 1
      },
      {
        "id": "DocumentReference.custodian",
        "path": "DocumentReference.custodian",
        "short": "Referencia a la institución",
        "definition": "Organization which maintains the document. Identifies the organization or group who is responsible for ongoing maintenance of and access to the document.",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://unicas-fhir.sanidad.gob.es/StructureDefinition/UNICASOrganization"
            ]
          }
        ]
      },
      {
        "id": "DocumentReference.custodian.reference",
        "path": "DocumentReference.custodian.reference",
        "short": "Referencia recurso FHIR",
        "definition": "Formato: [base]/Organization?identifier=[OID registro de número de REGCESS]|[Código REGCESS de la institución]"
      },
      {
        "id": "DocumentReference.custodian.type",
        "path": "DocumentReference.custodian.type",
        "short": "Tipo de recurso FHIR",
        "definition": "Type the reference refers to (e.g. \"Patient\") - 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.\n\nThe 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. \"Patient\" 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": 1
      },
      {
        "id": "DocumentReference.custodian.identifier",
        "path": "DocumentReference.custodian.identifier",
        "short": "Identificador de la institución. Cuando no tengamos recurso Organization, se debera informar el identificador de institución mediante código REGCESS",
        "definition": "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": 1
      },
      {
        "id": "DocumentReference.custodian.identifier.system",
        "path": "DocumentReference.custodian.identifier.system",
        "short": "OID registro de número de REGCESS",
        "definition": "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."
      },
      {
        "id": "DocumentReference.custodian.identifier.value",
        "path": "DocumentReference.custodian.identifier.value",
        "short": "Código REGCESS",
        "definition": "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."
      },
      {
        "id": "DocumentReference.custodian.display",
        "path": "DocumentReference.custodian.display",
        "short": "Nombre completo de la institución",
        "definition": "Text alternative for the resource. Plain text narrative that identifies the resource in addition to the resource reference."
      },
      {
        "id": "DocumentReference.description",
        "path": "DocumentReference.description",
        "short": "Título del informe/información ÚNICAS",
        "min": 1
      },
      {
        "id": "DocumentReference.content",
        "path": "DocumentReference.content",
        "short": "Contenido del documento codificado en Base64, que puede incluir formatos como PDF o HL7 CDA"
      },
      {
        "id": "DocumentReference.content.attachment.contentType",
        "path": "DocumentReference.content.attachment.contentType",
        "short": "Tipo de datos (application/pdf | multipart/x-hl7-cda-level-one)",
        "definition": "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."
      },
      {
        "id": "DocumentReference.content.attachment.data",
        "path": "DocumentReference.content.attachment.data",
        "short": "Datos en base64 (Debe indicar un HL7 CDA o un PDF convertido a datos base64)",
        "definition": "Data inline, base64ed. The actual data of the attachment - a sequence of bytes, base64 encoded."
      },
      {
        "id": "DocumentReference.content.attachment.url",
        "path": "DocumentReference.content.attachment.url",
        "short": "URL del datos en formato Base64 (recurso Binary)",
        "definition": "Uri where the data can be found. A location where the data can be accessed.",
        "min": 1
      }
    ]
  }
}