- columns:
    condition_id:
      data_type: character varying
      description: Reference to the condition ([Reference Data](#!/source/source.tamanu.tamanu.reference_data),
        `type = condition`).
      name: condition_id
    id:
      data_type: character varying
      description: Tamanu internal identifier (generally a UUID) in contributing_death_causes.
      name: id
    patient_death_data_id:
      data_type: character varying
      description: The [`patient_death_data`](#!/source/source.tamanu.tamanu.patient_death_data)
        record.
      name: patient_death_data_id
    time_after_onset:
      data_type: integer
      description: Time between onset of recorded cause and death in minutes.
      name: time_after_onset
  config:
    tags:
    - base
    - clinical
  description: Contributing causes recorded with the patient's death data.
  name: contributing_death_causes
  tags:
  - base
  - clinical
- columns:
    code:
      data_type: character varying
      description: Code for department.
      name: code
    facility_id:
      data_type: character varying
      description: Reference to the [facility](#!/source/source.tamanu.tamanu.facilities)
        this department is in.
      name: facility_id
    id:
      data_type: character varying
      description: Tamanu internal identifier (generally a UUID) in departments.
      name: id
    name:
      data_type: character varying
      description: Full readable name for department.
      name: name
    visibility_status:
      data_type: text
      description: "The visibility status of the record.\r\n\r\n- `current` indicates\
        \ the record is currently in use and should be visible and accessible to users\r\
        \n  on the User Interface.\r\n- `historical` indicates that the record is\
        \ no longer in use and should not be visible nor\r\n  accessible to users.\
        \ However, the record may still be present in Reporting.\r\n- `merged` indicates\
        \ that the record has been merged, is no longer in use and should not be visible\r\
        \n  nor accessible to users.\r\n\r\nThe default value is `current`. in departments."
      name: visibility_status
  config:
    tags:
    - base
    - reference
  description: Basic department info with a reference to parent facility.
  name: departments
  tags:
  - base
  - reference
- columns:
    discharged_by_id:
      data_type: character varying
      description: The [discharging clinician](#!/source/source.tamanu.tamanu.users).
      name: discharged_by_id
    disposition_id:
      data_type: character varying
      description: The discharge disposition or classification of the discharge ([Reference
        Data](#!/source/source.tamanu.tamanu.reference_data)).
      name: disposition_id
    encounter_id:
      data_type: character varying
      description: Reference to the [encounter](#!/source/source.tamanu.tamanu.encounters)
        this discharge is for.
      name: encounter_id
    id:
      data_type: character varying
      description: Tamanu internal identifier (generally a UUID) in discharges.
      name: id
    note:
      data_type: text
      description: "Free-form notes about the discharge.\r\n\r\nMay include treatment\
        \ plan and follow-ups, written by the discharging clinician.\r\n\r\nSince\
        \ v2.0, also see the [`notes`](#!/source/source.tamanu.tamanu.notes) table\
        \ for encounter and discharge notes."
      name: note
  config:
    tags:
    - base
    - clinical
  description: "Information about a discharge.\r\n\r\nA discharge is the end of the\
    \ lifecycle for an encounter."
  name: discharges
  tags:
  - base
  - clinical
- columns:
    datetime:
      data_type: timestamp
      description: Local date for the record in encounter_diagnoses.
      name: datetime
    diagnosed_by_id:
      data_type: character varying
      description: Reference to the [clinician](#!/source/source.tamanu.tamanu.users)
        recording that diagnosis.
      name: diagnosed_by_id
    diagnosis_id:
      data_type: character varying
      description: The diagnosis ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
      name: diagnosis_id
    encounter_id:
      data_type: character varying
      description: Reference to the [encounter](#!/source/source.tamanu.tamanu.encounters)
        this diagnosis is for.
      name: encounter_id
    id:
      data_type: character varying
      description: Tamanu internal identifier (generally a UUID) in encounter_diagnoses.
      name: id
    is_primary:
      data_type: boolean
      description: A boolean indicating if this is a primary diagnosis
      name: is_primary
  config:
    tags:
    - base
    - clinical
  description: Records diagnoses made during an encounter
  name: encounter_diagnoses
  tags:
  - base
  - clinical
- columns:
    diet_id:
      data_type: character varying(255)
      description: The diet ([Reference Data](#!/source/source.tamanu.tamanu.reference_data),
        `type = diet`).
      name: diet_id
    encounter_id:
      data_type: character varying(255)
      description: Reference to the [encounter](#!/source/source.tamanu.tamanu.encounters)
        this diet is for.
      name: encounter_id
    id:
      data_type: uuid
      description: Tamanu internal identifier (generally a UUID) in encounter_diets.
      name: id
  config:
    tags:
    - base
    - administration
  description: "A diet associated with an encounter.\r\n\r\nA patient can be placed\
    \ on a diet for various medical purposes.\r\nDiets are specified in reference\
    \ data."
  name: encounter_diets
  tags:
  - base
  - administration
- columns:
    change_type:
      data_type: character varying(255)
      description: "The field which was changed.\r\n\r\nOne of:\r\n- `encounter_type`\r\
        \n- `location`\r\n- `department`\r\n- `examiner`"
      name: change_type
    clinician_id:
      data_type: character varying(255)
      description: Reference to the [examiner](#!/source/source.tamanu.tamanu.users)
        for the encounter.
      name: clinician_id
    date:
      data_type: character(19)
      description: Local date for the record in encounter_history.
      name: date
    department_id:
      data_type: character varying(255)
      description: Reference to the [department](#!/source/source.tamanu.tamanu.departments)
        the encounter was in.
      name: department_id
    encounter_id:
      data_type: character varying(255)
      description: Reference to the original [encounter](#!/source/source.tamanu.tamanu.encounters)
        this history is for.
      name: encounter_id
    encounter_type:
      data_type: character varying(255)
      description: "The type of the encounter.\r\n\r\nOne of:\r\n- `admission`\r\n\
        - `clinic`\r\n- `imaging`\r\n- `emergency`\r\n- `observation`\r\n- `triage`\r\
        \n- `surveyResponse`\r\n- `vaccination`"
      name: encounter_type
    id:
      data_type: uuid
      description: Tamanu internal identifier (generally a UUID) in encounter_history.
      name: id
    location_id:
      data_type: character varying(255)
      description: Reference to the [location](#!/source/source.tamanu.tamanu.locations)
        the encounter was in.
      name: location_id
    updated_by_id:
      data_type: character varying(255)
      description: '[Who](#!/source/source.tamanu.tamanu.users) made the change.'
      name: updated_by_id
  config:
    tags:
    - base
    - clinical
  description: Records changes to an encounter's basic details.
  name: encounter_history
  tags:
  - base
  - clinical
- columns:
    encounter_id:
      data_type: character varying(255)
      description: The [encounter](#!/source/source.tamanu.tamanu.encounters)
      name: encounter_id
    id:
      data_type: uuid
      description: Tamanu internal identifier (generally a UUID) in encounter_prescriptions.
      name: id
    is_selected_for_discharge:
      data_type: boolean
      description: Whether the prescription is for when the patient is discharged.
      name: is_selected_for_discharge
      tags:
      - phi
    prescription_id:
      data_type: character varying(255)
      description: The [prescription](#!/source/source.tamanu.tamanu.prescriptions)
      name: prescription_id
      tags:
      - phi
  config:
    tags:
    - base
    - clinical
  description: Association of encounter to prescription
  name: encounter_prescriptions
  tags:
  - base
  - clinical
- columns:
    clinician_id:
      data_type: character varying(255)
      description: Reference to the [examiner](#!/source/source.tamanu.tamanu.users).
      name: clinician_id
    department_id:
      data_type: character varying(255)
      description: Reference to the [department](#!/source/source.tamanu.tamanu.departments)
        this encounter is in.
      name: department_id
    device_id:
      data_type: text
      description: "Unique identifier for the device that created the encounter.\r\
        \n\r\nDevice IDs are proper to each device and not globally recorded in e.g.\
        \ a `devices` table."
      name: device_id
    discharge_draft:
      data_type: jsonb
      description: Draft data of the encounter
      name: discharge_draft
    encounter_type:
      data_type: character varying(31)
      description: "The type of the encounter.\r\n\r\nOne of:\r\n- `admission`\r\n\
        - `clinic`\r\n- `imaging`\r\n- `emergency`\r\n- `observation`\r\n- `triage`\r\
        \n- `surveyResponse`\r\n- `vaccination`"
      name: encounter_type
    end_datetime:
      data_type: timestamp
      description: The date encounter was discharged/ended
      name: end_datetime
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in encounters.
      name: id
    location_id:
      data_type: character varying(255)
      description: Reference to the current [location](#!/source/source.tamanu.tamanu.locations)
        this encounter is in.
      name: location_id
    patient_billing_type_id:
      data_type: character varying(255)
      description: The billing type ([Reference Data](#!/source/source.tamanu.tamanu.reference_data))
        of the patient.
      name: patient_billing_type_id
    patient_id:
      data_type: character varying(255)
      description: Reference to the [patient](#!/source/source.tamanu.tamanu.patients).
      name: patient_id
    planned_location_id:
      data_type: character varying(255)
      description: "The [location](#!/source/source.tamanu.tamanu.locations) that\
        \ the encounter will transfer to at the\r\n`planned_location_start_time`."
      name: planned_location_id
    planned_location_start_datetime:
      data_type: timestamp
      description: The time that the encounter will transfer to the planned location.
      name: planned_location_start_datetime
    reason_for_encounter:
      data_type: text
      description: "Free-form information about the encounter.\r\n\r\nCan include\
        \ info like type of survey submitted, emergency diagnosis, etc."
      name: reason_for_encounter
    referral_source_id:
      data_type: character varying(255)
      description: The referral source ([Reference Data](#!/source/source.tamanu.tamanu.reference_data))
        of the patient.
      name: referral_source_id
    start_datetime:
      data_type: timestamp
      description: The beginning of the encounter
      name: start_datetime
  config:
    tags:
    - base
    - clinical
  description: Tracks the basic information of the patient encounters within Tamanu
    from start to finish
  name: encounters
  tags:
  - base
  - clinical
- columns:
    catchment_id:
      data_type: text
      description: Catchment area ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
      name: catchment_id
    city_town:
      data_type: character varying
      description: City or town of the facility.
      name: city_town
    code:
      data_type: character varying
      description: Code (identifier) for the facility.
      name: code
    contact_number:
      data_type: character varying
      description: Administrative contact number of the facility.
      name: contact_number
    division:
      data_type: character varying
      description: Administrative division this facility lives in.
      name: division
    email:
      data_type: character varying
      description: Administrative email address of the facility.
      name: email
    id:
      data_type: character varying
      description: Tamanu internal identifier (generally a UUID) in facilities.
      name: id
    is_sensitive:
      data_type: boolean
      description: If set to `true`, encounters created on this facility will only
        be viewable when logged into this facility
      name: is_sensitive
    name:
      data_type: character varying
      description: Full readable name.
      name: name
    street_address:
      data_type: character varying
      description: Street address of the facility.
      name: street_address
    type:
      data_type: character varying
      description: Type of the facility.
      name: type
    visibility_status:
      data_type: text
      description: "The visibility status of the record.\r\n\r\n- `current` indicates\
        \ the record is currently in use and should be visible and accessible to users\r\
        \n  on the User Interface.\r\n- `historical` indicates that the record is\
        \ no longer in use and should not be visible nor\r\n  accessible to users.\
        \ However, the record may still be present in Reporting.\r\n- `merged` indicates\
        \ that the record has been merged, is no longer in use and should not be visible\r\
        \n  nor accessible to users.\r\n\r\nThe default value is `current`. in facilities."
      name: visibility_status
  config:
    tags:
    - base
    - reference
  description: "Table of facilities.\r\n\r\nFacilities may be either or both of:\r\
    \n\r\n- Any healthcare facility, like hospitals, clinics, mobile vaccination vans,\
    \ laboratories, etc\r\n- A Tamanu Facility deployment.\r\n\r\nWhen syncing, patient\
    \ and related records are scoped to a facility, according to the\r\n[`patient_facilities`](#!/source/source.tamanu.tamanu.patient_facilities)\
    \ table."
  name: facilities
  tags:
  - base
  - reference
- columns:
    area_id:
      data_type: character varying(255)
      description: Reference to the imaging area ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
      name: area_id
    code:
      data_type: text
      description: External code.
      name: code
    description:
      data_type: text
      description: Human-friendly description for the area/code.
      name: description
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in imaging_area_external_codes.
      name: id
    visibility_status:
      data_type: text
      description: "The visibility status of the record.\r\n\r\n- `current` indicates\
        \ the record is currently in use and should be visible and accessible to users\r\
        \n  on the User Interface.\r\n- `historical` indicates that the record is\
        \ no longer in use and should not be visible nor\r\n  accessible to users.\
        \ However, the record may still be present in Reporting.\r\n- `merged` indicates\
        \ that the record has been merged, is no longer in use and should not be visible\r\
        \n  nor accessible to users.\r\n\r\nThe default value is `current`. in imaging_area_external_codes."
      name: visibility_status
  config:
    tags:
    - base
    - reference
  description: "External codes for imaging areas (such as for [PACS](https://en.wikipedia.org/wiki/Picture_archiving_and_communication_system)).\r\
    \n\r\nImaging areas are stored in [Reference Data](#!/source/source.tamanu.tamanu.reference_data),\
    \ this\r\ntable adds additional (external) codes."
  name: imaging_area_external_codes
  tags:
  - base
  - reference
- columns:
    area_id:
      data_type: character varying(255)
      description: The imaging area ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
      name: area_id
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in imaging_request_areas.
      name: id
    imaging_request_id:
      data_type: character varying
      description: The [imaging request](#!/source/source.tamanu.tamanu.imaging_requests).
      name: imaging_request_id
  config:
    tags:
    - base
    - clinical
  description: Areas to be imaged as part of an [imaging request](#!/source/source.tamanu.tamanu.imaging_requests).
  name: imaging_request_areas
  tags:
  - base
  - clinical
- columns:
    completed_by_id:
      data_type: character varying(255)
      description: Reference to the [user](#!/source/source.tamanu.tamanu.users) who
        completed this imaging.
      name: completed_by_id
    datetime:
      data_type: timestamp
      description: When the imaging was requested.
      name: datetime
    display_id:
      data_type: character varying(255)
      description: Short unique identifier used on the frontend.
      name: display_id
    encounter_id:
      data_type: character varying(255)
      description: Reference to the [encounter](#!/source/source.tamanu.tamanu.encounters)
        this imaging request is a part of.
      name: encounter_id
    id:
      data_type: character varying
      description: Tamanu internal identifier (generally a UUID) in imaging_requests.
      name: id
    imaging_type:
      data_type: character varying(31)
      description: "Type of imaging.\r\n\r\nOne of:\r\n- `angiogram`\r\n- `colonoscopy`\r\
        \n- `ctScan`\r\n- `ecg`\r\n- `echocardiogram`\r\n- `endoscopy`\r\n- `fluroscopy`\r\
        \n- `holterMonitor`\r\n- `mammogram`\r\n- `orthopantomography`\r\n- `mri`\r\
        \n- `stressTest`\r\n- `ultrasound`\r\n- `vascularStudy`\r\n- `xRay`"
      name: imaging_type
    location_group_id:
      data_type: character varying(255)
      description: Reference to the [location group](#!/source/source.tamanu.tamanu.location_groups)
        for this imaging request.
      name: location_group_id
    location_id:
      data_type: character varying(255)
      description: Reference to the [location](#!/source/source.tamanu.tamanu.locations)
        for this imaging request.
      name: location_id
    priority:
      data_type: character varying(255)
      description: "Priority of the request.\r\n\r\nThis is a customisable list; by\
        \ default the values are `routine`, `urgent`, `asap`, `stat`."
      name: priority
    reason_for_cancellation:
      data_type: character varying(1024)
      description: "If the request is cancelled, why that is.\r\n\r\nThis is a customisable\
        \ list; by default the values are `duplicate` and `entered-in-error`.\r\n\r\
        \nThe 31-character limit was [arbitrary to avoid extremely long values set\
        \ in error](https://github.com/beyondessential/tamanu/pull/3512/files#r1102169113)."
      name: reason_for_cancellation
    requested_by_id:
      data_type: character varying(255)
      description: Reference to the [user](#!/source/source.tamanu.tamanu.users) who
        requested this imaging.
      name: requested_by_id
    status:
      data_type: character varying(255)
      description: "The status of the request.\r\n\r\nOne of:\r\n- `pending`\r\n-\
        \ `in_progress`\r\n- `completed`\r\n- `cancelled`\r\n- `deleted`\r\n- `entered_in_error`"
      name: status
  config:
    tags:
    - base
    - clinical
  description: "Imaging requests are the entrypoint of imaging workflows in Tamanu.\r\
    \n\r\nEach row is a request for radiology to perform one or more imagings on a\
    \ patient.\r\n\r\nImagings can have one or more [request areas](#!/source/source.tamanu.tamanu.imaging_request_areas)\r\
    \nattached, and when completed will have [results](#!/source/source.tamanu.tamanu.imaging_results)."
  name: imaging_requests
  tags:
  - base
  - clinical
- columns:
    completed_by_id:
      data_type: character varying(255)
      description: Reference to the [user](#!/source/source.tamanu.tamanu.users) who
        completed this imaging.
      name: completed_by_id
    datetime:
      data_type: timestamp
      description: When this result was completed.
      name: datetime
    description:
      data_type: text
      description: Free-form description / notes about this imaging.
      name: description
    external_code:
      data_type: text
      description: External code for this result, used with PACS integration (generally
        via FHIR).
      name: external_code
    id:
      data_type: uuid
      description: Tamanu internal identifier (generally a UUID) in imaging_results.
      name: id
    imaging_request_id:
      data_type: character varying
      description: Reference to the [imaging request](#!/source/source.tamanu.tamanu.imaging_requests).
      name: imaging_request_id
    visibility_status:
      data_type: text
      description: "The visibility status of the record.\r\n\r\n- `current` indicates\
        \ the record is currently in use and should be visible and accessible to users\r\
        \n  on the User Interface.\r\n- `historical` indicates that the record is\
        \ no longer in use and should not be visible nor\r\n  accessible to users.\
        \ However, the record may still be present in Reporting.\r\n- `merged` indicates\
        \ that the record has been merged, is no longer in use and should not be visible\r\
        \n  nor accessible to users.\r\n\r\nThe default value is `current`. in imaging_results."
      name: visibility_status
  config:
    tags:
    - base
    - clinical
  description: "Result of an [imaging request](#!/source/source.tamanu.tamanu.imaging_requests).\r\
    \n\r\nIn practice, there is usually one or two results per request:\r\n- one containing\
    \ a reference to a PACS image, when imaging integrations are enabled;\r\n- one\
    \ containing notes from a doctor who analysed the image.\r\n\r\nHowever there\
    \ is no limit; for example there may be multiple notes from multiple doctors."
  name: imaging_results
  tags:
  - base
  - clinical
- columns:
    applied_by_id:
      data_type: character varying(255)
      description: The [user](#!/source/source.tamanu.tamanu.users) who applied this
        discount.
      name: applied_by_id
    datetime:
      data_type: timestamp
      description: When this discount was applied.
      name: datetime
    id:
      data_type: uuid
      description: Tamanu internal identifier (generally a UUID) in invoice_discounts.
      name: id
    invoice_id:
      data_type: uuid
      description: The [invoice](#!/source/source.tamanu.tamanu.invoices).
      name: invoice_id
    is_manual:
      data_type: boolean
      description: Indicates if the discount was manually added or based on an assessment
      name: is_manual
    percentage:
      data_type: numeric
      description: Percentage discount to apply to the invoice
      name: percentage
    reason:
      data_type: character varying(255)
      description: Reason the discount is given
      name: reason
  config:
    tags:
    - base
    - financial
  description: Invoice discount that is applied to the patient's portion of the discountable
    costs.
  name: invoice_discounts
  tags:
  - base
  - financial
- columns:
    id:
      data_type: uuid
      description: Tamanu internal identifier (generally a UUID) in invoice_insurer_payments.
      name: id
    insurer_id:
      data_type: character varying(255)
      description: The insurer ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
      name: insurer_id
    invoice_payment_id:
      data_type: uuid
      description: The [payment](#!/source/source.tamanu.tamanu.invoice_payments).
      name: invoice_payment_id
    reason:
      data_type: character varying(255)
      description: The reason for the payment. Generally this is used for rejections.
      name: reason
    status:
      data_type: character varying(255)
      description: "The status of this payment.\r\n\r\nOne of:\r\n- `unpaid`\r\n-\
        \ `paid`\r\n- `partial`\r\n- `rejected`"
      name: status
  config:
    tags:
    - base
    - financial
  description: Extra metadata about a payment when it was done by a patient.
  name: invoice_insurer_payments
  tags:
  - base
  - financial
- columns:
    id:
      data_type: uuid
      description: Tamanu internal identifier (generally a UUID) in invoice_insurers.
      name: id
    insurer_id:
      data_type: character varying(255)
      description: The insurer ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
      name: insurer_id
    invoice_id:
      data_type: uuid
      description: The [invoice](#!/source/source.tamanu.tamanu.invoices).
      name: invoice_id
    percentage:
      data_type: numeric
      description: How much of the invoice this insurer is paying.
      name: percentage
  config:
    tags:
    - base
    - financial
  description: Insurers to be used for an invoice.
  name: invoice_insurers
  tags:
  - base
  - financial
- columns:
    amount:
      data_type: numeric
      description: Discount amount of invoice items (can be percentage or a whole
        number)
      name: amount
    id:
      data_type: uuid
      description: Tamanu internal identifier (generally a UUID) in invoice_item_discounts.
      name: id
    invoice_item_id:
      data_type: uuid
      description: The [invoice item](#!/source/source.tamanu.tamanu.invoice_items).
      name: invoice_item_id
    reason:
      data_type: character varying(255)
      description: Free-form reason for the discount.
      name: reason
    type:
      data_type: character varying(255)
      description: Discount type of invoice items
      name: type
  config:
    tags:
    - base
    - financial
  description: Discounts applied to invoice items.
  name: invoice_item_discounts
  tags:
  - base
  - financial
- columns:
    date:
      data_type: date
      description: When the item was ordered.
      name: date
    id:
      data_type: uuid
      description: Tamanu internal identifier (generally a UUID) in invoice_items.
      name: id
    invoice_id:
      data_type: uuid
      description: The [invoice](#!/source/source.tamanu.tamanu.invoices).
      name: invoice_id
    note:
      data_type: character varying(255)
      description: Free-form note for this item.
      name: note
    ordered_by_id:
      data_type: character varying(255)
      description: '[Who](#!/source/source.tamanu.tamanu.users) ordered the item.'
      name: ordered_by_id
    product_code:
      data_type: character varying(255)
      description: Code of the product.
      name: product_code
    product_discountable:
      data_type: boolean
      description: "Whether this product can be discounted.\r\n\r\nThis is usually\
        \ copied from the [product](#!/source/source.tamanu.tamanu.invoice_products);\
        \ as\r\nproducts can change discountability it is stored here for the record."
      name: product_discountable
    product_id:
      data_type: character varying(255)
      description: The [product](#!/source/source.tamanu.tamanu.invoice_products).
      name: product_id
    product_name:
      data_type: character varying(255)
      description: "Name of the product.\r\n\r\nThis is usually copied from the [product](#!/source/source.tamanu.tamanu.invoice_products);\
        \ as\r\nproducts can change names it is stored here for the record."
      name: product_name
    product_price:
      data_type: numeric
      description: "Price of the product.\r\n\r\nThis is usually copied from the [product](#!/source/source.tamanu.tamanu.invoice_products);\
        \ as\r\nproducts can change price it is stored here for the record."
      name: product_price
    quantity:
      data_type: integer
      description: Quantity ordered.
      name: quantity
    source_id:
      data_type: uuid
      description: "Items can be direct references to [procedures](#!/source/source.tamanu.tamanu.procedures),\r\
        \n[lab tests](#!/source/source.tamanu.tamanu.lab_tests), and\r\n[imagings](#!/source/source.tamanu.tamanu.imaging_requests).\r\
        \n\r\nIn those cases, this field is set to the id of the \"source\" row.\r\
        \n\r\nIf this is set, the item is not editable."
      name: source_id
  config:
    tags:
    - base
    - financial
  description: Items (products) on invoices.
  name: invoice_items
  tags:
  - base
  - financial
- columns:
    id:
      data_type: uuid
      description: Tamanu internal identifier (generally a UUID) in invoice_patient_payments.
      name: id
    invoice_payment_id:
      data_type: uuid
      description: The [payment](#!/source/source.tamanu.tamanu.invoice_payments).
      name: invoice_payment_id
    method_id:
      data_type: character varying(255)
      description: The method used to pay ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
      name: method_id
  config:
    tags:
    - base
    - financial
  description: Extra metadata about a payment when it was done by a patient.
  name: invoice_patient_payments
  tags:
  - base
  - financial
- columns:
    amount:
      data_type: numeric
      description: Amount paid.
      name: amount
    date:
      data_type: date
      description: Local date for the record in invoice_payments.
      name: date
    id:
      data_type: uuid
      description: Tamanu internal identifier (generally a UUID) in invoice_payments.
      name: id
    invoice_id:
      data_type: uuid
      description: The [invoice](#!/source/source.tamanu.tamanu.invoices).
      name: invoice_id
    receipt_number:
      data_type: character varying(255)
      description: Receipt number. Usually auto-generated.
      name: receipt_number
    updated_by_id:
      data_type: character varying(255)
      description: Reference to the [user](#!/source/source.tamanu.tamanu.users) who
        updated this invoice payment.
      name: updated_by_id
  config:
    tags:
    - base
    - financial
  description: "Individual payment against an invoice.\r\n\r\nInvoices can be paid\
    \ in installments, by different parties, etc."
  name: invoice_payments
  tags:
  - base
  - financial
- columns:
    discountable:
      data_type: boolean
      description: Whether the product can be discounted.
      name: discountable
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in invoice_products.
      name: id
    name:
      data_type: text
      description: Name of the product.
      name: name
    price:
      data_type: numeric
      description: Price of the product.
      name: price
    visibility_status:
      data_type: text
      description: "The visibility status of the record.\r\n\r\n- `current` indicates\
        \ the record is currently in use and should be visible and accessible to users\r\
        \n  on the User Interface.\r\n- `historical` indicates that the record is\
        \ no longer in use and should not be visible nor\r\n  accessible to users.\
        \ However, the record may still be present in Reporting.\r\n- `merged` indicates\
        \ that the record has been merged, is no longer in use and should not be visible\r\
        \n  nor accessible to users.\r\n\r\nThe default value is `current`. in invoice_products."
      name: visibility_status
  config:
    tags:
    - base
    - reference
  description: Products which can be invoiced.
  name: invoice_products
  tags:
  - base
  - reference
- columns:
    datetime:
      data_type: timestamp
      description: Local date for the record in invoices.
      name: datetime
    display_id:
      data_type: character varying(255)
      description: Short unique identifier used on the frontend.
      name: display_id
    encounter_id:
      data_type: character varying(255)
      description: Reference to the [encounter](#!/source/source.tamanu.tamanu.encounters)
        this invoice is a part of.
      name: encounter_id
    id:
      data_type: uuid
      description: Tamanu internal identifier (generally a UUID) in invoices.
      name: id
    insurer_payment_status:
      data_type: character varying(255)
      description: "Payment status (insurer portion, if applicable).\r\n\r\nOne of:\r\
        \n- `unpaid`\r\n- `paid`\r\n- `partial`\r\n- `rejected`"
      name: insurer_payment_status
    patient_payment_status:
      data_type: character varying(255)
      description: "Payment status (patient portion, if applicable).\r\n\r\nOne of:\r\
        \n- `unpaid`\r\n- `paid`\r\n- `partial`"
      name: patient_payment_status
    status:
      data_type: character varying(255)
      description: "Status of the invoice.\r\n\r\nOne of:\r\n- `cancelled`\r\n- `in_progress`\r\
        \n- `finalised`"
      name: status
  config:
    tags:
    - base
    - financial
  description: Invoices related to encounters.
  name: invoices
  tags:
  - base
  - financial
- columns:
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in lab_request_logs.
      name: id
    lab_request_id:
      data_type: character varying(255)
      description: Reference to the [lab request](#!/source/source.tamanu.tamanu.lab_requests).
      name: lab_request_id
    status:
      data_type: character varying(255)
      description: The status the lab request was updated to.
      name: status
    updated_by_id:
      data_type: character varying(255)
      description: Reference to the [user](#!/source/source.tamanu.tamanu.users) who
        updated this lab request.
      name: updated_by_id
    updated_datetime:
      data_type: timestamp
      description: Timestamp of when record was last updated in lab_request_logs.
      name: updated_datetime
  config:
    tags:
    - base
    - clinical
    - log
  description: This is a log of who changed the status of a lab request when.
  name: lab_request_logs
  tags:
  - base
  - clinical
  - log
- columns:
    collected_by_id:
      data_type: character varying(255)
      description: Reference to the [Clinician](#!/source/source.tamanu.tamanu.users)
        who collected the sample.
      name: collected_by_id
    collected_datetime:
      data_type: timestamp
      description: When the sample was collected.
      name: collected_datetime
    department_id:
      data_type: character varying(255)
      description: Reference to the [Department](#!/source/source.tamanu.tamanu.departments)
        the request comes from.
      name: department_id
    display_id:
      data_type: character varying(255)
      description: Short unique identifier used on the frontend.
      name: display_id
    encounter_id:
      data_type: character varying(255)
      description: Reference to the [Encounter](#!/source/source.tamanu.tamanu.encounters)
        the request is a part of.
      name: encounter_id
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in lab_requests.
      name: id
    is_specimen_collected:
      data_type: boolean
      description: "Whether a specimen is attached.\r\n\r\nThis implies `specimen_type_id`."
      name: is_specimen_collected
    is_urgent:
      data_type: boolean
      description: Deprecated.
      name: is_urgent
    lab_sample_site_id:
      data_type: character varying(255)
      description: "Reference to the [Reference Data](#!/source/source.tamanu.tamanu.reference_data)\
        \ representing where\r\non the patient the sample was taken."
      name: lab_sample_site_id
    lab_test_category_id:
      data_type: character varying(255)
      description: "Reference to the [Reference Data](#!/source/source.tamanu.tamanu.reference_data)\
        \ representing the\r\ncategory of this request's test."
      name: lab_test_category_id
    lab_test_laboratory_id:
      data_type: character varying(255)
      description: "Reference to the [Reference Data](#!/source/source.tamanu.tamanu.reference_data)\
        \ representing the\r\nlaboratory fulfilling this request."
      name: lab_test_laboratory_id
    lab_test_panel_request_id:
      data_type: uuid
      description: "Reference to the [Test Panel Request](#!/source/source.tamanu.tamanu.lab_test_panel_requests)\r\
        \nassociated with this request, if any."
      name: lab_test_panel_request_id
    lab_test_priority_id:
      data_type: character varying(255)
      description: "Reference to the [Reference Data](#!/source/source.tamanu.tamanu.reference_data)\
        \ representing the\r\npriority of this request."
      name: lab_test_priority_id
    published_date:
      data_type: character(19)
      description: When this lab request's results were published.
      name: published_date
    reason_for_cancellation:
      data_type: character varying(31)
      description: "Why this request was cancelled.\r\n\r\nOne of:\r\n- `clinical`\r\
        \n- `duplicate`\r\n- `entered-in-error`\r\n- `other`\r\n- `patient-discharged`\r\
        \n- `patient-refused`"
      name: reason_for_cancellation
    requested_by_id:
      data_type: character varying(255)
      description: Reference to the [Clinician](#!/source/source.tamanu.tamanu.users)
        who submitted the request.
      name: requested_by_id
    requested_datetime:
      data_type: timestamp
      description: When the request was submitted.
      name: requested_datetime
    specimen_type_id:
      data_type: character varying(255)
      description: "Reference to the [Reference Data](#!/source/source.tamanu.tamanu.reference_data)\
        \ representing the\r\ntype of the specimen for the request, if specified."
      name: specimen_type_id
    status:
      data_type: character varying(255)
      description: "The status of the request.\r\n\r\nOne of:\r\n- `reception_pending`\r\
        \n- `results_pending`\r\n- `interim_results`\r\n- `to_be_verified`\r\n- `verified`\r\
        \n- `published`\r\n- `cancelled`\r\n- `invalidated`\r\n- `deleted`\r\n- `sample-not-collected`\r\
        \n- `entered-in-error`"
      name: status
    updated_datetime:
      data_type: timestamp
      description: Timestamp of when record was last updated in lab_requests which
        is used as a best estimate of modification datetime.
      name: updated_datetime
  config:
    tags:
    - base
    - clinical
  description: "Lab requests are the entrypoint of laboratory workflows in Tamanu.\r\
    \n\r\nEach row is a request for a laboratory to perform a group of tests on a\
    \ sample taken from a patient.\r\n\r\nIt will be updated over the course of the\
    \ workflow to various statuses, starting with\r\n`reception_pending` (lab has\
    \ not received the request yet), up to `published` (lab has completed the\r\n\
    tests and has attached verified results).\r\n\r\nSee also: `lab_request_attachments`,\
    \ `lab_request_logs`, `lab_results`, `lab_tests`,\r\n`lab_test_panels`, and related\
    \ tables to those."
  name: lab_requests
  tags:
  - base
  - clinical
- columns:
    id:
      description: Tamanu internal identifier (generally a UUID) in lab_test_panel_lab_test_types.
      name: id
    lab_test_panel_id:
      description: The [test panel](#!/source/source.tamanu.tamanu.lab_test_panels).
      name: lab_test_panel_id
    lab_test_type_id:
      description: The [test type](#!/source/source.tamanu.tamanu.lab_test_types).
      name: lab_test_type_id
  config:
    tags:
    - base
    - reference
  description: "The lab tests contained in a lab test panel.\r\n\r\nSee [`lab_test_panels`](#!/source/source.tamanu.tamanu.lab_test_panels)\
    \ for more about lab test\r\npanels, and [`lab_test_types`](#!/source/source.tamanu.tamanu.lab_test_types)\
    \ for the test types."
  name: lab_test_panel_lab_test_types
  tags:
  - base
  - reference
- columns:
    encounter_id:
      data_type: character varying(255)
      description: Reference to the [encounter](#!/source/source.tamanu.tamanu.encounters)
        this lab test panel request is a part of.
      name: encounter_id
    id:
      data_type: uuid
      description: Tamanu internal identifier (generally a UUID) in lab_test_panel_requests.
      name: id
    lab_test_panel_id:
      data_type: character varying(255)
      description: The [test panel](#!/source/source.tamanu.tamanu.lab_test_panels).
      name: lab_test_panel_id
  config:
    tags:
    - base
    - clinical
  description: "A request for a lab test panel.\r\n\r\nSee [`lab_test_panels`](#!/source/source.tamanu.tamanu.lab_test_panels)\
    \ for more about those."
  name: lab_test_panel_requests
  tags:
  - base
  - clinical
- columns:
    category_id:
      data_type: character varying(255)
      description: Reference to the category ([Reference Data](#!/source/source.tamanu.tamanu.reference_data))
        of this test panel.
      name: category_id
    code:
      data_type: character varying(255)
      description: Internal Tamanu code of the panel.
      name: code
    external_code:
      data_type: text
      description: External code, such as for interfacing with LIMS.
      name: external_code
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in lab_test_panels.
      name: id
    name:
      data_type: character varying(255)
      description: Name of the test panel.
      name: name
    visibility_status:
      data_type: character varying(255)
      description: "The visibility status of the record.\r\n\r\n- `current` indicates\
        \ the record is currently in use and should be visible and accessible to users\r\
        \n  on the User Interface.\r\n- `historical` indicates that the record is\
        \ no longer in use and should not be visible nor\r\n  accessible to users.\
        \ However, the record may still be present in Reporting.\r\n- `merged` indicates\
        \ that the record has been merged, is no longer in use and should not be visible\r\
        \n  nor accessible to users.\r\n\r\nThe default value is `current`. in lab_test_panels."
      name: visibility_status
  config:
    tags:
    - base
    - reference
  description: "A panel is a collection of lab test types, usually standardised.\r\
    \n\r\nFor example the BMP (basic metabolic panel) is a panel of 8 blood tests.\
    \ Instead of ordering all 8\r\ntests individually, a clinician can order the panel\
    \ all at once. This may also used to more\r\nefficiently use samples.\r\n\r\n\
    This table defines the available test panels, and\r\n[`lab_test_panel_lab_test_types`](#!/source/source.tamanu.tamanu.lab_test_panel_lab_test_types)\r\
    \ncontains the actual test types that are part of each panel. See\r\n[`lab_test_panel_requests`](#!/source/source.tamanu.tamanu.lab_test_panel_requests)\
    \ for requesting\r\npanels specifically, and [`lab_test_requests`](#!/source/source.tamanu.tamanu.lab_test_requests)\
    \ for\r\nrequesting lab tests in general."
  name: lab_test_panels
  tags:
  - base
  - reference
- columns:
    code:
      data_type: character varying(255)
      description: Internal Tamanu code of the test.
      name: code
    external_code:
      data_type: text
      description: External code for the test (such as for LIMS).
      name: external_code
    female_max:
      data_type: double precision
      description: Maximum typical range for females.
      name: female_max
    female_min:
      data_type: double precision
      description: Minimum typical range for females.
      name: female_min
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in lab_test_types.
      name: id
    is_sensitive:
      data_type: boolean
      description: Used to indicate if the lab test type is sensitive and should be
        hidden accordingly.
      name: is_sensitive
    lab_test_category_id:
      data_type: character varying(255)
      description: Reference to the category ([Reference Data](#!/source/source.tamanu.tamanu.reference_data))
        of this test.
      name: lab_test_category_id
    male_max:
      data_type: double precision
      description: Maximum typical range for males.
      name: male_max
    male_min:
      data_type: double precision
      description: Minimum typical range for males.
      name: male_min
    name:
      data_type: character varying(255)
      description: Human-friendly name of the test.
      name: name
    options:
      data_type: text
      description: Comma-separated list of options. Unused.
      name: options
    range_text:
      data_type: character varying(255)
      description: Unused.
      name: range_text
    result_type:
      data_type: character varying(255)
      description: "Input type of result.\r\n\r\nOne of:\r\n- `FreeText`\r\n- `Number`\r\
        \n- `Select`"
      name: result_type
    unit:
      data_type: character varying(255)
      description: Unit the test result is measured in.
      name: unit
    visibility_status:
      data_type: text
      description: "The visibility status of the record.\r\n\r\n- `current` indicates\
        \ the record is currently in use and should be visible and accessible to users\r\
        \n  on the User Interface.\r\n- `historical` indicates that the record is\
        \ no longer in use and should not be visible nor\r\n  accessible to users.\
        \ However, the record may still be present in Reporting.\r\n- `merged` indicates\
        \ that the record has been merged, is no longer in use and should not be visible\r\
        \n  nor accessible to users.\r\n\r\nThe default value is `current`. in lab_test_types."
      name: visibility_status
  config:
    tags:
    - base
    - reference
  description: "A kind of test that's possible to request.\r\n\r\nThis includes information\
    \ about the test itself, and also parameters around result formatting, like\r\n\
    data type, expected ranges, etc."
  name: lab_test_types
  tags:
  - base
  - reference
- columns:
    completed_datetime:
      data_type: timestamp
      description: Datetime at which the test was completed.
      name: completed_datetime
    date:
      data_type: date
      description: Local date for the record in lab_tests.
      name: date
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in lab_tests.
      name: id
    lab_request_id:
      data_type: character varying(255)
      description: The [lab request](#!/source/source.tamanu.tamanu.lab_requests)
        this test is part of.
      name: lab_request_id
    lab_test_method_id:
      data_type: character varying(255)
      description: Reference to the method ([Reference Data](#!/source/source.tamanu.tamanu.reference_data))
        of this test.
      name: lab_test_method_id
    lab_test_type_id:
      data_type: character varying(255)
      description: The [type](#!/source/source.tamanu.tamanu.lab_test_types) of the
        test.
      name: lab_test_type_id
    laboratory_officer:
      data_type: character varying(255)
      description: Name of the lab officer performing the test.
      name: laboratory_officer
    result:
      data_type: character varying(255)
      description: The result of the test.
      name: result
    verification:
      data_type: character varying(255)
      description: "Free-form field for a verification indication.\r\n\r\nMay be a\
        \ verifying or supervising officer's name, a department, lab notes..."
      name: verification
  config:
    tags:
    - base
    - clinical
  description: A single test as part of a [lab request](#!/source/source.tamanu.tamanu.lab_requests).
  name: lab_tests
  tags:
  - base
  - clinical
- columns:
    booking_type_id:
      data_type: character varying(255)
      description: "Reference to a [Reference Data](#!/source/source.tamanu.tamanu.reference_data)\r\
        \n(`type=bookingType`)."
      name: booking_type_id
    clinician_id:
      data_type: character varying(255)
      description: Reference to the [clinician](#!/source/source.tamanu.tamanu.users)
        recording that appointment.
      name: clinician_id
    encounter_id:
      data_type: character varying(255)
      description: Reference to the [encounter](#!/source/source.tamanu.tamanu.encounters)
        linked to this appointment
      name: encounter_id
    end_datetime:
      data_type: timestamp
      description: When the appointment ends.
      name: end_datetime
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in appointments.
      name: id
    is_high_priority:
      data_type: boolean
      description: Boolean specify if the appointment is high priority.
      name: is_high_priority
    location_id:
      data_type: character varying(255)
      description: The [location](#!/source/source.tamanu.tamanu.locations) where
        the appointment will take place.
      name: location_id
    patient_id:
      data_type: character varying(255)
      description: Reference to the [patient](#!/source/source.tamanu.tamanu.patients).
      name: patient_id
    start_datetime:
      data_type: timestamp
      description: When the appointment starts.
      name: start_datetime
    status:
      data_type: character varying(255)
      description: "The current status of the appointment record.\r\n\r\nOne of:\r\
        \n- `Confirmed`\r\n- `Arrived`\r\n- `No-show`\r\n- `Cancelled`"
      name: status
  config:
    tags:
    - base
    - clinical
  description: Table of appointments. (location bookings)
  name: location_bookings
  tags:
  - base
  - clinical
- columns:
    code:
      data_type: character varying(255)
      description: Code for location group
      name: code
    facility_id:
      data_type: character varying(255)
      description: Reference to the [facility](#!/source/source.tamanu.tamanu.facilities)
        this location group is in.
      name: facility_id
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in location_groups.
      name: id
    name:
      data_type: character varying(255)
      description: Full readable name for location group
      name: name
    visibility_status:
      data_type: text
      description: "The visibility status of the record.\r\n\r\n- `current` indicates\
        \ the record is currently in use and should be visible and accessible to users\r\
        \n  on the User Interface.\r\n- `historical` indicates that the record is\
        \ no longer in use and should not be visible nor\r\n  accessible to users.\
        \ However, the record may still be present in Reporting.\r\n- `merged` indicates\
        \ that the record has been merged, is no longer in use and should not be visible\r\
        \n  nor accessible to users.\r\n\r\nThe default value is `current`. in location_groups."
      name: visibility_status
  config:
    tags:
    - base
    - reference
  description: A group of locations managed as a single unit (e.g. a ward in hospital)
  name: location_groups
  tags:
  - base
  - reference
- columns:
    code:
      data_type: character varying(255)
      description: Code for location
      name: code
    facility_id:
      data_type: character varying(255)
      description: Reference to the [facility](#!/source/source.tamanu.tamanu.facilities)
        this location is in.
      name: facility_id
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in locations.
      name: id
    location_group_id:
      data_type: character varying(255)
      description: Reference to the [group](#!/source/source.tamanu.tamanu.location_groups)
        this location is in.
      name: location_group_id
    max_occupancy:
      data_type: integer
      description: The maximum number of patients that can be in this location
      name: max_occupancy
    name:
      data_type: character varying(255)
      description: Full readable name for location
      name: name
    visibility_status:
      data_type: text
      description: "The visibility status of the record.\r\n\r\n- `current` indicates\
        \ the record is currently in use and should be visible and accessible to users\r\
        \n  on the User Interface.\r\n- `historical` indicates that the record is\
        \ no longer in use and should not be visible nor\r\n  accessible to users.\
        \ However, the record may still be present in Reporting.\r\n- `merged` indicates\
        \ that the record has been merged, is no longer in use and should not be visible\r\
        \n  nor accessible to users.\r\n\r\nThe default value is `current`. in locations."
      name: visibility_status
  config:
    tags:
    - base
    - reference
  description: Information on the hospital locations.
  name: locations
  tags:
  - base
  - reference
- columns:
    authored_by_id:
      data_type: character varying(255)
      description: Reference to the [user](#!/source/source.tamanu.tamanu.users) who
        published this note.
      name: authored_by_id
    content:
      data_type: text
      description: The content of the note recorded.
      name: content
    datetime:
      data_type: timestamp
      description: Local date for the record in notes.
      name: datetime
    id:
      data_type: uuid
      description: Tamanu internal identifier (generally a UUID) in notes.
      name: id
    note_type:
      data_type: character varying(255)
      description: Type of note recorded.
      name: note_type
    on_behalf_of_id:
      data_type: character varying(255)
      description: Reference to the [user](#!/source/source.tamanu.tamanu.users) who
        wrote this note, if it wasn't the user who published it.
      name: on_behalf_of_id
    record_id:
      data_type: character varying(255)
      description: Polymorphic relationship to the record to which the note is attached
        (id).
      name: record_id
    record_type:
      data_type: character varying(255)
      description: Polymorphic relationship to the record to which the note is attached
        (type).
      name: record_type
    updated_note_id:
      data_type: uuid
      description: Reference to the [note](#!/source/source.tamanu.tamanu.notes) that
        is being revised.
      name: updated_note_id
    visibility_status:
      data_type: text
      description: "The visibility status of the record.\r\n\r\n- `current` indicates\
        \ the record is currently in use and should be visible and accessible to users\r\
        \n  on the User Interface.\r\n- `historical` indicates that the record is\
        \ no longer in use and should not be visible nor\r\n  accessible to users.\
        \ However, the record may still be present in Reporting.\r\n- `merged` indicates\
        \ that the record has been merged, is no longer in use and should not be visible\r\
        \n  nor accessible to users.\r\n\r\nThe default value is `current`. in notes."
      name: visibility_status
  config:
    tags:
    - base
    - clinical
  description: "Notes recorded by clinicians or system generated.\r\n\r\nAlso see\
    \ the deprecated [`note_items`](#!/source/source.tamanu.tamanu.note_items),\r\n\
    [`note_pages`](#!/source/source.tamanu.tamanu.note_pages), and the even older\r\
    \n[`notes_legacy`](#!/source/source.tamanu.tamanu.notes_legacy).\r\n\r\nThis is\
    \ the current version (3) of the notes system."
  name: notes
  tags:
  - base
  - clinical
- columns:
    appointment_type_id:
      data_type: character varying(255)
      description: "Reference to a [Reference Data](#!/source/source.tamanu.tamanu.reference_data)\r\
        \n(`type=appointmentType`)."
      name: appointment_type_id
    cancelled_at_date:
      data_type: character(10)
      description: The date from which appointments in a schedule have been cancelled,
        this is set when cancelling 'this and all future appointments'.
      name: cancelled_at_date
    clinician_id:
      data_type: character varying(255)
      description: Reference to the [clinician](#!/source/source.tamanu.tamanu.users)
        recording that appointment.
      name: clinician_id
    days_of_week:
      data_type: array
      description: "Stores an array of ISO weekday abbreviations. \r\nGiven `WEEKLY`\
        \ frequency `days_of_week` determines the weekday that the repeated appointment\
        \ occurs on. \r\nGiven `MONTHLY` frequency `days_of_week` is combined with\
        \ `nth_weekday` to determine the date in each month that the repeated appointment\
        \ occurs on.\r\n\r\nOne of: \r\n- `MO`\r\n- `TU`\r\n- `WE`\r\n- `TH`\r\n-\
        \ `FR`\r\n- `SA`\r\n- `SU`"
      name: days_of_week
    encounter_id:
      data_type: character varying(255)
      description: Reference to the [encounter](#!/source/source.tamanu.tamanu.encounters)
        linked to this appointment
      name: encounter_id
    end_datetime:
      data_type: timestamp
      description: When the appointment ends.
      name: end_datetime
    frequency:
      data_type: character varying(255)
      description: "How often the the recurrence occurs.\r\n\r\nOne of:\r\n- `WEEKLY`\r\
        \n- `MONTHLY`"
      name: frequency
    generated_until_date:
      data_type: character(10)
      description: The date of the most recent appointment in a schedule, this is
        set after generation of the repeated appointment and then updated if it is
        necessary to generate further appointments.
      name: generated_until_date
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in appointments.
      name: id
    interval:
      data_type: integer
      description: "The recurrence interval. For example:\r\n- For a `frequency` of\
        \ `WEEKLY`, an `interval` of 1 means \"Once a week.\"\r\n- For a `frequency`\
        \ of `MONTHLY`, an `interval` of 3 means \"Every 3 months.\""
      name: interval
    is_fully_generated:
      data_type: boolean
      description: Whether or not all repeating appointments have been created for
        a schedule
      name: is_fully_generated
    is_high_priority:
      data_type: boolean
      description: Boolean specify if the appointment is high priority.
      name: is_high_priority
    location_group_id:
      data_type: character varying(255)
      description: The [location group](#!/source/source.tamanu.tamanu.location_groups)
        where the appointment will take place.]
      name: location_group_id
    nth_weekday:
      data_type: integer
      description: "Ordinal weekday for monthly recurrence interpreted with `days_of_week`\
        \ for example:\r\n- `1` with `days_of_week = ['MO']` =  First Monday of the\
        \ month\r\n- `2` with `days_of_week = ['TU']` =  Second Tuesday of the month\r\
        \n- `-1` with `days_of_week = ['FR']` = Last Friday of the month"
      name: nth_weekday
    occurrence_count:
      data_type: integer
      description: "When this value is set, the recurrence ends after generating the\
        \ specified number of occurrences\r\nAt least one of `occurrence_count` or\
        \ `until_date` must be set."
      name: occurrence_count
    patient_id:
      data_type: character varying(255)
      description: Reference to the [patient](#!/source/source.tamanu.tamanu.patients).
      name: patient_id
    schedule_id:
      data_type: uuid
      description: Reference to the [appointment schedule](#!/source/source.tamanu.tamanu.appointment_schedules)
        in the case of repeating appointments.
      name: schedule_id
    start_datetime:
      data_type: timestamp
      description: When the appointment starts.
      name: start_datetime
    status:
      data_type: character varying(255)
      description: "The current status of the appointment record.\r\n\r\nOne of:\r\
        \n- `Confirmed`\r\n- `Arrived`\r\n- `No-show`\r\n- `Cancelled`"
      name: status
    until_date:
      data_type: date
      description: "The end date for the recurrence. No occurrences will be generated\
        \ beyond this date. \r\nBoth `until_date` and `occurrence_count` cannot be\
        \ null at the same time to ensure the recurrence has an end condition."
      name: until_date
  config:
    tags:
    - base
    - clinical
  description: Table of appointments. (outpatient appointment)
  name: outpatient_appointments
  tags:
  - base
  - clinical
- columns:
    blood_type:
      data_type: character varying(255)
      description: "Blood type.\r\n\r\nOne of:\r\n- `A+`\r\n- `A-`\r\n- `AB-`\r\n\
        - `AB+`\r\n- `B+`\r\n- `B-`\r\n- `O+`\r\n- `O-`"
      name: blood_type
      tags:
      - quasi_identifier
    country_id:
      data_type: character varying(255)
      description: Reference to patient country of residence ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
      name: country_id
      tags:
      - quasi_identifier
    country_of_birth_id:
      data_type: character varying(255)
      description: Reference to patient country of birth ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
      name: country_of_birth_id
      tags:
      - quasi_identifier
    division_id:
      data_type: character varying(255)
      description: Reference to patient administrative division of residence ([Reference
        Data](#!/source/source.tamanu.tamanu.reference_data)).
      name: division_id
      tags:
      - quasi_identifier
    educational_level:
      data_type: character varying(255)
      description: Highest educational attainment.
      name: educational_level
      tags:
      - quasi_identifier
    ethnicity_id:
      data_type: character varying(255)
      description: Reference to patient ethnicity ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
      name: ethnicity_id
      tags:
      - quasi_identifier
    father_id:
      data_type: character varying(255)
      description: Reference to [patient](#!/source/source.tamanu.tamanu.patients)
        ID of father / parent.
      name: father_id
      tags:
      - quasi_identifier
    health_center_id:
      data_type: text
      description: Reference to patient primary health center ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
      name: health_center_id
      tags:
      - quasi_identifier
    insurer_id:
      data_type: character varying(255)
      description: Reference to patient insurer ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
      name: insurer_id
      tags:
      - quasi_identifier
    marital_status:
      data_type: character varying(255)
      description: "Marital status.\r\n\r\nOne of:\r\n- `Defacto`\r\n- `Married`\r\
        \n- `Single`\r\n- `Widow`\r\n- `Divorced`\r\n- `Separated`\r\n- `Unknown`"
      name: marital_status
      tags:
      - quasi_identifier
    medical_area_id:
      data_type: character varying(255)
      description: Reference to patient administrative medical area of residence ([Reference
        Data](#!/source/source.tamanu.tamanu.reference_data)).
      name: medical_area_id
      tags:
      - quasi_identifier
    mother_id:
      data_type: character varying(255)
      description: Reference to [patient](#!/source/source.tamanu.tamanu.patients)
        ID of mother / parent.
      name: mother_id
      tags:
      - quasi_identifier
    nationality_id:
      data_type: character varying(255)
      description: Reference to patient nationality ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
      name: nationality_id
      tags:
      - quasi_identifier
    nursing_zone_id:
      data_type: character varying(255)
      description: Reference to patient administrative nursing zone of residence ([Reference
        Data](#!/source/source.tamanu.tamanu.reference_data)).
      name: nursing_zone_id
      tags:
      - quasi_identifier
    occupation_id:
      data_type: character varying(255)
      description: Reference to patient occupation ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
      name: occupation_id
      tags:
      - quasi_identifier
    patient_billing_type_id:
      data_type: character varying(255)
      description: Reference to patient billing type.
      name: patient_billing_type_id
      tags:
      - quasi_identifier
    patient_id:
      data_type: text
      description: Tamanu internal identifier (generally a UUID) in patient_additional_data.
      name: patient_id
    place_of_birth:
      data_type: character varying(255)
      description: Free-form place of birth (typically a place name or country).
      name: place_of_birth
      tags:
      - quasi_identifier
    registered_by_id:
      data_type: character varying(255)
      description: Reference to the [user](#!/source/source.tamanu.tamanu.users) who
        registered the patient in Tamanu.
      name: registered_by_id
    registration_date:
      data_type: date
      description: Timestamp of when record was created in patient_additional_data
        which is used as a best estimate of registration date.
      name: registration_date
    religion_id:
      data_type: character varying(255)
      description: Reference to patient religion ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
      name: religion_id
      tags:
      - quasi_identifier
    secondary_village_id:
      data_type: text
      description: "Reference to patient administrative village of residence ([Reference\
        \ Data](#!/source/source.tamanu.tamanu.reference_data), secondary).\r\n\r\n\
        See also [`patients.village_id`](#!/source/source.tamanu.tamanu.patients)."
      name: secondary_village_id
      tags:
      - quasi_identifier
    subdivision_id:
      data_type: character varying(255)
      description: Reference to patient administrative subdivision of residence ([Reference
        Data](#!/source/source.tamanu.tamanu.reference_data)).
      name: subdivision_id
      tags:
      - quasi_identifier
    title:
      data_type: character varying(255)
      description: 'Patient name: title.'
      name: title
    updated_by_field:
      data_type: json
      description: "JSON object recording the updated datetime for individual columns.\r\
        \n\r\nAs PADs contain a lot of disparate data, it's not uncommon that fields\
        \ are edited separately in\r\ndifferent facilities. The default sync strategy\
        \ is for the last edit to a whole row to \"win out\" in\r\ncase of a conflict,\
        \ but this can lead to discarding important data in the case of PADs. This\
        \ field\r\nis used to implement per-field \"last edit wins\" instead."
      name: updated_by_field
  config:
    tags:
    - base
    - patient
  description: "Core or adjunct patient data that doesn't fit elsewhere, but is only\
    \ downloaded to a facility once a\r\npatient is marked for sync.\r\n\r\nThis is\
    \ often referred to as \"PAD\".\r\n\r\nSee also `patient_field_definition_categories`,\
    \ `patient_field_definitions`, and `patient_field_values`,\r\nwhich define and\
    \ specify custom/non-standard data to be stored against patients."
  name: patient_additional_data
  tags:
  - base
  - patient
- columns:
    blood_type:
      data_type: text
      description: "Blood type.\r\n\r\nOne of:\r\n- `A+`\r\n- `A-`\r\n- `AB-`\r\n\
        - `AB+`\r\n- `B+`\r\n- `B-`\r\n- `O+`\r\n- `O-` from history."
      name: blood_type
      tags:
      - quasi_identifier
    changelog_id:
      data_type: uuid
      description: The ID of the change log row. UUID
      name: changelog_id
    country_id:
      data_type: text
      description: Reference to patient country of residence ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
        from history.
      name: country_id
      tags:
      - quasi_identifier
    country_of_birth_id:
      data_type: text
      description: Reference to patient country of birth ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
        from history.
      name: country_of_birth_id
      tags:
      - quasi_identifier
    division_id:
      data_type: text
      description: Reference to patient administrative division of residence ([Reference
        Data](#!/source/source.tamanu.tamanu.reference_data)). from history.
      name: division_id
      tags:
      - quasi_identifier
    educational_level:
      data_type: text
      description: Highest educational attainment. from history.
      name: educational_level
      tags:
      - quasi_identifier
    ethnicity_id:
      data_type: text
      description: Reference to patient ethnicity ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
        from history.
      name: ethnicity_id
      tags:
      - quasi_identifier
    father_id:
      data_type: text
      description: Reference to [patient](#!/source/source.tamanu.tamanu.patients)
        ID of father / parent. from history.
      name: father_id
      tags:
      - quasi_identifier
    health_center_id:
      data_type: text
      description: Reference to patient primary health center ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
        from history.
      name: health_center_id
      tags:
      - quasi_identifier
    insurer_id:
      data_type: text
      description: Reference to patient insurer ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
        from history.
      name: insurer_id
      tags:
      - quasi_identifier
    logged_at:
      data_type: timestamp
      description: The timestamp this change was logged. in patient additional data
        history.
      name: logged_at
    marital_status:
      data_type: text
      description: "Marital status.\r\n\r\nOne of:\r\n- `Defacto`\r\n- `Married`\r\
        \n- `Single`\r\n- `Widow`\r\n- `Divorced`\r\n- `Separated`\r\n- `Unknown`\
        \ from history."
      name: marital_status
      tags:
      - quasi_identifier
    medical_area_id:
      data_type: text
      description: Reference to patient administrative medical area of residence ([Reference
        Data](#!/source/source.tamanu.tamanu.reference_data)). from history.
      name: medical_area_id
      tags:
      - quasi_identifier
    mother_id:
      data_type: text
      description: Reference to [patient](#!/source/source.tamanu.tamanu.patients)
        ID of mother / parent. from history.
      name: mother_id
      tags:
      - quasi_identifier
    nationality_id:
      data_type: text
      description: Reference to patient nationality ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
        from history.
      name: nationality_id
      tags:
      - quasi_identifier
    nursing_zone_id:
      data_type: text
      description: Reference to patient administrative nursing zone of residence ([Reference
        Data](#!/source/source.tamanu.tamanu.reference_data)). from history.
      name: nursing_zone_id
      tags:
      - quasi_identifier
    occupation_id:
      data_type: text
      description: Reference to patient occupation ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
        from history.
      name: occupation_id
      tags:
      - quasi_identifier
    patient_billing_type_id:
      data_type: text
      description: Reference to patient billing type. from history.
      name: patient_billing_type_id
      tags:
      - quasi_identifier
    patient_id:
      data_type: text
      description: Tamanu internal identifier (generally a UUID) in patient_additional_data
        from history.
      name: patient_id
    place_of_birth:
      data_type: text
      description: Free-form place of birth (typically a place name or country). from
        history.
      name: place_of_birth
      tags:
      - quasi_identifier
    registered_by_id:
      data_type: text
      description: Reference to the [user](#!/source/source.tamanu.tamanu.users) who
        registered the patient in Tamanu. from history.
      name: registered_by_id
    registration_date:
      data_type: date
      description: Timestamp of when record was created in patient additional data
        history which is used as a best estimate of registration date.
      name: registration_date
    religion_id:
      data_type: text
      description: Reference to patient religion ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
        from history.
      name: religion_id
      tags:
      - quasi_identifier
    secondary_village_id:
      data_type: text
      description: "Reference to patient administrative village of residence ([Reference\
        \ Data](#!/source/source.tamanu.tamanu.reference_data), secondary).\r\n\r\n\
        See also [`patients.village_id`](#!/source/source.tamanu.tamanu.patients).\
        \ from history."
      name: secondary_village_id
      tags:
      - quasi_identifier
    subdivision_id:
      data_type: text
      description: Reference to patient administrative subdivision of residence ([Reference
        Data](#!/source/source.tamanu.tamanu.reference_data)). from history.
      name: subdivision_id
      tags:
      - quasi_identifier
    title:
      data_type: text
      description: 'Patient name: title. from history.'
      name: title
    updated_by_field:
      data_type: jsonb
      description: "JSON object recording the updated datetime for individual columns.\r\
        \n\r\nAs PADs contain a lot of disparate data, it's not uncommon that fields\
        \ are edited separately in\r\ndifferent facilities. The default sync strategy\
        \ is for the last edit to a whole row to \"win out\" in\r\ncase of a conflict,\
        \ but this can lead to discarding important data in the case of PADs. This\
        \ field\r\nis used to implement per-field \"last edit wins\" instead. from\
        \ history."
      name: updated_by_field
    updated_by_user_id:
      data_type: text
      description: "The value of the `updated_by_user_id` field of the change data.\r\
        \n\r\nThis is extracted from the data to make it easier to query on. in patient\
        \ additional data history."
      name: updated_by_user_id
  config:
    tags:
    - base
    - patient
    - log
  description: "Change logs of Core or adjunct patient data that doesn't fit elsewhere,\
    \ but is only downloaded to a facility once a\r\npatient is marked for sync.\r\
    \n\r\nThis is often referred to as \"PAD\".\r\n\r\nSee also `patient_field_definition_categories`,\
    \ `patient_field_definitions`, and `patient_field_values`,\r\nwhich define and\
    \ specify custom/non-standard data to be stored against patients."
  name: patient_additional_data_change_logs
  tags:
  - base
  - patient
  - log
- columns:
    allergy_id:
      data_type: character varying(255)
      description: Reference to an allergy ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
      name: allergy_id
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in patient_allergies.
      name: id
    patient_id:
      data_type: character varying(255)
      description: Reference to the [patient](#!/source/source.tamanu.tamanu.patients).
      name: patient_id
    recorded_by:
      data_type: character varying(255)
      description: Reference to the [practitioner](#!/source/source.tamanu.tamanu.users)
        recording this allergy.
      name: recorded_by
    recorded_date:
      data_type: date
      description: Datetime at which this allergy was recorded.
      name: recorded_date
  config:
    tags:
    - base
    - clinical
  description: "List of allergies known of the patient.\r\n\r\nIn Tamanu this is displayed\
    \ and entered in the patient view sidebar, under \"Allergies\".\r\n\r\nSee also:\
    \ `public.patient_care_plans`, `public.patient_conditions`,\r\n`public.patient_family_histories`,\
    \ `public.patient_issues`."
  name: patient_allergies
  tags:
  - base
  - clinical
- columns:
    apgar_score_five_minutes:
      data_type: integer
      description: '[Apgar score](https://en.wikipedia.org/wiki/Apgar_score) five
        minutes after birth.'
      name: apgar_score_five_minutes
    apgar_score_one_minute:
      data_type: integer
      description: '[Apgar score](https://en.wikipedia.org/wiki/Apgar_score) one minute
        after birth.'
      name: apgar_score_one_minute
    apgar_score_ten_minutes:
      data_type: integer
      description: '[Apgar score](https://en.wikipedia.org/wiki/Apgar_score) ten minutes
        after birth.'
      name: apgar_score_ten_minutes
    attendant_at_birth:
      data_type: character varying(255)
      description: "The type of the attendant at birth.\r\n\r\nOne of:\r\n- `doctor`\r\
        \n- `midwife`\r\n- `nurse`\r\n- `traditional_birth_attentdant`\r\n- `other`"
      name: attendant_at_birth
    birth_delivery_type:
      data_type: character varying(255)
      description: "Type of delivery.\r\n\r\nOne of:\r\n- `normal_vaginal_delivery`\r\
        \n- `breech`\r\n- `emergency_c_section`\r\n- `elective_c_section`\r\n- `vacuum_extraction`\r\
        \n- `forceps`\r\n- `other`"
      name: birth_delivery_type
    birth_facility_id:
      data_type: character varying(255)
      description: "Reference to the [facility](#!/source/source.tamanu.tamanu.facilities)\
        \ the birth was recorded at.\r\n\r\nThis is only required when `registered_birth_place`\
        \ is `health_facility`."
      name: birth_facility_id
    birth_length:
      data_type: numeric
      description: Length in cm at birth.
      name: birth_length
    birth_time:
      data_type: time
      description: Datetime of birth.
      name: birth_time
    birth_type:
      data_type: character varying(255)
      description: '`single` or `plural` birth.'
      name: birth_type
    birth_weight:
      data_type: numeric
      description: Weight in kg at birth.
      name: birth_weight
    gestational_age_estimate:
      data_type: double precision
      description: Gestational age estimate (weeks).
      name: gestational_age_estimate
    name_of_attendant_at_birth:
      data_type: character varying(255)
      description: Name of attendant at birth.
      name: name_of_attendant_at_birth
    patient_id:
      data_type: character varying(255)
      description: "Reference to the [patient](#!/source/source.tamanu.tamanu.patients).\r\
        \n\r\nThere is at most one `patient_birth_data` row per patient.\r\n\r\nNote\
        \ that the `id` column is generated from this column to enforce this."
      name: patient_id
    registered_birth_place:
      data_type: character varying(255)
      description: "Type of the actual birth place.\r\n\r\nOne of:\r\n- `health_facility`\r\
        \n- `home`\r\n- `other`"
      name: registered_birth_place
    registration_date:
      data_type: date
      description: Timestamp of when record was created in patient_birth_data.
      name: registration_date
  config:
    tags:
    - base
    - clinical
  description: "Information about the birth of the patient, if their birth was recorded\
    \ into Tamanu.\r\n\r\nThis is specifically data about the newborn, and only the\
    \ birth-relevant data.\r\nOther patient data is found in the normal tables i.e.\
    \ `patients`, `patient_additional_data`, etc."
  name: patient_birth_data
  tags:
  - base
  - clinical
- columns:
    condition_id:
      data_type: character varying(255)
      description: Reference to a diagnosis describing this issue ([Reference Data](#!/source/source.tamanu.tamanu.reference_data)).
      name: condition_id
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in patient_conditions.
      name: id
    is_resolved:
      data_type: boolean
      description: Whether the condition has resolved.
      name: is_resolved
    note:
      data_type: character varying(255)
      description: Free-form description of this condition.
      name: note
    patient_id:
      data_type: character varying(255)
      description: Reference to the [patient](#!/source/source.tamanu.tamanu.patients).
      name: patient_id
    recorded_by_id:
      data_type: character varying(255)
      description: "Reference to the [practitioner](#!/source/source.tamanu.tamanu.users)\
        \ diagnosing/recording this\r\ncondition."
      name: recorded_by_id
    recorded_datetime:
      data_type: timestamp
      description: Datetime at which this issue was recorded.
      name: recorded_datetime
    resolution_note:
      data_type: text
      description: Free-form description or notes about the resolution of this condition.
      name: resolution_note
    resolved_by_id:
      data_type: character varying(255)
      description: "Reference to the [practitioner](#!/source/source.tamanu.tamanu.users)\
        \ diagnosing/recording the\r\nresolution of this condition."
      name: resolved_by_id
    resolved_datetime:
      data_type: character(19)
      description: Datetime at which this issue was resolved.
      name: resolved_datetime
  config:
    tags:
    - base
    - clinical
  description: "List of ongoing conditions known about a patient.\r\n\r\nIn Tamanu\
    \ this is displayed and entered in the patient view sidebar, under \"Ongoing conditions\"\
    .\r\n\r\nSee also: `public.patient_allergies`, `public.patient_care_plans`,\r\n\
    `public.patient_family_histories`, `public.patient_issues`."
  name: patient_conditions
  tags:
  - base
  - clinical
- columns:
    condition_id:
      data_type: character varying(255)
      description: Reference to the condition ([Reference Data](#!/source/source.tamanu.tamanu.reference_data),
        `type = condition`).
      name: condition_id
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in contributing_death_causes.
      name: id
    min_after_onset:
      data_type: integer
      description: Time between onset of recorded cause and death in minutes.
      name: min_after_onset
    patient_death_data_id:
      data_type: character varying(255)
      description: The [`patient_death_data`](#!/source/source.tamanu.tamanu.patient_death_data)
        record.
      name: patient_death_data_id
  config:
    tags:
    - base
    - clinical
  description: Contributing causes recorded with the patient's death data.
  name: patient_death_contributing_causes
  tags:
  - base
  - clinical
- columns:
    antecedent_cause1_condition_id:
      data_type: character varying(255)
      description: "Reference to an antecedent (1) cause of death\r\n([Reference Data](#!/source/source.tamanu.tamanu.reference_data)),\
        \ if applicable."
      name: antecedent_cause1_condition_id
    antecedent_cause1_mins_after_onset:
      data_type: integer
      description: The time in minutes after onset of an antecedent (1) cause of death,
        if applicable.
      name: antecedent_cause1_mins_after_onset
    antecedent_cause2_condition_id:
      data_type: character varying(255)
      description: "Reference to an antecedent (2) cause of death\r\n([Reference Data](#!/source/source.tamanu.tamanu.reference_data)),\
        \ if applicable."
      name: antecedent_cause2_condition_id
    antecedent_cause2_mins_after_onset:
      data_type: integer
      description: The time in minutes after onset of an antecedent (2) cause of death,
        if applicable.
      name: antecedent_cause2_mins_after_onset
    antecedent_cause3_condition_id:
      data_type: character varying(255)
      description: "Reference to an antecedent (3) cause of death\r\n([Reference Data](#!/source/source.tamanu.tamanu.reference_data)),\
        \ if applicable."
      name: antecedent_cause3_condition_id
    antecedent_cause3_mins_after_onset:
      data_type: integer
      description: The time in minutes after onset of an antecedent (3) cause of death,
        if applicable.
      name: antecedent_cause3_mins_after_onset
    birth_weight:
      data_type: integer
      description: If the deceased was a foetus, stillborn, or infant, their birth
        weight.
      name: birth_weight
    carrier_age:
      data_type: integer
      description: If the deceased was a foetus, stillborn, or infant, the age of
        the carrier.
      name: carrier_age
    carrier_existing_condition_id:
      data_type: character varying(255)
      description: "If the deceased was a foetus, stillborn, or infant, any relevant\
        \ existing condition\r\n([Reference Data](#!/source/source.tamanu.tamanu.reference_data))\
        \ of the carrier."
      name: carrier_existing_condition_id
    carrier_pregnancy_weeks:
      data_type: integer
      description: If the deceased was a foetus, stillborn, or infant, how many weeks
        pregnant their carrier was.
      name: carrier_pregnancy_weeks
    external_cause_date:
      data_type: date
      description: Datetime of external cause of death, if applicable.
      name: external_cause_date
    external_cause_location:
      data_type: character varying(255)
      description: Physical location of external cause of death, if applicable.
      name: external_cause_location
    external_cause_notes:
      data_type: text
      description: Free-form description of external cause of death, if applicable.
      name: external_cause_notes
    facility_id:
      data_type: character varying(255)
      description: Reference to the [facility](#!/source/source.tamanu.tamanu.facilities)
        where this death is being recorded.
      name: facility_id
    had_recent_surgery:
      data_type: character varying(255)
      description: Free-form description of the most recent surgery the patient received,
        if any.
      name: had_recent_surgery
    hours_survived_since_birth:
      data_type: integer
      description: If the deceased was an infant, how many days since the birth passed
        before their death.
      name: hours_survived_since_birth
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in patient_death_data.
      name: id
    is_final:
      data_type: boolean
      description: "Whether this date record is final.\r\n\r\nIn Tamanu, this is set\
        \ by a supervisor after review, and cannot be reversed; it causes all fields\
        \ to\r\nbecome read-only. The only way to undo this record is through a `death_revert_logs`."
      name: is_final
    last_surgery_date:
      data_type: date
      description: Datetime of the most recent surgery the patient received, if any.
      name: last_surgery_date
    last_surgery_reason_id:
      data_type: character varying(255)
      description: "Reference to a `diagnosis` ([Reference Data](#!/source/source.tamanu.tamanu.reference_data))\
        \ for the\r\nreason of the most recent surgery the patient received, if any."
      name: last_surgery_reason_id
    manner:
      data_type: character varying(255)
      description: Free-form description of the manner of death.
      name: manner
    patient_id:
      data_type: character varying(255)
      description: The [patient](#!/source/source.tamanu.tamanu.patients) who died.
      name: patient_id
    pregnancy_contributed:
      data_type: character varying(255)
      description: Whether the pregnancy contributed to the death.
      name: pregnancy_contributed
    primary_cause_condition_id:
      data_type: character varying(255)
      description: "Reference to the primary cause of death\r\n([Reference Data](#!/source/source.tamanu.tamanu.reference_data)),\
        \ if known."
      name: primary_cause_condition_id
    primary_cause_mins_after_onset:
      data_type: integer
      description: The time in minutes after onset of the primary cause of death,
        if known.
      name: primary_cause_mins_after_onset
    recorded_by_id:
      data_type: character varying(255)
      description: Reference to the [clinician](#!/source/source.tamanu.tamanu.users)
        who is recording this death.
      name: recorded_by_id
    visibility_status:
      data_type: text
      description: "The visibility status of the record.\r\n\r\n- `current` indicates\
        \ the record is currently in use and should be visible and accessible to users\r\
        \n  on the User Interface.\r\n- `historical` indicates that the record is\
        \ no longer in use and should not be visible nor\r\n  accessible to users.\
        \ However, the record may still be present in Reporting.\r\n- `merged` indicates\
        \ that the record has been merged, is no longer in use and should not be visible\r\
        \n  nor accessible to users.\r\n\r\nThe default value is `current`. in patient_death_data."
      name: visibility_status
    was_fetal_or_infant:
      data_type: boolean
      description: Whether the deceased was themselves a foetus or infant.
      name: was_fetal_or_infant
    was_outside_health_facility:
      data_type: boolean
      description: Whether the death occurred outside of the facility.
      name: was_outside_health_facility
    was_pregnant:
      data_type: character varying(255)
      description: Whether the deceased was pregnant.
      name: was_pregnant
    was_stillborn:
      data_type: character varying(255)
      description: Whether the deceased was themselves stillborn.
      name: was_stillborn
    was_within_day_of_birth:
      data_type: boolean
      description: If the deceased was a foetus, stillborn, or infant, whether their
        passing was on the day of their birth.
      name: was_within_day_of_birth
  config:
    tags:
    - base
    - clinical
  description: Information about a patient's death.
  name: patient_death_data
  tags:
  - base
  - clinical
- columns:
    definition_id:
      data_type: character varying(255)
      description: The [field definition](#!/source/source.tamanu.tamanu.patient_field_definitions).
      name: definition_id
    patient_id:
      data_type: character varying(255)
      description: Reference to the [patient](#!/source/source.tamanu.tamanu.patients).
      name: patient_id
    value:
      data_type: text
      description: Value.
      name: value
  config:
    tags:
    - base
    - patient
  description: "Values recorded in custom patient fields.\r\n\r\nThe `id` column is\
    \ generated to enforce one value row per field definition per patient."
  name: patient_field_values
  tags:
  - base
  - patient
- columns:
    datetime:
      data_type: timestamp
      description: Local date for the record in patient_program_registration_conditions.
      name: datetime
    deleted_by_id:
      data_type: character varying(255)
      description: Reference to the [Clinician](#!/source/source.tamanu.tamanu.users)
        that removed the condition.
      name: deleted_by_id
    deleted_datetime:
      data_type: timestamp
      description: Date field which is a timestamp of record being deleted in patient_program_registration_conditions.
      name: deleted_datetime
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in patient_program_registration_conditions.
      name: id
    patient_program_registration_id:
      data_type: uuid
      description: "Reference to the [Patient Program Registry](#!/source/source.tamanu.tamanu.patient_program_registrations)\r\
        \nof the condition."
      name: patient_program_registration_id
    program_registry_condition_category_id:
      data_type: character varying(255)
      description: "Reference to the [Program Registry Condition Category](#!/source/source.tamanu.tamanu.program_registry_condition_categories)\r\
        \nof the condition."
      name: program_registry_condition_category_id
    program_registry_condition_id:
      data_type: character varying(255)
      description: Reference to the [Program Registry Condition](#!/source/source.tamanu.tamanu.program_registry_conditions).
      name: program_registry_condition_id
    reason_for_change:
      data_type: character varying(255)
      description: Optional field for recording the reason for changing the condition.
      name: reason_for_change
    recorded_by_id:
      data_type: character varying(255)
      description: Reference to the [Clinician](#!/source/source.tamanu.tamanu.users)
        recording that condition.
      name: recorded_by_id
  config:
    tags:
    - base
    - clinical
  description: Table of conditions related to patients in a program registration.
  name: patient_program_registration_conditions
  tags:
  - base
  - clinical
- columns:
    changelog_id:
      data_type: uuid
      description: The ID of the change log row. UUID
      name: changelog_id
    datetime:
      data_type: timestamp
      description: Local date for the record in patient_program_registration_conditions
        history.
      name: datetime
    deleted_by_id:
      data_type: text
      description: Reference to the [Clinician](#!/source/source.tamanu.tamanu.users)
        that removed the condition. from history.
      name: deleted_by_id
    deleted_datetime:
      data_type: timestamp
      description: Date field which is a timestamp of record being deleted in patient_program_registration_conditions
        history.
      name: deleted_datetime
    id:
      data_type: text
      description: Tamanu internal identifier (generally a UUID) in patient_program_registration_conditions.
      name: id
    logged_at:
      data_type: timestamp
      description: The timestamp this change was logged. in patient program registration
        condition record.
      name: logged_at
    patient_program_registration_id:
      data_type: text
      description: "Reference to the [Patient Program Registry](#!/source/source.tamanu.tamanu.patient_program_registrations)\r\
        \nof the condition. from history."
      name: patient_program_registration_id
    program_registry_condition_category_id:
      data_type: text
      description: "Reference to the [Program Registry Condition Category](#!/source/source.tamanu.tamanu.program_registry_condition_categories)\r\
        \nof the condition. from history."
      name: program_registry_condition_category_id
    program_registry_condition_id:
      data_type: text
      description: Reference to the [Program Registry Condition](#!/source/source.tamanu.tamanu.program_registry_conditions).
        from history.
      name: program_registry_condition_id
    reason_for_change:
      data_type: text
      description: Optional field for recording the reason for changing the condition.
        from history.
      name: reason_for_change
    recorded_by_id:
      data_type: text
      description: Reference to the [Clinician](#!/source/source.tamanu.tamanu.users)
        recording that condition. from history.
      name: recorded_by_id
    updated_by_user_id:
      data_type: text
      description: "The value of the `updated_by_user_id` field of the change data.\r\
        \n\r\nThis is extracted from the data to make it easier to query on. in patient\
        \ program registration condition record."
      name: updated_by_user_id
  config:
    tags:
    - base
    - clinical
    - log
  description: Change logs of Table of conditions related to patients in a program
    registration.
  name: patient_program_registration_conditions_change_logs
  tags:
  - base
  - clinical
  - log
- columns:
    clinical_status_id:
      data_type: character varying(255)
      description: "Reference to the [Program Registry Clinical Status](#!/source/source.tamanu.tamanu.program_registry_clinical_statuses)\r\
        \nof the registration."
      name: clinical_status_id
    datetime:
      data_type: timestamp
      description: Local date for the record in patient_program_registrations.
      name: datetime
    deactivated_by_id:
      data_type: character varying(255)
      description: The clinician that removed the patient from the program registry.
      name: deactivated_by_id
    deactivated_datetime:
      data_type: timestamp
      description: The date that the patient from the program registry.
      name: deactivated_datetime
    facility_id:
      data_type: character varying(255)
      description: "Reference to the [Facility](#!/source/source.tamanu.tamanu.facilities)\
        \ this program\r\nregistration is from."
      name: facility_id
    id:
      data_type: uuid
      description: Tamanu internal identifier (generally a UUID) in patient_program_registrations.
      name: id
    patient_id:
      data_type: character varying(255)
      description: Reference to the [Patient](#!/source/source.tamanu.tamanu.patients).
      name: patient_id
    program_registry_id:
      data_type: character varying(255)
      description: "Reference to the [Program Registry](#!/source/source.tamanu.tamanu.program_registries)\r\
        \nof the registration."
      name: program_registry_id
    registered_by_id:
      data_type: character varying(255)
      description: "Reference to the [Clinician](#!/source/source.tamanu.tamanu.users)\
        \ recording that\r\nregistration."
      name: registered_by_id
    registering_facility_id:
      data_type: character varying(255)
      description: "Reference to the [Facility](#!/source/source.tamanu.tamanu.facilities)\
        \ where the\r\nregistration was registered in."
      name: registering_facility_id
    registration_status:
      data_type: text
      description: "The current status of the registration.\r\n\r\nOne of:\r\n- `active`\r\
        \n- `inactive`\r\n- `recordedInError`"
      name: registration_status
    village_id:
      data_type: character varying(255)
      description: "Reference to the [Reference Data](#!/source/source.tamanu.tamanu.reference_data)\r\
        \n(`type=village`) this program registration is from."
      name: village_id
  config:
    tags:
    - base
    - clinical
  description: "Table with information about the program registrations of a patient.\
    \ This is helpful\r\nto enroll a specific patient within a program that will be\
    \ followed for an extended\r\nperiod of time.\r\n\r\n**This table is append-only.**\r\
    \nA new record is created every time there is a change to the status of a registration.\
    \ \r\n\r\nAt the moment, this implies that when merging two patients, both with\
    \ a registration to the same\r\nregistry, the merged patient ends up with two\
    \ registrations."
  name: patient_program_registrations
  tags:
  - base
  - clinical
- columns:
    changelog_id:
      data_type: uuid
      description: The ID of the change log row. UUID
      name: changelog_id
    clinical_status_id:
      data_type: text
      description: "Reference to the [Program Registry Clinical Status](#!/source/source.tamanu.tamanu.program_registry_clinical_statuses)\r\
        \nof the registration. from history."
      name: clinical_status_id
    datetime:
      data_type: timestamp
      description: Local date for the record in patient_program_registrations history.
      name: datetime
    deactivated_by_id:
      data_type: text
      description: The clinician that removed the patient from the program registry.
        from history.
      name: deactivated_by_id
    deactivated_datetime:
      data_type: timestamp
      description: The date that the patient from the program registry. from history.
      name: deactivated_datetime
    facility_id:
      data_type: text
      description: "Reference to the [Facility](#!/source/source.tamanu.tamanu.facilities)\
        \ this program\r\nregistration is from. from history."
      name: facility_id
    id:
      data_type: text
      description: Tamanu internal identifier (generally a UUID) in patient_program_registrations.
      name: id
    logged_at:
      data_type: timestamp
      description: The timestamp this change was logged. in patient_program registrations
        history.
      name: logged_at
    patient_id:
      data_type: text
      description: Reference to the [Patient](#!/source/source.tamanu.tamanu.patients).
        from history.
      name: patient_id
    program_registry_id:
      data_type: text
      description: "Reference to the [Program Registry](#!/source/source.tamanu.tamanu.program_registries)\r\
        \nof the registration. from history."
      name: program_registry_id
    registered_by_id:
      data_type: text
      description: "Reference to the [Clinician](#!/source/source.tamanu.tamanu.users)\
        \ recording that\r\nregistration. from history."
      name: registered_by_id
    registering_facility_id:
      data_type: text
      description: "Reference to the [Facility](#!/source/source.tamanu.tamanu.facilities)\
        \ where the\r\nregistration was registered in. from history."
      name: registering_facility_id
    registration_status:
      data_type: text
      description: "The current status of the registration.\r\n\r\nOne of:\r\n- `active`\r\
        \n- `inactive`\r\n- `recordedInError` from history."
      name: registration_status
    updated_by_user_id:
      data_type: text
      description: "The value of the `updated_by_user_id` field of the change data.\r\
        \n\r\nThis is extracted from the data to make it easier to query on. in patient_program\
        \ registrations history."
      name: updated_by_user_id
    village_id:
      data_type: text
      description: "Reference to the [Reference Data](#!/source/source.tamanu.tamanu.reference_data)\r\
        \n(`type=village`) this program registration is from. from history."
      name: village_id
  config:
    tags:
    - base
    - clinical
    - log
  description: "Change logs of Table with information about the program registrations\
    \ of a patient. This is helpful\r\nto enroll a specific patient within a program\
    \ that will be followed for an extended\r\nperiod of time.\r\n\r\n**This table\
    \ is append-only.**\r\nA new record is created every time there is a change to\
    \ the status of a registration. \r\n\r\nAt the moment, this implies that when\
    \ merging two patients, both with a registration to the same\r\nregistry, the\
    \ merged patient ends up with two registrations."
  name: patient_program_registrations_change_logs
  tags:
  - base
  - clinical
  - log
- columns:
    days_till_due:
      data_type: integer
      description: "Number of days until the scheduled vaccine is due. Negative numbers\
        \ indicates the number of days in the past the vaccine\r\nwas due."
      name: days_till_due
    due_date:
      data_type: date
      description: Due date of the scheduled vaccine.
      name: due_date
    patient_id:
      data_type: character varying
      description: The [patient](#!/source/source.tamanu.tamanu.patients).
      name: patient_id
    status:
      data_type: text
      description: Status of the upcoming vaccination listed ['DUE', 'OVERDUE', 'MISSED',
        'SCHEDULED', 'UPCOMING']
      name: status
    vaccine_category:
      data_type: character varying
      description: Vaccine category [Routine, Catch-up, Campaign, Other]
      name: vaccine_category
    vaccine_id:
      data_type: character varying
      description: Reference to the vaccine ([Reference Data](#!/source/source.tamanu.tamanu.reference_data),
        `type = drug`).
      name: vaccine_id
    vaccine_schedules_id:
      data_type: character varying
      description: Reference to the [scheduled vaccine](#!/source/source.tamanu.tamanu.scheduled_vaccines).
      name: vaccine_schedules_id
  config:
    tags:
    - base
    - clinical
  description: "A **view** which lists patients and next vaccine due for a given vaccine\
    \ type.\r\n\r\nThe first dose of a vaccine type is based on weeks from birth due\
    \ whilst subsequent doses are based on weeks from last \r\nvaccination due.\r\n\
    \r\nAge limits in years and thresholds in days for scheduled status are configurable\
    \ with the following defaults:\r\n\r\n- Age = 15\r\n- Status: Scheduled = 28\r\
    \n- Status: Upcoming = 7\r\n- Status: Due = -7\r\n- Status: Overdue = -55\r\n\
    - Status: Missed = -Infinity"
  name: patient_vaccinations_upcoming
  tags:
  - base
  - clinical
- columns:
    date_of_birth:
      data_type: date
      description: Date of birth of patient
      name: date_of_birth
      tags:
      - quasi_identifier
    date_of_death:
      data_type: timestamp
      description: Date and time of death of patient
      name: date_of_death
      tags:
      - quasi_identifier
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in patients.
      name: id
    registration_date:
      data_type: date
      description: Timestamp of when record was created in patients which is used
        as a best estimate of registration date.
      name: registration_date
    sex:
      data_type: character varying(255)
      description: "Sex of patient.\r\n\r\nOne of:\r\n- `male`\r\n- `female`\r\n-\
        \ `other`"
      name: sex
      tags:
      - quasi_identifier
    village_id:
      data_type: character varying(255)
      description: Tamanu village identifier defined in the reference data
      name: village_id
      tags:
      - quasi_identifier
  config:
    tags:
    - base
    - patient
  description: "The central record for a patient.\r\n\r\n⚠️ The full contents of this\
    \ table are synced to all devices, and in larger deployments this may be\r\nhundreds\
    \ of thousands of records (or even millions), so it is critical to keep the row\
    \ size small.\r\n\r\nOnly contains basic patient data (name, dob, etc.): the bare\
    \ minimum to be able to find that patient\r\nin the system from the search page.\r\
    \n\r\nThe remainder of the patient data is stored in the `patient_additional_data`\
    \ table, which is only\r\nsynced to a device once it has marked that patient for\
    \ sync (in the `patient_facility` table)."
  name: patients
  tags:
  - base
  - patient
- columns:
    back_end_context:
      data_type: jsonb
      description: A JSON object containing back end information about the record
        access
      name: back_end_context
    device_id:
      data_type: text
      description: The id for the device that the user was accessing the record on
      name: device_id
    facility_id:
      data_type: text
      description: The facility that the record was accessed on
      name: facility_id
    front_end_context:
      data_type: jsonb
      description: A JSON object containing front end information about the record
        access
      name: front_end_context
    id:
      data_type: uuid
      description: Tamanu internal identifier (generally a UUID) in patients_access_logs.
      name: id
    is_mobile:
      data_type: boolean
      description: Whether or not the user accessed the record from mobile
      name: is_mobile
    logged_at:
      data_type: timestamp with time zone
      description: The time string of when the record was accessed
      name: logged_at
    patient_id:
      data_type: text
      description: Tamanu internal identifier (generally a UUID) in patients.
      name: patient_id
    session_id:
      data_type: text
      description: The user session that the record was accessed on
      name: session_id
    user_id:
      data_type: text
      description: Tamanu internal identifier (generally a UUID) in users.
      name: user_id
    version:
      data_type: text
      description: The version of tamanu the record was created on
      name: version
  config:
    tags:
    - base
    - administration
    - log
  description: Access logs of patient data
  name: patients_access_logs
  tags:
  - base
  - administration
  - log
- columns:
    changelog_id:
      data_type: uuid
      description: The ID of the change log row. UUID
      name: changelog_id
    date_of_birth:
      data_type: date
      description: Date of birth of patient from history.
      name: date_of_birth
      tags:
      - quasi_identifier
    date_of_death:
      data_type: timestamp
      description: Date and time of death of patient from history.
      name: date_of_death
      tags:
      - quasi_identifier
    id:
      data_type: text
      description: Tamanu internal identifier (generally a UUID) in patients.
      name: id
    logged_at:
      data_type: timestamp
      description: The timestamp this change was logged. in patients history.
      name: logged_at
    registration_date:
      data_type: date
      description: Timestamp of when record was created in patients history which
        is used as a best estimate of registration date.
      name: registration_date
    sex:
      data_type: text
      description: "Sex of patient.\r\n\r\nOne of:\r\n- `male`\r\n- `female`\r\n-\
        \ `other` from history."
      name: sex
      tags:
      - quasi_identifier
    updated_by_user_id:
      data_type: text
      description: "The value of the `updated_by_user_id` field of the change data.\r\
        \n\r\nThis is extracted from the data to make it easier to query on. in patients\
        \ history."
      name: updated_by_user_id
    village_id:
      data_type: text
      description: Tamanu village identifier defined in the reference data from history.
      name: village_id
      tags:
      - quasi_identifier
  config:
    tags:
    - base
    - patient
    - log
  description: "Change logs for The central record for a patient.\r\n\r\n⚠️ The full\
    \ contents of this table are synced to all devices, and in larger deployments\
    \ this may be\r\nhundreds of thousands of records (or even millions), so it is\
    \ critical to keep the row size small.\r\n\r\nOnly contains basic patient data\
    \ (name, dob, etc.): the bare minimum to be able to find that patient\r\nin the\
    \ system from the search page.\r\n\r\nThe remainder of the patient data is stored\
    \ in the `patient_additional_data` table, which is only\r\nsynced to a device\
    \ once it has marked that patient for sync (in the `patient_facility` table)."
  name: patients_change_logs
  tags:
  - base
  - patient
  - log
- columns:
    date_of_birth:
      data_type: date
      description: Date of birth of patient
      name: date_of_birth
      tags:
      - quasi_identifier
    date_of_death:
      data_type: timestamp
      description: Date and time of death of patient
      name: date_of_death
      tags:
      - quasi_identifier
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in patients.
      name: id
    registration_date:
      data_type: date
      description: Timestamp of when record was created in patients which is used
        as a best estimate of registration date.
      name: registration_date
    sex:
      data_type: character varying(255)
      description: "Sex of patient.\r\n\r\nOne of:\r\n- `male`\r\n- `female`\r\n-\
        \ `other`"
      name: sex
      tags:
      - quasi_identifier
    village_id:
      data_type: character varying(255)
      description: Tamanu village identifier defined in the reference data
      name: village_id
      tags:
      - quasi_identifier
  config:
    tags:
    - base
    - patient
  description: "Only includes patients that have been merged. The central record for\
    \ a patient.\r\n\r\n⚠️ The full contents of this table are synced to all devices,\
    \ and in larger deployments this may be\r\nhundreds of thousands of records (or\
    \ even millions), so it is critical to keep the row size small.\r\n\r\nOnly contains\
    \ basic patient data (name, dob, etc.): the bare minimum to be able to find that\
    \ patient\r\nin the system from the search page.\r\n\r\nThe remainder of the patient\
    \ data is stored in the `patient_additional_data` table, which is only\r\nsynced\
    \ to a device once it has marked that patient for sync (in the `patient_facility`\
    \ table)."
  name: patients_merged
  tags:
  - base
  - patient
- columns:
    datetime:
      data_type: timestamp
      description: Local date and time for the record in prescriptions.
      name: datetime
    discontinued_by_id:
      data_type: character varying(255)
      description: If the prescription was discontinued, who did it.
      name: discontinued_by_id
    discontinued_datetime:
      data_type: timestamp
      description: If the prescription was discontinued, when that happened.
      name: discontinued_datetime
    discontinuing_reason:
      data_type: character varying(255)
      description: If the prescription was discontinued, why that happened.
      name: discontinuing_reason
    dose_amount:
      data_type: numeric
      description: Numeric field to record dose amount
      name: dose_amount
    duration_unit:
      data_type: character varying(255)
      description: The duration unit of the prescription
      name: duration_unit
    duration_value:
      data_type: numeric
      description: The duration value of the prescription
      name: duration_value
    end_datetime:
      data_type: timestamp
      description: When the prescription ends.
      name: end_datetime
    frequency:
      data_type: character varying(255)
      description: The frequency of the prescription
      name: frequency
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in prescriptions.
      name: id
    ideal_times:
      data_type: array
      description: Ideal times which are specified by prescriber
      name: ideal_times
    indication:
      data_type: character varying(255)
      description: The [indication of use](https://en.wikipedia.org/wiki/Indication_(medicine))
        for the medicine.
      name: indication
    is_discontinued:
      data_type: boolean
      description: Whether the prescription was discontinued.
      name: is_discontinued
    is_ongoing:
      data_type: boolean
      description: A flag to determine whether or not the current prescription is
        ongoing
      name: is_ongoing
    is_phone_order:
      data_type: boolean
      description: A flag to determine whether or not the current prescription is
        phone order
      name: is_phone_order
    is_prn:
      data_type: boolean
      description: A flag to determine whether or not the current prescription is
        prn
      name: is_prn
    is_variable_dose:
      data_type: boolean
      description: A flag to determine whether or not the current prescription is
        variable does
      name: is_variable_dose
    medication_id:
      data_type: character varying(255)
      description: The medication ([Reference Data](#!/source/source.tamanu.tamanu.reference_data),
        `type = drug`).
      name: medication_id
    prescriber_id:
      data_type: character varying(255)
      description: '[Who](#!/source/source.tamanu.tamanu.users) prescribed the medication.'
      name: prescriber_id
    quantity:
      data_type: integer
      description: Quantity of medicine to dispense.
      name: quantity
    repeats:
      data_type: integer
      description: How many times this prescription can be repeatedly dispensed without
        a new prescription.
      name: repeats
    route:
      data_type: character varying(255)
      description: Administration route for the medication.
      name: route
    start_datetime:
      data_type: timestamp
      description: The start date of the prescription
      name: start_datetime
    units:
      data_type: character varying(255)
      description: The units of the prescription
      name: units
  config:
    tags:
    - base
    - clinical
  description: Records prescriptions for medications.
  name: prescriptions
  tags:
  - base
  - clinical
- columns:
    anaesthetic_id:
      data_type: character varying(255)
      description: Reference to the anaesthetic ([Reference Data](#!/source/source.tamanu.tamanu.reference_data),
        `type = drug`).
      name: anaesthetic_id
    anaesthetist_id:
      data_type: character varying(255)
      description: Reference to the [anaesthetist](#!/source/source.tamanu.tamanu.users).
      name: anaesthetist_id
    assistant_id:
      data_type: character varying(255)
      description: Reference to the [assistant](#!/source/source.tamanu.tamanu.users).
      name: assistant_id
    clinician_id:
      data_type: character varying(255)
      description: Reference to the [physician](#!/source/source.tamanu.tamanu.users).
      name: clinician_id
    completed_note:
      data_type: text
      description: Free-form notes at completion of the procedure.
      name: completed_note
    date:
      data_type: date
      description: Local date for the record in procedures.
      name: date
    encounter_id:
      data_type: character varying(255)
      description: The [encounter](#!/source/source.tamanu.tamanu.encounters) this
        procedure is a part of.
      name: encounter_id
    end_time:
      data_type: time
      description: When the procedure ended, if it's completed.
      name: end_time
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in procedures.
      name: id
    is_completed:
      data_type: boolean
      description: Whether the procedure has completed.
      name: is_completed
    location_id:
      data_type: character varying(255)
      description: Reference to the [location](#!/source/source.tamanu.tamanu.locations)
        the procedure happens in.
      name: location_id
    note:
      data_type: text
      description: Free-form description of the procedure.
      name: note
    procedure_type_id:
      data_type: character varying(255)
      description: Reference to the procedure type ([Reference Data](#!/source/source.tamanu.tamanu.reference_data),
        `type = procedureType`).
      name: procedure_type_id
    start_time:
      data_type: time
      description: When the procedure started.
      name: start_time
  config:
    tags:
    - base
    - clinical
  description: Record of each procedure in progress or completed.
  name: procedures
  tags:
  - base
  - clinical
- columns:
    code:
      data_type: character varying(255)
      description: "Machine-friendly short name for the question.\r\n\r\nThis is also\
        \ used to refer to questions within criteria and such."
      name: code
    default_options:
      data_type: text
      description: Default options if this is a dropdown.
      name: default_options
    default_text:
      data_type: character varying(255)
      description: Default value.
      name: default_text
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in program_data_elements.
      name: id
    indicator:
      data_type: character varying(255)
      description: "Another name for the data element.\r\n\r\nIt's named `indicator`\
        \ from mimicry of Tupaia."
      name: indicator
    name:
      data_type: character varying(255)
      description: Human-friendly name
      name: name
    type:
      data_type: character varying(31)
      description: "Type of the field.\r\n\r\nTypes are here: <https://github.com/beyondessential/tamanu/blob/main/packages/constants/src/surveys.ts>"
      name: type
    visualisation_config:
      data_type: text
      description: JSON visualisation configuration.
      name: visualisation_config
  config:
    tags:
    - base
    - reference
  description: "Describes how a survey question gets stored.\r\n\r\nSee [survey screen\
    \ components](#!/source/source.tamanu.tamanu.survey_screen_components), which\r\
    \ndescribes how the question is displayed."
  name: program_data_elements
  tags:
  - base
  - reference
- columns:
    code:
      data_type: text
      description: Machine-friendly identifier.
      name: code
    currently_at_type:
      data_type: text
      description: "Defines what kind of location the registry can be filtered with.\r\
        \n\r\nOne of:\r\n- `village`\r\n- `facility`"
      name: currently_at_type
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in program_registries.
      name: id
    name:
      data_type: text
      description: Human-friendly name.
      name: name
    program_id:
      data_type: character varying(255)
      description: Reference to a [program](#!/source/source.tamanu.tamanu.programs).
      name: program_id
    visibility_status:
      data_type: text
      description: "The visibility status of the record.\r\n\r\n- `current` indicates\
        \ the record is currently in use and should be visible and accessible to users\r\
        \n  on the User Interface.\r\n- `historical` indicates that the record is\
        \ no longer in use and should not be visible nor\r\n  accessible to users.\
        \ However, the record may still be present in Reporting.\r\n- `merged` indicates\
        \ that the record has been merged, is no longer in use and should not be visible\r\
        \n  nor accessible to users.\r\n\r\nThe default value is `current`. in program_registries."
      name: visibility_status
  config:
    tags:
    - base
    - reference
  description: "Table of program registries.\r\n\r\nThis provides functionality to\
    \ track a patient population defined by a particular disease or\r\ncondition,\
    \ and follow this population over time.\r\n\r\nThis table defines the different\
    \ registries available to track users with."
  name: program_registries
  tags:
  - base
  - reference
- columns:
    code:
      data_type: text
      description: Code (identifier) for the clinical status.
      name: code
    color:
      data_type: text
      description: "A color for the clinical status.\r\n\r\nOne of:\r\n- `purple`\r\
        \n- `pink`\r\n- `orange`\r\n- `yellow`\r\n- `blue`\r\n- `green`\r\n- `grey`\r\
        \n- `red`\r\n- `brown`\r\n- `teal`"
      name: color
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in program_registry_clinical_statuses.
      name: id
    name:
      data_type: text
      description: The name of the clinical status.
      name: name
    program_registry_id:
      data_type: character varying(255)
      description: "Reference to the [Program Registry](#!/source/source.tamanu.tamanu.program_registries)\r\
        \nthe status is a part of."
      name: program_registry_id
    visibility_status:
      data_type: text
      description: "The visibility status of the record.\r\n\r\n- `current` indicates\
        \ the record is currently in use and should be visible and accessible to users\r\
        \n  on the User Interface.\r\n- `historical` indicates that the record is\
        \ no longer in use and should not be visible nor\r\n  accessible to users.\
        \ However, the record may still be present in Reporting.\r\n- `merged` indicates\
        \ that the record has been merged, is no longer in use and should not be visible\r\
        \n  nor accessible to users.\r\n\r\nThe default value is `current`. in program_registry_clinical_statuses."
      name: visibility_status
  config:
    tags:
    - base
    - reference
  description: Table of clinical statuses used in program registries.
  name: program_registry_clinical_statuses
  tags:
  - base
  - reference
- columns:
    code:
      data_type: text
      description: Code (identifier) for the condition.
      name: code
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in program_registry_conditions.
      name: id
    name:
      data_type: text
      description: The name of the condition.
      name: name
    program_registry_id:
      data_type: character varying(255)
      description: "Reference to the [Program Registry](#!/source/source.tamanu.tamanu.program_registries)\r\
        \nthe condition is a part of."
      name: program_registry_id
    visibility_status:
      data_type: text
      description: "The visibility status of the record.\r\n\r\n- `current` indicates\
        \ the record is currently in use and should be visible and accessible to users\r\
        \n  on the User Interface.\r\n- `historical` indicates that the record is\
        \ no longer in use and should not be visible nor\r\n  accessible to users.\
        \ However, the record may still be present in Reporting.\r\n- `merged` indicates\
        \ that the record has been merged, is no longer in use and should not be visible\r\
        \n  nor accessible to users.\r\n\r\nThe default value is `current`. in program_registry_conditions."
      name: visibility_status
  config:
    tags:
    - base
    - reference
  description: Table of program registry conditions.
  name: program_registry_condition_categories
  tags:
  - base
  - reference
- columns:
    code:
      data_type: text
      description: Code (identifier) for the condition.
      name: code
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in program_registry_conditions.
      name: id
    name:
      data_type: text
      description: The name of the condition.
      name: name
    program_registry_id:
      data_type: character varying(255)
      description: "Reference to the [Program Registry](#!/source/source.tamanu.tamanu.program_registries)\r\
        \nthe condition is a part of."
      name: program_registry_id
    visibility_status:
      data_type: text
      description: "The visibility status of the record.\r\n\r\n- `current` indicates\
        \ the record is currently in use and should be visible and accessible to users\r\
        \n  on the User Interface.\r\n- `historical` indicates that the record is\
        \ no longer in use and should not be visible nor\r\n  accessible to users.\
        \ However, the record may still be present in Reporting.\r\n- `merged` indicates\
        \ that the record has been merged, is no longer in use and should not be visible\r\
        \n  nor accessible to users.\r\n\r\nThe default value is `current`. in program_registry_conditions."
      name: visibility_status
  config:
    tags:
    - base
    - reference
  description: Table of program registry conditions.
  name: program_registry_conditions
  tags:
  - base
  - reference
- columns:
    code:
      data_type: character varying(255)
      description: Machine-friendly code.
      name: code
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in programs.
      name: id
    name:
      data_type: character varying(255)
      description: Human-friendly name.
      name: name
  config:
    tags:
    - base
    - reference
  description: Groups of [surveys](#!/source/source.tamanu.tamanu.surveys) or [program
    registries](#!/source/source.tamanu.tamanu.program_registries).
  name: programs
  tags:
  - base
  - reference
- columns:
    code:
      data_type: character varying(255)
      description: Code of the data item (short value, alphanumerics and hyphens).
      name: code
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in reference_data.
      name: id
    name:
      data_type: text
      description: Actual data
      name: name
    type:
      data_type: character varying(255)
      description: "Class of the data (referred to in code).\r\n\r\nWhenever this\
        \ table is referred to in a relationship, it's to a specific `type` here.\
        \ For example a\r\ntable might have a `diagnosis_id`, which is a reference\
        \ to this table, for specifically only the\r\nrows with `type = diagnosis`."
      name: type
    visibility_status:
      data_type: text
      description: "The visibility status of the record.\r\n\r\n- `current` indicates\
        \ the record is currently in use and should be visible and accessible to users\r\
        \n  on the User Interface.\r\n- `historical` indicates that the record is\
        \ no longer in use and should not be visible nor\r\n  accessible to users.\
        \ However, the record may still be present in Reporting.\r\n- `merged` indicates\
        \ that the record has been merged, is no longer in use and should not be visible\r\
        \n  nor accessible to users.\r\n\r\nThe default value is `current`. in reference_data."
      name: visibility_status
  config:
    tags:
    - base
    - reference
  description: "User imported reference data for the environment grouped by type.\r\
    \n\r\n- Catch-all for simple reference data types - there are a LOT of kinds of\
    \ reference data that exist as just an ID, a \r\nstring label, and occasionally\
    \ a code; these are all grouped into this table to avoid overcomplicating the\
    \ schema.\r\n- Occasionally a type of simple reference data will gain some complexity,\
    \ at which point it will be refactored/migrated \r\nout to use its own table.\r\
    \n- Simple reference data types include a code, type, name and visibility status.\r\
    \n- Example types include `diagnosis`, `procedures`"
  name: reference_data
  tags:
  - base
  - reference
- columns:
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in referrals.
      name: id
    initiating_encounter_id:
      data_type: character varying(255)
      description: Reference to the [initiating encounter](#!/source/source.tamanu.tamanu.encounters).
      name: initiating_encounter_id
    referred_facility:
      data_type: character varying(255)
      description: Unused.
      name: referred_facility
    status:
      data_type: character varying(255)
      description: "Status of the referral.\r\n\r\nOne of:\r\n- `pending`\r\n- `cancelled`\r\
        \n- `completed`"
      name: status
    survey_response_id:
      data_type: character varying(255)
      description: Reference to the [survey response](#!/source/source.tamanu.tamanu.survey_responses)
        with more data.
      name: survey_response_id
  config:
    tags:
    - base
    - clinical
  description: "[Referrals](https://en.wikipedia.org/wiki/Referral_(medicine)).\r\n\
    \r\nReferrals use a confusing mix of data in the `referrals` table and\r\n[`survey_response_answers`](#!/source/source.tamanu.tamanu.survey_response_answers)\
    \ identified by\r\nthe text of the question they are for. \r\n\r\nSome additional\
    \ data is captured in\r\n[survey response answers](#!/source/source.tamanu.tamanu.survey_response_answers),\
    \ but this is\r\nvariable and not enforced through any validation:\r\n- Where\
    \ the person is being referred to can be captured by a range of questions, sometimes\
    \ with a\r\n  list of hard coded facility name options, or location groups, or\
    \ departments.\r\n- Who the referral is \"completed by\" can be captured by a\
    \ question either the name\r\n  'Referring doctor' or 'Referral completed by'.\r\
    \n- Some referrals are the product of a previous screening survey. In some cases\
    \ (e.g. Samoa) there is\r\n  a SurveyLink question that captures which survey\
    \ led to this referral, in others (e.g. Nauru)\r\n  there is no such question\
    \ so the two survey responses cannot be reliably linked."
  name: referrals
  tags:
  - base
  - clinical
- columns:
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in roles.
      name: id
    name:
      data_type: character varying(255)
      description: Readable name for the role.
      name: name
  config:
    tags:
    - base
    - administration
  description: "These are sets of permissions that are given to users to determine\
    \ what they can do in Tamanu.\r\n\r\nThe actual permissions are associated to\
    \ the role in the\r\n[`permissions`](#!/source/source.tamanu.tamanu.permissions)\
    \ table."
  name: roles
  tags:
  - base
  - administration
- columns:
    body:
      data_type: text
      description: Value of the answer.
      name: body
    data_element_id:
      data_type: character varying(255)
      description: Reference to the [question](#!/source/source.tamanu.tamanu.program_data_elements).
      name: data_element_id
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in survey_response_answers.
      name: id
    name:
      data_type: character varying(255)
      description: Name of the question.
      name: name
    response_id:
      data_type: character varying(255)
      description: The [survey response](#!/source/source.tamanu.tamanu.survey_responses).
      name: response_id
  config:
    tags:
    - base
    - clinical
  description: A single answer as part of a [survey response](#!/source/source.tamanu.tamanu.survey_responses).
  name: survey_response_answers
  tags:
  - base
  - clinical
- columns:
    encounter_id:
      data_type: character varying(255)
      description: Reference to the [encounter](#!/source/source.tamanu.tamanu.encounters)
        this survey response is a part of.
      name: encounter_id
    end_datetime:
      data_type: timestamp
      description: When the survey was completed.
      name: end_datetime
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in survey_responses.
      name: id
    is_notified:
      data_type: boolean
      description: "If the [survey](#!/source/source.tamanu.tamanu.surveys) is `notifiable`,\
        \ whether this response's\r\nnotification has been sent."
      name: is_notified
    result_text:
      data_type: text
      description: The textual value that is the summary of the survey response.
      name: result_text
    start_datetime:
      data_type: timestamp
      description: When the survey was started.
      name: start_datetime
    submitted_by_id:
      data_type: character varying(255)
      description: Reference to the [user](#!/source/source.tamanu.tamanu.users) recording
        this survey response.
      name: submitted_by_id
    survey_id:
      data_type: character varying(255)
      description: The [survey](#!/source/source.tamanu.tamanu.surveys) being responded
        to.
      name: survey_id
  config:
    tags:
    - base
    - clinical
  description: "A response to a survey (as recorded by a practitioner).\r\n\r\nTypically\
    \ surveys are filled on behalf of patients as part of an encounter.\r\n\r\nBecause\
    \ there are multiple distinct kinds of dates at play here:\r\n- `created_at`,\
    \ `updated_at`, `deleted_at` are system data for syncing and cannot be relied\
    \ on for realtime\r\n- `start_time`, `end_time` are real datetimes automatically\
    \ recorded when starting and submitting a survey response\r\n- in survey response\
    \ answers, there could be a data element for targeting the date of when exactly\
    \ the data is recorded in real time."
  name: survey_responses
  tags:
  - base
  - clinical
- columns:
    calculation:
      data_type: character varying(255)
      description: "Math expression to do calculations on the entered value before\
        \ it's saved.\r\n\r\nFor example `questionCode + 3`."
      name: calculation
    component_index:
      data_type: integer
      description: The absolute index (order) of the component in the survey.
      name: component_index
    config:
      data_type: character varying(255)
      description: JSON additional config of the component.
      name: config
    data_element_id:
      data_type: character varying(255)
      description: "Reference to the [data element](#!/source/source.tamanu.tamanu.program_data_elements)\
        \ configuring\r\nhow the data from the question is stored."
      name: data_element_id
    detail:
      data_type: character varying(255)
      description: Longer description or explanatory text of this component.
      name: detail
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in survey_screen_components.
      name: id
    options:
      data_type: character varying(255)
      description: JSON array of strings of options to be selected.
      name: options
    screen_index:
      data_type: integer
      description: "Screen this component should appear on.\r\n\r\nSurveys can have\
        \ multiple \"screens\" or pages, this index sets where this particular question\
        \ sits."
      name: screen_index
    survey_id:
      data_type: character varying(255)
      description: The [survey](#!/source/source.tamanu.tamanu.surveys).
      name: survey_id
    text:
      data_type: character varying(255)
      description: Description or question of this component.
      name: text
    validation_criteria:
      data_type: text
      description: JSON criteria that determines whether the value entered in this
        component is accepted.
      name: validation_criteria
    visibility_criteria:
      data_type: character varying(255)
      description: "JSON criteria that determines when this component is visible.\r\
        \n\r\nA criteria is a list of other components' codes and the value that will\
        \ make this question show up:\r\n\r\n```json\r\n{\r\n  \"otherQuestion\":\
        \ \"Yes\"\r\n}\r\n```\r\n\r\nThere can also be the special criterium `{\"\
        hidden\": true}` which always hides the question, and the\r\nspecial key `\"\
        _conjunction\": \"or\"` which makes it so _any one_ item in the list is sufficient\
        \ to\r\nshow the question, instead of the default where _all_ items must match."
      name: visibility_criteria
    visibility_status:
      data_type: character varying(255)
      description: "The visibility status of the record.\r\n\r\n- `current` indicates\
        \ the record is currently in use and should be visible and accessible to users\r\
        \n  on the User Interface.\r\n- `historical` indicates that the record is\
        \ no longer in use and should not be visible nor\r\n  accessible to users.\
        \ However, the record may still be present in Reporting.\r\n- `merged` indicates\
        \ that the record has been merged, is no longer in use and should not be visible\r\
        \n  nor accessible to users.\r\n\r\nThe default value is `current`. in survey_screen_components."
      name: visibility_status
  config:
    tags:
    - base
    - reference
  description: "Describes how a survey question gets displayed.\r\n\r\nSee [program\
    \ data element](#!/source/source.tamanu.tamanu.program_data_elements), which describes\r\
    \nhow the data from the question is stored."
  name: survey_screen_components
  tags:
  - base
  - reference
- columns:
    code:
      data_type: character varying(255)
      description: Machine-friendly code.
      name: code
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in surveys.
      name: id
    is_notifiable:
      data_type: boolean
      description: "Whether filling this survey sends a notification email.\r\n\r\n\
        These are sent by the `SurveyCompletionNotifierProcessor` scheduled task."
      name: is_notifiable
    is_sensitive:
      data_type: boolean
      description: Whether the data recorded in the survey is sensitive.
      name: is_sensitive
    name:
      data_type: character varying(255)
      description: Human-friendly name.
      name: name
    notify_email_addresses:
      data_type: array
      description: If `notifiable` is true, where to send the notification.
      name: notify_email_addresses
    program_id:
      data_type: character varying(255)
      description: The [program](#!/source/source.tamanu.tamanu.programs) grouping
        this survey.
      name: program_id
    survey_type:
      data_type: character varying(255)
      description: "Type of survey.\r\n\r\nOne of:\r\n- `programs`\r\n- `referral`\r\
        \n- `obsolete`\r\n- `vitals`"
      name: survey_type
    visibility_status:
      data_type: character varying(255)
      description: "The visibility status of the record.\r\n\r\n- `current` indicates\
        \ the record is currently in use and should be visible and accessible to users\r\
        \n  on the User Interface.\r\n- `historical` indicates that the record is\
        \ no longer in use and should not be visible nor\r\n  accessible to users.\
        \ However, the record may still be present in Reporting.\r\n- `merged` indicates\
        \ that the record has been merged, is no longer in use and should not be visible\r\
        \n  nor accessible to users.\r\n\r\nThe default value is `current`. in surveys."
      name: visibility_status
  config:
    tags:
    - base
    - reference
  description: "Surveys, aka custom forms that can be filled by practitioners.\r\n\
    \r\nThese are composed of [screen components](#!/source/source.tamanu.tamanu.survey_screen_components)."
  name: surveys
  tags:
  - base
  - reference
- columns:
    arrival_datetime:
      data_type: timestamp
      description: When the patient arrived.
      name: arrival_datetime
    arrival_mode_id:
      data_type: character varying(255)
      description: Reference to how the patient arrived ([Reference Data](#!/source/source.tamanu.tamanu.reference_data),
        `type = arrivalMode`).
      name: arrival_mode_id
    chief_complaint_id:
      data_type: character varying(255)
      description: Reference to the primary complaint ([Reference Data](#!/source/source.tamanu.tamanu.reference_data),
        `type = triageReason`).
      name: chief_complaint_id
    clinician_id:
      data_type: character varying(255)
      description: Reference to the [practitioner](#!/source/source.tamanu.tamanu.users)
        assigned to this patient.
      name: clinician_id
    closed_datetime:
      data_type: timestamp
      description: When the patient was processed.
      name: closed_datetime
    encounter_id:
      data_type: character varying(255)
      description: Reference to the [encounter](#!/source/source.tamanu.tamanu.encounters)
        this triage is for.
      name: encounter_id
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in triages.
      name: id
    score:
      data_type: text
      description: Classification done by the triage practitioner.
      name: score
    secondary_complaint_id:
      data_type: character varying(255)
      description: Reference to the secondary complaint ([Reference Data](#!/source/source.tamanu.tamanu.reference_data),
        `type = triageReason`).
      name: secondary_complaint_id
    triage_datetime:
      data_type: timestamp
      description: When the patient was triaged.
      name: triage_datetime
  config:
    tags:
    - base
    - clinical
  description: Triage data of patients waiting in an emergency department.
  name: triages
  tags:
  - base
  - clinical
- columns:
    display_id:
      data_type: character varying(255)
      description: "Display identifier for the user.\r\n\r\nThis may be the employee\
        \ code or badge number."
      name: display_id
    display_name:
      data_type: character varying(255)
      description: The human readable display name for the user.
      name: display_name
    email:
      data_type: character varying(255)
      description: Email address for user. This is used to login and receive emails.
      name: email
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in users.
      name: id
    phone_number:
      data_type: character varying(255)
      description: "Phone number for the user.\r\n\r\nThis is not currently available\
        \ anywhere visible."
      name: phone_number
    role:
      data_type: character varying(255)
      description: "The role of the user, which sets their permission level.\r\n\r\
        \nThe special values `admin` and `system` indicate a superadmin and a system\
        \ user respectively."
      name: role
    visibility_status:
      data_type: character varying(255)
      description: "The visibility status of the record.\r\n\r\n- `current` indicates\
        \ the record is currently in use and should be visible and accessible to users\r\
        \n  on the User Interface.\r\n- `historical` indicates that the record is\
        \ no longer in use and should not be visible nor\r\n  accessible to users.\
        \ However, the record may still be present in Reporting.\r\n- `merged` indicates\
        \ that the record has been merged, is no longer in use and should not be visible\r\
        \n  nor accessible to users.\r\n\r\nThe default value is `current`. in users."
      name: visibility_status
  config:
    tags:
    - base
    - administration
  description: "Records of each user that can login to Tamanu.\r\n\r\nThis includes\
    \ machine users.\r\n\r\nThere is one special user account with an all-zero `id`,\
    \ which is the global \"system\" user. This is\r\nused as a pseudo identity where\
    \ the Tamanu system itself takes an action that normally is performed\r\nby a\
    \ human or API user."
  name: users
  tags:
  - base
  - administration
- columns:
    batch:
      data_type: character varying(255)
      description: Batch identifier of vaccine administrations recorded
      name: batch
    circumstance_ids:
      data_type: array
      description: "Array of references to [Reference Data](#!/source/source.tamanu.tamanu.reference_data)\r\
        \n(`type=vaccineCircumstance`)."
      name: circumstance_ids
    consent_given_by:
      data_type: text
      description: "Free text field recording who gave consent for the vaccination.\r\
        \nThis is usually the patient themselves, but may differ for children or dependent\r\
        \npersons or other cases."
      name: consent_given_by
    datetime:
      data_type: timestamp
      description: Local date for the record in vaccine_administrations.
      name: datetime
    department_id:
      data_type: character varying(255)
      description: "Reference to the [Department](#!/source/source.tamanu.tamanu.departments)\
        \ at which the vaccine was\r\ngiven."
      name: department_id
    disease:
      data_type: text
      description: Disease the vaccine addresses of the vaccine administration recorded
      name: disease
    encounter_id:
      data_type: character varying(255)
      description: Reference to the [Encounter](#!/source/source.tamanu.tamanu.encounters)
        this vaccine was given in.
      name: encounter_id
    given_by_id:
      data_type: text
      description: "Free text field for the name of the health practitioner who administered\
        \ the\r\nvaccine. This is defaulted to the `display_name` of the logged-in\
        \ User, but can\r\nbe changed. It is not a requirement that the administerer\
        \ is a Tamanu User."
      name: given_by_id
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in vaccine_administrations.
      name: id
    injection_site:
      data_type: character varying(255)
      description: Injection site of the vaccine administrations recorded
      name: injection_site
    is_consented:
      data_type: boolean
      description: Consent of the vaccine administrations recorded
      name: is_consented
    is_given_elsewhere:
      data_type: boolean
      description: Checks if the vaccine was given elsewhere
      name: is_given_elsewhere
    location_id:
      data_type: character varying(255)
      description: "Reference to the [Location](#!/source/source.tamanu.tamanu.locations)\
        \ at which the vaccine was\r\ngiven."
      name: location_id
    not_given_reason_id:
      data_type: character varying(255)
      description: "Reference to a [Reference Data](#!/source/source.tamanu.tamanu.reference_data)\r\
        \n(`type=vaccineNotGivenReason`).\r\n\r\nThese are presented as a dropdown\
        \ for ease of recording and reporting, alongside the free-text field."
      name: not_given_reason_id
    reason:
      data_type: character varying(255)
      description: Reason for vaccine administrations `NOT_GIVEN` status. This is
        a free text field
      name: reason
    recorded_by_id:
      data_type: character varying(255)
      description: "Reference to the [User](#!/source/source.tamanu.tamanu.users)\
        \ who recorded this vaccination.\r\nThis may differ from the User or person\
        \ who administered the vaccine."
      name: recorded_by_id
    scheduled_vaccine_id:
      data_type: character varying(255)
      description: "Reference to the [Scheduled Vaccine](#!/source/source.tamanu.tamanu.scheduled_vaccines)\
        \ that was\r\nadministered."
      name: scheduled_vaccine_id
    status:
      data_type: character varying(255)
      description: "Status of vaccine administrations recorded. \r\n\r\nThe `RECORDED_IN_ERROR`\
        \ status is assigned to vaccines initially recorded\r\nas `GIVEN` that are\
        \ then deleted.\r\n\r\nThe `HISTORICAL` status is assigned to vaccines initially\
        \ recorded as \r\n`NOT_GIVEN` that are then recorded as `GIVEN`. This `HISTORICAL`\
        \ status \r\nkeeps a record that the vaccine was marked as `NOT_GIVEN` but\
        \ hides this\r\nrecord from the frontend to avoid confusion or conflict with\
        \ the `GIVEN`\r\nrecord."
      name: status
    vaccine_brand:
      data_type: text
      description: Vaccine brand of the vaccine administration recorded
      name: vaccine_brand
    vaccine_name:
      data_type: text
      description: Vaccine name of the vaccine administration recorded
      name: vaccine_name
  config:
    tags:
    - base
    - clinical
  description: "Table of vaccines administered to patients.\r\n\r\nVaccinations are\
    \ recorded via the Vaccinations modal; they are selected\r\nfrom a list of Scheduled\
    \ Vaccines and linked to a Patient via an Encounter."
  name: vaccine_administrations
  tags:
  - base
  - clinical
- columns:
    batch:
      data_type: text
      description: Batch identifier of vaccine administrations recorded from history.
      name: batch
    changelog_id:
      data_type: uuid
      description: The ID of the change log row. UUID
      name: changelog_id
    circumstance_ids:
      data_type: text
      description: "Array of references to [Reference Data](#!/source/source.tamanu.tamanu.reference_data)\r\
        \n(`type=vaccineCircumstance`). from history."
      name: circumstance_ids
    consent_given_by:
      data_type: text
      description: "Free text field recording who gave consent for the vaccination.\r\
        \nThis is usually the patient themselves, but may differ for children or dependent\r\
        \npersons or other cases. from history."
      name: consent_given_by
    created_at:
      data_type: timestamp
      description: Timestamp of when record was created in vaccine_administrations
        from history.
      name: created_at
    datetime:
      data_type: timestamp
      description: Local date for the record in vaccine_administrations from history.
      name: datetime
    department_id:
      data_type: text
      description: "Reference to the [Department](#!/source/source.tamanu.tamanu.departments)\
        \ at which the vaccine was\r\ngiven. from history."
      name: department_id
    disease:
      data_type: text
      description: Disease the vaccine addresses of the vaccine administration recorded
        from history.
      name: disease
    encounter_id:
      data_type: text
      description: Reference to the [Encounter](#!/source/source.tamanu.tamanu.encounters)
        this vaccine was given in. from history.
      name: encounter_id
    given_by:
      data_type: text
      description: "Free text field for the name of the health practitioner who administered\
        \ the\r\nvaccine. This is defaulted to the `display_name` of the logged-in\
        \ User, but can\r\nbe changed. It is not a requirement that the administerer\
        \ is a Tamanu User. from history."
      name: given_by
    id:
      data_type: text
      description: Tamanu internal identifier (generally a UUID) in vaccine_administrations
        from history.
      name: id
    injection_site:
      data_type: text
      description: Injection site of the vaccine administrations recorded from history.
      name: injection_site
    is_consented:
      data_type: boolean
      description: Consent of the vaccine administrations recorded from history.
      name: is_consented
    is_given_elsewhere:
      data_type: boolean
      description: Checks if the vaccine was given elsewhere from history.
      name: is_given_elsewhere
    location_id:
      data_type: text
      description: "Reference to the [Location](#!/source/source.tamanu.tamanu.locations)\
        \ at which the vaccine was\r\ngiven. from history."
      name: location_id
    logged_at:
      data_type: timestamp
      description: The timestamp this change was logged. in vaccine administrations
        history.
      name: logged_at
    not_given_reason_id:
      data_type: text
      description: "Reference to a [Reference Data](#!/source/source.tamanu.tamanu.reference_data)\r\
        \n(`type=vaccineNotGivenReason`).\r\n\r\nThese are presented as a dropdown\
        \ for ease of recording and reporting, alongside the free-text field. from\
        \ history."
      name: not_given_reason_id
    reason:
      data_type: text
      description: Reason for vaccine administrations `NOT_GIVEN` status. This is
        a free text field from history.
      name: reason
    recorded_by_id:
      data_type: text
      description: "Reference to the [User](#!/source/source.tamanu.tamanu.users)\
        \ who recorded this vaccination.\r\nThis may differ from the User or person\
        \ who administered the vaccine. from history."
      name: recorded_by_id
    scheduled_vaccine_id:
      data_type: text
      description: "Reference to the [Scheduled Vaccine](#!/source/source.tamanu.tamanu.scheduled_vaccines)\
        \ that was\r\nadministered. from history."
      name: scheduled_vaccine_id
    status:
      data_type: text
      description: "Status of vaccine administrations recorded. \r\n\r\nThe `RECORDED_IN_ERROR`\
        \ status is assigned to vaccines initially recorded\r\nas `GIVEN` that are\
        \ then deleted.\r\n\r\nThe `HISTORICAL` status is assigned to vaccines initially\
        \ recorded as \r\n`NOT_GIVEN` that are then recorded as `GIVEN`. This `HISTORICAL`\
        \ status \r\nkeeps a record that the vaccine was marked as `NOT_GIVEN` but\
        \ hides this\r\nrecord from the frontend to avoid confusion or conflict with\
        \ the `GIVEN`\r\nrecord. from history."
      name: status
    updated_at:
      data_type: timestamp
      description: Timestamp of when record was last updated in vaccine_administrations
        from history.
      name: updated_at
    updated_by_user_id:
      data_type: text
      description: "The value of the `updated_by_user_id` field of the change data.\r\
        \n\r\nThis is extracted from the data to make it easier to query on. in vaccine\
        \ administrations history."
      name: updated_by_user_id
    vaccine_brand:
      data_type: text
      description: Vaccine brand of the vaccine administration recorded from history.
      name: vaccine_brand
    vaccine_name:
      data_type: text
      description: Vaccine name of the vaccine administration recorded from history.
      name: vaccine_name
  config:
    tags:
    - base
    - clinical
    - log
  description: "Change logs of Table of vaccines administered to patients.\r\n\r\n\
    Vaccinations are recorded via the Vaccinations modal; they are selected\r\nfrom\
    \ a list of Scheduled Vaccines and linked to a Patient via an Encounter."
  name: vaccine_administrations_change_logs
  tags:
  - base
  - clinical
  - log
- columns:
    category:
      data_type: character varying(255)
      description: Vaccine category [Routine, Catch-up, Campaign, Other]
      name: category
    dose_label:
      data_type: character varying(255)
      description: "Dose label indicates what will appear on the front end of Tamanu\
        \ re when the dose is due. It can be a time in a child's \r\nlife (e.g. 'Birth',\
        \ '6 weeks') or a dose of vaccine (e.g. 'Dose 1', 'Dose 2')"
      name: dose_label
    id:
      data_type: character varying(255)
      description: Tamanu internal identifier (generally a UUID) in vaccine_schedules.
      name: id
    index:
      data_type: integer
      description: "This column is used to show when a second dose is due in relation\
        \ to the first dose. For example, if dose 1 is due at 6 \r\nweeks and dose\
        \ 2 is due at 10 weeks, this column would read '4' against the 10 week dose\
        \ as dose 2 is due 4 weeks after \r\ndose 1 is given."
      name: index
    label:
      data_type: character varying(255)
      description: "Contents of the label column is what will be displayed on the\
        \ front end of Tamanu \r\nunder fields labelled 'Vaccine'. This is where the\
        \ vaccine name is listed. E.g. 'BCG'."
      name: label
    sort_index:
      data_type: integer
      description: Sort index defaults to 0
      name: sort_index
    vaccine_id:
      data_type: character varying(255)
      description: "Use the vaccineId column to link the id column of the Reference\
        \ Data sheet Drug to the vaccine schedule. Copy the exact \r\nid from the\
        \ id column in the reference data sheet Drug and paste it in the vaccineId\
        \ column in the Scheduled Vaccine \r\nsheet."
      name: vaccine_id
    visibility_status:
      data_type: text
      description: "The visibility status of the record.\r\n\r\n- `current` indicates\
        \ the record is currently in use and should be visible and accessible to users\r\
        \n  on the User Interface.\r\n- `historical` indicates that the record is\
        \ no longer in use and should not be visible nor\r\n  accessible to users.\
        \ However, the record may still be present in Reporting.\r\n- `merged` indicates\
        \ that the record has been merged, is no longer in use and should not be visible\r\
        \n  nor accessible to users.\r\n\r\nThe default value is `current`. in vaccine_schedules."
      name: visibility_status
    weeks_from_birth_due:
      data_type: integer
      description: "This column is used to tell Tamanu how many weeks from the child's\
        \ date of birth a vaccine is due. This will populate \r\nthe front end within\
        \ the Vaccine schedule section in the column 'Due date'. For a vaccine to\
        \ appear in the Vaccine \r\nschedule a dose must have a `weeksFromBirthDue`\
        \ entered into the reference data. \r\n\r\nThis field should be used only\
        \ for the first dose of the vaccine. Subsequent doses should use \r\n`weeks_from_last_vaccination_due`"
      name: weeks_from_birth_due
    weeks_from_last_vaccination_due:
      data_type: integer
      description: "This column is used to show when a second dose is due in relation\
        \ to the first dose. For example, if dose 1 is due at 6 \r\nweeks and dose\
        \ 2 is due at 10 weeks, this column would read '4' against the 10 week dose\
        \ as dose 2 is due 4 weeks after \r\ndose 1 is given. The order of a vaccine\
        \ dose is defined at the `index` field. \r\n\r\nThis field should not be used\
        \ for the first dose but for subsequent doses. First dose should use `weeks_from_birth_due`"
      name: weeks_from_last_vaccination_due
  config:
    tags:
    - base
    - clinical
  description: "A vaccine schedule listing all vaccines expected to be given to a\
    \ child as part of a country wide Expanded Program of \r\nImmunisation can be\
    \ incorporated into Tamanu to show each dose and due date on the front end of\
    \ the system. \r\n\r\nFirst dose of a vaccine should use `weeks_from_birth_due`\
    \ whilst subsequent doses should use \r\n`weeks_from_last_vaccination_due`."
  name: vaccine_schedules
  tags:
  - base
  - clinical
