--- title: "document_reference" description: "Maximal set merged from: http://hl7.org/fhir/us/core/StructureDefinition/us-core-adi-documentreference, http://hl7.org/fhir/us/core/StructureDefinition/us-core-documentreference" --- Maximal set merged from: http://hl7.org/fhir/us/core/StructureDefinition/us-core-adi-documentreference, http://hl7.org/fhir/us/core/StructureDefinition/us-core-documentreference ## Source | Model | Leg | Role | |---|---|---| | `us-core-adi-documentreference+us-core-documentreference` | FHIR | defines this table | ## Columns | Column | Type | Null | Description | Source | |---|---|---|---|---| | `id` | `uuid primary key` | no | DocumentReference.id | — | | `created_at` | `timestamptz` | no | Row creation timestamp. | — | | `updated_at` | `timestamptz` | no | Row update timestamp; maintained by the application. | — | | `created_by` | `text` | no | Actor who created the row. | — | | `updated_by` | `text` | no | Actor who last updated the row. | — | | `master_identifier_value`
`master_identifier_system` | text, text
`text`, `text` | yes | Master Version Specific Identifier | `DocumentReference.masterIdentifier` | | `identifier_value`
`identifier_system` | text, text
`text`, `text` | yes | Other identifiers for the document | `DocumentReference.identifier` | | `status` | `text` | yes | current \| superseded \| entered-in-error | `DocumentReference.status` | | `doc_status` | `text` | yes | preliminary \| final \| amended \| entered-in-error | `DocumentReference.docStatus` | | `type`
`type_code`
`type_system`
`type_valueset_id` | coded text
`text`, `text`, `text`, `text` | yes | Kind of document (LOINC if possible) | `DocumentReference.type` | | `subject_device_id`
`subject_patient_id`
`subject_practitioner_id` | uuid, uuid, uuid
`uuid`, `uuid`, `uuid` | yes | Who/what is the subject of the document | `DocumentReference.subject` | | `date` | `timestamptz` | yes | When this document reference was created | `DocumentReference.date` | | `authenticator_organization_id`
`authenticator_practitioner_id`
`authenticator_practitioner_role_id` | uuid, uuid, uuid
`uuid`, `uuid`, `uuid` | yes | Who/what authenticated the document | `DocumentReference.authenticator` | | `custodian_id` | `uuid` | yes | Organization which maintains the document | `DocumentReference.custodian` | | `description` | `text` | yes | Human-readable description | `DocumentReference.description` | | `context_period_start`
`context_period_end` | timestamptz, timestamptz
`timestamptz`, `timestamptz` | yes | Time of service that is being documented | `DocumentReference.context.period` | ## Constraints ```sql check (master_identifier_system is null or master_identifier_value is not null) check (identifier_system is null or identifier_value is not null) check ((type is null and type_code is null and type_system is null and type_valueset_id is null) or (type is not null and type_code is not null and type_system is not null and type_valueset_id is not null)) check (num_nonnulls(subject_device_id, subject_patient_id, subject_practitioner_id) <= 1) check (num_nonnulls(authenticator_organization_id, authenticator_practitioner_id, authenticator_practitioner_role_id) <= 1) check (context_period_start is null or context_period_end is null or context_period_start <= context_period_end) ``` ## References | Columns | Target | On delete | |---|---|---| | `type_valueset_id, type_code, type_system, type` | [`valueset_code`](/docs/tables/valueset_code) | restrict | | `subject_device_id` | [`device`](/docs/tables/device) | no action | | `subject_patient_id` | [`patient`](/docs/tables/patient) | no action | | `subject_practitioner_id` | [`practitioner`](/docs/tables/practitioner) | no action | | `authenticator_organization_id` | [`organization`](/docs/tables/organization) | no action | | `authenticator_practitioner_id` | [`practitioner`](/docs/tables/practitioner) | no action | | `authenticator_practitioner_role_id` | [`practitioner_role`](/docs/tables/practitioner_role) | no action | | `custodian_id` | [`organization`](/docs/tables/organization) | no action | ## Referenced by - [`document_reference_other_identifier`](/docs/tables/document_reference_other_identifier) via `document_reference_id` - [`document_reference_category`](/docs/tables/document_reference_category) via `document_reference_id` - [`document_reference_author`](/docs/tables/document_reference_author) via `document_reference_id` - [`document_reference_relates_to`](/docs/tables/document_reference_relates_to) via `document_reference_id` - [`document_reference_relates_to`](/docs/tables/document_reference_relates_to) via `target_id` - [`document_reference_security_label`](/docs/tables/document_reference_security_label) via `document_reference_id` - [`document_reference_content`](/docs/tables/document_reference_content) via `document_reference_id` - [`document_reference_encounter`](/docs/tables/document_reference_encounter) via `document_reference_id` ## Indexes - `document_reference_subject_device_id_idx` on `subject_device_id` - `document_reference_subject_patient_id_idx` on `subject_patient_id` - `document_reference_subject_practitioner_id_idx` on `subject_practitioner_id` - `document_reference_authenticator_organization_id_idx` on `authenticator_organization_id` - `document_reference_authenticator_practitioner_id_idx` on `authenticator_practitioner_id` - `document_reference_authenticator_practitioner_role_id_idx` on `authenticator_practitioner_role_id` - `document_reference_custodian_id_idx` on `custodian_id` ## Child tables 7 tables hang off `document_reference`, one row per repetition. ### `document_reference_other_identifier` Child table — one row per repetition, deleted with its parent. | Column | Type | Null | Description | Source | |---|---|---|---|---| | `id` | `uuid primary key` | no | Primary key. | — | | `document_reference_id` | `uuid` → [`document_reference`](/docs/tables/document_reference) | no | — | — | | `identifier_value` | `text` | no | — | — | | `identifier_system` | `text` | yes | — | — | | `identifier_use` | `text` | yes | — | — | | `valid_from` | `timestamptz` | yes | — | — | | `valid_until` | `timestamptz` | yes | — | — | #### Unique - `document_reference_id, identifier_system, identifier_value` #### References | Columns | Target | On delete | |---|---|---| | `document_reference_id` | [`document_reference`](/docs/tables/document_reference) | cascade | ### `document_reference_category` Child table — one row per repetition, deleted with its parent. | Column | Type | Null | Description | Source | |---|---|---|---|---| | `id` | `uuid primary key` | no | Primary key. | — | | `document_reference_id` | `uuid` → [`document_reference`](/docs/tables/document_reference) | no | — | — | | `category`
`category_code`
`category_system` | text, text, text
`text`, `text`, `text` | yes | Categorization of document | `DocumentReference.category` | #### Constraints ```sql check ((category_code is null and category_system is null) or (category_code is not null and category_system is not null)) ``` #### References | Columns | Target | On delete | |---|---|---| | `document_reference_id` | [`document_reference`](/docs/tables/document_reference) | cascade | #### Indexes - `document_reference_category_document_reference_id_idx` on `document_reference_id` ### `document_reference_author` Child table — one row per repetition, deleted with its parent. | Column | Type | Null | Description | Source | |---|---|---|---|---| | `id` | `uuid primary key` | no | Primary key. | — | | `document_reference_id` | `uuid` → [`document_reference`](/docs/tables/document_reference) | no | — | — | | `device_id`
`organization_id`
`patient_id`
`practitioner_id`
`practitioner_role_id`
`related_person_id` | uuid, uuid, uuid, uuid, uuid, uuid
`uuid`, `uuid`, `uuid`, `uuid`, `uuid`, `uuid` | yes | Who and/or what authored the document | `DocumentReference.author` | #### Constraints ```sql check (num_nonnulls(device_id, organization_id, patient_id, practitioner_id, practitioner_role_id, related_person_id) = 1) ``` #### References | Columns | Target | On delete | |---|---|---| | `document_reference_id` | [`document_reference`](/docs/tables/document_reference) | cascade | | `device_id` | [`device`](/docs/tables/device) | no action | | `organization_id` | [`organization`](/docs/tables/organization) | no action | | `patient_id` | [`patient`](/docs/tables/patient) | no action | | `practitioner_id` | [`practitioner`](/docs/tables/practitioner) | no action | | `practitioner_role_id` | [`practitioner_role`](/docs/tables/practitioner_role) | no action | | `related_person_id` | [`related_person`](/docs/tables/related_person) | no action | #### Indexes - `document_reference_author_document_reference_id_idx` on `document_reference_id` - `document_reference_author_device_id_idx` on `device_id` - `document_reference_author_organization_id_idx` on `organization_id` - `document_reference_author_patient_id_idx` on `patient_id` - `document_reference_author_practitioner_id_idx` on `practitioner_id` - `document_reference_author_practitioner_role_id_idx` on `practitioner_role_id` - `document_reference_author_related_person_id_idx` on `related_person_id` ### `document_reference_relates_to` Child table — one row per repetition, deleted with its parent. | Column | Type | Null | Description | Source | |---|---|---|---|---| | `id` | `uuid primary key` | no | Primary key. | — | | `document_reference_id` | `uuid` → [`document_reference`](/docs/tables/document_reference) | no | — | — | | `code` | `text` | yes | replaces \| transforms \| signs \| appends | `DocumentReference.relatesTo.code` | | `target_id` | `uuid` | yes | Target of the relationship | `DocumentReference.relatesTo.target` | #### References | Columns | Target | On delete | |---|---|---| | `document_reference_id` | [`document_reference`](/docs/tables/document_reference) | cascade | | `target_id` | [`document_reference`](/docs/tables/document_reference) | no action | #### Indexes - `document_reference_relates_to_document_reference_id_idx` on `document_reference_id` - `document_reference_relates_to_target_id_idx` on `target_id` ### `document_reference_security_label` Child table — one row per repetition, deleted with its parent. | Column | Type | Null | Description | Source | |---|---|---|---|---| | `id` | `uuid primary key` | no | Primary key. | — | | `document_reference_id` | `uuid` → [`document_reference`](/docs/tables/document_reference) | no | — | — | | `security_label`
`security_label_code`
`security_label_system` | text, text, text
`text`, `text`, `text` | yes | Document security-tags | `DocumentReference.securityLabel` | #### Constraints ```sql check ((security_label_code is null and security_label_system is null) or (security_label_code is not null and security_label_system is not null)) ``` #### References | Columns | Target | On delete | |---|---|---| | `document_reference_id` | [`document_reference`](/docs/tables/document_reference) | cascade | #### Indexes - `document_reference_security_label_document_reference_id_idx` on `document_reference_id` ### `document_reference_content` Child table — one row per repetition, deleted with its parent. | Column | Type | Null | Description | Source | |---|---|---|---|---| | `id` | `uuid primary key` | no | Primary key. | — | | `document_reference_id` | `uuid` → [`document_reference`](/docs/tables/document_reference) | no | — | — | | `attachment` | `uuid` → [`attachment`](/docs/tables/attachment) | yes | Where to access the document | `DocumentReference.content.attachment` | | `format`
`format_code`
`format_system` | text, text, text
`text`, `text`, `text` | yes | Format/content rules for the document | `DocumentReference.content.format` | #### Constraints ```sql check ((format_code is null and format_system is null) or (format_code is not null and format_system is not null)) ``` #### References | Columns | Target | On delete | |---|---|---| | `document_reference_id` | [`document_reference`](/docs/tables/document_reference) | cascade | | `attachment` | [`attachment`](/docs/tables/attachment) | restrict | #### Indexes - `document_reference_content_document_reference_id_idx` on `document_reference_id` - `document_reference_content_attachment_idx` on `attachment` ### `document_reference_encounter` Child table — one row per repetition, deleted with its parent. | Column | Type | Null | Description | Source | |---|---|---|---|---| | `id` | `uuid primary key` | no | Primary key. | — | | `document_reference_id` | `uuid` → [`document_reference`](/docs/tables/document_reference) | no | — | — | | `encounter_id` | `uuid` | no | Context of the document content | `DocumentReference.context.encounter` | #### Unique - `document_reference_id, encounter_id` #### References | Columns | Target | On delete | |---|---|---| | `document_reference_id` | [`document_reference`](/docs/tables/document_reference) | cascade | | `encounter_id` | [`encounter`](/docs/tables/encounter) | no action | #### Indexes - `document_reference_encounter_encounter_id_idx` on `encounter_id` ## Value sets | Value set | Codes | |---|---| | `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1115.41` | 0 |