{
  "components": {
    "schemas": {
      "AccountingAccount": {
        "description": "Account is one line of the chart of accounts.",
        "properties": {
          "active": {
            "type": "boolean"
          },
          "balance": {
            "description": "Balance is summed from the posted lines, signed the way the account's own kind reads: a debit balance is positive on an asset or expense, a credit balance is positive on income, a liability or equity.",
            "readOnly": true,
            "type": "number"
          },
          "code": {
            "description": "A posting account needs one; a heading does not.",
            "nullable": true,
            "type": "string"
          },
          "grouping": {
            "nullable": true,
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "is_bank": {
            "type": "boolean"
          },
          "kind": {
            "description": "Under a parent, an account takes the parent's kind whatever is chosen here: an asset cannot sit in the expense tree.",
            "enum": [
              "ASSET",
              "LIABILITY",
              "EQUITY",
              "INCOME",
              "EXPENSE"
            ],
            "type": "string"
          },
          "line_count": {
            "description": "LineCount so a heading with postings on it is visible.",
            "readOnly": true,
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "parent_id": {
            "nullable": true,
            "type": "string"
          },
          "postable": {
            "type": "boolean"
          },
          "role": {
            "description": "Role is the level in the tree: a GROUP tops a tree, a CONTROL totals posting accounts, and only a POSTING account takes a line.",
            "enum": [
              "GROUP",
              "CONTROL",
              "POSTING"
            ],
            "type": "string"
          },
          "sort_order": {
            "type": "integer"
          },
          "statement_section": {
            "description": "StatementSection splits expenses into cost of sales and operating, which is what makes a gross profit computable.",
            "enum": [
              "COST_OF_SALES",
              "OPERATING"
            ],
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "AccountingBudget": {
        "description": "Budget is one budget line beside its actual.",
        "properties": {
          "account_code": {
            "type": "string"
          },
          "account_id": {
            "type": "string"
          },
          "account_name": {
            "type": "string"
          },
          "actual": {
            "description": "COMPUTED from the posted lines for that account and period.",
            "type": "number"
          },
          "amount": {
            "type": "number"
          },
          "department": {
            "nullable": true,
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "period_month": {
            "nullable": true,
            "type": "integer"
          },
          "period_year": {
            "type": "integer"
          },
          "used_pct": {
            "description": "UsedPct, or null when the budget is nought — a percentage of nothing is not a large number, it is not a number.",
            "nullable": true,
            "type": "integer"
          },
          "variance": {
            "type": "number"
          }
        },
        "type": "object"
      },
      "AccountingEntryInput": {
        "description": "EntryInput raises an entry.",
        "properties": {
          "entry_date": {
            "nullable": true,
            "type": "string"
          },
          "lines": {
            "items": {
              "$ref": "#/components/schemas/AccountingLineInput"
            },
            "type": "array"
          },
          "memo": {
            "type": "string"
          },
          "post": {
            "description": "Post it straight away, rather than leaving it as a draft.",
            "type": "boolean"
          },
          "source": {
            "description": "Where an entry came from.",
            "enum": [
              "MANUAL",
              "OPENING"
            ],
            "type": "string"
          },
          "source_id": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "AccountingFilingChange": {
        "description": "FilingChange is what can still change about a return that is due. Filing, paying and waiving are MoveFiling's, with the receipt or the reason each needs; the kind and period are what the return IS.  table: tax_filings",
        "properties": {
          "amount_due": {
            "type": "number"
          },
          "due_on": {
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "AccountingFilingInput": {
        "description": "FilingInput is a return, recorded before it is due.  table: tax_filings",
        "properties": {
          "amount_due": {
            "type": "number"
          },
          "due_on": {
            "type": "string"
          },
          "kind": {
            "description": "PAYE, NSSF, NHIF, VAT — or whatever else the country asks to be filed.",
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "period_month": {
            "nullable": true,
            "type": "integer"
          },
          "period_year": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "AccountingFiscalYearInput": {
        "description": "FiscalYearInput opens a year.",
        "properties": {
          "ends_on": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "starts_on": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "AccountingFundingInput": {
        "description": "FundingInput creates or edits one.",
        "properties": {
          "account_id": {
            "type": "string"
          },
          "active": {
            "nullable": true,
            "type": "boolean"
          },
          "branch_name": {
            "nullable": true,
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "institution": {
            "nullable": true,
            "type": "string"
          },
          "is_default": {
            "type": "boolean"
          },
          "kind": {
            "enum": [
              "cash",
              "bank",
              "mobile"
            ],
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "number": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "AccountingLineInput": {
        "description": "LineInput is one line of a new entry.",
        "properties": {
          "account_id": {
            "type": "string"
          },
          "credit": {
            "type": "number"
          },
          "debit": {
            "type": "number"
          },
          "department": {
            "nullable": true,
            "type": "string"
          },
          "description": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "AccountingPreferencesInput": {
        "description": "PreferencesInput edits them. Every field is a pointer: a settings save that cannot tell \"leave it alone\" from \"clear it\" clears half the form.",
        "properties": {
          "allow_negative_funding": {
            "nullable": true,
            "type": "boolean"
          },
          "cash_group_id": {
            "nullable": true,
            "type": "string"
          },
          "lock_date": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "AccountingStatementLine": {
        "description": "StatementLine is one line off a bank statement.",
        "properties": {
          "amount": {
            "type": "number"
          },
          "bank_account_id": {
            "type": "string"
          },
          "bank_reference": {
            "nullable": true,
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "matched_amount": {
            "nullable": true,
            "type": "number"
          },
          "matched_at": {
            "nullable": true,
            "type": "string"
          },
          "matched_entry_reference": {
            "description": "What it was matched to, for the reconciliation view.",
            "nullable": true,
            "type": "string"
          },
          "matched_line_id": {
            "nullable": true,
            "type": "string"
          },
          "note": {
            "nullable": true,
            "type": "string"
          },
          "value_date": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "AccountingTaxRateInput": {
        "description": "TaxRateInput adds or edits a rate.",
        "properties": {
          "active": {
            "nullable": true,
            "type": "boolean"
          },
          "code": {
            "type": "string"
          },
          "inclusive": {
            "nullable": true,
            "type": "boolean"
          },
          "liability_account_id": {
            "nullable": true,
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "rate": {
            "type": "number"
          }
        },
        "type": "object"
      },
      "BillingBillInput": {
        "description": "BillInput opens a bill.",
        "properties": {
          "items": {
            "items": {
              "$ref": "#/components/schemas/BillingItemInput"
            },
            "type": "array"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "patient_id": {
            "type": "string"
          },
          "payer": {
            "nullable": true,
            "type": "string"
          },
          "scheme_id": {
            "nullable": true,
            "type": "string"
          },
          "visit_id": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "BillingChargeRuleInput": {
        "description": "ChargeRuleInput is one fee being saved. A nil Price leaves the price list alone and only moves the binding.",
        "properties": {
          "code": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "price": {
            "nullable": true,
            "type": "number"
          }
        },
        "type": "object"
      },
      "BillingExpenseInput": {
        "description": "ExpenseInput records a spend.",
        "properties": {
          "amount": {
            "nullable": true,
            "type": "number"
          },
          "category": {
            "enum": [
              "Operating",
              "Utilities",
              "Supplies",
              "Maintenance",
              "Transport",
              "Staff",
              "Rent",
              "Other"
            ],
            "nullable": true,
            "type": "string"
          },
          "department": {
            "nullable": true,
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "method": {
            "nullable": true,
            "type": "string"
          },
          "payee": {
            "nullable": true,
            "type": "string"
          },
          "spent_on": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "BillingItemInput": {
        "description": "ItemInput adds a line.",
        "properties": {
          "category": {
            "nullable": true,
            "type": "string"
          },
          "code": {
            "nullable": true,
            "type": "string"
          },
          "department": {
            "nullable": true,
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "quantity": {
            "nullable": true,
            "type": "number"
          },
          "source": {
            "nullable": true,
            "type": "string"
          },
          "source_id": {
            "nullable": true,
            "type": "string"
          },
          "unit_price": {
            "nullable": true,
            "type": "number"
          }
        },
        "type": "object"
      },
      "BillingPatientFlowInput": {
        "description": "PatientFlowInput edits the screen. Every field is a pointer: a settings save that cannot tell \"leave it alone\" from \"clear it\" clears half the form.",
        "properties": {
          "consultation": {
            "$ref": "#/components/schemas/BillingChargeRuleInput"
          },
          "payment_before_service": {
            "nullable": true,
            "type": "boolean"
          },
          "registration": {
            "$ref": "#/components/schemas/BillingChargeRuleInput"
          }
        },
        "type": "object"
      },
      "BillingPaymentInput": {
        "description": "PaymentInput takes money.",
        "properties": {
          "amount": {
            "type": "number"
          },
          "method": {
            "enum": [
              "Cash",
              "Mobile Money",
              "Card",
              "Bank Transfer",
              "Insurance",
              "Cheque",
              "Waiver"
            ],
            "nullable": true,
            "type": "string"
          },
          "reference": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "BillingSaleInput": {
        "description": "SaleInput is a whole counter sale.",
        "properties": {
          "amount": {
            "description": "Amount is what the customer handed over, and it has THREE answers:  - absent: pay the bill in full.",
            "nullable": true,
            "type": "number"
          },
          "lines": {
            "items": {
              "$ref": "#/components/schemas/BillingSaleLine"
            },
            "type": "array"
          },
          "method": {
            "type": "string"
          },
          "patient_id": {
            "type": "string"
          },
          "reference": {
            "type": "string"
          },
          "visit_id": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "BillingSaleLine": {
        "description": "SaleLine is one thing being sold across a counter.",
        "properties": {
          "batch_id": {
            "description": "BatchID is set for anything coming off a shelf.",
            "nullable": true,
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "department": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "quantity": {
            "type": "number"
          },
          "unit_price": {
            "nullable": true,
            "type": "number"
          }
        },
        "type": "object"
      },
      "BillingSchemeInput": {
        "description": "SchemeInput adds or edits an insurer.",
        "properties": {
          "active": {
            "nullable": true,
            "type": "boolean"
          },
          "code": {
            "type": "string"
          },
          "contact_person": {
            "nullable": true,
            "type": "string"
          },
          "contract_expiry": {
            "nullable": true,
            "type": "string"
          },
          "contract_no": {
            "nullable": true,
            "type": "string"
          },
          "coverage_pct": {
            "nullable": true,
            "type": "number"
          },
          "email": {
            "nullable": true,
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "phone": {
            "nullable": true,
            "type": "string"
          },
          "preauth_above": {
            "nullable": true,
            "type": "number"
          },
          "settlement_days": {
            "nullable": true,
            "type": "integer"
          }
        },
        "type": "object"
      },
      "BillingTariffInput": {
        "description": "TariffInput sets a price.  table: service_tariffs — its vocabularies come from that table's CHECK lists.",
        "properties": {
          "active": {
            "nullable": true,
            "type": "boolean"
          },
          "category": {
            "enum": [
              "Consultation",
              "Laboratory",
              "Radiology",
              "Procedure",
              "Pharmacy",
              "Bed",
              "Theatre",
              "Nursing",
              "Other"
            ],
            "nullable": true,
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "department": {
            "nullable": true,
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "payer": {
            "nullable": true,
            "type": "string"
          },
          "price": {
            "nullable": true,
            "type": "number"
          }
        },
        "type": "object"
      },
      "ClinicalAppointmentInput": {
        "description": "AppointmentInput books a slot.",
        "properties": {
          "clinician_id": {
            "nullable": true,
            "type": "string"
          },
          "clinician_name": {
            "nullable": true,
            "type": "string"
          },
          "department": {
            "nullable": true,
            "type": "string"
          },
          "duration_min": {
            "nullable": true,
            "type": "integer"
          },
          "kind": {
            "enum": [
              "CONSULTATION",
              "FOLLOW_UP",
              "PROCEDURE",
              "ANTENATAL",
              "IMMUNISATION",
              "REVIEW",
              "THEATRE"
            ],
            "nullable": true,
            "type": "string"
          },
          "location_id": {
            "nullable": true,
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "patient_id": {
            "type": "string"
          },
          "reason": {
            "nullable": true,
            "type": "string"
          },
          "scheduled_for": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "ClinicalDoseInput": {
        "description": "DoseInput schedules a dose.",
        "properties": {
          "admission_id": {
            "nullable": true,
            "type": "string"
          },
          "dose": {
            "type": "string"
          },
          "due_at": {
            "nullable": true,
            "type": "string"
          },
          "medicine": {
            "type": "string"
          },
          "patient_id": {
            "type": "string"
          },
          "prescription_item_id": {
            "nullable": true,
            "type": "string"
          },
          "route": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "ClinicalEmergencyInput": {
        "description": "EmergencyInput records an arrival.",
        "properties": {
          "arrival_mode": {
            "enum": [
              "WALK_IN",
              "AMBULANCE",
              "REFERRED",
              "POLICE",
              "OTHER"
            ],
            "nullable": true,
            "type": "string"
          },
          "brought_by": {
            "nullable": true,
            "type": "string"
          },
          "category": {
            "nullable": true,
            "type": "string"
          },
          "patient_id": {
            "nullable": true,
            "type": "string"
          },
          "presenting_complaint": {
            "nullable": true,
            "type": "string"
          },
          "triage_category": {
            "nullable": true,
            "type": "integer"
          },
          "unknown_label": {
            "nullable": true,
            "type": "string"
          },
          "visit_id": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "ClinicalRecordInput": {
        "description": "RecordInput codes something.  table: record_entries — its vocabularies come from that table's CHECK lists.",
        "properties": {
          "admission_id": {
            "nullable": true,
            "type": "string"
          },
          "body": {
            "nullable": true,
            "type": "string"
          },
          "code": {
            "nullable": true,
            "type": "string"
          },
          "coding_system": {
            "nullable": true,
            "type": "string"
          },
          "kind": {
            "enum": [
              "DIAGNOSIS",
              "PROCEDURE",
              "NOTE",
              "SUMMARY"
            ],
            "nullable": true,
            "type": "string"
          },
          "notifiable": {
            "nullable": true,
            "type": "boolean"
          },
          "patient_id": {
            "type": "string"
          },
          "rank": {
            "enum": [
              "PRIMARY",
              "SECONDARY",
              "COMPLICATION"
            ],
            "nullable": true,
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "visit_id": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "ClinicalReferralInput": {
        "description": "ReferralInput sends or records one.",
        "properties": {
          "clinical_summary": {
            "nullable": true,
            "type": "string"
          },
          "contact": {
            "nullable": true,
            "type": "string"
          },
          "department": {
            "nullable": true,
            "type": "string"
          },
          "direction": {
            "enum": [
              "OUT",
              "IN"
            ],
            "nullable": true,
            "type": "string"
          },
          "facility": {
            "type": "string"
          },
          "patient_id": {
            "type": "string"
          },
          "reason": {
            "type": "string"
          },
          "urgency": {
            "enum": [
              "ROUTINE",
              "URGENT",
              "EMERGENCY"
            ],
            "nullable": true,
            "type": "string"
          },
          "visit_id": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "ClinicalTaskInput": {
        "description": "TaskInput adds a nursing job.  table: nursing_tasks — its vocabularies come from that table's CHECK lists.",
        "properties": {
          "admission_id": {
            "nullable": true,
            "type": "string"
          },
          "category": {
            "enum": [
              "OBSERVATION",
              "MEDICATION",
              "HYGIENE",
              "WOUND",
              "MOBILITY",
              "FEEDING",
              "MONITORING",
              "OTHER"
            ],
            "nullable": true,
            "type": "string"
          },
          "due_at": {
            "nullable": true,
            "type": "string"
          },
          "every_hours": {
            "nullable": true,
            "type": "integer"
          },
          "instructions": {
            "nullable": true,
            "type": "string"
          },
          "patient_id": {
            "type": "string"
          },
          "task": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "CommercialClient": {
        "description": "Client is a corporate account.",
        "properties": {
          "account_manager": {
            "nullable": true,
            "type": "string"
          },
          "address": {
            "nullable": true,
            "type": "string"
          },
          "close_reason": {
            "nullable": true,
            "type": "string"
          },
          "contacts": {
            "items": {
              "$ref": "#/components/schemas/CommercialContact"
            },
            "type": "array"
          },
          "contract_days_left": {
            "description": "Negative once the contract has lapsed.",
            "nullable": true,
            "type": "integer"
          },
          "contract_ends": {
            "nullable": true,
            "type": "string"
          },
          "contract_ref": {
            "nullable": true,
            "type": "string"
          },
          "contract_starts": {
            "nullable": true,
            "type": "string"
          },
          "credit_limit": {
            "nullable": true,
            "type": "number"
          },
          "discount_pct": {
            "type": "number"
          },
          "email": {
            "nullable": true,
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "kind": {
            "enum": [
              "CORPORATE",
              "INSURER",
              "NGO",
              "GOVERNMENT",
              "SCHOOL",
              "OTHER"
            ],
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "open_follow_ups": {
            "type": "integer"
          },
          "outstanding": {
            "description": "Outstanding, computed from the bills raised against this client's payer name.",
            "type": "number"
          },
          "payment_terms_days": {
            "nullable": true,
            "type": "integer"
          },
          "phone": {
            "nullable": true,
            "type": "string"
          },
          "reference": {
            "description": "Numbered by the server when the account is opened.",
            "readOnly": true,
            "type": "string"
          },
          "region": {
            "nullable": true,
            "type": "string"
          },
          "scheme_id": {
            "nullable": true,
            "type": "string"
          },
          "scheme_name": {
            "nullable": true,
            "type": "string"
          },
          "status": {
            "enum": [
              "PROSPECT",
              "ACTIVE",
              "SUSPENDED",
              "CLOSED"
            ],
            "type": "string"
          },
          "tin": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "CommercialContact": {
        "description": "Contact is one person at a client.",
        "properties": {
          "client_id": {
            "type": "string"
          },
          "client_name": {
            "type": "string"
          },
          "email": {
            "nullable": true,
            "type": "string"
          },
          "full_name": {
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "is_primary": {
            "type": "boolean"
          },
          "job_title": {
            "nullable": true,
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "phone": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "CommercialDiscountRule": {
        "description": "DiscountRule is policy.",
        "properties": {
          "active": {
            "type": "boolean"
          },
          "applies_to": {
            "type": "string"
          },
          "approval_above": {
            "nullable": true,
            "type": "number"
          },
          "id": {
            "type": "string"
          },
          "kind": {
            "enum": [
              "PERCENT",
              "AMOUNT"
            ],
            "type": "string"
          },
          "max_amount": {
            "nullable": true,
            "type": "number"
          },
          "name": {
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "requires_approval": {
            "type": "boolean"
          },
          "value": {
            "type": "number"
          }
        },
        "type": "object"
      },
      "CommercialFollowUp": {
        "description": "FollowUp is something somebody promised to do.",
        "properties": {
          "assigned_to_name": {
            "nullable": true,
            "type": "string"
          },
          "client_id": {
            "nullable": true,
            "type": "string"
          },
          "client_name": {
            "nullable": true,
            "type": "string"
          },
          "detail": {
            "nullable": true,
            "type": "string"
          },
          "done_on": {
            "nullable": true,
            "type": "string"
          },
          "due_on": {
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "outcome": {
            "nullable": true,
            "type": "string"
          },
          "overdue_days": {
            "description": "Positive once it is late.",
            "nullable": true,
            "type": "integer"
          },
          "patient_id": {
            "nullable": true,
            "type": "string"
          },
          "patient_name": {
            "nullable": true,
            "type": "string"
          },
          "status": {
            "enum": [
              "OPEN",
              "DONE",
              "CANCELLED"
            ],
            "type": "string"
          },
          "subject": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "CommercialInteraction": {
        "description": "Interaction is one entry in the append-only contact log.  table: client_interactions — its vocabularies come from that table's CHECK lists.",
        "properties": {
          "client_id": {
            "type": "string"
          },
          "contact_id": {
            "nullable": true,
            "type": "string"
          },
          "contact_name": {
            "nullable": true,
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "kind": {
            "enum": [
              "CALL",
              "VISIT",
              "EMAIL",
              "MEETING",
              "COMPLAINT",
              "NOTE"
            ],
            "type": "string"
          },
          "occurred_at": {
            "type": "string"
          },
          "outcome": {
            "nullable": true,
            "type": "string"
          },
          "recorded_by_name": {
            "nullable": true,
            "type": "string"
          },
          "summary": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "CommercialLineInput": {
        "description": "LineInput is one line being written.",
        "properties": {
          "code": {
            "nullable": true,
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "product_id": {
            "nullable": true,
            "type": "string"
          },
          "quantity": {
            "type": "number"
          },
          "unit_price": {
            "type": "number"
          }
        },
        "type": "object"
      },
      "CommercialOrderInput": {
        "description": "OrderInput raises an order directly.",
        "properties": {
          "client_id": {
            "nullable": true,
            "type": "string"
          },
          "client_name": {
            "type": "string"
          },
          "discount_pct": {
            "type": "number"
          },
          "items": {
            "items": {
              "$ref": "#/components/schemas/CommercialLineInput"
            },
            "type": "array"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "patient_id": {
            "nullable": true,
            "type": "string"
          },
          "required_by": {
            "nullable": true,
            "type": "string"
          },
          "tax_pct": {
            "type": "number"
          }
        },
        "type": "object"
      },
      "CommercialQuotationInput": {
        "description": "QuotationInput raises a quote.",
        "properties": {
          "client_id": {
            "nullable": true,
            "type": "string"
          },
          "client_name": {
            "type": "string"
          },
          "discount_pct": {
            "type": "number"
          },
          "items": {
            "items": {
              "$ref": "#/components/schemas/CommercialLineInput"
            },
            "type": "array"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "patient_id": {
            "nullable": true,
            "type": "string"
          },
          "tax_pct": {
            "type": "number"
          },
          "terms": {
            "nullable": true,
            "type": "string"
          },
          "valid_until": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "CommercialReturnInput": {
        "description": "ReturnInput records a return.",
        "properties": {
          "bill_id": {
            "nullable": true,
            "type": "string"
          },
          "client_id": {
            "nullable": true,
            "type": "string"
          },
          "items": {
            "items": {
              "properties": {
                "description": {
                  "type": "string"
                },
                "product_id": {
                  "nullable": true,
                  "type": "string"
                },
                "quantity": {
                  "type": "number"
                },
                "unit_price": {
                  "type": "number"
                }
              },
              "type": "object"
            },
            "type": "array"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "party_name": {
            "type": "string"
          },
          "patient_id": {
            "nullable": true,
            "type": "string"
          },
          "reason": {
            "type": "string"
          },
          "reason_code": {
            "enum": [
              "WRONG_ITEM",
              "DAMAGED",
              "EXPIRED",
              "ADVERSE_REACTION",
              "NOT_NEEDED",
              "OVERSUPPLY",
              "OTHER"
            ],
            "type": "string"
          },
          "refund_amount": {
            "type": "number"
          },
          "restock": {
            "type": "boolean"
          }
        },
        "type": "object"
      },
      "DevicesClaim": {
        "description": "Claim is what a workstation sends to activate.",
        "properties": {
          "app_version": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "fingerprint": {
            "description": "Fingerprint is SHA-256 over three hardware parts, from the workstation.",
            "type": "string"
          },
          "hostname": {
            "type": "string"
          },
          "key_scope": {
            "description": "KeyScope says where the private half lives: \"dpapi\" or \"cng\".",
            "enum": [
              "dpapi",
              "cng"
            ],
            "type": "string"
          },
          "os_version": {
            "type": "string"
          },
          "public_key": {
            "description": "PublicKey is base64 SPKI DER for a P-256 key whose private half stays on that machine.",
            "type": "string"
          }
        },
        "type": "object"
      },
      "DevicesNewActivation": {
        "description": "NewActivation is what an administrator chooses on the Devices screen.",
        "properties": {
          "allowed_cidrs": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "expires_in_hours": {
            "description": "ExpiresInHours is how long the CODE may be typed in.",
            "nullable": true,
            "type": "integer"
          },
          "facility_id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "lease_days": {
            "description": "LeaseDays is how long the DEVICE lasts before it must be seen on this network again.",
            "nullable": true,
            "type": "integer"
          },
          "never_expires": {
            "type": "boolean"
          },
          "station_role": {
            "enum": [
              "reception",
              "cashier",
              "pharmacy",
              "laboratory",
              "ward",
              "admin"
            ],
            "type": "string"
          }
        },
        "type": "object"
      },
      "DiagnosticsOrderInput": {
        "description": "OrderInput places a request.",
        "properties": {
          "clinical_notes": {
            "nullable": true,
            "type": "string"
          },
          "discipline": {
            "enum": [
              "LAB",
              "IMAGING"
            ],
            "nullable": true,
            "type": "string"
          },
          "patient_id": {
            "type": "string"
          },
          "priority": {
            "enum": [
              "ROUTINE",
              "URGENT",
              "STAT"
            ],
            "nullable": true,
            "type": "string"
          },
          "test_codes": {
            "description": "TestCodes are catalogue codes.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "visit_id": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "DiagnosticsResultInput": {
        "description": "ResultInput records one value.",
        "properties": {
          "comment": {
            "nullable": true,
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "value_num": {
            "nullable": true,
            "type": "number"
          },
          "value_text": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "DiagnosticsTestInput": {
        "description": "TestInput adds or edits a catalogue entry.",
        "properties": {
          "active": {
            "nullable": true,
            "type": "boolean"
          },
          "category": {
            "nullable": true,
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "critical_high": {
            "nullable": true,
            "type": "number"
          },
          "critical_low": {
            "nullable": true,
            "type": "number"
          },
          "discipline": {
            "enum": [
              "LAB",
              "IMAGING"
            ],
            "nullable": true,
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "ref_high": {
            "nullable": true,
            "type": "number"
          },
          "ref_low": {
            "nullable": true,
            "type": "number"
          },
          "specimen": {
            "nullable": true,
            "type": "string"
          },
          "tariff_code": {
            "nullable": true,
            "type": "string"
          },
          "turnaround_hours": {
            "nullable": true,
            "type": "integer"
          },
          "unit": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "Envelope": {
        "description": "The response envelope every endpoint replies with.",
        "properties": {
          "data": {
            "description": "The payload. Always present; null when there is nothing to send.",
            "nullable": true
          },
          "message": {
            "description": "Human wording, shown to the operator as it stands.",
            "example": "Patients retrieved",
            "type": "string"
          },
          "success": {
            "example": true,
            "type": "boolean"
          }
        },
        "required": [
          "success",
          "message",
          "data"
        ],
        "type": "object"
      },
      "Error": {
        "description": "A refusal. `success` is false and `data` is null; `message` carries the server's own wording.",
        "properties": {
          "data": {
            "nullable": true
          },
          "message": {
            "example": "You do not have permission to do that",
            "type": "string"
          },
          "success": {
            "example": false,
            "type": "boolean"
          }
        },
        "required": [
          "success",
          "message",
          "data"
        ],
        "type": "object"
      },
      "HandlersAssistNote": {
        "description": "assistNote is what the console sends. Deliberately NOT the patient record: there is no id here, and no way to ask for one.",
        "properties": {
          "ageYears": {
            "type": "integer"
          },
          "allergies": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "chiefComplaint": {
            "type": "string"
          },
          "examination": {
            "type": "string"
          },
          "historyOfPresentIllness": {
            "type": "string"
          },
          "knownConditions": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "pregnant": {
            "type": "boolean"
          },
          "sex": {
            "enum": [
              "Male",
              "Female",
              "Ambiguous"
            ],
            "type": "string"
          },
          "vitals": {
            "properties": {
              "diastolic": {
                "nullable": true,
                "type": "integer"
              },
              "heartRate": {
                "nullable": true,
                "type": "integer"
              },
              "oxygenSaturation": {
                "nullable": true,
                "type": "integer"
              },
              "respiratoryRate": {
                "nullable": true,
                "type": "integer"
              },
              "systolic": {
                "nullable": true,
                "type": "integer"
              },
              "temperature": {
                "nullable": true,
                "type": "number"
              }
            },
            "type": "object"
          }
        },
        "type": "object"
      },
      "HandlersChangePasswordRequest": {
        "properties": {
          "current_password": {
            "type": "string"
          },
          "new_password": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "HandlersEmailConfigBody": {
        "description": "emailConfigBody is the mail server, and the address mail comes from.",
        "properties": {
          "from": {
            "properties": {
              "email": {
                "type": "string"
              },
              "name": {
                "nullable": true,
                "type": "string"
              }
            },
            "type": "object"
          },
          "is_active": {
            "nullable": true,
            "type": "boolean"
          },
          "smtp": {
            "properties": {
              "encryption": {
                "enum": [
                  "tls",
                  "ssl",
                  "none"
                ],
                "nullable": true,
                "type": "string"
              },
              "host": {
                "type": "string"
              },
              "password": {
                "description": "Sent back as it was shown to keep the stored password.",
                "nullable": true,
                "type": "string"
              },
              "port": {
                "description": "587 for TLS, 465 for SSL.",
                "type": "integer"
              },
              "username": {
                "nullable": true,
                "type": "string"
              }
            },
            "type": "object"
          }
        },
        "type": "object"
      },
      "HandlersForgotPasswordRequest": {
        "properties": {
          "contact": {
            "description": "Contact is the email address or phone number on the account.",
            "type": "string"
          },
          "workspace": {
            "description": "Workspace is the hospital, in the hosted service: an address may be on accounts at two hospitals, and only the one named is reset.",
            "type": "string"
          }
        },
        "type": "object"
      },
      "HandlersLoginRequest": {
        "description": "loginRequest accepts the field name the caller happens to use. The staff console signs people in by username, the patient portal by email, and both mean the same thing to the auth service — one \"identifier\" it resolves itself.",
        "properties": {
          "email": {
            "type": "string"
          },
          "identifier": {
            "type": "string"
          },
          "password": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "platform": {
            "description": "Platform signs in one of the service's own operators, who belong to no hospital.",
            "type": "boolean"
          },
          "username": {
            "type": "string"
          },
          "workspace": {
            "description": "Workspace is the hospital's code, in the hosted service: which of its hospitals the identifier and password belong to.",
            "type": "string"
          }
        },
        "type": "object"
      },
      "HandlersLogoutRequest": {
        "description": "logoutRequest optionally widens a logout to every device.",
        "properties": {
          "all_devices": {
            "type": "boolean"
          }
        },
        "type": "object"
      },
      "HandlersMoveRequest": {
        "description": "moveRequest is a deposit, a withdrawal or a transfer.  One shape for all three, because the screens are one screen with different wording and a request that only half-matches is easier to debug than three near-identical structs that have drifted.",
        "properties": {
          "account_id": {
            "type": "string"
          },
          "amount": {
            "type": "number"
          },
          "note": {
            "type": "string"
          },
          "to_account_id": {
            "type": "string"
          },
          "to_facility_id": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "HandlersPurchaseInput": {
        "description": "purchaseInput is what a hospital asks to buy.",
        "properties": {
          "branches": {
            "type": "integer"
          },
          "months": {
            "type": "integer"
          },
          "plan_code": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "HandlersRefreshRequest": {
        "description": "refreshRequest carries the refresh token to rotate.",
        "properties": {
          "refresh_token": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "HandlersResetPasswordRequest": {
        "properties": {
          "code": {
            "type": "string"
          },
          "contact": {
            "type": "string"
          },
          "new_password": {
            "type": "string"
          },
          "workspace": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "HandlersSystemSettingsInput": {
        "description": "systemSettingsInput is the whole screen. Every field is optional; a field that is absent is left as it is, and a branding field sent EMPTY is cleared.",
        "properties": {
          "accent": {
            "description": "The logo and the icon are NOT here.",
            "enum": [
              "gold",
              "blue",
              "teal",
              "violet",
              "emerald",
              "rose"
            ],
            "nullable": true,
            "type": "string"
          },
          "country": {
            "description": "Read against, not merely displayed — see the note at the top.",
            "nullable": true,
            "type": "string"
          },
          "currency": {
            "nullable": true,
            "type": "string"
          },
          "date_format": {
            "description": "The keys of `dateFormats`.",
            "enum": [
              "dd/mm/yyyy",
              "dd mmm yyyy",
              "yyyy-mm-dd",
              "mm/dd/yyyy"
            ],
            "nullable": true,
            "type": "string"
          },
          "document_accent": {
            "nullable": true,
            "type": "string"
          },
          "document_footer": {
            "nullable": true,
            "type": "string"
          },
          "document_theme": {
            "description": "The look of the printed documents.",
            "enum": [
              "plain",
              "band",
              "ruled"
            ],
            "nullable": true,
            "type": "string"
          },
          "invoice_due_days": {
            "nullable": true,
            "type": "string"
          },
          "invoice_notice": {
            "nullable": true,
            "type": "string"
          },
          "invoice_terms": {
            "description": "The invoice wording.",
            "nullable": true,
            "type": "string"
          },
          "login_message": {
            "nullable": true,
            "type": "string"
          },
          "name": {
            "nullable": true,
            "type": "string"
          },
          "short_name": {
            "nullable": true,
            "type": "string"
          },
          "support_email": {
            "nullable": true,
            "type": "string"
          },
          "support_phone": {
            "nullable": true,
            "type": "string"
          },
          "tagline": {
            "nullable": true,
            "type": "string"
          },
          "timezone": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "HandlersVerifyTwoFactorRequest": {
        "description": "verifyTwoFactorRequest answers a challenge from Login.",
        "properties": {
          "code": {
            "type": "string"
          },
          "session_token": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "HrApplicant": {
        "description": "Applicant is one person against one vacancy.",
        "properties": {
          "created_at": {
            "type": "string"
          },
          "cv_url": {
            "nullable": true,
            "type": "string"
          },
          "email": {
            "nullable": true,
            "type": "string"
          },
          "full_name": {
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "interviewed_on": {
            "nullable": true,
            "type": "string"
          },
          "phone": {
            "nullable": true,
            "type": "string"
          },
          "qualification": {
            "nullable": true,
            "type": "string"
          },
          "score": {
            "nullable": true,
            "type": "integer"
          },
          "staff_id": {
            "nullable": true,
            "type": "string"
          },
          "stage": {
            "enum": [
              "APPLIED",
              "SHORTLISTED",
              "INTERVIEWED",
              "OFFERED",
              "HIRED",
              "REJECTED",
              "WITHDRAWN"
            ],
            "type": "string"
          },
          "stage_note": {
            "nullable": true,
            "type": "string"
          },
          "vacancy_id": {
            "type": "string"
          },
          "vacancy_title": {
            "type": "string"
          },
          "years_experience": {
            "nullable": true,
            "type": "integer"
          }
        },
        "type": "object"
      },
      "HrTrainingChange": {
        "description": "TrainingChange corrects a course on the record. Whose it is does not change.  table: training_records",
        "properties": {
          "certificate_url": {
            "nullable": true,
            "type": "string"
          },
          "completed_on": {
            "nullable": true,
            "type": "string"
          },
          "course": {
            "type": "string"
          },
          "cpd_points": {
            "nullable": true,
            "type": "number"
          },
          "expires_on": {
            "nullable": true,
            "type": "string"
          },
          "mandatory": {
            "type": "boolean"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "provider": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "HrTrainingInput": {
        "description": "TrainingInput is a course somebody attended.  # ITS OWN TYPE, NOT Training  The POST bound the read model, so the form offered the person's number, name and department — which are the staff record's, and were never stored here. A department chosen on the form came back as the department the person actually works in.  table: training_records",
        "properties": {
          "certificate_url": {
            "nullable": true,
            "type": "string"
          },
          "completed_on": {
            "nullable": true,
            "type": "string"
          },
          "course": {
            "type": "string"
          },
          "cpd_points": {
            "nullable": true,
            "type": "number"
          },
          "expires_on": {
            "nullable": true,
            "type": "string"
          },
          "mandatory": {
            "type": "boolean"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "provider": {
            "nullable": true,
            "type": "string"
          },
          "staff_id": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "HrVacancy": {
        "description": "Vacancy is an open post.",
        "properties": {
          "applied": {
            "description": "The pipeline, counted.",
            "readOnly": true,
            "type": "integer"
          },
          "cadre": {
            "nullable": true,
            "type": "string"
          },
          "close_reason": {
            "nullable": true,
            "type": "string"
          },
          "closes_on": {
            "nullable": true,
            "type": "string"
          },
          "days_open": {
            "description": "DaysOpen — a vacancy nobody has filled in four months is a finding.",
            "readOnly": true,
            "type": "integer"
          },
          "department": {
            "nullable": true,
            "type": "string"
          },
          "description": {
            "nullable": true,
            "type": "string"
          },
          "employment_type": {
            "enum": [
              "PERMANENT",
              "CONTRACT",
              "LOCUM",
              "INTERN",
              "VOLUNTEER"
            ],
            "type": "string"
          },
          "hired": {
            "readOnly": true,
            "type": "integer"
          },
          "id": {
            "type": "string"
          },
          "interviewed": {
            "readOnly": true,
            "type": "integer"
          },
          "job_title": {
            "type": "string"
          },
          "offered": {
            "readOnly": true,
            "type": "integer"
          },
          "positions": {
            "type": "integer"
          },
          "posted_on": {
            "type": "string"
          },
          "reference": {
            "description": "Numbered by the server when the vacancy is opened.",
            "readOnly": true,
            "type": "string"
          },
          "rejected": {
            "readOnly": true,
            "type": "integer"
          },
          "requirements": {
            "nullable": true,
            "type": "string"
          },
          "shortlisted": {
            "readOnly": true,
            "type": "integer"
          },
          "status": {
            "enum": [
              "OPEN",
              "CLOSED",
              "FILLED",
              "CANCELLED"
            ],
            "type": "string"
          }
        },
        "type": "object"
      },
      "InpatientAdmissionInput": {
        "description": "AdmissionInput admits somebody.",
        "properties": {
          "bed_id": {
            "nullable": true,
            "type": "string"
          },
          "consultant_name": {
            "nullable": true,
            "type": "string"
          },
          "diagnosis": {
            "nullable": true,
            "type": "string"
          },
          "patient_id": {
            "type": "string"
          },
          "reason": {
            "nullable": true,
            "type": "string"
          },
          "visit_id": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "InpatientBedInput": {
        "description": "BedInput adds or edits a bed.",
        "properties": {
          "label": {
            "type": "string"
          },
          "status": {
            "enum": [
              "AVAILABLE",
              "CLEANING",
              "MAINTENANCE",
              "CLOSED"
            ],
            "nullable": true,
            "type": "string"
          },
          "status_reason": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "InpatientWardInput": {
        "description": "WardInput opens or edits a ward.",
        "properties": {
          "code": {
            "type": "string"
          },
          "daily_rate": {
            "nullable": true,
            "type": "number"
          },
          "kind": {
            "enum": [
              "GENERAL",
              "MALE",
              "FEMALE",
              "PAEDIATRIC",
              "MATERNITY",
              "SURGICAL",
              "ICU",
              "ISOLATION",
              "PRIVATE",
              "NURSERY"
            ],
            "nullable": true,
            "type": "string"
          },
          "location_id": {
            "nullable": true,
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "sex_restriction": {
            "enum": [
              "Male",
              "Female"
            ],
            "nullable": true,
            "type": "string"
          },
          "status": {
            "enum": [
              "Active",
              "Closed"
            ],
            "nullable": true,
            "type": "string"
          },
          "tariff_code": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "InventoryCatalogueInput": {
        "description": "CatalogueInput adds or edits an entry. Every optional field is a pointer so an edit that leaves a field alone is told apart from one that clears it.",
        "properties": {
          "active": {
            "nullable": true,
            "type": "boolean"
          },
          "base_unit_id": {
            "nullable": true,
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "factor": {
            "nullable": true,
            "type": "number"
          },
          "manufacturer": {
            "nullable": true,
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "parent_id": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "InventoryCataloguePreferencesInput": {
        "description": "CataloguePreferencesInput edits them.",
        "properties": {
          "code_prefix": {
            "nullable": true,
            "type": "string"
          },
          "default_unit_id": {
            "nullable": true,
            "type": "string"
          },
          "require_brand": {
            "nullable": true,
            "type": "boolean"
          },
          "require_category": {
            "nullable": true,
            "type": "boolean"
          }
        },
        "type": "object"
      },
      "InventoryDispenseInput": {
        "description": "DispenseInput hands medicine over.",
        "properties": {
          "batch_id": {
            "type": "string"
          },
          "item_id": {
            "type": "string"
          },
          "quantity": {
            "type": "number"
          }
        },
        "type": "object"
      },
      "InventoryMovementInput": {
        "description": "MovementInput records a movement out of, or an adjustment to, a batch.",
        "properties": {
          "batch_id": {
            "type": "string"
          },
          "issued_to": {
            "nullable": true,
            "type": "string"
          },
          "kind": {
            "description": "Receipts are /inventory/receipts, with the supplier and the cost.",
            "enum": [
              "ISSUE",
              "TRANSFER_OUT",
              "WRITE_OFF",
              "ADJUSTMENT",
              "RETURN"
            ],
            "type": "string"
          },
          "quantity": {
            "type": "number"
          },
          "reason": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "InventoryPrescriptionInput": {
        "description": "PrescriptionInput writes a prescription.",
        "properties": {
          "items": {
            "items": {
              "$ref": "#/components/schemas/InventoryRxItemInput"
            },
            "type": "array"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "patient_id": {
            "type": "string"
          },
          "visit_id": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "InventoryProductInput": {
        "description": "ProductInput adds or edits a catalogue entry.",
        "properties": {
          "active": {
            "nullable": true,
            "type": "boolean"
          },
          "brand_id": {
            "nullable": true,
            "type": "string"
          },
          "category": {
            "nullable": true,
            "type": "string"
          },
          "category_id": {
            "description": "The catalogue lookups.",
            "nullable": true,
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "controlled": {
            "nullable": true,
            "type": "boolean"
          },
          "form": {
            "nullable": true,
            "type": "string"
          },
          "generic_name": {
            "nullable": true,
            "type": "string"
          },
          "kind": {
            "enum": [
              "DRUG",
              "SUPPLY",
              "REAGENT",
              "EQUIPMENT",
              "OTHER"
            ],
            "nullable": true,
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "prescription_only": {
            "nullable": true,
            "type": "boolean"
          },
          "reorder_level": {
            "nullable": true,
            "type": "number"
          },
          "sale_price": {
            "nullable": true,
            "type": "number"
          },
          "strength": {
            "nullable": true,
            "type": "string"
          },
          "tariff_code": {
            "nullable": true,
            "type": "string"
          },
          "unit": {
            "nullable": true,
            "type": "string"
          },
          "unit_id": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "InventoryReceiptInput": {
        "description": "ReceiptInput books stock in.",
        "properties": {
          "batch_number": {
            "type": "string"
          },
          "expiry_date": {
            "nullable": true,
            "type": "string"
          },
          "location_id": {
            "nullable": true,
            "type": "string"
          },
          "product_code": {
            "type": "string"
          },
          "product_id": {
            "type": "string"
          },
          "quantity": {
            "type": "number"
          },
          "supplier_id": {
            "nullable": true,
            "type": "string"
          },
          "unit_cost": {
            "nullable": true,
            "type": "number"
          }
        },
        "type": "object"
      },
      "InventoryRxItemInput": {
        "description": "RxItemInput is one line of a new prescription.",
        "properties": {
          "code": {
            "nullable": true,
            "type": "string"
          },
          "dose": {
            "type": "string"
          },
          "duration": {
            "nullable": true,
            "type": "string"
          },
          "frequency": {
            "type": "string"
          },
          "instructions": {
            "nullable": true,
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "product_id": {
            "nullable": true,
            "type": "string"
          },
          "quantity": {
            "nullable": true,
            "type": "number"
          },
          "route": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "InventorySupplierInput": {
        "description": "SupplierInput adds or edits a supplier.",
        "properties": {
          "active": {
            "nullable": true,
            "type": "boolean"
          },
          "address": {
            "nullable": true,
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "contact_person": {
            "nullable": true,
            "type": "string"
          },
          "email": {
            "nullable": true,
            "type": "string"
          },
          "lead_days": {
            "nullable": true,
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "payment_terms": {
            "nullable": true,
            "type": "string"
          },
          "phone": {
            "nullable": true,
            "type": "string"
          },
          "tin": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "InventoryVariantInput": {
        "description": "VariantInput adds a variant to a product.",
        "properties": {
          "active": {
            "nullable": true,
            "type": "boolean"
          },
          "code": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "reorder_level": {
            "nullable": true,
            "type": "number"
          },
          "sale_price": {
            "nullable": true,
            "type": "number"
          },
          "unit_id": {
            "nullable": true,
            "type": "string"
          },
          "variant_attributes": {
            "additionalProperties": {},
            "type": "object"
          }
        },
        "type": "object"
      },
      "OperationsCaseInput": {
        "description": "CaseInput records a case.  table: notifiable_cases — its vocabularies come from that table's CHECK lists.",
        "properties": {
          "age_years": {
            "nullable": true,
            "type": "integer"
          },
          "classification": {
            "enum": [
              "SUSPECTED",
              "PROBABLE",
              "CONFIRMED",
              "DISCARDED"
            ],
            "type": "string"
          },
          "condition_id": {
            "nullable": true,
            "type": "string"
          },
          "condition_name": {
            "type": "string"
          },
          "lab_confirmed": {
            "type": "boolean"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "onset_on": {
            "nullable": true,
            "type": "string"
          },
          "outcome": {
            "enum": [
              "UNDER_TREATMENT",
              "RECOVERED",
              "REFERRED",
              "DIED",
              "UNKNOWN"
            ],
            "type": "string"
          },
          "patient_id": {
            "nullable": true,
            "type": "string"
          },
          "patient_name": {
            "type": "string"
          },
          "reported_by": {
            "nullable": true,
            "type": "string"
          },
          "sex": {
            "enum": [
              "Male",
              "Female",
              "Ambiguous"
            ],
            "nullable": true,
            "type": "string"
          },
          "specimen_taken": {
            "type": "boolean"
          },
          "village": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "OperationsCondition": {
        "description": "Condition is a notifiable condition.",
        "properties": {
          "active": {
            "type": "boolean"
          },
          "case_definition": {
            "nullable": true,
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "urgency": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "OperationsIntegration": {
        "description": "Integration is one outside connection.",
        "properties": {
          "code": {
            "type": "string"
          },
          "credential_present": {
            "description": "Whether that name currently resolves to anything.",
            "type": "boolean"
          },
          "credential_ref": {
            "description": "The NAME of a secret, never the secret.",
            "nullable": true,
            "type": "string"
          },
          "days_since_ok": {
            "description": "DaysSinceOK — negative is impossible; null means never reached at all, which is a different and worse answer than \"a long time ago\".",
            "nullable": true,
            "type": "integer"
          },
          "enabled": {
            "type": "boolean"
          },
          "endpoint": {
            "nullable": true,
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "kind": {
            "enum": [
              "SMS",
              "PAYMENT",
              "INSURANCE",
              "REPORTING",
              "LAB",
              "IMAGING",
              "EMAIL",
              "OTHER"
            ],
            "type": "string"
          },
          "last_error": {
            "nullable": true,
            "type": "string"
          },
          "last_error_at": {
            "nullable": true,
            "type": "string"
          },
          "last_ok_at": {
            "nullable": true,
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "OperationsMessageInput": {
        "description": "MessageInput queues a message.",
        "properties": {
          "body": {
            "type": "string"
          },
          "channel": {
            "enum": [
              "SMS",
              "EMAIL",
              "WHATSAPP",
              "IN_APP"
            ],
            "type": "string"
          },
          "patient_id": {
            "nullable": true,
            "type": "string"
          },
          "recipient": {
            "type": "string"
          },
          "recipient_name": {
            "nullable": true,
            "type": "string"
          },
          "subject": {
            "nullable": true,
            "type": "string"
          },
          "template_id": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "OperationsTemplate": {
        "description": "Template is a message template.  table: message_templates — its vocabularies come from that table's CHECK lists.",
        "properties": {
          "active": {
            "type": "boolean"
          },
          "body": {
            "type": "string"
          },
          "category": {
            "enum": [
              "APPOINTMENT",
              "RESULT",
              "BILLING",
              "FOLLOW_UP",
              "CAMPAIGN",
              "GENERAL"
            ],
            "type": "string"
          },
          "channel": {
            "enum": [
              "SMS",
              "EMAIL",
              "WHATSAPP",
              "IN_APP"
            ],
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "placeholders": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "subject": {
            "nullable": true,
            "type": "string"
          },
          "used_count": {
            "description": "UsedCount so a template nobody uses is visible.",
            "type": "integer"
          }
        },
        "type": "object"
      },
      "OrganizationDepartmentInput": {
        "description": "DepartmentInput opens or edits a cost centre.",
        "properties": {
          "annual_budget": {
            "nullable": true,
            "type": "number"
          },
          "code": {
            "type": "string"
          },
          "head_name": {
            "nullable": true,
            "type": "string"
          },
          "head_user_id": {
            "nullable": true,
            "type": "string"
          },
          "kind": {
            "enum": [
              "Clinical",
              "Diagnostic",
              "Support",
              "Administrative"
            ],
            "nullable": true,
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "phone": {
            "nullable": true,
            "type": "string"
          },
          "status": {
            "enum": [
              "Active",
              "Inactive"
            ],
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "OrganizationFacilityInput": {
        "description": "FacilityInput opens or edits a branch.",
        "properties": {
          "address": {
            "nullable": true,
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "district": {
            "nullable": true,
            "type": "string"
          },
          "email": {
            "nullable": true,
            "type": "string"
          },
          "is_primary": {
            "nullable": true,
            "type": "boolean"
          },
          "licensed_beds": {
            "nullable": true,
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "ownership": {
            "enum": [
              "Public",
              "Private",
              "Faith-based",
              "Parastatal"
            ],
            "nullable": true,
            "type": "string"
          },
          "phone": {
            "nullable": true,
            "type": "string"
          },
          "region": {
            "nullable": true,
            "type": "string"
          },
          "status": {
            "enum": [
              "Active",
              "Inactive"
            ],
            "nullable": true,
            "type": "string"
          },
          "tier": {
            "enum": [
              "Dispensary",
              "Clinic",
              "Health Centre",
              "Medical Centre",
              "Hospital",
              "Referral Hospital"
            ],
            "nullable": true,
            "type": "string"
          },
          "ward": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "OrganizationLocationInput": {
        "description": "LocationInput opens or edits a place.",
        "properties": {
          "building": {
            "nullable": true,
            "type": "string"
          },
          "capacity": {
            "nullable": true,
            "type": "integer"
          },
          "code": {
            "type": "string"
          },
          "department_id": {
            "nullable": true,
            "type": "string"
          },
          "floor": {
            "nullable": true,
            "type": "string"
          },
          "kind": {
            "enum": [
              "Room",
              "Counter",
              "Ward",
              "Theatre",
              "Store",
              "Laboratory",
              "Office",
              "Other"
            ],
            "nullable": true,
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "enum": [
              "Active",
              "Inactive"
            ],
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "OrganizationOrganizationInput": {
        "description": "OrganizationInput edits the organisation. Every field is optional; absent means unchanged.",
        "properties": {
          "address": {
            "nullable": true,
            "type": "string"
          },
          "country": {
            "nullable": true,
            "type": "string"
          },
          "currency": {
            "nullable": true,
            "type": "string"
          },
          "district": {
            "nullable": true,
            "type": "string"
          },
          "email": {
            "nullable": true,
            "type": "string"
          },
          "fiscal_year_start": {
            "nullable": true,
            "type": "integer"
          },
          "legal_name": {
            "nullable": true,
            "type": "string"
          },
          "licence_expiry": {
            "nullable": true,
            "type": "string"
          },
          "licence_no": {
            "nullable": true,
            "type": "string"
          },
          "logo_url": {
            "nullable": true,
            "type": "string"
          },
          "name": {
            "nullable": true,
            "type": "string"
          },
          "ownership": {
            "enum": [
              "Public",
              "Private",
              "Faith-based",
              "Parastatal"
            ],
            "nullable": true,
            "type": "string"
          },
          "phone": {
            "nullable": true,
            "type": "string"
          },
          "region": {
            "nullable": true,
            "type": "string"
          },
          "registration_no": {
            "nullable": true,
            "type": "string"
          },
          "timezone": {
            "nullable": true,
            "type": "string"
          },
          "tin": {
            "nullable": true,
            "type": "string"
          },
          "vrn": {
            "nullable": true,
            "type": "string"
          },
          "website": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "PageMeta": {
        "properties": {
          "current_page": {
            "example": 1,
            "type": "integer"
          },
          "last_page": {
            "example": 4,
            "type": "integer"
          },
          "per_page": {
            "example": 50,
            "type": "integer"
          },
          "total": {
            "example": 173,
            "type": "integer"
          }
        },
        "required": [
          "current_page",
          "per_page",
          "last_page",
          "total"
        ],
        "type": "object"
      },
      "PagedEnvelope": {
        "properties": {
          "data": {
            "items": {},
            "type": "array"
          },
          "message": {
            "type": "string"
          },
          "meta": {
            "$ref": "#/components/schemas/PageMeta"
          },
          "success": {
            "example": true,
            "type": "boolean"
          }
        },
        "required": [
          "success",
          "message",
          "data",
          "meta"
        ],
        "type": "object"
      },
      "PatientsInput": {
        "description": "Input creates or edits a file. Optional fields are pointers so an update can distinguish \"clear this\" from \"leave it alone\".  table: patients — its vocabularies come from that table's CHECK lists.",
        "properties": {
          "address": {
            "nullable": true,
            "type": "string"
          },
          "age_years": {
            "nullable": true,
            "type": "integer"
          },
          "allergies": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "blood_group": {
            "enum": [
              "A+",
              "A-",
              "B+",
              "B-",
              "AB+",
              "AB-",
              "O+",
              "O-",
              "Unknown"
            ],
            "nullable": true,
            "type": "string"
          },
          "chronic_conditions": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "date_of_birth": {
            "nullable": true,
            "type": "string"
          },
          "date_of_death": {
            "nullable": true,
            "type": "string"
          },
          "district": {
            "nullable": true,
            "type": "string"
          },
          "email": {
            "nullable": true,
            "type": "string"
          },
          "first_name": {
            "type": "string"
          },
          "gender": {
            "enum": [
              "Male",
              "Female",
              "Other",
              "Unknown"
            ],
            "type": "string"
          },
          "insurance_expiry": {
            "nullable": true,
            "type": "string"
          },
          "insurance_number": {
            "nullable": true,
            "type": "string"
          },
          "insurance_provider": {
            "nullable": true,
            "type": "string"
          },
          "last_name": {
            "type": "string"
          },
          "marital_status": {
            "nullable": true,
            "type": "string"
          },
          "middle_name": {
            "nullable": true,
            "type": "string"
          },
          "national_id": {
            "nullable": true,
            "type": "string"
          },
          "next_of_kin": {
            "nullable": true,
            "type": "string"
          },
          "next_of_kin_phone": {
            "nullable": true,
            "type": "string"
          },
          "next_of_kin_relation": {
            "nullable": true,
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "occupation": {
            "nullable": true,
            "type": "string"
          },
          "patient_number": {
            "description": "PatientNumber is normally left empty and issued by the server.",
            "type": "string"
          },
          "phone": {
            "nullable": true,
            "type": "string"
          },
          "region": {
            "nullable": true,
            "type": "string"
          },
          "registered_date": {
            "nullable": true,
            "type": "string"
          },
          "status": {
            "enum": [
              "active",
              "inactive",
              "deceased"
            ],
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "PlatformAnnouncementInput": {
        "description": "AnnouncementInput posts one.",
        "properties": {
          "body": {
            "type": "string"
          },
          "department": {
            "nullable": true,
            "type": "string"
          },
          "expires_at": {
            "nullable": true,
            "type": "string"
          },
          "pinned": {
            "nullable": true,
            "type": "boolean"
          },
          "publish": {
            "nullable": true,
            "type": "boolean"
          },
          "title": {
            "type": "string"
          },
          "urgency": {
            "enum": [
              "NORMAL",
              "IMPORTANT",
              "URGENT"
            ],
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "PlatformApprovalInput": {
        "description": "ApprovalInput asks for a signature.",
        "properties": {
          "amount": {
            "nullable": true,
            "type": "number"
          },
          "assigned_to": {
            "nullable": true,
            "type": "string"
          },
          "detail": {
            "nullable": true,
            "type": "string"
          },
          "entity": {
            "nullable": true,
            "type": "string"
          },
          "entity_id": {
            "nullable": true,
            "type": "string"
          },
          "kind": {
            "enum": [
              "EXPENSE",
              "DISCOUNT",
              "LEAVE",
              "PURCHASE",
              "WRITE_OFF",
              "OVERTIME",
              "OTHER"
            ],
            "type": "string"
          },
          "title": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "PlatformDocumentInput": {
        "description": "DocumentInput files one.",
        "properties": {
          "category": {
            "enum": [
              "LICENCE",
              "CONTRACT",
              "CERTIFICATE",
              "POLICY",
              "INSURANCE",
              "LEASE",
              "OTHER"
            ],
            "nullable": true,
            "type": "string"
          },
          "counterparty": {
            "nullable": true,
            "type": "string"
          },
          "department": {
            "nullable": true,
            "type": "string"
          },
          "expires_on": {
            "nullable": true,
            "type": "string"
          },
          "file_url": {
            "nullable": true,
            "type": "string"
          },
          "issued_on": {
            "nullable": true,
            "type": "string"
          },
          "location": {
            "nullable": true,
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "owner_name": {
            "nullable": true,
            "type": "string"
          },
          "reference": {
            "nullable": true,
            "type": "string"
          },
          "status": {
            "enum": [
              "ACTIVE",
              "EXPIRED",
              "SUPERSEDED",
              "ARCHIVED"
            ],
            "nullable": true,
            "type": "string"
          },
          "title": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "PlatformStaffInput": {
        "description": "StaffInput adds or edits a staff record.  table: staff_members — its vocabularies come from that table's CHECK lists.",
        "properties": {
          "bank_account": {
            "nullable": true,
            "type": "string"
          },
          "bank_name": {
            "nullable": true,
            "type": "string"
          },
          "basic_pay": {
            "nullable": true,
            "type": "number"
          },
          "cadre": {
            "nullable": true,
            "type": "string"
          },
          "date_of_birth": {
            "nullable": true,
            "type": "string"
          },
          "department": {
            "nullable": true,
            "type": "string"
          },
          "email": {
            "nullable": true,
            "type": "string"
          },
          "employment_type": {
            "enum": [
              "PERMANENT",
              "CONTRACT",
              "LOCUM",
              "INTERN",
              "VOLUNTEER"
            ],
            "nullable": true,
            "type": "string"
          },
          "ended_on": {
            "nullable": true,
            "type": "string"
          },
          "first_name": {
            "type": "string"
          },
          "gender": {
            "enum": [
              "Male",
              "Female",
              "Other",
              "Unknown"
            ],
            "nullable": true,
            "type": "string"
          },
          "job_title": {
            "type": "string"
          },
          "last_name": {
            "type": "string"
          },
          "licence_body": {
            "nullable": true,
            "type": "string"
          },
          "licence_expiry": {
            "nullable": true,
            "type": "string"
          },
          "licence_no": {
            "nullable": true,
            "type": "string"
          },
          "next_of_kin": {
            "nullable": true,
            "type": "string"
          },
          "next_of_kin_phone": {
            "nullable": true,
            "type": "string"
          },
          "nhif_number": {
            "nullable": true,
            "type": "string"
          },
          "nssf_number": {
            "nullable": true,
            "type": "string"
          },
          "phone": {
            "nullable": true,
            "type": "string"
          },
          "staff_number": {
            "type": "string"
          },
          "started_on": {
            "nullable": true,
            "type": "string"
          },
          "status": {
            "enum": [
              "ACTIVE",
              "ON_LEAVE",
              "SUSPENDED",
              "LEFT"
            ],
            "nullable": true,
            "type": "string"
          },
          "tin": {
            "nullable": true,
            "type": "string"
          },
          "user_id": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "ProcurementInvoiceInput": {
        "description": "InvoiceInput records one.",
        "properties": {
          "due_date": {
            "nullable": true,
            "type": "string"
          },
          "invoice_date": {
            "nullable": true,
            "type": "string"
          },
          "invoice_number": {
            "type": "string"
          },
          "items": {
            "items": {
              "$ref": "#/components/schemas/ProcurementInvoiceItemInput"
            },
            "type": "array"
          },
          "order_id": {
            "nullable": true,
            "type": "string"
          },
          "supplier_id": {
            "type": "string"
          },
          "tax_amount": {
            "type": "number"
          }
        },
        "type": "object"
      },
      "ProcurementInvoiceItemInput": {
        "properties": {
          "account_id": {
            "nullable": true,
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "quantity": {
            "type": "number"
          },
          "receipt_item_id": {
            "nullable": true,
            "type": "string"
          },
          "unit_cost": {
            "type": "number"
          }
        },
        "type": "object"
      },
      "ProcurementOrderInput": {
        "description": "OrderInput raises one.",
        "properties": {
          "expected_on": {
            "nullable": true,
            "type": "string"
          },
          "items": {
            "items": {
              "$ref": "#/components/schemas/ProcurementOrderItemInput"
            },
            "type": "array"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "supplier_id": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "ProcurementOrderItemInput": {
        "properties": {
          "account_id": {
            "nullable": true,
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "product_id": {
            "nullable": true,
            "type": "string"
          },
          "quantity": {
            "type": "number"
          },
          "unit_cost": {
            "type": "number"
          }
        },
        "type": "object"
      },
      "ProcurementPaymentInput": {
        "description": "PaymentInput pays one.",
        "properties": {
          "amount": {
            "type": "number"
          },
          "bank_reference": {
            "nullable": true,
            "type": "string"
          },
          "method": {
            "enum": [
              "Cash",
              "Mobile Money",
              "Card",
              "Bank Transfer",
              "Insurance",
              "Cheque",
              "Waiver"
            ],
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "ProcurementReceiptInput": {
        "description": "ReceiptInput books a delivery.",
        "properties": {
          "delivery_note": {
            "nullable": true,
            "type": "string"
          },
          "items": {
            "items": {
              "$ref": "#/components/schemas/ProcurementReceiptItemInput"
            },
            "type": "array"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "order_id": {
            "nullable": true,
            "type": "string"
          },
          "supplier_id": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "ProcurementReceiptItemInput": {
        "description": "ReceiptItemInput is one delivered line. The batch details are here rather than on the order because they are properties of what actually arrived: the supplier's batch number and its expiry are not knowable when ordering.",
        "properties": {
          "batch_number": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "expiry_date": {
            "nullable": true,
            "type": "string"
          },
          "location_id": {
            "nullable": true,
            "type": "string"
          },
          "order_item_id": {
            "nullable": true,
            "type": "string"
          },
          "product_id": {
            "nullable": true,
            "type": "string"
          },
          "quantity": {
            "type": "number"
          },
          "unit_cost": {
            "type": "number"
          }
        },
        "type": "object"
      },
      "ProgramsEnrolInput": {
        "description": "EnrolInput starts an enrolment.",
        "properties": {
          "diagnosis": {
            "nullable": true,
            "type": "string"
          },
          "enrolled_on": {
            "nullable": true,
            "type": "string"
          },
          "next_appointment": {
            "nullable": true,
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "patient_id": {
            "type": "string"
          },
          "phase": {
            "nullable": true,
            "type": "string"
          },
          "program": {
            "enum": [
              "TB",
              "CTC",
              "NCD"
            ],
            "type": "string"
          },
          "regimen": {
            "nullable": true,
            "type": "string"
          },
          "transferred_from": {
            "nullable": true,
            "type": "string"
          },
          "transferred_in": {
            "nullable": true,
            "type": "boolean"
          }
        },
        "type": "object"
      },
      "ProgramsResultInput": {
        "description": "ResultInput records a measurement.  table: program_results — its vocabularies come from that table's CHECK lists.",
        "properties": {
          "interpretation": {
            "enum": [
              "Good",
              "Borderline",
              "Poor",
              "Positive",
              "Negative"
            ],
            "nullable": true,
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "measured_on": {
            "nullable": true,
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "recorded_by": {
            "nullable": true,
            "type": "string"
          },
          "unit": {
            "nullable": true,
            "type": "string"
          },
          "value_numeric": {
            "nullable": true,
            "type": "number"
          },
          "value_text": {
            "nullable": true,
            "type": "string"
          },
          "visit_id": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "ProgramsVisitInput": {
        "description": "VisitInput records a clinic contact.",
        "properties": {
          "attended": {
            "nullable": true,
            "type": "boolean"
          },
          "doses_dispensed": {
            "nullable": true,
            "type": "integer"
          },
          "doses_expected": {
            "nullable": true,
            "type": "integer"
          },
          "missed_reason": {
            "nullable": true,
            "type": "string"
          },
          "next_appointment": {
            "nullable": true,
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "phase": {
            "nullable": true,
            "type": "string"
          },
          "regimen": {
            "nullable": true,
            "type": "string"
          },
          "scheduled_on": {
            "nullable": true,
            "type": "string"
          },
          "seen_by": {
            "nullable": true,
            "type": "string"
          },
          "weight_kg": {
            "nullable": true,
            "type": "number"
          }
        },
        "type": "object"
      },
      "ProvisionSignup": {
        "description": "Signup is what the owner filled in.",
        "properties": {
          "country": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "hospital_name": {
            "type": "string"
          },
          "language": {
            "type": "string"
          },
          "owner_name": {
            "type": "string"
          },
          "password": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "tier": {
            "enum": [
              "Dispensary",
              "Clinic",
              "Health Centre",
              "Medical Centre",
              "Hospital",
              "Referral Hospital"
            ],
            "type": "string"
          },
          "workspace": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "RchANCInput": {
        "description": "ANCInput books a pregnancy.",
        "properties": {
          "edd": {
            "nullable": true,
            "type": "string"
          },
          "gravida": {
            "nullable": true,
            "type": "integer"
          },
          "high_risk": {
            "nullable": true,
            "type": "boolean"
          },
          "lmp": {
            "nullable": true,
            "type": "string"
          },
          "para": {
            "nullable": true,
            "type": "integer"
          },
          "patient_id": {
            "type": "string"
          },
          "risk_factors": {
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "type": "object"
      },
      "RchANCVisitInput": {
        "description": "ANCVisitInput records a contact.",
        "properties": {
          "bp_diastolic": {
            "nullable": true,
            "type": "integer"
          },
          "bp_systolic": {
            "nullable": true,
            "type": "integer"
          },
          "danger_signs": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "foetal_heart_rate": {
            "nullable": true,
            "type": "integer"
          },
          "fundal_height_cm": {
            "nullable": true,
            "type": "integer"
          },
          "gestation_weeks": {
            "nullable": true,
            "type": "integer"
          },
          "haemoglobin": {
            "nullable": true,
            "type": "number"
          },
          "hiv_tested": {
            "nullable": true,
            "type": "boolean"
          },
          "iptp_given": {
            "nullable": true,
            "type": "boolean"
          },
          "iron_folate": {
            "nullable": true,
            "type": "boolean"
          },
          "llin_given": {
            "nullable": true,
            "type": "boolean"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "seen_by": {
            "nullable": true,
            "type": "string"
          },
          "syphilis_tested": {
            "nullable": true,
            "type": "boolean"
          },
          "tt_given": {
            "description": "Interventions given at this contact, added to the running counts.",
            "nullable": true,
            "type": "boolean"
          },
          "weight_kg": {
            "nullable": true,
            "type": "number"
          }
        },
        "type": "object"
      },
      "RchBirthInput": {
        "description": "BirthInput records a baby.",
        "properties": {
          "apgar_1": {
            "nullable": true,
            "type": "integer"
          },
          "apgar_5": {
            "nullable": true,
            "type": "integer"
          },
          "bcg_given": {
            "nullable": true,
            "type": "boolean"
          },
          "breastfed_within_hour": {
            "nullable": true,
            "type": "boolean"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "outcome": {
            "enum": [
              "Live birth",
              "Fresh stillbirth",
              "Macerated stillbirth",
              "Early neonatal death"
            ],
            "nullable": true,
            "type": "string"
          },
          "polio_0": {
            "nullable": true,
            "type": "boolean"
          },
          "resuscitated": {
            "nullable": true,
            "type": "boolean"
          },
          "sex": {
            "enum": [
              "Male",
              "Female",
              "Ambiguous"
            ],
            "nullable": true,
            "type": "string"
          },
          "vitamin_k": {
            "nullable": true,
            "type": "boolean"
          },
          "weight_g": {
            "nullable": true,
            "type": "integer"
          }
        },
        "type": "object"
      },
      "RchDeliveryInput": {
        "description": "DeliveryInput admits somebody in labour.",
        "properties": {
          "anc_id": {
            "nullable": true,
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "patient_id": {
            "type": "string"
          },
          "place": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "RchDeliveryOutcomeInput": {
        "description": "DeliveryOutcomeInput closes a delivery.",
        "properties": {
          "blood_loss_ml": {
            "nullable": true,
            "type": "integer"
          },
          "conducted_by": {
            "nullable": true,
            "type": "string"
          },
          "mode": {
            "enum": [
              "SVD",
              "Assisted",
              "Caesarean",
              "Breech",
              "Vacuum",
              "Forceps"
            ],
            "nullable": true,
            "type": "string"
          },
          "mother_complications": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "mother_outcome": {
            "enum": [
              "Alive",
              "Died",
              "Referred"
            ],
            "nullable": true,
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "RchFPInput": {
        "description": "FPInput starts a method.",
        "properties": {
          "counselled_on_alternatives": {
            "nullable": true,
            "type": "boolean"
          },
          "method": {
            "type": "string"
          },
          "next_due_on": {
            "nullable": true,
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "patient_id": {
            "type": "string"
          },
          "removal_due_on": {
            "nullable": true,
            "type": "string"
          },
          "side_effects": {
            "nullable": true,
            "type": "string"
          },
          "started_on": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "RchGrowthInput": {
        "description": "GrowthInput records a weighing.",
        "properties": {
          "age_months": {
            "nullable": true,
            "type": "integer"
          },
          "height_cm": {
            "nullable": true,
            "type": "number"
          },
          "measured_by": {
            "nullable": true,
            "type": "string"
          },
          "measured_on": {
            "nullable": true,
            "type": "string"
          },
          "muac_mm": {
            "nullable": true,
            "type": "integer"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "oedema": {
            "nullable": true,
            "type": "boolean"
          },
          "patient_id": {
            "type": "string"
          },
          "weight_kg": {
            "type": "number"
          }
        },
        "type": "object"
      },
      "RchPNCInput": {
        "description": "PNCInput records a postnatal contact.",
        "properties": {
          "baby_danger_signs": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "baby_temp": {
            "nullable": true,
            "type": "number"
          },
          "baby_weight_g": {
            "nullable": true,
            "type": "integer"
          },
          "bleeding": {
            "nullable": true,
            "type": "string"
          },
          "cord_condition": {
            "nullable": true,
            "type": "string"
          },
          "family_planning_counselled": {
            "nullable": true,
            "type": "boolean"
          },
          "feeding": {
            "nullable": true,
            "type": "string"
          },
          "mother_bp_diastolic": {
            "nullable": true,
            "type": "integer"
          },
          "mother_bp_systolic": {
            "nullable": true,
            "type": "integer"
          },
          "mother_danger_signs": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "mother_temp": {
            "nullable": true,
            "type": "number"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "seen_by": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "StackAppraisalInput": {
        "description": "AppraisalInput opens or edits a review.",
        "properties": {
          "employee_comment": {
            "type": "string"
          },
          "period": {
            "type": "string"
          },
          "period_end": {
            "type": "string"
          },
          "period_start": {
            "type": "string"
          },
          "promotion_recommended": {
            "nullable": true,
            "type": "boolean"
          },
          "rating": {
            "type": "string"
          },
          "rating_label": {
            "type": "string"
          },
          "reviewer_staff_id": {
            "type": "string"
          },
          "staff_id": {
            "description": "StaffID is required when opening; ignored on an edit, because an appraisal does not move between people.",
            "type": "string"
          },
          "summary": {
            "type": "string"
          },
          "type": {
            "enum": [
              "self",
              "manager",
              "peer",
              "360"
            ],
            "type": "string"
          }
        },
        "type": "object"
      },
      "StackAttendanceInput": {
        "description": "AttendanceInput records a day.",
        "properties": {
          "clock_in": {
            "nullable": true,
            "type": "string"
          },
          "clock_out": {
            "nullable": true,
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "reason": {
            "description": "Reason is required when this CHANGES a day already recorded.",
            "nullable": true,
            "type": "string"
          },
          "staff_id": {
            "type": "string"
          },
          "status": {
            "enum": [
              "PRESENT",
              "LATE",
              "ABSENT",
              "ON_LEAVE",
              "OFF_DUTY",
              "SICK",
              "HALF_DAY"
            ],
            "type": "string"
          },
          "work_date": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "StackConfirmInput": {
        "description": "ConfirmInput completes somebody's probation.",
        "properties": {
          "confirmed_on": {
            "description": "ConfirmedOn defaults to today when blank.",
            "type": "string"
          },
          "new_status": {
            "description": "NewStatus is what they become.",
            "type": "string"
          },
          "notes": {
            "type": "string"
          },
          "staff_id": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "StackContractInput": {
        "description": "ContractInput sets the terms somebody is employed on.  # WHY THIS EXISTS  The Contracts and Onboarding screens showed a computed view over hr-service's employees — the type, the dates, the probation, whether it has lapsed — and there was NO WAY to write any of it, from this backend or from either client. A contract that runs out could be seen and not renewed; probation could be seen to be overdue and its months could not be corrected. hr-service has answered `PUT /internal/employees/{id}` since it was written; nothing here called it.  Every field is optional. What is left blank is left ALONE rather than blanked: renewing a contract should not clear somebody's probation record.",
        "properties": {
          "contract_end": {
            "description": "ContractEnd empty means open-ended.",
            "nullable": true,
            "type": "string"
          },
          "contract_start": {
            "nullable": true,
            "type": "string"
          },
          "employment_type": {
            "description": "EmploymentType is the catalogue code.",
            "enum": [
              "permanent",
              "contract",
              "locum",
              "intern",
              "casual",
              "volunteer"
            ],
            "nullable": true,
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "probation_end": {
            "nullable": true,
            "type": "string"
          },
          "probation_months": {
            "nullable": true,
            "type": "integer"
          }
        },
        "type": "object"
      },
      "StackDepartmentInput": {
        "description": "DepartmentInput opens or edits one. Pointers throughout, so an edit that names two fields does not blank the other six — hr-service treats an absent field as \"leave it\".",
        "properties": {
          "code": {
            "nullable": true,
            "type": "string"
          },
          "description": {
            "nullable": true,
            "type": "string"
          },
          "manager_id": {
            "nullable": true,
            "type": "string"
          },
          "name": {
            "nullable": true,
            "type": "string"
          },
          "parent_id": {
            "nullable": true,
            "type": "string"
          },
          "status": {
            "enum": [
              "Active",
              "Inactive"
            ],
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "StackEmployeeDocumentInput": {
        "description": "EmployeeDocumentInput files a paper, or edits what is recorded about one.",
        "properties": {
          "expires_on": {
            "nullable": true,
            "type": "string"
          },
          "file_id": {
            "nullable": true,
            "type": "string"
          },
          "file_name": {
            "nullable": true,
            "type": "string"
          },
          "issued_on": {
            "nullable": true,
            "type": "string"
          },
          "issuer": {
            "nullable": true,
            "type": "string"
          },
          "mime_type": {
            "nullable": true,
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "number": {
            "nullable": true,
            "type": "string"
          },
          "size_bytes": {
            "format": "int64",
            "nullable": true,
            "type": "integer"
          },
          "staff_id": {
            "description": "StaffID is required when filing; ignored on an edit, because a document does not move between people.",
            "type": "string"
          },
          "status": {
            "nullable": true,
            "type": "string"
          },
          "type_code": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "StackFormAnswer": {
        "description": "FormAnswer is one reply to one question.",
        "properties": {
          "question_id": {
            "type": "string"
          },
          "value": {
            "description": "Value is whatever the question type calls for: a string, a number, a boolean, a list of chosen options."
          }
        },
        "type": "object"
      },
      "StackHRSettingInput": {
        "description": "HRSettingInput adds or edits an entry.",
        "properties": {
          "code": {
            "nullable": true,
            "type": "string"
          },
          "description": {
            "nullable": true,
            "type": "string"
          },
          "extra": {
            "additionalProperties": {},
            "description": "Extra is merged into the body as the catalogue's own columns.",
            "type": "object"
          },
          "name": {
            "nullable": true,
            "type": "string"
          },
          "status": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "StackJobPositionInput": {
        "description": "PositionInput opens or edits a post.",
        "properties": {
          "code": {
            "nullable": true,
            "type": "string"
          },
          "currency": {
            "nullable": true,
            "type": "string"
          },
          "default_role_code": {
            "nullable": true,
            "type": "string"
          },
          "department_id": {
            "nullable": true,
            "type": "string"
          },
          "description": {
            "nullable": true,
            "type": "string"
          },
          "headcount_limit": {
            "nullable": true,
            "type": "integer"
          },
          "level": {
            "nullable": true,
            "type": "integer"
          },
          "max_salary": {
            "nullable": true,
            "type": "string"
          },
          "min_salary": {
            "nullable": true,
            "type": "string"
          },
          "name": {
            "nullable": true,
            "type": "string"
          },
          "requires_system_access": {
            "nullable": true,
            "type": "boolean"
          },
          "status": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "StackLeaveInput": {
        "description": "LeaveInput applies for leave.",
        "properties": {
          "days": {
            "type": "number"
          },
          "ends_on": {
            "type": "string"
          },
          "handover_to": {
            "nullable": true,
            "type": "string"
          },
          "leave_type": {
            "type": "string"
          },
          "reason": {
            "nullable": true,
            "type": "string"
          },
          "staff_id": {
            "type": "string"
          },
          "starts_on": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "StackObjectiveInput": {
        "description": "ObjectiveInput sets or edits an objective.",
        "properties": {
          "appraisal_id": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "due_date": {
            "type": "string"
          },
          "metric": {
            "type": "string"
          },
          "progress": {
            "nullable": true,
            "type": "integer"
          },
          "staff_id": {
            "type": "string"
          },
          "status": {
            "enum": [
              "draft",
              "active",
              "achieved",
              "missed",
              "cancelled"
            ],
            "type": "string"
          },
          "target": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "weight": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "StackPayDeductionInput": {
        "description": "PayDeductionInput starts a standing amount, or edits one.",
        "properties": {
          "amount_per_period": {
            "nullable": true,
            "type": "string"
          },
          "component_code": {
            "nullable": true,
            "type": "string"
          },
          "end_period": {
            "nullable": true,
            "type": "integer"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "recovered_amount": {
            "nullable": true,
            "type": "string"
          },
          "source": {
            "nullable": true,
            "type": "string"
          },
          "source_reference": {
            "nullable": true,
            "type": "string"
          },
          "staff_id": {
            "description": "StaffID is required when starting one; ignored on an edit, because a debt does not move between people.",
            "type": "string"
          },
          "start_period": {
            "nullable": true,
            "type": "integer"
          },
          "status": {
            "nullable": true,
            "type": "string"
          },
          "total_amount": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "StackPayPalSettingsInput": {
        "description": "PayPalSettingsInput saves them. An empty Secret keeps the stored one.",
        "properties": {
          "brand_name": {
            "type": "string"
          },
          "client_id": {
            "type": "string"
          },
          "environment": {
            "type": "string"
          },
          "secret": {
            "nullable": true,
            "type": "string"
          },
          "webhook_id": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "StackQuestion": {
        "description": "Question is one thing asked.",
        "properties": {
          "description": {
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "options": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "position": {
            "type": "integer"
          },
          "required": {
            "type": "boolean"
          },
          "type": {
            "enum": [
              "text",
              "textarea",
              "single_choice",
              "multi_choice",
              "rating",
              "nps",
              "boolean",
              "number"
            ],
            "type": "string"
          }
        },
        "type": "object"
      },
      "StackReinstateInput": {
        "description": "ReinstateInput puts somebody back on duty.",
        "properties": {
          "effective_date": {
            "type": "string"
          },
          "new_status": {
            "type": "string"
          },
          "reason": {
            "type": "string"
          },
          "staff_id": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "StackSalaryGradeInput": {
        "description": "SalaryGradeInput opens or edits a band.",
        "properties": {
          "code": {
            "nullable": true,
            "type": "string"
          },
          "currency": {
            "nullable": true,
            "type": "string"
          },
          "description": {
            "nullable": true,
            "type": "string"
          },
          "level": {
            "nullable": true,
            "type": "integer"
          },
          "max_salary": {
            "nullable": true,
            "type": "string"
          },
          "min_salary": {
            "nullable": true,
            "type": "string"
          },
          "name": {
            "nullable": true,
            "type": "string"
          },
          "status": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "StackServiceProviderPatch": {
        "description": "ServiceProviderPatch is what a settings screen may change about a provider.",
        "properties": {
          "is_active": {
            "nullable": true,
            "type": "boolean"
          },
          "is_default": {
            "nullable": true,
            "type": "boolean"
          },
          "settings": {
            "additionalProperties": {},
            "type": "object"
          }
        },
        "type": "object"
      },
      "StackShiftInput": {
        "description": "ShiftInput declares how many people a slot needs.",
        "properties": {
          "department": {
            "type": "string"
          },
          "ends_at": {
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "required": {
            "type": "integer"
          },
          "shift_date": {
            "type": "string"
          },
          "slot": {
            "type": "string"
          },
          "starts_at": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "StackSuspendInput": {
        "description": "SuspendInput takes somebody off duty without ending their employment.",
        "properties": {
          "effective_date": {
            "type": "string"
          },
          "reason": {
            "type": "string"
          },
          "staff_id": {
            "type": "string"
          },
          "until_date": {
            "description": "UntilDate is when the suspension is expected to lift.",
            "type": "string"
          },
          "with_pay": {
            "description": "WithPay decides whether payroll keeps paying, and it is a pointer because there is no safe default.",
            "nullable": true,
            "type": "boolean"
          }
        },
        "type": "object"
      },
      "StackTaxBand": {
        "description": "TaxBand is one line of the gazetted PAYE table.",
        "properties": {
          "description": {
            "type": "string"
          },
          "effective_from": {
            "type": "string"
          },
          "fixed_amount": {
            "description": "FixedAmount is what the bands BELOW this one come to.",
            "type": "number"
          },
          "id": {
            "type": "string"
          },
          "lower_bound": {
            "type": "number"
          },
          "rate": {
            "description": "Rate as a percentage, the way the table is published.",
            "type": "number"
          },
          "upper_bound": {
            "description": "UpperBound null is the top band, which has no ceiling.",
            "nullable": true,
            "type": "number"
          }
        },
        "type": "object"
      },
      "StackTerminateInput": {
        "description": "TerminateInput ends somebody's employment.",
        "properties": {
          "eligible_for_rehire": {
            "description": "EligibleForRehire is a pointer so \"not stated\" is distinguishable from \"no\".",
            "nullable": true,
            "type": "boolean"
          },
          "exit_reason": {
            "type": "string"
          },
          "exit_type": {
            "description": "ExitType is required.",
            "enum": [
              "resignation",
              "dismissal",
              "redundancy",
              "retirement",
              "contract_expiry",
              "death",
              "abscondment"
            ],
            "type": "string"
          },
          "final_status": {
            "type": "string"
          },
          "staff_id": {
            "type": "string"
          },
          "termination_date": {
            "description": "TerminationDate defaults to today when blank.",
            "type": "string"
          }
        },
        "type": "object"
      },
      "StackTransferInput": {
        "description": "TransferInput moves somebody between departments, posts or branches.",
        "properties": {
          "effective_date": {
            "type": "string"
          },
          "event_type": {
            "description": "EventType says what KIND of move this is — transfer, promotion, demotion, redeployment.",
            "enum": [
              "transfer",
              "promotion",
              "demotion",
              "redeployment"
            ],
            "type": "string"
          },
          "reason": {
            "type": "string"
          },
          "staff_id": {
            "type": "string"
          },
          "to_branch_id": {
            "type": "string"
          },
          "to_department_id": {
            "type": "string"
          },
          "to_manager_id": {
            "type": "string"
          },
          "to_position_id": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "SupportAssetAssignment": {
        "description": "AssetAssignment issues a piece of equipment to somebody, or takes it back.  TWO ACTS, ONE SHAPE. Issuing sets who has it and when it is due; returning sets the date it came back. They share a struct because they are the same row being written twice, and separating them into two endpoints would let one be used to overwrite the other's fields by accident.",
        "properties": {
          "assigned_on": {
            "nullable": true,
            "type": "string"
          },
          "due_back_on": {
            "nullable": true,
            "type": "string"
          },
          "note": {
            "nullable": true,
            "type": "string"
          },
          "returned_on": {
            "nullable": true,
            "type": "string"
          },
          "staff_id": {
            "description": "StaffID empty RETURNS the asset: it goes back to belonging to a location rather than to a person.",
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "SupportAssetEventInput": {
        "description": "AssetEventInput logs one.  table: asset_events — its vocabularies come from that table's CHECK lists.",
        "properties": {
          "cost": {
            "nullable": true,
            "type": "number"
          },
          "detail": {
            "type": "string"
          },
          "downtime_hours": {
            "nullable": true,
            "type": "integer"
          },
          "kind": {
            "enum": [
              "SERVICE",
              "REPAIR",
              "BREAKDOWN",
              "INSPECTION",
              "MOVE",
              "CONDEMN"
            ],
            "nullable": true,
            "type": "string"
          },
          "performed_by": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "SupportAssetInput": {
        "description": "AssetInput adds or edits equipment.",
        "properties": {
          "category": {
            "nullable": true,
            "type": "string"
          },
          "department": {
            "nullable": true,
            "type": "string"
          },
          "location_id": {
            "nullable": true,
            "type": "string"
          },
          "make_model": {
            "nullable": true,
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "purchase_cost": {
            "nullable": true,
            "type": "number"
          },
          "purchased_on": {
            "nullable": true,
            "type": "string"
          },
          "serial_no": {
            "nullable": true,
            "type": "string"
          },
          "service_every_days": {
            "nullable": true,
            "type": "integer"
          },
          "status": {
            "enum": [
              "IN_SERVICE",
              "UNDER_REPAIR",
              "AWAITING_PARTS",
              "CONDEMNED",
              "DISPOSED"
            ],
            "nullable": true,
            "type": "string"
          },
          "status_reason": {
            "nullable": true,
            "type": "string"
          },
          "tag": {
            "type": "string"
          },
          "warranty_until": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "SupportBloodRequestInput": {
        "description": "BloodRequestInput asks for blood.",
        "properties": {
          "blood_group": {
            "nullable": true,
            "type": "string"
          },
          "component": {
            "enum": [
              "WHOLE_BLOOD",
              "PACKED_CELLS",
              "PLASMA",
              "PLATELETS",
              "CRYOPRECIPITATE"
            ],
            "nullable": true,
            "type": "string"
          },
          "indication": {
            "nullable": true,
            "type": "string"
          },
          "patient_id": {
            "type": "string"
          },
          "units": {
            "nullable": true,
            "type": "integer"
          },
          "urgency": {
            "enum": [
              "ROUTINE",
              "URGENT",
              "EMERGENCY"
            ],
            "nullable": true,
            "type": "string"
          },
          "visit_id": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "SupportBloodUnitInput": {
        "description": "BloodUnitInput books a unit in.",
        "properties": {
          "blood_group": {
            "enum": [
              "A+",
              "A-",
              "B+",
              "B-",
              "AB+",
              "AB-",
              "O+",
              "O-"
            ],
            "type": "string"
          },
          "collected_on": {
            "nullable": true,
            "type": "string"
          },
          "component": {
            "enum": [
              "WHOLE_BLOOD",
              "PACKED_CELLS",
              "PLASMA",
              "PLATELETS",
              "CRYOPRECIPITATE"
            ],
            "nullable": true,
            "type": "string"
          },
          "donor_reference": {
            "nullable": true,
            "type": "string"
          },
          "expires_on": {
            "type": "string"
          },
          "screen_notes": {
            "nullable": true,
            "type": "string"
          },
          "screened": {
            "nullable": true,
            "type": "boolean"
          },
          "unit_number": {
            "type": "string"
          },
          "volume_ml": {
            "nullable": true,
            "type": "integer"
          }
        },
        "type": "object"
      },
      "SupportBodyInput": {
        "description": "BodyInput receives a body.",
        "properties": {
          "bay_id": {
            "nullable": true,
            "type": "string"
          },
          "cause_of_death": {
            "nullable": true,
            "type": "string"
          },
          "certificate_no": {
            "nullable": true,
            "type": "string"
          },
          "certified_by": {
            "nullable": true,
            "type": "string"
          },
          "died_at": {
            "nullable": true,
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "patient_id": {
            "nullable": true,
            "type": "string"
          },
          "received_from": {
            "nullable": true,
            "type": "string"
          },
          "unknown_label": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "SupportReleaseInput": {
        "description": "ReleaseInput releases a body to a named person.",
        "properties": {
          "receiver_id_number": {
            "type": "string"
          },
          "receiver_id_type": {
            "type": "string"
          },
          "receiver_name": {
            "type": "string"
          },
          "receiver_relation": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "SupportTripInput": {
        "description": "TripInput dispatches a vehicle.  table: vehicle_trips — its vocabularies come from that table's CHECK lists.",
        "properties": {
          "crew": {
            "nullable": true,
            "type": "string"
          },
          "driver": {
            "nullable": true,
            "type": "string"
          },
          "from_place": {
            "nullable": true,
            "type": "string"
          },
          "kind": {
            "enum": [
              "EMERGENCY",
              "TRANSFER",
              "DISCHARGE",
              "ERRAND"
            ],
            "nullable": true,
            "type": "string"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "patient_id": {
            "nullable": true,
            "type": "string"
          },
          "to_place": {
            "nullable": true,
            "type": "string"
          },
          "vehicle_id": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "SupportVehicleInput": {
        "description": "VehicleInput adds or edits a vehicle.",
        "properties": {
          "capability": {
            "enum": [
              "BLS",
              "ALS"
            ],
            "nullable": true,
            "type": "string"
          },
          "fuel_pct": {
            "nullable": true,
            "type": "integer"
          },
          "inspection_expiry": {
            "nullable": true,
            "type": "string"
          },
          "insurance_expiry": {
            "nullable": true,
            "type": "string"
          },
          "kind": {
            "enum": [
              "AMBULANCE",
              "UTILITY",
              "MOTORCYCLE",
              "OTHER"
            ],
            "nullable": true,
            "type": "string"
          },
          "make_model": {
            "nullable": true,
            "type": "string"
          },
          "odometer_km": {
            "nullable": true,
            "type": "integer"
          },
          "registration": {
            "type": "string"
          },
          "status": {
            "enum": [
              "AVAILABLE",
              "ON_TRIP",
              "MAINTENANCE",
              "OUT_OF_SERVICE"
            ],
            "nullable": true,
            "type": "string"
          },
          "status_reason": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "TheatreChecklistInput": {
        "description": "ChecklistInput records one stage of the safety checklist.",
        "properties": {
          "by": {
            "type": "string"
          },
          "count_discrepancy_note": {
            "nullable": true,
            "type": "string"
          },
          "instruments_in": {
            "nullable": true,
            "type": "integer"
          },
          "instruments_out": {
            "nullable": true,
            "type": "integer"
          },
          "stage": {
            "enum": [
              "SIGN_IN",
              "TIME_OUT",
              "SIGN_OUT"
            ],
            "type": "string"
          },
          "swabs_in": {
            "nullable": true,
            "type": "integer"
          },
          "swabs_out": {
            "nullable": true,
            "type": "integer"
          }
        },
        "type": "object"
      },
      "TheatreOutcomeInput": {
        "description": "OutcomeInput closes an operation.  table: surgeries — its vocabularies come from that table's CHECK lists.",
        "properties": {
          "blood_loss_ml": {
            "nullable": true,
            "type": "integer"
          },
          "complications": {
            "nullable": true,
            "type": "string"
          },
          "findings": {
            "nullable": true,
            "type": "string"
          },
          "outcome": {
            "enum": [
              "Completed",
              "Abandoned",
              "Converted",
              "Died on table"
            ],
            "nullable": true,
            "type": "string"
          },
          "specimen_taken": {
            "nullable": true,
            "type": "boolean"
          }
        },
        "type": "object"
      },
      "TheatreRoomInput": {
        "description": "RoomInput adds or edits a theatre.  table: theatre_rooms — its vocabularies come from that table's CHECK lists.",
        "properties": {
          "code": {
            "type": "string"
          },
          "kind": {
            "enum": [
              "MAJOR",
              "MINOR",
              "DAY_CASE",
              "OBSTETRIC",
              "ENDOSCOPY"
            ],
            "nullable": true,
            "type": "string"
          },
          "location_id": {
            "nullable": true,
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "enum": [
              "AVAILABLE",
              "CLEANING",
              "MAINTENANCE",
              "CLOSED"
            ],
            "nullable": true,
            "type": "string"
          },
          "status_reason": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "TheatreSurgeryInput": {
        "description": "SurgeryInput schedules an operation.",
        "properties": {
          "admission_id": {
            "nullable": true,
            "type": "string"
          },
          "anaesthesia": {
            "enum": [
              "General",
              "Spinal",
              "Epidural",
              "Regional",
              "Local",
              "Sedation"
            ],
            "nullable": true,
            "type": "string"
          },
          "anaesthetist_name": {
            "nullable": true,
            "type": "string"
          },
          "indication": {
            "nullable": true,
            "type": "string"
          },
          "laterality": {
            "enum": [
              "Left",
              "Right",
              "Bilateral",
              "N/A"
            ],
            "nullable": true,
            "type": "string"
          },
          "patient_id": {
            "type": "string"
          },
          "planned_minutes": {
            "nullable": true,
            "type": "integer"
          },
          "procedure_code": {
            "nullable": true,
            "type": "string"
          },
          "procedure_name": {
            "type": "string"
          },
          "room_id": {
            "nullable": true,
            "type": "string"
          },
          "scheduled_for": {
            "type": "string"
          },
          "surgeon_name": {
            "nullable": true,
            "type": "string"
          },
          "urgency": {
            "enum": [
              "ELECTIVE",
              "URGENT",
              "EMERGENCY"
            ],
            "nullable": true,
            "type": "string"
          },
          "visit_id": {
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "VisitsInput": {
        "description": "Input opens or edits a visit.  table: visits — its vocabularies come from that table's CHECK lists.",
        "properties": {
          "acuity": {
            "nullable": true,
            "type": "integer"
          },
          "chief_complaint": {
            "nullable": true,
            "type": "string"
          },
          "clinician_id": {
            "nullable": true,
            "type": "string"
          },
          "department": {
            "nullable": true,
            "type": "string"
          },
          "diagnosis": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "examination": {
            "nullable": true,
            "type": "string"
          },
          "history": {
            "nullable": true,
            "type": "string"
          },
          "icd_codes": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "insurance_number": {
            "nullable": true,
            "type": "string"
          },
          "needs_doctor": {
            "description": "NeedsDoctor is the tick at the reception desk: is this attendance going to a doctor?  IT DECIDES A CHARGE, WHICH IS WHY IT IS ASKED RATHER THAN ASSUMED.",
            "nullable": true,
            "type": "boolean"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "outcome": {
            "enum": [
              "Treated",
              "Admitted",
              "Referred",
              "Died",
              "Left without being seen",
              "Follow-up arranged"
            ],
            "nullable": true,
            "type": "string"
          },
          "patient_id": {
            "type": "string"
          },
          "payer": {
            "nullable": true,
            "type": "string"
          },
          "referred_to": {
            "nullable": true,
            "type": "string"
          },
          "service_code": {
            "description": "ServiceCode is the tariff the attendance is being registered against — the consultation the clerk picked at the desk.",
            "nullable": true,
            "type": "string"
          },
          "status": {
            "description": "REGISTERED, or nothing, asks for the patient to be routed from the front desk — to the cashier where payment comes first, to triage where it does not — so the visit is kept at the state it was routed to.",
            "enum": [
              "REGISTERED",
              "WAITING_PAYMENT",
              "PAID",
              "WAITING_TRIAGE",
              "IN_TRIAGE",
              "WAITING_DOCTOR",
              "IN_CONSULTATION",
              "WAITING_LAB",
              "LAB_PROCESSING",
              "LAB_COMPLETED",
              "WAITING_DOCTOR_REVIEW",
              "WAITING_PHARMACY",
              "ADMITTED",
              "COMPLETED",
              "CANCELLED"
            ],
            "nullable": true,
            "type": "string"
          },
          "treatment_plan": {
            "nullable": true,
            "type": "string"
          },
          "visit_type": {
            "enum": [
              "OUTPATIENT",
              "EMERGENCY",
              "INPATIENT",
              "FOLLOW_UP",
              "ANTENATAL",
              "IMMUNISATION",
              "PROCEDURE",
              "REVIEW"
            ],
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "VisitsVitalsInput": {
        "description": "VitalsInput records one set.",
        "properties": {
          "bp_diastolic": {
            "nullable": true,
            "type": "integer"
          },
          "bp_systolic": {
            "nullable": true,
            "type": "integer"
          },
          "height_cm": {
            "nullable": true,
            "type": "number"
          },
          "notes": {
            "nullable": true,
            "type": "string"
          },
          "pain_score": {
            "nullable": true,
            "type": "integer"
          },
          "pulse_bpm": {
            "nullable": true,
            "type": "integer"
          },
          "respiratory_rate": {
            "nullable": true,
            "type": "integer"
          },
          "spo2": {
            "nullable": true,
            "type": "integer"
          },
          "temperature_c": {
            "nullable": true,
            "type": "number"
          },
          "weight_kg": {
            "nullable": true,
            "type": "number"
          }
        },
        "type": "object"
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "bearerFormat": "JWT",
        "description": "The access token from POST /api/v1/auth/login. Send it as `Authorization: Bearer \u003ctoken\u003e`.",
        "scheme": "bearer",
        "type": "http"
      },
      "internalKey": {
        "description": "The shared key the scheduler uses for /internal/jobs. Not for user-facing clients.",
        "in": "header",
        "name": "X-API-Key",
        "type": "apiKey"
      }
    }
  },
  "info": {
    "description": "The single HTTP surface behind the management console, the patient portal, and any\nmobile or desktop client built on this system. Every endpoint is generated from the\nrouter and handlers themselves, so what is written here is what the server does.",
    "title": "Selanim Medix API",
    "version": "1.0.0"
  },
  "openapi": "3.0.3",
  "paths": {
    "/": {
      "get": {
        "description": "**From the router:** Landing + liveness.\n\n**Access:** open — no token required.",
        "operationId": "getRoot",
        "responses": {
          "200": {
            "content": {
              "text/html; charset=utf-8": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "The stored file, with its own content type."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [],
        "summary": "Is the landing route. Browsers (Accept: text/html) get the Selanim Medix page below; API clients get the same information as JSON. This is the first thing an operator sees when the stack comes up.",
        "tags": [
          "meta"
        ]
      }
    },
    "/api/v1": {
      "get": {
        "description": "**Access:** open — no token required.",
        "operationId": "getApiInfo",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [],
        "summary": "Returns machine-readable project metadata plus the catalogue of services available to this backend.",
        "tags": [
          "meta"
        ]
      }
    },
    "/api/v1/access/permissions": {
      "get": {
        "description": "**Permission:** `role:read`",
        "operationId": "getAccessPermissions",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns every permission code that can be granted, grouped by the module it belongs to.",
        "tags": [
          "access"
        ],
        "x-permissions": [
          "role:read"
        ]
      }
    },
    "/api/v1/access/roles": {
      "get": {
        "description": "**Permission:** `role:read`",
        "operationId": "getAccessRoles",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns every role, each with what it grants.",
        "tags": [
          "access"
        ],
        "x-permissions": [
          "role:read"
        ]
      },
      "post": {
        "description": "**Permission:** `role:manage`",
        "operationId": "postAccessRoles",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds a role. It grants nothing until permissions are set on it.",
        "tags": [
          "access"
        ],
        "x-permissions": [
          "role:manage"
        ]
      }
    },
    "/api/v1/access/roles/{id}/permissions": {
      "put": {
        "description": "Replace, not add: an administrator unticking a box has to mean the permission goes away. Everybody holding the role is affected at once, which is what a role is for.\n\n**Permission:** `role:manage`",
        "operationId": "putAccessRolesIdPermissions",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "permissions": {
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Replaces what a role grants.",
        "tags": [
          "access"
        ],
        "x-permissions": [
          "role:manage"
        ]
      }
    },
    "/api/v1/access/users": {
      "get": {
        "description": "**Permission:** `user:read`",
        "operationId": "getAccessUsers",
        "parameters": [
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "default": 1,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "page_size",
            "required": false,
            "schema": {
              "default": 20,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PagedEnvelope"
                }
              }
            },
            "description": "A page of rows, with `meta` carrying the counts."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns a page of the account register, each with its roles.",
        "tags": [
          "access"
        ],
        "x-permissions": [
          "user:read"
        ]
      },
      "post": {
        "description": "**Permission:** `user:create`",
        "operationId": "postAccessUsers",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "email": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  },
                  "phone": {
                    "type": "string"
                  },
                  "role_code": {
                    "type": "string"
                  },
                  "username": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Opens an account. It holds nothing until a role is granted.",
        "tags": [
          "access"
        ],
        "x-permissions": [
          "user:create"
        ]
      }
    },
    "/api/v1/access/users/{id}/password-reset": {
      "post": {
        "description": "THE ADMINISTRATOR NEVER LEARNS THE PASSWORD. They start the reset; the code goes to the account's own email or phone, and only the person holding it can finish. The alternative — an administrator typing a new password for somebody — hands every administrator the ability to sign in as any clinician and leave that clinician's name on the record they write.\n\n**From the router:** Starts a reset; it does not perform one. The code goes to the account's own contact, so an administrator can unstick a locked-out nurse without ever being able to sign in as her.\n\n**Permission:** `user:update`",
        "operationId": "postAccessUsersIdPasswordReset",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Sends a reset code to an account an administrator names.",
        "tags": [
          "access"
        ],
        "x-permissions": [
          "user:update"
        ]
      }
    },
    "/api/v1/access/users/{id}/roles": {
      "get": {
        "description": "**Permission:** `user:read`",
        "operationId": "getAccessUsersIdRoles",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the roles an account holds.",
        "tags": [
          "access"
        ],
        "x-permissions": [
          "user:read"
        ]
      },
      "post": {
        "description": "**Permission:** `user:assign_role`",
        "operationId": "postAccessUsersIdRoles",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "role_code": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Gives an account a role.",
        "tags": [
          "access"
        ],
        "x-permissions": [
          "user:assign_role"
        ]
      }
    },
    "/api/v1/access/users/{id}/roles/{code}": {
      "delete": {
        "description": "**Permission:** `user:assign_role`",
        "operationId": "deleteAccessUsersIdRolesCode",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "code",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Withdraws a role.",
        "tags": [
          "access"
        ],
        "x-permissions": [
          "user:assign_role"
        ]
      }
    },
    "/api/v1/access/users/{id}/status": {
      "patch": {
        "description": "There is no delete. An account that signed a discharge summary last year has to keep existing for the summary to still name somebody.\n\n**Permission:** `user:update`",
        "operationId": "patchAccessUsersIdStatus",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "status": {
                    "enum": [
                      "active",
                      "inactive",
                      "suspended"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Activates, deactivates or suspends an account.",
        "tags": [
          "access"
        ],
        "x-permissions": [
          "user:update"
        ]
      }
    },
    "/api/v1/account/checkout": {
      "post": {
        "description": "**Permission:** `subscription:manage`\n\n**Rate limit:** 30 per hour per client address.",
        "operationId": "postAccountCheckout",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HandlersPurchaseInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Too many requests from this address."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Raises the invoice and makes the PayPal order for it. The page hands the order id to PayPal's button and keeps the reference for capture.",
        "tags": [
          "account"
        ],
        "x-permissions": [
          "subscription:manage"
        ],
        "x-rate-limit": "30 per hour"
      }
    },
    "/api/v1/account/checkout/capture": {
      "post": {
        "description": "**Permission:** `subscription:manage`",
        "operationId": "postAccountCheckoutCapture",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reference": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Takes the money for an order the payer approved and applies it to the invoice. Safe to repeat.",
        "tags": [
          "account"
        ],
        "x-permissions": [
          "subscription:manage"
        ]
      }
    },
    "/api/v1/account/export": {
      "get": {
        "description": "**Permission:** `subscription:manage`\n\n**Rate limit:** 6 per hour per client address.",
        "operationId": "getAccountExport",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Too many requests from this address."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Hands the hospital its records: every table of its database, one CSV each, in a zip. It is theirs, and a hospital that stops paying must still be able to take it away.",
        "tags": [
          "account"
        ],
        "x-permissions": [
          "subscription:manage"
        ],
        "x-rate-limit": "6 per hour"
      }
    },
    "/api/v1/account/find-workspace": {
      "post": {
        "description": "**Access:** open — no token required.\n\n**Rate limit:** 5 per hour per client address.",
        "operationId": "postAccountFindWorkspace",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "email": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Too many requests from this address."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [],
        "summary": "Emails the workspace codes an address is the owner of. It answers the same whether or not there are any, so it cannot be used to learn which addresses have signed up.",
        "tags": [
          "account"
        ],
        "x-rate-limit": "5 per hour"
      }
    },
    "/api/v1/account/invoices": {
      "get": {
        "description": "**Permission:** `subscription:manage`",
        "operationId": "getAccountInvoices",
        "parameters": [
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "page_size",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists the hospital's invoices, newest first.",
        "tags": [
          "account"
        ],
        "x-permissions": [
          "subscription:manage"
        ]
      }
    },
    "/api/v1/account/invoices/{id}": {
      "get": {
        "description": "**Permission:** `subscription:manage`",
        "operationId": "getAccountInvoicesId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is one of them, with its lines.",
        "tags": [
          "account"
        ],
        "x-permissions": [
          "subscription:manage"
        ]
      }
    },
    "/api/v1/account/invoices/{id}/pdf": {
      "get": {
        "description": "**Permission:** `subscription:manage`",
        "operationId": "getAccountInvoicesIdPdf",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "language",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/pdf": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "The document, as a PDF."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Draws an invoice — stamped paid once it is, which makes it the receipt.",
        "tags": [
          "account"
        ],
        "x-permissions": [
          "subscription:manage"
        ]
      }
    },
    "/api/v1/account/payment-config": {
      "get": {
        "description": "**Permission:** `subscription:manage`",
        "operationId": "getAccountPaymentConfig",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is what the PayPal button needs to draw itself.",
        "tags": [
          "account"
        ],
        "x-permissions": [
          "subscription:manage"
        ]
      }
    },
    "/api/v1/account/plans": {
      "get": {
        "description": "**Access:** open — no token required.\n\n**Rate limit:** 120 per minute per client address.",
        "operationId": "getAccountPlans",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Too many requests from this address."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [],
        "summary": "Are the packages on sale, with their prices and modules: the pricing on the sign-up page and the cards on the billing page. Open, like any price list in a shop window.",
        "tags": [
          "account"
        ],
        "x-rate-limit": "120 per minute"
      }
    },
    "/api/v1/account/quote": {
      "post": {
        "description": "**Permission:** `subscription:manage`",
        "operationId": "postAccountQuote",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HandlersPurchaseInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Prices a purchase without writing anything: the lines and the total the billing page shows before the PayPal button.",
        "tags": [
          "account"
        ],
        "x-permissions": [
          "subscription:manage"
        ]
      }
    },
    "/api/v1/account/signup": {
      "post": {
        "description": "**Access:** open — no token required.\n\n**Rate limit:** 10 per hour per client address.",
        "operationId": "postAccountSignup",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "accept_terms": {
                    "type": "boolean"
                  },
                  "code": {
                    "type": "string"
                  },
                  "country": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  },
                  "hospital_name": {
                    "type": "string"
                  },
                  "language": {
                    "type": "string"
                  },
                  "owner_name": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  },
                  "phone": {
                    "type": "string"
                  },
                  "tier": {
                    "enum": [
                      "Dispensary",
                      "Clinic",
                      "Health Centre",
                      "Medical Centre",
                      "Hospital",
                      "Referral Hospital"
                    ],
                    "type": "string"
                  },
                  "workspace": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Too many requests from this address."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [],
        "summary": "Makes a hospital: checks the code, registers the hospital, makes the owner's account and starts the trial, and finishes the rest in the background. The owner then waits on SignupStatus.",
        "tags": [
          "account"
        ],
        "x-rate-limit": "10 per hour"
      }
    },
    "/api/v1/account/signup/code": {
      "post": {
        "description": "**Access:** open — no token required.\n\n**Rate limit:** 10 per hour per client address.",
        "operationId": "postAccountSignupCode",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "email": {
                    "type": "string"
                  },
                  "language": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Too many requests from this address."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [],
        "summary": "Sends a six-digit code to the address a hospital is being signed up with.",
        "tags": [
          "account"
        ],
        "x-rate-limit": "10 per hour"
      }
    },
    "/api/v1/account/signup/{tenant}/status": {
      "get": {
        "description": "**Access:** open — no token required.\n\n**Rate limit:** 120 per minute per client address.",
        "operationId": "getAccountSignupTenantStatus",
        "parameters": [
          {
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Too many requests from this address."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [],
        "summary": "Is how far a new hospital's preparation has got. Open: the id is a UUID only its owner has just been given.",
        "tags": [
          "account"
        ],
        "x-rate-limit": "120 per minute"
      }
    },
    "/api/v1/account/subscription": {
      "get": {
        "description": "**Permission:** `subscription:manage`",
        "operationId": "getAccountSubscription",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is the hospital's subscription page: the plan, the dates, the branches, the invoices due, and what it may use.",
        "tags": [
          "account"
        ],
        "x-permissions": [
          "subscription:manage"
        ]
      }
    },
    "/api/v1/account/workspaces/{code}": {
      "get": {
        "description": "**Access:** open — no token required.\n\n**Rate limit:** 120 per minute per client address.",
        "operationId": "getAccountWorkspacesCode",
        "parameters": [
          {
            "in": "path",
            "name": "code",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Too many requests from this address."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [],
        "summary": "Answers whether a workspace code belongs to a hospital, and which. The sign-in screen shows the hospital's name before anybody types a password; the sign-up form asks whether a code is free.",
        "tags": [
          "account"
        ],
        "x-rate-limit": "120 per minute"
      }
    },
    "/api/v1/accounting/accounts": {
      "get": {
        "description": "Named for the chart rather than \"accounts\": ListAccounts already means user accounts in the access API, and two handlers with one name is how somebody wires a ledger route to the user directory.\n\n**Permission:** `accounting:read`",
        "operationId": "getAccountingAccounts",
        "parameters": [
          {
            "in": "query",
            "name": "inactive",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "kind",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "default": 1,
              "type": "integer"
            }
          },
          {
            "description": "Capped at 200. `page_size` is accepted as an alias.",
            "in": "query",
            "name": "per_page",
            "required": false,
            "schema": {
              "default": 50,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "postable",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "description": "Free-text filter.",
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PagedEnvelope"
                }
              }
            },
            "description": "A page of rows, with `meta` carrying the counts."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the chart with balances.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      },
      "post": {
        "description": "**Permission:** `account:manage`",
        "operationId": "postAccountingAccounts",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountingAccount"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits an account.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "account:manage"
        ]
      }
    },
    "/api/v1/accounting/accounts/{id}": {
      "delete": {
        "description": "**Permission:** `account:manage`",
        "operationId": "deleteAccountingAccountsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Removes an account nothing has used.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "account:manage"
        ]
      },
      "put": {
        "description": "**Permission:** `account:manage`",
        "operationId": "putAccountingAccountsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountingAccount"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits an account.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "account:manage"
        ]
      }
    },
    "/api/v1/accounting/accounts/{id}/move": {
      "post": {
        "description": "**Permission:** `account:manage`",
        "operationId": "postAccountingAccountsIdMove",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "parent_id": {
                    "type": "string"
                  },
                  "sort_order": {
                    "type": "integer"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Reparents an account or reorders it among its siblings.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "account:manage"
        ]
      }
    },
    "/api/v1/accounting/ageing": {
      "get": {
        "description": "**Permission:** `accounting:read`",
        "operationId": "getAccountingAgeing",
        "parameters": [
          {
            "in": "query",
            "name": "direction",
            "required": false,
            "schema": {
              "default": "receivable",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Buckets what is owed, in either direction.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      }
    },
    "/api/v1/accounting/bank": {
      "get": {
        "description": "**Permission:** `accounting:read`",
        "operationId": "getAccountingBank",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the bank and cash accounts.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      }
    },
    "/api/v1/accounting/bank/statement/{id}/match": {
      "post": {
        "description": "**Permission:** `bank:reconcile`",
        "operationId": "postAccountingBankStatementIdMatch",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "journal_line_id": {
                    "type": "string"
                  },
                  "note": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Ties a statement line to a ledger line, or unties it.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "bank:reconcile"
        ]
      }
    },
    "/api/v1/accounting/bank/{id}/statement": {
      "get": {
        "description": "**Permission:** `accounting:read`",
        "operationId": "getAccountingBankIdStatement",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 200,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "unmatched",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns a bank account's statement.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      },
      "post": {
        "description": "**Permission:** `bank:reconcile`",
        "operationId": "postAccountingBankIdStatement",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountingStatementLine"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records what the bank says.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "bank:reconcile"
        ]
      }
    },
    "/api/v1/accounting/budgets": {
      "get": {
        "description": "**Permission:** `accounting:read`",
        "operationId": "getAccountingBudgets",
        "parameters": [
          {
            "in": "query",
            "name": "department",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "year",
            "required": false,
            "schema": {
              "default": 0,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns budget lines with their actuals.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      },
      "post": {
        "description": "**Permission:** `budget:manage`",
        "operationId": "postAccountingBudgets",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountingBudget"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Sets a budget line.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "budget:manage"
        ]
      }
    },
    "/api/v1/accounting/entries": {
      "get": {
        "description": "**Permission:** `accounting:read`",
        "operationId": "getAccountingEntries",
        "parameters": [
          {
            "in": "query",
            "name": "account_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "source",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the journal.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      },
      "post": {
        "description": "Balance is enforced by the database at commit, not here. An application check holds right up until somebody writes a line in a script.\n\n**Permission:** `ledger:post`",
        "operationId": "postAccountingEntries",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountingEntryInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Writes a journal entry.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "ledger:post"
        ]
      }
    },
    "/api/v1/accounting/entries/{id}": {
      "get": {
        "description": "**Permission:** `accounting:read`",
        "operationId": "getAccountingEntriesId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one entry with its lines.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      }
    },
    "/api/v1/accounting/entries/{id}/post": {
      "post": {
        "description": "**Permission:** `ledger:post`",
        "operationId": "postAccountingEntriesIdPost",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Posts a draft.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "ledger:post"
        ]
      }
    },
    "/api/v1/accounting/entries/{id}/reverse": {
      "post": {
        "description": "There is no edit and no delete. Both entries stay on the record, so the history shows what was posted and what was done about it.\n\n**Permission:** `ledger:reverse`",
        "operationId": "postAccountingEntriesIdReverse",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Posts the mirror image of a posted entry.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "ledger:reverse"
        ]
      }
    },
    "/api/v1/accounting/filings": {
      "get": {
        "description": "**Permission:** `accounting:read`",
        "operationId": "getAccountingFilings",
        "parameters": [
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "year",
            "required": false,
            "schema": {
              "default": 0,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns statutory returns.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      },
      "post": {
        "description": "**Permission:** `tax:manage`",
        "operationId": "postAccountingFilings",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountingFilingInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records a return that is due.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "tax:manage"
        ]
      }
    },
    "/api/v1/accounting/filings/{id}": {
      "put": {
        "description": "ITS OWN BODY. It shared the whole Filing with the POST, so the edit form offered the kind, the status and the date filed — none of which this ever changed — and the server said \"saved\" and kept none of it.\n\n**Permission:** `tax:manage`",
        "operationId": "putAccountingFilingsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountingFilingChange"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Corrects a return that is still due.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "tax:manage"
        ]
      }
    },
    "/api/v1/accounting/filings/{id}/status": {
      "post": {
        "description": "Filed and paid are separate. A return submitted and not paid is the one that attracts the penalty, and a single status cannot say which happened.\n\n**Permission:** `tax:manage`",
        "operationId": "postAccountingFilingsIdStatus",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "amount": {
                    "type": "number"
                  },
                  "reason": {
                    "type": "string"
                  },
                  "receipt_no": {
                    "type": "string"
                  },
                  "status": {
                    "enum": [
                      "FILED",
                      "PAID",
                      "WAIVED"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Files, pays or waives a return.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "tax:manage"
        ]
      }
    },
    "/api/v1/accounting/posting-failures": {
      "get": {
        "description": "This is the screen that makes automatic posting honest. Postings are never allowed to refuse a payment or a clinical write — a patient at a till is not the person to tell about an unconfigured chart — so the ones that cannot be made land here instead. A queue nobody looks at is the same as a log, which is why it is a page rather than a log line.\n\n**Permission:** `accounting:read`",
        "operationId": "getAccountingPostingFailures",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "resolved",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists events that happened but could not reach the ledger.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      }
    },
    "/api/v1/accounting/readiness": {
      "get": {
        "description": "Asked at SETUP, not at the counter. Every required role with nothing bound to it is a whole class of transaction that will land in the exception queue instead of the accounts, and the time to find that out is while somebody is configuring the system.\n\n**Permission:** `accounting:read`",
        "operationId": "getAccountingReadiness",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Reports whether the chart can support automatic posting.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      }
    },
    "/api/v1/accounting/reconciliation": {
      "get": {
        "description": "Three comparisons, each reaching the same fact from the opposite end: receivables against unpaid bills, the inventory account against the value of every stock movement, cash against the till. Automatic posting is only worth having if somebody can prove it worked, and this is the proof.\n\n**Permission:** `accounting:read`",
        "operationId": "getAccountingReconciliation",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Compares the ledger against the rest of the system.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      }
    },
    "/api/v1/accounting/settings/bindings": {
      "get": {
        "description": "The unbound ones come back too, with a count of the required ones still missing: a screen that lists only what is configured cannot show anybody what is not, which is the only question it exists to answer.\n\n**Permission:** `accounting:read`",
        "operationId": "getAccountingSettingsBindings",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns every system role and whatever it points at.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      }
    },
    "/api/v1/accounting/settings/bindings/{role}": {
      "put": {
        "description": "**Permission:** `accounting:configure`",
        "operationId": "putAccountingSettingsBindingsRole",
        "parameters": [
          {
            "in": "path",
            "name": "role",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "account_id": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Points a role at an account.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:configure"
        ]
      }
    },
    "/api/v1/accounting/settings/chart/adopt": {
      "post": {
        "description": "SAFE TO RUN TWICE, and the answer says why: it reports what it created and what it found already there. It only ever adds — nothing existing is renamed, moved, deactivated, or rebound.\n\n**From the router:** The rules the chart is posted under. `accounting:configure` is separate from `account:manage`: adding an expense account is bookkeeping, whereas closing a year or rebinding what \"Sales\" posts to changes what everybody else's postings do.\n\n**Permission:** `accounting:configure`",
        "operationId": "postAccountingSettingsChartAdopt",
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Generates the accounts the system needs.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:configure"
        ]
      }
    },
    "/api/v1/accounting/settings/currencies": {
      "get": {
        "description": "**Permission:** `accounting:read`",
        "operationId": "getAccountingSettingsCurrencies",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists what the organisation trades in.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      }
    },
    "/api/v1/accounting/settings/fiscal-years": {
      "get": {
        "description": "**Permission:** `accounting:read`",
        "operationId": "getAccountingSettingsFiscalYears",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists the accounting periods.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      },
      "post": {
        "description": "**Permission:** `accounting:configure`",
        "operationId": "postAccountingSettingsFiscalYears",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountingFiscalYearInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Opens one, or edits one still open.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:configure"
        ]
      }
    },
    "/api/v1/accounting/settings/fiscal-years/{id}": {
      "put": {
        "description": "**Permission:** `accounting:configure`",
        "operationId": "putAccountingSettingsFiscalYearsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountingFiscalYearInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Opens one, or edits one still open.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:configure"
        ]
      }
    },
    "/api/v1/accounting/settings/fiscal-years/{id}/close": {
      "post": {
        "description": "**Permission:** `accounting:configure`",
        "operationId": "postAccountingSettingsFiscalYearsIdClose",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Seals a period. There is no reopen.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:configure"
        ]
      }
    },
    "/api/v1/accounting/settings/preferences": {
      "get": {
        "description": "**Permission:** `accounting:read`",
        "operationId": "getAccountingSettingsPreferences",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the one row of them.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      },
      "put": {
        "description": "**Permission:** `accounting:configure`",
        "operationId": "putAccountingSettingsPreferences",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountingPreferencesInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Edits them.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:configure"
        ]
      }
    },
    "/api/v1/accounting/settings/prefixes": {
      "get": {
        "description": "**Permission:** `accounting:read`",
        "operationId": "getAccountingSettingsPrefixes",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists the reference prefixes.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      }
    },
    "/api/v1/accounting/settings/prefixes/{kind}": {
      "put": {
        "description": "**Permission:** `accounting:configure`",
        "operationId": "putAccountingSettingsPrefixesKind",
        "parameters": [
          {
            "in": "path",
            "name": "kind",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "prefix": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Changes one.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:configure"
        ]
      }
    },
    "/api/v1/accounting/settings/tax-rates": {
      "get": {
        "description": "**Permission:** `accounting:read`",
        "operationId": "getAccountingSettingsTaxRates",
        "parameters": [
          {
            "in": "query",
            "name": "inactive",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists the rates.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      },
      "post": {
        "description": "**Permission:** `tax:manage`",
        "operationId": "postAccountingSettingsTaxRates",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountingTaxRateInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits one.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "tax:manage"
        ]
      }
    },
    "/api/v1/accounting/settings/tax-rates/{id}": {
      "delete": {
        "description": "**Permission:** `tax:manage`",
        "operationId": "deleteAccountingSettingsTaxRatesId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Withdraws one. Never deleted — an invoice raised under it still refers to it.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "tax:manage"
        ]
      },
      "put": {
        "description": "**Permission:** `tax:manage`",
        "operationId": "putAccountingSettingsTaxRatesId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountingTaxRateInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits one.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "tax:manage"
        ]
      }
    },
    "/api/v1/accounting/statements": {
      "get": {
        "description": "**Permission:** `accounting:read`",
        "operationId": "getAccountingStatements",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Builds the income statement and balance sheet.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      }
    },
    "/api/v1/accounting/summary": {
      "get": {
        "description": "**Permission:** `accounting:read`",
        "operationId": "getAccountingSummary",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is the overview.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      }
    },
    "/api/v1/accounting/tree": {
      "get": {
        "description": "**From the router:** The chart as a tree, and the two operations a flat list never needed: moving an account, and removing one nothing has used.\n\n**Permission:** `accounting:read`",
        "operationId": "getAccountingTree",
        "parameters": [
          {
            "in": "query",
            "name": "inactive",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the chart of accounts as a tree, totals rolled up.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      }
    },
    "/api/v1/accounting/trial-balance": {
      "get": {
        "description": "**Permission:** `accounting:read`",
        "operationId": "getAccountingTrialBalance",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns every account with its balance.",
        "tags": [
          "accounting"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      }
    },
    "/api/v1/accounts/dashboard": {
      "get": {
        "description": "**Permission:** `accounting:read`",
        "operationId": "getAccountsDashboard",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is the branch's money: the totals, and every account.",
        "tags": [
          "accounts"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      }
    },
    "/api/v1/accounts/funding": {
      "get": {
        "description": "**Permission:** `accounting:read`",
        "operationId": "getAccountsFunding",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "inactive",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the branch's accounts with their balances.",
        "tags": [
          "accounts"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      },
      "post": {
        "description": "**Permission:** `funding:manage`",
        "operationId": "postAccountsFunding",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountingFundingInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Creates or edits one.",
        "tags": [
          "accounts"
        ],
        "x-permissions": [
          "funding:manage"
        ]
      }
    },
    "/api/v1/accounts/funding/deposit": {
      "post": {
        "description": "CAPITAL ONLY. A patient paying a bill does not come through here — that posts against their receivable when the receipt is written. Routing it here would credit the owner with money the hospital earned and the income statement would never see it.\n\n**From the router:** Moving money. A deposit here is CAPITAL, not a customer paying — a patient's payment posts against their receivable at the till and never reaches this route.\n\n**Permission:** `funding:move`",
        "operationId": "postAccountsFundingDeposit",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HandlersMoveRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Puts new money in: Dr the account, Cr owner's capital.",
        "tags": [
          "accounts"
        ],
        "x-permissions": [
          "funding:move"
        ]
      }
    },
    "/api/v1/accounts/funding/transfer": {
      "post": {
        "description": "**Permission:** `funding:move`",
        "operationId": "postAccountsFundingTransfer",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HandlersMoveRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Moves money between accounts, in this branch or to another.",
        "tags": [
          "accounts"
        ],
        "x-permissions": [
          "funding:move"
        ]
      }
    },
    "/api/v1/accounts/funding/withdraw": {
      "post": {
        "description": "**Permission:** `funding:move`",
        "operationId": "postAccountsFundingWithdraw",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HandlersMoveRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Takes money out for the owner.",
        "tags": [
          "accounts"
        ],
        "x-permissions": [
          "funding:move"
        ]
      }
    },
    "/api/v1/accounts/funding/{id}": {
      "delete": {
        "description": "**Permission:** `funding:manage`",
        "operationId": "deleteAccountsFundingId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Removes one that has never held money.",
        "tags": [
          "accounts"
        ],
        "x-permissions": [
          "funding:manage"
        ]
      },
      "get": {
        "description": "**Permission:** `accounting:read`",
        "operationId": "getAccountsFundingId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one.",
        "tags": [
          "accounts"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      },
      "put": {
        "description": "**Permission:** `funding:manage`",
        "operationId": "putAccountsFundingId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountingFundingInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Creates or edits one.",
        "tags": [
          "accounts"
        ],
        "x-permissions": [
          "funding:manage"
        ]
      }
    },
    "/api/v1/accounts/funding/{id}/default": {
      "post": {
        "description": "**Permission:** `funding:manage`",
        "operationId": "postAccountsFundingIdDefault",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Points a kind's routing at this account.",
        "tags": [
          "accounts"
        ],
        "x-permissions": [
          "funding:manage"
        ]
      }
    },
    "/api/v1/accounts/funding/{id}/movements": {
      "get": {
        "description": "**Permission:** `accounting:read`",
        "operationId": "getAccountsFundingIdMovements",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is one account's history, read from the journal.",
        "tags": [
          "accounts"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      }
    },
    "/api/v1/accounts/transactions": {
      "get": {
        "description": "One endpoint behind four screens. Transactions is this unfiltered; Transfers, Deposits and Withdrawals are this with a source. Four endpoints would be four places for the branch scoping to be got wrong, and the one that was would be the one nobody tested.\n\n**Permission:** `accounting:read`",
        "operationId": "getAccountsTransactions",
        "parameters": [
          {
            "in": "query",
            "name": "account",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "source",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is every movement across the branch's accounts.",
        "tags": [
          "accounts"
        ],
        "x-permissions": [
          "accounting:read"
        ]
      }
    },
    "/api/v1/admin/announcements": {
      "get": {
        "description": "**Permission:** `announcement:read`",
        "operationId": "getAdminAnnouncements",
        "parameters": [
          {
            "in": "query",
            "name": "drafts",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 50,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the notice board.",
        "tags": [
          "admin"
        ],
        "x-permissions": [
          "announcement:read"
        ]
      },
      "post": {
        "description": "**Permission:** `announcement:manage`",
        "operationId": "postAdminAnnouncements",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PlatformAnnouncementInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Posts a notice.",
        "tags": [
          "admin"
        ],
        "x-permissions": [
          "announcement:manage"
        ]
      }
    },
    "/api/v1/admin/announcements/{id}": {
      "delete": {
        "description": "**Permission:** `announcement:manage`",
        "operationId": "deleteAdminAnnouncementsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Takes a notice down.",
        "tags": [
          "admin"
        ],
        "x-permissions": [
          "announcement:manage"
        ]
      }
    },
    "/api/v1/admin/approvals": {
      "get": {
        "description": "**From the router:** \"My approvals\" is on everybody's menu; ListApprovals narrows a caller without approval:read to what waits on them.\n\n**Access:** any signed-in account. No further permission.",
        "operationId": "getAdminApprovals",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "mine",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns what is waiting.",
        "tags": [
          "admin"
        ]
      },
      "post": {
        "description": "**Permission:** `approval:request`",
        "operationId": "postAdminApprovals",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PlatformApprovalInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Asks for a signature.",
        "tags": [
          "admin"
        ],
        "x-permissions": [
          "approval:request"
        ]
      }
    },
    "/api/v1/admin/approvals/{id}/decide": {
      "post": {
        "description": "**Permission:** `approval:decide`",
        "operationId": "postAdminApprovalsIdDecide",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "note": {
                    "type": "string"
                  },
                  "status": {
                    "enum": [
                      "APPROVED",
                      "REJECTED",
                      "WITHDRAWN"
                    ],
                    "type": "string"
                  },
                  "step": {
                    "description": "Step is the workflow transition, when this request is on a multi-step route.",
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Approves or rejects.",
        "tags": [
          "admin"
        ],
        "x-permissions": [
          "approval:decide"
        ]
      }
    },
    "/api/v1/admin/audit": {
      "get": {
        "description": "**Permission:** `audit:read`",
        "operationId": "getAdminAudit",
        "parameters": [
          {
            "in": "query",
            "name": "action",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "entity",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 200,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the log.",
        "tags": [
          "admin"
        ],
        "x-permissions": [
          "audit:read"
        ]
      }
    },
    "/api/v1/admin/documents": {
      "get": {
        "description": "**Permission:** `document:read`",
        "operationId": "getAdminDocuments",
        "parameters": [
          {
            "in": "query",
            "name": "category",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the register.",
        "tags": [
          "admin"
        ],
        "x-permissions": [
          "document:read"
        ]
      },
      "post": {
        "description": "**Permission:** `document:manage`",
        "operationId": "postAdminDocuments",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PlatformDocumentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Files or edits one.",
        "tags": [
          "admin"
        ],
        "x-permissions": [
          "document:manage"
        ]
      }
    },
    "/api/v1/admin/documents/{id}": {
      "put": {
        "description": "**Permission:** `document:manage`",
        "operationId": "putAdminDocumentsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PlatformDocumentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Files or edits one.",
        "tags": [
          "admin"
        ],
        "x-permissions": [
          "document:manage"
        ]
      }
    },
    "/api/v1/admin/portal/accounts": {
      "post": {
        "description": "Linking an account to the wrong patient is the worst thing that can happen in this domain, so it records who did it.\n\n**Permission:** `portal:link`",
        "operationId": "postAdminPortalAccounts",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "patient_id": {
                    "type": "string"
                  },
                  "user_id": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Connects a sign-in to a patient record.",
        "tags": [
          "admin"
        ],
        "x-permissions": [
          "portal:link"
        ]
      }
    },
    "/api/v1/admin/portal/dependants": {
      "post": {
        "description": "**Permission:** `portal:delegate`",
        "operationId": "postAdminPortalDependants",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "account_id": {
                    "type": "string"
                  },
                  "can_book": {
                    "type": "boolean"
                  },
                  "can_see_bills": {
                    "type": "boolean"
                  },
                  "can_see_results": {
                    "type": "boolean"
                  },
                  "expires_on": {
                    "type": "string"
                  },
                  "patient_id": {
                    "type": "string"
                  },
                  "relationship": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lets one portal account see another patient's record.",
        "tags": [
          "admin"
        ],
        "x-permissions": [
          "portal:delegate"
        ]
      }
    },
    "/api/v1/admin/portal/dependants/{id}/revoke": {
      "post": {
        "description": "The row stays, with a date and a reason. Deleting it would leave no record that the access ever existed, which is exactly what somebody investigating a complaint needs to see.\n\n**Permission:** `portal:delegate`",
        "operationId": "postAdminPortalDependantsIdRevoke",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Ends an access grant.",
        "tags": [
          "admin"
        ],
        "x-permissions": [
          "portal:delegate"
        ]
      }
    },
    "/api/v1/admin/portal/patients/{id}": {
      "get": {
        "description": "Gated on `portal:link` rather than `patient:read`, because the answer is not clinical: it is a list of the OTHER people who can read this patient's results. A clerk who may open a file has no business with that list.\n\n**Permission:** `portal:link`",
        "operationId": "getAdminPortalPatientsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Reports one patient's portal position: whether they have a sign-in, and who else may see their record.",
        "tags": [
          "admin"
        ],
        "x-permissions": [
          "portal:link"
        ]
      }
    },
    "/api/v1/admin/reports": {
      "get": {
        "description": "Not from a summary table that something has to remember to update: a reporting table written separately from the thing it reports on is wrong by the end of the first week, and wrong in a way nobody notices, because the report is the only place anybody looks.\n\n**Permission:** `report:read`",
        "operationId": "getAdminReports",
        "parameters": [
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Counts a period from the operational tables.",
        "tags": [
          "admin"
        ],
        "x-permissions": [
          "report:read"
        ]
      }
    },
    "/api/v1/admin/reports/export": {
      "get": {
        "description": "A section is named because a period report is five different tables — a daily series, the top diagnoses, the split by department, by payer, by age — and a single CSV holding all five is a file somebody has to take apart by hand before they can use it.\n\n**From the router:** The same figures, as a file. Same permission: an export carries exactly what the screen shows, and gating one and not the other protects nothing.\n\n**Permission:** `report:read`",
        "operationId": "getAdminReportsExport",
        "parameters": [
          {
            "in": "query",
            "name": "format",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "section",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/octet-stream": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "The stored file, with its own content type."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Renders an operational period as a file.",
        "tags": [
          "admin"
        ],
        "x-permissions": [
          "report:read"
        ]
      }
    },
    "/api/v1/admin/staff": {
      "get": {
        "description": "**Permission:** `staff:read`",
        "operationId": "getAdminStaff",
        "parameters": [
          {
            "in": "query",
            "name": "department",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "default": 1,
              "type": "integer"
            }
          },
          {
            "description": "Capped at 200. `page_size` is accepted as an alias.",
            "in": "query",
            "name": "per_page",
            "required": false,
            "schema": {
              "default": 50,
              "type": "integer"
            }
          },
          {
            "description": "Free-text filter.",
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PagedEnvelope"
                }
              }
            },
            "description": "A page of rows, with `meta` carrying the counts."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the directory.",
        "tags": [
          "admin"
        ],
        "x-permissions": [
          "staff:read"
        ]
      },
      "post": {
        "description": "**Permission:** `staff:manage`",
        "operationId": "postAdminStaff",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PlatformStaffInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits a staff record.",
        "tags": [
          "admin"
        ],
        "x-permissions": [
          "staff:manage"
        ]
      }
    },
    "/api/v1/admin/staff/{id}": {
      "put": {
        "description": "**Permission:** `staff:manage`",
        "operationId": "putAdminStaffId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PlatformStaffInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits a staff record.",
        "tags": [
          "admin"
        ],
        "x-permissions": [
          "staff:manage"
        ]
      }
    },
    "/api/v1/admin/summary": {
      "get": {
        "description": "**Permission:** `staff:read`",
        "operationId": "getAdminSummary",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Counts the administration.",
        "tags": [
          "admin"
        ],
        "x-permissions": [
          "staff:read"
        ]
      }
    },
    "/api/v1/analytics/journey": {
      "get": {
        "description": "**Permission:** `analytics:read`",
        "operationId": "getAnalyticsJourney",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "steps",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is where patients are, how long each stage takes, and where attendances stop.",
        "tags": [
          "analytics"
        ],
        "x-permissions": [
          "analytics:read"
        ]
      }
    },
    "/api/v1/analytics/overview": {
      "get": {
        "description": "One request rather than six, because six would be six round trips for a page that is always drawn whole, and because the headline figures and the breakdowns have to describe the SAME period — two requests a second apart either side of midnight would not.\n\n**Permission:** `analytics:read`",
        "operationId": "getAnalyticsOverview",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is the whole dashboard in one request.",
        "tags": [
          "analytics"
        ],
        "x-permissions": [
          "analytics:read"
        ]
      }
    },
    "/api/v1/analytics/usage": {
      "get": {
        "description": "THE ONLY ENDPOINT HERE THAT IS NOT EXACT, and the response says so in a field rather than only in this comment. Events are emitted fire-and-forget by the audit middleware, so a service restart loses a handful. That is the right trade for \"which screens are used and when the busy hours are\", and the wrong one for anything about money — which is why nothing about money comes from here.\n\nA stream that is down is not an error. The page renders the exact figures and says this panel could not be reached, which is more useful than a 503 over a panel nobody would have made a decision from.\n\n**Permission:** `analytics:read`",
        "operationId": "getAnalyticsUsage",
        "parameters": [
          {
            "in": "query",
            "name": "event",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "interval",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is what staff do in the console, from the event stream.",
        "tags": [
          "analytics"
        ],
        "x-permissions": [
          "analytics:read"
        ]
      }
    },
    "/api/v1/attachments": {
      "get": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "getAttachments",
        "parameters": [
          {
            "in": "query",
            "name": "entity_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "entity_type",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns what is filed against one record.",
        "tags": [
          "attachments"
        ]
      },
      "post": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "postAttachments",
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "properties": {
                  "entity_id": {
                    "type": "string"
                  },
                  "entity_type": {
                    "type": "string"
                  },
                  "file": {
                    "format": "binary",
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Files one against a record.",
        "tags": [
          "attachments"
        ]
      }
    },
    "/api/v1/attachments/{id}": {
      "delete": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "deleteAttachmentsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Removes one.",
        "tags": [
          "attachments"
        ]
      }
    },
    "/api/v1/attachments/{id}/download": {
      "get": {
        "description": "The file's OWN record is fetched first, purely to learn what it is attached to — the permission is then the entity's. Asking the caller to tell us the entity type would let them name one they are allowed to read.\n\n**Access:** any signed-in account. No further permission.",
        "operationId": "getAttachmentsIdDownload",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/octet-stream": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "The stored file, with its own content type."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Streams one back.",
        "tags": [
          "attachments"
        ]
      }
    },
    "/api/v1/attachments/{id}/text": {
      "get": {
        "description": "WHAT THIS IS ACTUALLY FOR. A referral letter arrives as a photograph of a page. A clerk who needs the referring doctor's name has, without this, to open an image, read it on screen and retype it — which is where the transcription errors come from. This returns the text so it can be read and copied.\n\nThe permission is the RECORD's, exactly as it is for the file itself: whoever may open the patient may read what was filed against them. Reading the words on a page is not a lesser act than looking at it.\n\n**Access:** any signed-in account. No further permission.",
        "operationId": "getAttachmentsIdText",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the words in a scanned file.",
        "tags": [
          "attachments"
        ]
      }
    },
    "/api/v1/auth/2fa/totp/setup": {
      "post": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "postAuth2faTotpSetup",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Begins adding one: the secret and a QR code to scan.",
        "tags": [
          "auth"
        ]
      }
    },
    "/api/v1/auth/2fa/totp/status": {
      "get": {
        "description": "**From the router:** Adding an authenticator app to one's own account.\n\n**Access:** any signed-in account. No further permission.",
        "operationId": "getAuth2faTotpStatus",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Says whether the caller has an authenticator app.",
        "tags": [
          "auth"
        ]
      }
    },
    "/api/v1/auth/2fa/totp/verify": {
      "post": {
        "description": "**Access:** any signed-in account. No further permission.\n\n**Rate limit:** 20 per hour per client address.",
        "operationId": "postAuth2faTotpVerify",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "code": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Too many requests from this address."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Finishes with a code from the app, and answers the recovery codes, once.",
        "tags": [
          "auth"
        ],
        "x-rate-limit": "20 per hour"
      }
    },
    "/api/v1/auth/login": {
      "post": {
        "description": "**Access:** open — no token required.",
        "operationId": "postAuthLogin",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HandlersLoginRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [],
        "summary": "Signs a user in with an identifier and password.",
        "tags": [
          "auth"
        ]
      }
    },
    "/api/v1/auth/logout": {
      "post": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "postAuthLogout",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HandlersLogoutRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Ends the caller's session.",
        "tags": [
          "auth"
        ]
      }
    },
    "/api/v1/auth/me": {
      "get": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "getAuthMe",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the signed-in user together with their roles and permissions. The console calls it on every page load to rebuild its navigation without having to trust anything it cached locally.",
        "tags": [
          "auth"
        ]
      }
    },
    "/api/v1/auth/password": {
      "post": {
        "description": "There is no permission on it. One that every account had to hold would not be a permission, and an account that cannot change its own password is an account whose password never changes after somebody else has typed it in.\n\n**From the router:** Changing your own password is in the same class: an account that cannot change its own is an account whose password stays whatever the person who created it typed.\n\n**Access:** any signed-in account. No further permission.",
        "operationId": "postAuthPassword",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HandlersChangePasswordRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Changes the caller's own password.",
        "tags": [
          "auth"
        ]
      }
    },
    "/api/v1/auth/password/forgot": {
      "post": {
        "description": "IT ANSWERS THE SAME WAY WHETHER OR NOT THE ACCOUNT EXISTS. Anything else is a way to ask this hospital, one address at a time and without signing in, which of its staff have accounts here — and to do it from outside the building, because this route has to be reachable by somebody who is locked out.\n\n**Access:** open — no token required.\n\n**Rate limit:** 10 per minute per client address.",
        "operationId": "postAuthPasswordForgot",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HandlersForgotPasswordRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Too many requests from this address."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [],
        "summary": "Sends a reset code to the contact given.",
        "tags": [
          "auth"
        ],
        "x-rate-limit": "10 per minute"
      }
    },
    "/api/v1/auth/password/reset": {
      "post": {
        "description": "The code and the new password arrive together. Splitting them into two calls would mean holding the verified ticket in the browser between them, which is a session in everything but name and buys nothing: the person is standing at the form either way.\n\n**Access:** open — no token required.\n\n**Rate limit:** 10 per minute per client address.",
        "operationId": "postAuthPasswordReset",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HandlersResetPasswordRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Too many requests from this address."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [],
        "summary": "Completes a forgotten-password reset.",
        "tags": [
          "auth"
        ],
        "x-rate-limit": "10 per minute"
      }
    },
    "/api/v1/auth/refresh": {
      "post": {
        "description": "**Access:** open — no token required.",
        "operationId": "postAuthRefresh",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HandlersRefreshRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [],
        "summary": "Exchanges a refresh token for a new token pair.",
        "tags": [
          "auth"
        ]
      }
    },
    "/api/v1/auth/verify-2fa": {
      "post": {
        "description": "**Access:** open — no token required.",
        "operationId": "postAuthVerify2fa",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HandlersVerifyTwoFactorRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [],
        "summary": "Completes a login that stopped for a second factor.",
        "tags": [
          "auth"
        ]
      }
    },
    "/api/v1/billing/bills": {
      "get": {
        "description": "**Permission:** `bill:read`",
        "operationId": "getBillingBills",
        "parameters": [
          {
            "in": "query",
            "name": "date",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "outstanding",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "payer",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the bill register.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "bill:read"
        ]
      },
      "post": {
        "description": "**Permission:** `bill:create`",
        "operationId": "postBillingBills",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillingBillInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Raises a bill.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "bill:create"
        ]
      }
    },
    "/api/v1/billing/bills/{id}": {
      "get": {
        "description": "**Permission:** `bill:read`",
        "operationId": "getBillingBillsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one bill with its lines and receipts.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "bill:read"
        ]
      }
    },
    "/api/v1/billing/bills/{id}/claim": {
      "post": {
        "description": "The reference is optional in the request and MANDATORY in the answer when the scheme requires it: a claim over that scheme's `preauth_above` is refused without one, and the refusal names both the claim and the threshold.\n\n**Permission:** `claim:manage`",
        "operationId": "postBillingBillsIdClaim",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "preauth_reference": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Bills a scheme for what it covers.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "claim:manage"
        ]
      }
    },
    "/api/v1/billing/bills/{id}/credit-note": {
      "get": {
        "description": "IT IS REFUSED FOR A BILL THAT IS STILL OWED, and that refusal is the most important line in this file. A credit note says a debt was reduced. Issued against a live bill it is a document asserting something untrue, on the hospital's letterhead, with a number on it — and it is exactly the document somebody would want in order to make a debt disappear quietly. If nothing has been cancelled, written off or discounted, there is nothing to credit.\n\nITS NUMBER IS DERIVED FROM THE BILL'S, not drawn from a sequence. Reprinting a document must produce the same document; a fresh number on every print would mean a patient and the hospital holding two credit notes for one reduction, with no way to tell they were the same event.\n\n**From the router:** The note that takes a demand back. Same permission as the invoice — it is a view of the same bill — and the handler refuses outright for a bill that is still owed, because a credit note against a live debt is a false document and exactly the one somebody would want.\n\n**Permission:** `bill:read`",
        "operationId": "getBillingBillsIdCreditNote",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "language",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/pdf": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "The document, as a PDF."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Draws the note that takes back what a bill demanded.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "bill:read"
        ]
      }
    },
    "/api/v1/billing/bills/{id}/discount": {
      "post": {
        "description": "**Permission:** `bill:discount`",
        "operationId": "postBillingBillsIdDiscount",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "amount": {
                    "type": "number"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Reduces a bill, with a reason.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "bill:discount"
        ]
      }
    },
    "/api/v1/billing/bills/{id}/invoice": {
      "get": {
        "description": "GATED ON bill:read, the same permission as looking at the bill on screen. A bill somebody may read is a bill they may print: the paper and the screen carry identical information, and a gate on one and not the other protects nothing while stopping somebody doing their job at a printer.\n\n**From the router:** The invoice. Gated on bill:read, exactly as the screen is: a bill somebody may look at is a bill they may print, and a separate print permission would protect nothing while stopping a clerk handing a patient the paper they are standing there asking for.\n\n**Permission:** `bill:read`",
        "operationId": "getBillingBillsIdInvoice",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "language",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/pdf": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "The document, as a PDF."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Draws the invoice for one bill.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "bill:read"
        ]
      }
    },
    "/api/v1/billing/bills/{id}/issue": {
      "post": {
        "description": "**Permission:** `bill:update`",
        "operationId": "postBillingBillsIdIssue",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Turns a draft into an invoice.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "bill:update"
        ]
      }
    },
    "/api/v1/billing/bills/{id}/items": {
      "post": {
        "description": "**Permission:** `bill:update`",
        "operationId": "postBillingBillsIdItems",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillingItemInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Puts a line on a bill.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "bill:update"
        ]
      }
    },
    "/api/v1/billing/bills/{id}/items/{itemId}": {
      "delete": {
        "description": "Draft only. Once a bill is issued the patient has been shown it, and quietly removing a line from a document somebody has already seen is how a dispute becomes unresolvable.\n\n**Permission:** `bill:update`",
        "operationId": "deleteBillingBillsIdItemsItemId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "itemId",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Takes a line off a DRAFT bill.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "bill:update"
        ]
      }
    },
    "/api/v1/billing/bills/{id}/payments": {
      "post": {
        "description": "**Permission:** `payment:create`",
        "operationId": "postBillingBillsIdPayments",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillingPaymentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Receives money against a bill.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "payment:create"
        ]
      }
    },
    "/api/v1/billing/bills/{id}/void": {
      "post": {
        "description": "**Permission:** `bill:void`",
        "operationId": "postBillingBillsIdVoid",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  },
                  "status": {
                    "enum": [
                      "CANCELLED",
                      "WRITTEN_OFF"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Cancels a bill or writes it off.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "bill:void"
        ]
      }
    },
    "/api/v1/billing/claims": {
      "get": {
        "description": "**Permission:** `insurance:read`",
        "operationId": "getBillingClaims",
        "parameters": [
          {
            "in": "query",
            "name": "scheme_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the claim register.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "insurance:read"
        ]
      }
    },
    "/api/v1/billing/claims/{id}/advance": {
      "post": {
        "description": "**Permission:** `claim:manage`",
        "operationId": "postBillingClaimsIdAdvance",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "approved": {
                    "nullable": true,
                    "type": "number"
                  },
                  "reason": {
                    "type": "string"
                  },
                  "status": {
                    "enum": [
                      "SUBMITTED",
                      "QUERIED",
                      "APPROVED",
                      "PART_APPROVED",
                      "REJECTED",
                      "PAID"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Moves a claim along and records what the scheme allowed.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "claim:manage"
        ]
      }
    },
    "/api/v1/billing/claims/{id}/invoice": {
      "get": {
        "description": "WHAT IS DEMANDED IS THE SCHEME'S SHARE, not the bill's total. Cover is copied onto a bill the day it is raised, so a claim settled in March is settled at the March arrangement — reading today's percentage would rewrite history every time a contract was renegotiated, and always in one party's favour.\n\n**From the router:** The claim on paper, for a scheme that wants one. Gated with the register it comes from: printing a claim is reading a claim.\n\n**Permission:** `insurance:read`",
        "operationId": "getBillingClaimsIdInvoice",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "language",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/pdf": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "The document, as a PDF."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Draws the hospital's claim against a scheme.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "insurance:read"
        ]
      }
    },
    "/api/v1/billing/expenses": {
      "get": {
        "description": "**Permission:** `expense:read`",
        "operationId": "getBillingExpenses",
        "parameters": [
          {
            "in": "query",
            "name": "category",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns what was spent.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "expense:read"
        ]
      },
      "post": {
        "description": "**Permission:** `expense:create`",
        "operationId": "postBillingExpenses",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillingExpenseInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Books a spend, pending approval.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "expense:create"
        ]
      }
    },
    "/api/v1/billing/expenses/{id}/decide": {
      "post": {
        "description": "**Permission:** `expense:approve`",
        "operationId": "postBillingExpensesIdDecide",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  },
                  "status": {
                    "enum": [
                      "APPROVED",
                      "REJECTED",
                      "PAID"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Approves or rejects a spend.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "expense:approve"
        ]
      }
    },
    "/api/v1/billing/expenses/{id}/voucher": {
      "get": {
        "description": "AN UNAPPROVED EXPENSE STILL PRINTS, and says so. The voucher is what somebody carries to get an expense approved as often as it is what records an approved one; refusing to draw it until approval would mean the approval had to happen on a screen with no paper in front of it.\n\n**From the router:** The voucher. On expense:read, not expense:approve — it is as often the paper somebody carries IN ORDER to get an expense approved as it is the record of an approved one, and it says on its face when it has not been approved.\n\n**Permission:** `expense:read`",
        "operationId": "getBillingExpensesIdVoucher",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "language",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/pdf": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "The document, as a PDF."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Draws the authority for one expense.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "expense:read"
        ]
      }
    },
    "/api/v1/billing/flow": {
      "get": {
        "description": "**From the router:** The front desk's two fees and the collection rule. Gated on the price list's own permissions rather than an accounting one: this says what the counter charges, and the person who maintains the price list is the person who knows.\n\n**Permission:** `tariff:read`",
        "operationId": "getBillingFlow",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the front desk's charges and collection rule.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "tariff:read"
        ]
      },
      "put": {
        "description": "**Permission:** `tariff:manage`",
        "operationId": "putBillingFlow",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillingPatientFlowInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Saves them.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "tariff:manage"
        ]
      }
    },
    "/api/v1/billing/patients/{id}/statement": {
      "get": {
        "description": "A DIFFERENT QUESTION FROM AN INVOICE. An invoice asks somebody to pay a figure. A statement answers \"how did I get here\" — it is what is produced when a patient disputes a balance, or arrives with a handful of receipts and wants them accounted for. So it is a table of EVENTS with a balance running down it, not a longer invoice.\n\nN+1 ON PURPOSE, and only just. The payments are fetched one bill at a time rather than in a single query, because the alternative is a bespoke join that exists solely for this document. A statement is printed rarely and by hand; fifty small queries on that path is a trade worth making to avoid a second way of reading payments that could disagree with the first.\n\n**From the router:** Everything that has happened on one patient's account. Gated on bill:read rather than on patient:read: it is a page of money, and seeing what somebody was charged is not part of seeing who they are.\n\n**Permission:** `bill:read`",
        "operationId": "getBillingPatientsIdStatement",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "language",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/pdf": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "The document, as a PDF."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Draws everything that has happened on one patient's account.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "bill:read"
        ]
      }
    },
    "/api/v1/billing/payments": {
      "get": {
        "description": "**Permission:** `payment:read`",
        "operationId": "getBillingPayments",
        "parameters": [
          {
            "in": "query",
            "name": "date",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 200,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "method",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the day's takings.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "payment:read"
        ]
      }
    },
    "/api/v1/billing/payments/{id}/receipt": {
      "get": {
        "description": "**From the router:** The receipt itself. Gated on payment:read rather than payment:create: reprinting one a patient has lost is a records job, not a till job.\n\n**Permission:** `payment:read`",
        "operationId": "getBillingPaymentsIdReceipt",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "language",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/pdf": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "The document, as a PDF."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Draws the receipt for one payment.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "payment:read"
        ]
      }
    },
    "/api/v1/billing/payments/{id}/reverse": {
      "post": {
        "description": "**Permission:** `payment:reverse`",
        "operationId": "postBillingPaymentsIdReverse",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Cancels a receipt with a counter-entry.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "payment:reverse"
        ]
      }
    },
    "/api/v1/billing/sales": {
      "post": {
        "description": "ONE REQUEST, because a sale is one event. What this replaces was four calls made from the browser — open the bill, add each line, issue it, take the payment — and a dropped connection between any two of them left a half-sale for somebody to unpick at the counter with a queue behind them. There is now no state in which the patient has paid for a bill that does not exist, or holds goods the shelf still thinks it has.\n\n**From the router:** The till. One request for a whole sale, gated on creating a bill AND taking money, because it does both — a cashier who may only raise bills must not be able to ring one up and receipt it in a single call that skips the second gate.\n\n**Permission:** `bill:create` + `payment:create`",
        "operationId": "postBillingSales",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillingSaleInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Rings up a counter sale: the bill, its lines, the stock, and the money.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "bill:create",
          "payment:create"
        ]
      }
    },
    "/api/v1/billing/schemes": {
      "get": {
        "description": "**Permission:** `insurance:read`",
        "operationId": "getBillingSchemes",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the insurers, each with what it owes.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "insurance:read"
        ]
      },
      "post": {
        "description": "**Permission:** `claim:manage`",
        "operationId": "postBillingSchemes",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillingSchemeInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits an insurer.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "claim:manage"
        ]
      }
    },
    "/api/v1/billing/schemes/{id}": {
      "put": {
        "description": "**Permission:** `claim:manage`",
        "operationId": "putBillingSchemesId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillingSchemeInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits an insurer.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "claim:manage"
        ]
      }
    },
    "/api/v1/billing/summary": {
      "get": {
        "description": "**Permission:** `bill:read`",
        "operationId": "getBillingSummary",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Counts the day's money.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "bill:read"
        ]
      }
    },
    "/api/v1/billing/tariffs": {
      "get": {
        "description": "**Permission:** `tariff:read`",
        "operationId": "getBillingTariffs",
        "parameters": [
          {
            "in": "query",
            "name": "category",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "payer",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the price list.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "tariff:read"
        ]
      },
      "post": {
        "description": "A change retires the old row and writes a new one. Yesterday's invoices have to remain explicable, and the only way to explain them is to still have the price that produced them.\n\n**Permission:** `tariff:manage`",
        "operationId": "postBillingTariffs",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BillingTariffInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records a price.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "tariff:manage"
        ]
      }
    },
    "/api/v1/billing/till": {
      "get": {
        "description": "The caller's OWN, always: the account id comes from the token, never from the query. A cashier reconciling their drawer has no business reading somebody else's, and passing the id in would make that a matter of typing a different one.\n\n**From the router:** Your OWN till. The account id comes from the token, never from a query — a cashier reconciling their drawer has no business reading somebody else's, and passing an id in would make that a matter of typing a different one. Gated on taking money rather than on reading receipts, because that is who has a drawer.\n\n**Permission:** `payment:create`",
        "operationId": "getBillingTill",
        "parameters": [
          {
            "in": "query",
            "name": "date",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is the caller's own shift — what a drawer is counted against.",
        "tags": [
          "billing"
        ],
        "x-permissions": [
          "payment:create"
        ]
      }
    },
    "/api/v1/clinical/appointments": {
      "get": {
        "description": "**Permission:** `appointment:read`",
        "operationId": "getClinicalAppointments",
        "parameters": [
          {
            "in": "query",
            "name": "date",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "department",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 200,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the diary.",
        "tags": [
          "clinical"
        ],
        "x-permissions": [
          "appointment:read"
        ]
      },
      "post": {
        "description": "**Permission:** `appointment:manage`",
        "operationId": "postClinicalAppointments",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClinicalAppointmentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Makes one.",
        "tags": [
          "clinical"
        ],
        "x-permissions": [
          "appointment:manage"
        ]
      }
    },
    "/api/v1/clinical/appointments/{id}/reschedule": {
      "post": {
        "description": "**Permission:** `appointment:manage`",
        "operationId": "postClinicalAppointmentsIdReschedule",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "scheduled_for": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Moves it to another time.",
        "tags": [
          "clinical"
        ],
        "x-permissions": [
          "appointment:manage"
        ]
      }
    },
    "/api/v1/clinical/appointments/{id}/status": {
      "post": {
        "description": "**Permission:** `appointment:manage`",
        "operationId": "postClinicalAppointmentsIdStatus",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  },
                  "status": {
                    "enum": [
                      "BOOKED",
                      "CONFIRMED",
                      "ARRIVED",
                      "IN_PROGRESS",
                      "COMPLETED",
                      "DID_NOT_ATTEND",
                      "CANCELLED"
                    ],
                    "type": "string"
                  },
                  "visit_id": {
                    "nullable": true,
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Changes its status.",
        "tags": [
          "clinical"
        ],
        "x-permissions": [
          "appointment:manage"
        ]
      }
    },
    "/api/v1/clinical/assist": {
      "post": {
        "description": "Gated on prescription:write — the permission held by people who write up a consultation. Reading a differential is part of writing one up, and giving it its own permission would mean an administrator has to grant a second thing before the panel a clinician already has appears.\n\n**From the router:** The clinical assistant. Gated on the permission held by whoever writes up a consultation — reading a differential is part of writing one, and a permission of its own would mean an administrator has to grant a second thing before a panel the clinician already has appears.\n\n**Permission:** `prescription:write`",
        "operationId": "postClinicalAssist",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HandlersAssistNote"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Reads a consultation note and returns a differential.",
        "tags": [
          "clinical"
        ],
        "x-permissions": [
          "prescription:write"
        ]
      }
    },
    "/api/v1/clinical/doses": {
      "get": {
        "description": "**Permission:** `nursing:read`",
        "operationId": "getClinicalDoses",
        "parameters": [
          {
            "in": "query",
            "name": "admission_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "due",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 200,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the medicine round.",
        "tags": [
          "clinical"
        ],
        "x-permissions": [
          "nursing:read"
        ]
      },
      "post": {
        "description": "**Permission:** `nursing:record`",
        "operationId": "postClinicalDoses",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClinicalDoseInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Puts a dose on the round.",
        "tags": [
          "clinical"
        ],
        "x-permissions": [
          "nursing:record"
        ]
      }
    },
    "/api/v1/clinical/doses/{id}": {
      "post": {
        "description": "**Permission:** `nursing:record`",
        "operationId": "postClinicalDosesId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "notes": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  },
                  "status": {
                    "enum": [
                      "GIVEN",
                      "NOT_GIVEN",
                      "REFUSED",
                      "HELD"
                    ],
                    "type": "string"
                  },
                  "witness": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records a dose given, refused, held or not given.",
        "tags": [
          "clinical"
        ],
        "x-permissions": [
          "nursing:record"
        ]
      }
    },
    "/api/v1/clinical/emergency": {
      "get": {
        "description": "**Permission:** `emergency:read`",
        "operationId": "getClinicalEmergency",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "open",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the board: sickest first, then longest waiting.",
        "tags": [
          "clinical"
        ],
        "x-permissions": [
          "emergency:read"
        ]
      },
      "post": {
        "description": "**Permission:** `emergency:triage`",
        "operationId": "postClinicalEmergency",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClinicalEmergencyInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records an arrival.",
        "tags": [
          "clinical"
        ],
        "x-permissions": [
          "emergency:triage"
        ]
      }
    },
    "/api/v1/clinical/emergency/{id}/status": {
      "post": {
        "description": "**Permission:** `emergency:treat`",
        "operationId": "postClinicalEmergencyIdStatus",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "note": {
                    "type": "string"
                  },
                  "status": {
                    "enum": [
                      "WAITING",
                      "IN_TRIAGE",
                      "IN_RESUS",
                      "IN_TREATMENT",
                      "AWAITING_ADMISSION",
                      "ADMITTED",
                      "DISCHARGED",
                      "REFERRED",
                      "DIED",
                      "LEFT_WITHOUT_BEING_SEEN"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Moves a casualty case along.",
        "tags": [
          "clinical"
        ],
        "x-permissions": [
          "emergency:treat"
        ]
      }
    },
    "/api/v1/clinical/emergency/{id}/triage": {
      "post": {
        "description": "**Permission:** `emergency:triage`",
        "operationId": "postClinicalEmergencyIdTriage",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "category": {
                    "type": "integer"
                  },
                  "complaint": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Assigns an acuity category.",
        "tags": [
          "clinical"
        ],
        "x-permissions": [
          "emergency:triage"
        ]
      }
    },
    "/api/v1/clinical/records": {
      "get": {
        "description": "**Permission:** `record:read`",
        "operationId": "getClinicalRecords",
        "parameters": [
          {
            "in": "query",
            "name": "kind",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "notifiable",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "patient_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns coded entries.",
        "tags": [
          "clinical"
        ],
        "x-permissions": [
          "record:read"
        ]
      },
      "post": {
        "description": "**From the router:** Coding is a records-office job with reporting consequences: a notifiable condition entered here goes onto a weekly return.\n\n**Permission:** `record:code`",
        "operationId": "postClinicalRecords",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClinicalRecordInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Codes a diagnosis, procedure or note.",
        "tags": [
          "clinical"
        ],
        "x-permissions": [
          "record:code"
        ]
      }
    },
    "/api/v1/clinical/referrals": {
      "get": {
        "description": "**Permission:** `referral:read`",
        "operationId": "getClinicalReferrals",
        "parameters": [
          {
            "in": "query",
            "name": "direction",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns them, in or out.",
        "tags": [
          "clinical"
        ],
        "x-permissions": [
          "referral:read"
        ]
      },
      "post": {
        "description": "**Permission:** `referral:manage`",
        "operationId": "postClinicalReferrals",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClinicalReferralInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Sends a referral or records one received.",
        "tags": [
          "clinical"
        ],
        "x-permissions": [
          "referral:manage"
        ]
      }
    },
    "/api/v1/clinical/referrals/{id}/advance": {
      "post": {
        "description": "**Permission:** `referral:manage`",
        "operationId": "postClinicalReferralsIdAdvance",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "feedback": {
                    "type": "string"
                  },
                  "status": {
                    "enum": [
                      "SENT",
                      "ACKNOWLEDGED",
                      "ACCEPTED",
                      "DECLINED",
                      "ARRIVED",
                      "COMPLETED",
                      "CANCELLED"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Moves it along and records what came back.",
        "tags": [
          "clinical"
        ],
        "x-permissions": [
          "referral:manage"
        ]
      }
    },
    "/api/v1/clinical/summary": {
      "get": {
        "description": "**Permission:** `nursing:read`",
        "operationId": "getClinicalSummary",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Counts the floor.",
        "tags": [
          "clinical"
        ],
        "x-permissions": [
          "nursing:read"
        ]
      }
    },
    "/api/v1/clinical/tasks": {
      "get": {
        "description": "**Permission:** `nursing:read`",
        "operationId": "getClinicalTasks",
        "parameters": [
          {
            "in": "query",
            "name": "admission_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "due",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 200,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the nursing round.",
        "tags": [
          "clinical"
        ],
        "x-permissions": [
          "nursing:read"
        ]
      },
      "post": {
        "description": "**Permission:** `nursing:record`",
        "operationId": "postClinicalTasks",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClinicalTaskInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Schedules a nursing job.",
        "tags": [
          "clinical"
        ],
        "x-permissions": [
          "nursing:record"
        ]
      }
    },
    "/api/v1/clinical/tasks/{id}": {
      "post": {
        "description": "**Permission:** `nursing:record`",
        "operationId": "postClinicalTasksId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "notes": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  },
                  "status": {
                    "enum": [
                      "DONE",
                      "NOT_DONE",
                      "CANCELLED"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records a task as done or not done.",
        "tags": [
          "clinical"
        ],
        "x-permissions": [
          "nursing:record"
        ]
      }
    },
    "/api/v1/commercial/clients": {
      "get": {
        "description": "**Permission:** `client:read`",
        "operationId": "getCommercialClients",
        "parameters": [
          {
            "in": "query",
            "name": "kind",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "default": 1,
              "type": "integer"
            }
          },
          {
            "description": "Capped at 200. `page_size` is accepted as an alias.",
            "in": "query",
            "name": "per_page",
            "required": false,
            "schema": {
              "default": 50,
              "type": "integer"
            }
          },
          {
            "description": "Free-text filter.",
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PagedEnvelope"
                }
              }
            },
            "description": "A page of rows, with `meta` carrying the counts."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the account list.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "client:read"
        ]
      },
      "post": {
        "description": "**Permission:** `client:manage`",
        "operationId": "postCommercialClients",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CommercialClient"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits an account.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "client:manage"
        ]
      }
    },
    "/api/v1/commercial/clients/{id}": {
      "get": {
        "description": "**Permission:** `client:read`",
        "operationId": "getCommercialClientsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one account with its contacts.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "client:read"
        ]
      },
      "put": {
        "description": "**Permission:** `client:manage`",
        "operationId": "putCommercialClientsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CommercialClient"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits an account.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "client:manage"
        ]
      }
    },
    "/api/v1/commercial/contacts": {
      "get": {
        "description": "**Permission:** `client:read`",
        "operationId": "getCommercialContacts",
        "parameters": [
          {
            "in": "query",
            "name": "client_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the people at a client, or everybody.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "client:read"
        ]
      },
      "post": {
        "description": "**Permission:** `client:manage`",
        "operationId": "postCommercialContacts",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CommercialContact"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits a contact.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "client:manage"
        ]
      }
    },
    "/api/v1/commercial/contacts/{id}": {
      "put": {
        "description": "**Permission:** `client:manage`",
        "operationId": "putCommercialContactsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CommercialContact"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits a contact.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "client:manage"
        ]
      }
    },
    "/api/v1/commercial/discount-rules": {
      "get": {
        "description": "**Permission:** `bill:read`",
        "operationId": "getCommercialDiscountRules",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the policy.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "bill:read"
        ]
      },
      "post": {
        "description": "**Permission:** `discount:manage`",
        "operationId": "postCommercialDiscountRules",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CommercialDiscountRule"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits policy.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "discount:manage"
        ]
      }
    },
    "/api/v1/commercial/discount-rules/{id}": {
      "put": {
        "description": "**Permission:** `discount:manage`",
        "operationId": "putCommercialDiscountRulesId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CommercialDiscountRule"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits policy.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "discount:manage"
        ]
      }
    },
    "/api/v1/commercial/discounts-granted": {
      "get": {
        "description": "Read from the bills rather than from a total kept beside the rules: what was given is a fact about a bill, and a second copy would be a second number for the same money.\n\n**Permission:** `bill:read`",
        "operationId": "getCommercialDiscountsGranted",
        "parameters": [
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Reads what was actually given, from the bills.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "bill:read"
        ]
      }
    },
    "/api/v1/commercial/follow-ups": {
      "get": {
        "description": "**Permission:** `followup:read`",
        "operationId": "getCommercialFollowUps",
        "parameters": [
          {
            "in": "query",
            "name": "client_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "overdue",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns what is outstanding.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "followup:read"
        ]
      },
      "post": {
        "description": "**Permission:** `followup:manage`",
        "operationId": "postCommercialFollowUps",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CommercialFollowUp"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records something to do.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "followup:manage"
        ]
      }
    },
    "/api/v1/commercial/follow-ups/{id}/close": {
      "post": {
        "description": "**Permission:** `followup:manage`",
        "operationId": "postCommercialFollowUpsIdClose",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "outcome": {
                    "type": "string"
                  },
                  "status": {
                    "enum": [
                      "DONE",
                      "CANCELLED"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records what happened.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "followup:manage"
        ]
      }
    },
    "/api/v1/commercial/interactions": {
      "get": {
        "description": "**Permission:** `client:read`",
        "operationId": "getCommercialInteractions",
        "parameters": [
          {
            "in": "query",
            "name": "client_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the contact log.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "client:read"
        ]
      },
      "post": {
        "description": "There is no update and no delete for these, deliberately. What somebody was told on the phone in June is not editable in July.\n\n**Permission:** `client:manage`",
        "operationId": "postCommercialInteractions",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CommercialInteraction"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Appends to the contact log.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "client:manage"
        ]
      }
    },
    "/api/v1/commercial/orders": {
      "get": {
        "description": "**Permission:** `quotation:read`",
        "operationId": "getCommercialOrders",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the order book.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "quotation:read"
        ]
      },
      "post": {
        "description": "**Permission:** `quotation:manage`",
        "operationId": "postCommercialOrders",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CommercialOrderInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Writes an order directly.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "quotation:manage"
        ]
      }
    },
    "/api/v1/commercial/orders/{id}/cancel": {
      "post": {
        "description": "**Permission:** `quotation:manage`",
        "operationId": "postCommercialOrdersIdCancel",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Closes an order with a reason.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "quotation:manage"
        ]
      }
    },
    "/api/v1/commercial/orders/{id}/lines/{line}/deliver": {
      "post": {
        "description": "**Permission:** `quotation:manage`",
        "operationId": "postCommercialOrdersIdLinesLineDeliver",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "line",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "batch_id": {
                    "description": "BatchID is required for a stocked line: the batch decides the expiry the customer receives and the cost the margin is computed from.",
                    "nullable": true,
                    "type": "string"
                  },
                  "quantity": {
                    "type": "number"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records what actually went out.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "quotation:manage"
        ]
      }
    },
    "/api/v1/commercial/quotations": {
      "get": {
        "description": "**Permission:** `quotation:read`",
        "operationId": "getCommercialQuotations",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the quote register.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "quotation:read"
        ]
      },
      "post": {
        "description": "**Permission:** `quotation:manage`",
        "operationId": "postCommercialQuotations",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CommercialQuotationInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Writes a quote.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "quotation:manage"
        ]
      }
    },
    "/api/v1/commercial/quotations/{id}/convert": {
      "post": {
        "description": "The lines are copied, prices and all. An order that repriced itself when the quote was touched would not be the price that was agreed.\n\n**Permission:** `quotation:manage`",
        "operationId": "postCommercialQuotationsIdConvert",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Turns a quote into an order.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "quotation:manage"
        ]
      }
    },
    "/api/v1/commercial/quotations/{id}/status": {
      "post": {
        "description": "**Permission:** `quotation:manage`",
        "operationId": "postCommercialQuotationsIdStatus",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  },
                  "status": {
                    "enum": [
                      "SENT",
                      "ACCEPTED",
                      "DECLINED",
                      "EXPIRED"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Sends, accepts, declines or expires a quote.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "quotation:manage"
        ]
      }
    },
    "/api/v1/commercial/returns": {
      "get": {
        "description": "**Permission:** `salesreturn:read`",
        "operationId": "getCommercialReturns",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists goods coming back.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "salesreturn:read"
        ]
      },
      "post": {
        "description": "**Permission:** `salesreturn:manage`",
        "operationId": "postCommercialReturns",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CommercialReturnInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Writes a return request.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "salesreturn:manage"
        ]
      }
    },
    "/api/v1/commercial/returns/{id}/decide": {
      "post": {
        "description": "Behind its own permission: a return puts money back and stock on a shelf, and the person handing over the refund should not be the person authorising it.\n\n**Permission:** `salesreturn:decide`",
        "operationId": "postCommercialReturnsIdDecide",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "note": {
                    "type": "string"
                  },
                  "status": {
                    "enum": [
                      "APPROVED",
                      "CREDITED",
                      "REJECTED"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Approves, credits or rejects.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "salesreturn:decide"
        ]
      }
    },
    "/api/v1/commercial/summary": {
      "get": {
        "description": "**Permission:** `client:read`",
        "operationId": "getCommercialSummary",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Counts the commercial side.",
        "tags": [
          "commercial"
        ],
        "x-permissions": [
          "client:read"
        ]
      }
    },
    "/api/v1/dashboard": {
      "get": {
        "description": "**From the router:** Administration. There is NO audit:write. Nothing outside the server writes the audit log — it is appended to as a side effect of what people do, and an endpoint that let a client post entries would let a client forge them. The dashboard is on everybody's menu: any signed-in person reads it, and sees the figures their own permissions let them see.\n\n**Access:** any signed-in account. No further permission.",
        "operationId": "getDashboard",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Counts the day.",
        "tags": [
          "dashboard"
        ]
      }
    },
    "/api/v1/devices": {
      "get": {
        "description": "**Permission:** `device:read`",
        "operationId": "getDevices",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "include_revoked",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Answers GET /api/v1/devices.",
        "tags": [
          "devices"
        ],
        "x-permissions": [
          "device:read"
        ]
      }
    },
    "/api/v1/devices/activate": {
      "post": {
        "description": "# NO TOKEN, BY NECESSITY\n\nA workstation being set up has nobody signed in on it: the activation screen comes BEFORE the login screen, because a machine that is not on the register cannot be trusted with a password. So the key is the credential, and it is one-time, expiring, rate-limited and refused off the hospital's own network.\n\nThe rate limit is on the route in the router, keyed on the caller's address — the same limiter the feedback pair uses, with a much tighter ceiling.\n\n**Access:** open — no token required.\n\n**Rate limit:** 5 per hour per client address.",
        "operationId": "postDevicesActivate",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DevicesClaim"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Too many requests from this address."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [],
        "summary": "Answers POST /api/v1/devices/activate.",
        "tags": [
          "devices"
        ],
        "x-rate-limit": "5 per hour"
      }
    },
    "/api/v1/devices/activations": {
      "post": {
        "description": "**From the router:** Issuing and withdrawing a key are the same permission: whoever may add a workstation may un-add one they have just mistyped.\n\n**Permission:** `device:issue`",
        "operationId": "postDevicesActivations",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DevicesNewActivation"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Answers POST /api/v1/devices/activations.",
        "tags": [
          "devices"
        ],
        "x-permissions": [
          "device:issue"
        ]
      }
    },
    "/api/v1/devices/activations/{id}": {
      "delete": {
        "description": "**Permission:** `device:issue`",
        "operationId": "deleteDevicesActivationsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Answers DELETE /api/v1/devices/activations/:id.",
        "tags": [
          "devices"
        ],
        "x-permissions": [
          "device:issue"
        ]
      }
    },
    "/api/v1/devices/events": {
      "get": {
        "description": "**Permission:** `device:read`",
        "operationId": "getDevicesEvents",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Answers GET /api/v1/devices/events and .../:id/events.",
        "tags": [
          "devices"
        ],
        "x-permissions": [
          "device:read"
        ]
      }
    },
    "/api/v1/devices/{id}/events": {
      "get": {
        "description": "**Permission:** `device:read`",
        "operationId": "getDevicesIdEvents",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Answers GET /api/v1/devices/events and .../:id/events.",
        "tags": [
          "devices"
        ],
        "x-permissions": [
          "device:read"
        ]
      }
    },
    "/api/v1/devices/{id}/revoke": {
      "post": {
        "description": "**From the router:** Withdrawing a WORKSTATION is its own permission. It is the action somebody takes when a laptop has been stolen, and it is also the action that frees a licence slot — so it belongs to whoever is answerable for the count.\n\n**Permission:** `device:revoke`",
        "operationId": "postDevicesIdRevoke",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Answers POST /api/v1/devices/:id/revoke.",
        "tags": [
          "devices"
        ],
        "x-permissions": [
          "device:revoke"
        ]
      }
    },
    "/api/v1/diagnostics/critical": {
      "get": {
        "description": "Gated on `lab:read` rather than something narrower: the point of this list is that somebody sees it. A permission that kept it from a ward nurse would be working against the only reason it exists.\n\n**From the router:** The critical list is gated on plain read on purpose: the whole point of it is that somebody sees it, and a narrower permission would work against the only reason it exists.\n\n**Permission:** `lab:read`",
        "operationId": "getDiagnosticsCritical",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns every critical value nobody has acknowledged.",
        "tags": [
          "diagnostics"
        ],
        "x-permissions": [
          "lab:read"
        ]
      }
    },
    "/api/v1/diagnostics/orders": {
      "get": {
        "description": "**Permission:** `lab:read`",
        "operationId": "getDiagnosticsOrders",
        "parameters": [
          {
            "in": "query",
            "name": "date",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "discipline",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "pending",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "priority",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the bench queue or the register.",
        "tags": [
          "diagnostics"
        ],
        "x-permissions": [
          "lab:read"
        ]
      },
      "post": {
        "description": "**Permission:** `lab:order`",
        "operationId": "postDiagnosticsOrders",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DiagnosticsOrderInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Places a request.",
        "tags": [
          "diagnostics"
        ],
        "x-permissions": [
          "lab:order"
        ]
      }
    },
    "/api/v1/diagnostics/orders/{id}": {
      "get": {
        "description": "**Permission:** `lab:read`",
        "operationId": "getDiagnosticsOrdersId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one order with its results.",
        "tags": [
          "diagnostics"
        ],
        "x-permissions": [
          "lab:read"
        ]
      }
    },
    "/api/v1/diagnostics/orders/{id}/advance": {
      "post": {
        "description": "**Permission:** `lab:process`",
        "operationId": "postDiagnosticsOrdersIdAdvance",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  },
                  "status": {
                    "enum": [
                      "ORDERED",
                      "AWAITING_PAYMENT",
                      "COLLECTED",
                      "IN_PROGRESS",
                      "RESULTED",
                      "VERIFIED",
                      "DELIVERED",
                      "CANCELLED"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Moves an order along the bench.",
        "tags": [
          "diagnostics"
        ],
        "x-permissions": [
          "lab:process"
        ]
      }
    },
    "/api/v1/diagnostics/orders/{id}/reject": {
      "post": {
        "description": "**Permission:** `lab:process`",
        "operationId": "postDiagnosticsOrdersIdReject",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Sends a sample back with the reason.",
        "tags": [
          "diagnostics"
        ],
        "x-permissions": [
          "lab:process"
        ]
      }
    },
    "/api/v1/diagnostics/orders/{id}/report": {
      "get": {
        "description": "Behind lab:read, the permission the same order needs on a screen — see PayslipPDF for why the paper and the screen answer to one gate.\n\n**From the router:** The report on paper, behind the gate the order has on a screen. It prints before verification under a PRELIMINARY stamp, and not at all while nothing is resulted (printing_lab.go).\n\n**Permission:** `lab:read`",
        "operationId": "getDiagnosticsOrdersIdReport",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "language",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/pdf": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "The document, as a PDF."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Draws the report for one order.",
        "tags": [
          "diagnostics"
        ],
        "x-permissions": [
          "lab:read"
        ]
      }
    },
    "/api/v1/diagnostics/orders/{id}/results": {
      "post": {
        "description": "**Permission:** `lab:result`",
        "operationId": "postDiagnosticsOrdersIdResults",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "results": {
                    "items": {
                      "$ref": "#/components/schemas/DiagnosticsResultInput"
                    },
                    "type": "array"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records values.",
        "tags": [
          "diagnostics"
        ],
        "x-permissions": [
          "lab:result"
        ]
      }
    },
    "/api/v1/diagnostics/orders/{id}/verify": {
      "post": {
        "description": "**Permission:** `lab:verify`",
        "operationId": "postDiagnosticsOrdersIdVerify",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Releases a result.",
        "tags": [
          "diagnostics"
        ],
        "x-permissions": [
          "lab:verify"
        ]
      }
    },
    "/api/v1/diagnostics/results/{id}/acknowledge": {
      "post": {
        "description": "**Permission:** `lab:read`",
        "operationId": "postDiagnosticsResultsIdAcknowledge",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records that a named person has seen a critical value.",
        "tags": [
          "diagnostics"
        ],
        "x-permissions": [
          "lab:read"
        ]
      }
    },
    "/api/v1/diagnostics/results/{id}/release": {
      "post": {
        "description": "Its own permission, because deciding that somebody may read their own result is a clinical judgement. It is the single point at which this system could otherwise tell a person they have cancer with nobody in the room.\n\n**From the router:** Releasing a result to the patient is a CLINICAL judgement, so it has its own permission rather than riding on lab:verify. It is the single point at which this system could otherwise tell somebody they have cancer with nobody in the room.\n\n**Permission:** `result:release`",
        "operationId": "postDiagnosticsResultsIdRelease",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "withhold_reason": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Makes a result visible to the patient, or withholds it.",
        "tags": [
          "diagnostics"
        ],
        "x-permissions": [
          "result:release"
        ]
      }
    },
    "/api/v1/diagnostics/summary": {
      "get": {
        "description": "**Permission:** `lab:read`",
        "operationId": "getDiagnosticsSummary",
        "parameters": [
          {
            "in": "query",
            "name": "discipline",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Counts the bench.",
        "tags": [
          "diagnostics"
        ],
        "x-permissions": [
          "lab:read"
        ]
      }
    },
    "/api/v1/diagnostics/tests": {
      "get": {
        "description": "**Permission:** `lab:read`",
        "operationId": "getDiagnosticsTests",
        "parameters": [
          {
            "in": "query",
            "name": "discipline",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the catalogue.",
        "tags": [
          "diagnostics"
        ],
        "x-permissions": [
          "lab:read"
        ]
      },
      "post": {
        "description": "**From the router:** Editing a reference range silently changes what counts as abnormal for every result entered afterwards. A manager's decision, not a bench technician's.\n\n**Permission:** `lab:manage`",
        "operationId": "postDiagnosticsTests",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DiagnosticsTestInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits a catalogue entry.",
        "tags": [
          "diagnostics"
        ],
        "x-permissions": [
          "lab:manage"
        ]
      }
    },
    "/api/v1/diagnostics/tests/{id}": {
      "put": {
        "description": "**Permission:** `lab:manage`",
        "operationId": "putDiagnosticsTestsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DiagnosticsTestInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits a catalogue entry.",
        "tags": [
          "diagnostics"
        ],
        "x-permissions": [
          "lab:manage"
        ]
      }
    },
    "/api/v1/feedback/forms": {
      "get": {
        "description": "**Permission:** `feedback:read`",
        "operationId": "getFeedbackForms",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 50,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the feedback forms.",
        "tags": [
          "feedback"
        ],
        "x-permissions": [
          "feedback:read"
        ]
      },
      "post": {
        "description": "**Permission:** `feedback:manage`",
        "operationId": "postFeedbackForms",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "anonymous": {
                    "description": "Anonymous defaults to TRUE when it is not sent, which is the opposite of Go's zero value and is the point.",
                    "nullable": true,
                    "type": "boolean"
                  },
                  "description": {
                    "type": "string"
                  },
                  "multiple": {
                    "type": "boolean"
                  },
                  "title": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Opens a new form, in draft.",
        "tags": [
          "feedback"
        ],
        "x-permissions": [
          "feedback:manage"
        ]
      }
    },
    "/api/v1/feedback/forms/{id}": {
      "get": {
        "description": "**Permission:** `feedback:read`",
        "operationId": "getFeedbackFormsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one with its questions.",
        "tags": [
          "feedback"
        ],
        "x-permissions": [
          "feedback:read"
        ]
      }
    },
    "/api/v1/feedback/forms/{id}/questions": {
      "post": {
        "description": "**Permission:** `feedback:manage`",
        "operationId": "postFeedbackFormsIdQuestions",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackQuestion"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Puts one question on a form.",
        "tags": [
          "feedback"
        ],
        "x-permissions": [
          "feedback:manage"
        ]
      }
    },
    "/api/v1/feedback/forms/{id}/results": {
      "get": {
        "description": "AGGREGATES ONLY. There is no route here that returns individual responses, and that is deliberate: on an anonymous form the individual answers are the one thing nobody in the hospital should be reading, and a route that returned them would be used the week somebody wanted to know who complained.\n\n**Permission:** `feedback:read`",
        "operationId": "getFeedbackFormsIdResults",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is what the answers came to.",
        "tags": [
          "feedback"
        ],
        "x-permissions": [
          "feedback:read"
        ]
      }
    },
    "/api/v1/feedback/forms/{id}/status": {
      "post": {
        "description": "**Permission:** `feedback:manage`",
        "operationId": "postFeedbackFormsIdStatus",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "status": {
                    "enum": [
                      "draft",
                      "published",
                      "closed"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Publishes a form or closes it.",
        "tags": [
          "feedback"
        ],
        "x-permissions": [
          "feedback:manage"
        ]
      }
    },
    "/api/v1/health": {
      "get": {
        "description": "It answers 200 even when the stack is in pieces. That is deliberate: this is a REPORT, not a probe. A 503 here would be read by a load balancer as \"the backend is down\" and take the console out over a service the console does not use, and the operator reading this screen needs the detail, not the refusal.\n\nThe probe runs on every call rather than from a cache. A health page that shows a stale green light is worse than no health page: somebody stops investigating.\n\n**Permission:** `platform:health`",
        "operationId": "getHealth",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Probes every microservice and reports the aggregate.",
        "tags": [
          "health"
        ],
        "x-permissions": [
          "platform:health"
        ]
      }
    },
    "/api/v1/hr/applicants": {
      "get": {
        "description": "**Permission:** `recruitment:read`",
        "operationId": "getHrApplicants",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 200,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "stage",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "vacancy_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the pipeline.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "recruitment:read"
        ]
      },
      "post": {
        "description": "**Permission:** `recruitment:manage`",
        "operationId": "postHrApplicants",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HrApplicant"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records an application.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "recruitment:manage"
        ]
      }
    },
    "/api/v1/hr/applicants/{id}/stage": {
      "post": {
        "description": "**Permission:** `recruitment:manage`",
        "operationId": "postHrApplicantsIdStage",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "note": {
                    "type": "string"
                  },
                  "score": {
                    "nullable": true,
                    "type": "integer"
                  },
                  "stage": {
                    "enum": [
                      "APPLIED",
                      "SHORTLISTED",
                      "INTERVIEWED",
                      "OFFERED",
                      "HIRED",
                      "REJECTED",
                      "WITHDRAWN"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Advances or rejects one.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "recruitment:manage"
        ]
      }
    },
    "/api/v1/hr/attendance": {
      "get": {
        "description": "**Permission:** `hr:read`",
        "operationId": "getHrAttendance",
        "parameters": [
          {
            "in": "query",
            "name": "date",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "department",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 200,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "staff_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns a day, or one person's history.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hr:read"
        ]
      },
      "post": {
        "description": "**Permission:** `hr:record`",
        "operationId": "postHrAttendance",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackAttendanceInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Writes one person's day.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hr:record"
        ]
      }
    },
    "/api/v1/hr/attendance/summary": {
      "get": {
        "description": "Its own route rather than a figure on the list, because it answers a question the list cannot: eleven people present means nothing until somebody knows whether eighty were expected.\n\n**Permission:** `hr:read`",
        "operationId": "getHrAttendanceSummary",
        "parameters": [
          {
            "in": "query",
            "name": "date",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is how much of a day has actually been entered.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hr:read"
        ]
      }
    },
    "/api/v1/hr/contracts": {
      "get": {
        "description": "Gated on `hr:read` rather than on a code of its own: an employment type and a contract end date are on every staff profile already. What is NOT here, and stays behind payroll's codes, is what anybody is paid.\n\n**Permission:** `hr:read`",
        "operationId": "getHrContracts",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists what everybody is employed on, soonest to lapse first.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hr:read"
        ]
      }
    },
    "/api/v1/hr/contracts/{staffId}": {
      "put": {
        "description": "{\"employment_type\":…, \"contract_start\":…, \"contract_end\":…, \"probation_months\":…, \"probation_end\":…, \"notes\":…}\n\n# WHY THIS ROUTE HAD TO EXIST\n\nThe Contracts and Onboarding screens could SEE that a contract runs out next month, that probation ended in March and nobody confirmed it, and offered no way to do anything about either. There was no route on this backend, and none on the console, that could write a contract term — the staff record carries the employment type and the start date and stops there. hr-service has always answered the write; nothing called it.\n\nBehind `employment:manage`, with the rest of the employment acts: renewing a contract is the same kind of decision as confirming a probation or recording a transfer, and it is written to the employment history the same way.\n\n**Permission:** `employment:manage`",
        "operationId": "putHrContractsStaffId",
        "parameters": [
          {
            "in": "path",
            "name": "staffId",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackContractInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Writes the terms one person is employed on.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "employment:manage"
        ]
      }
    },
    "/api/v1/hr/deductions": {
      "get": {
        "description": "**From the router:** Benefits and deductions. Gated on payroll's codes, because a standing deduction IS a line on a payslip. Somebody who may see what people are paid may see it; somebody who may build a run may set it.\n\n**Permission:** `payroll:read`",
        "operationId": "getHrDeductions",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "staff_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the standing amounts.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "payroll:read"
        ]
      },
      "post": {
        "description": "**Permission:** `payroll:manage`",
        "operationId": "postHrDeductions",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackPayDeductionInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Starts a standing amount, or edits one.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "payroll:manage"
        ]
      }
    },
    "/api/v1/hr/deductions/{id}": {
      "delete": {
        "description": "**Permission:** `payroll:manage`",
        "operationId": "deleteHrDeductionsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Ends a standing amount.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "payroll:manage"
        ]
      },
      "put": {
        "description": "**Permission:** `payroll:manage`",
        "operationId": "putHrDeductionsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackPayDeductionInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Starts a standing amount, or edits one.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "payroll:manage"
        ]
      }
    },
    "/api/v1/hr/departments": {
      "get": {
        "description": "**From the router:** The establishment. The employing departments, the posts inside them and the pay bands those posts sit on. All three come from hr-service, which owns them because a payroll run is grouped by them. These are gated on `department:*` and `position:*` rather than on `hr:read`, because picking a post from a dropdown and inventing a post are different acts: one is done by anybody filling in a transfer form, the other commits a salary the budget carries.\n\n**Permission:** `department:read`",
        "operationId": "getHrDepartments",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the employing departments.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "department:read"
        ]
      },
      "post": {
        "description": "**Permission:** `department:manage`",
        "operationId": "postHrDepartments",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackDepartmentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Opens a department, or edits one.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "department:manage"
        ]
      }
    },
    "/api/v1/hr/departments/{id}": {
      "delete": {
        "description": "**Permission:** `department:manage`",
        "operationId": "deleteHrDepartmentsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Closes a department.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "department:manage"
        ]
      },
      "put": {
        "description": "**Permission:** `department:manage`",
        "operationId": "putHrDepartmentsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackDepartmentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Opens a department, or edits one.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "department:manage"
        ]
      }
    },
    "/api/v1/hr/disciplinary": {
      "get": {
        "description": "IT IS THE SAME EVENT LOG as onboarding and offboarding read, filtered to the acts that take somebody off duty and put them back. There is no separate disciplinary record because a suspension already IS one: it has a date, a reason, a decision about pay and the name of whoever made it.\n\n**Permission:** `employment:manage`",
        "operationId": "getHrDisciplinary",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 0,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "staff_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists suspensions and returns to duty.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "employment:manage"
        ]
      }
    },
    "/api/v1/hr/documents": {
      "get": {
        "description": "**From the router:** The personnel file. Its own codes, not `hr:read`. This is somebody's qualifications, their identity documents and their police clearance — the most sensitive reading in employment after payroll. `/expiring` and `/summary` are registered BEFORE `/:id` would be a problem, and there is no `/:id` GET at all: a single document is read from the listing the console already has, and a route that took an id here would shadow both of these words.\n\n**Permission:** `hrdocument:read`",
        "operationId": "getHrDocuments",
        "parameters": [
          {
            "in": "query",
            "name": "expiring_within",
            "required": false,
            "schema": {
              "default": 0,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 0,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "staff_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "type_code",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "unverified",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the personnel papers.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hrdocument:read"
        ]
      },
      "post": {
        "description": "**Permission:** `hrdocument:manage`",
        "operationId": "postHrDocuments",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackEmployeeDocumentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records a paper, or edits one.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hrdocument:manage"
        ]
      }
    },
    "/api/v1/hr/documents/expiring": {
      "get": {
        "description": "**Permission:** `hrdocument:read`",
        "operationId": "getHrDocumentsExpiring",
        "parameters": [
          {
            "in": "query",
            "name": "days",
            "required": false,
            "schema": {
              "default": 0,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is the renewal list.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hrdocument:read"
        ]
      }
    },
    "/api/v1/hr/documents/summary": {
      "get": {
        "description": "**Permission:** `hrdocument:read`",
        "operationId": "getHrDocumentsSummary",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Counts the file.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hrdocument:read"
        ]
      }
    },
    "/api/v1/hr/documents/{id}": {
      "delete": {
        "description": "**Permission:** `hrdocument:manage`",
        "operationId": "deleteHrDocumentsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Withdraws a filed paper.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hrdocument:manage"
        ]
      },
      "put": {
        "description": "**Permission:** `hrdocument:manage`",
        "operationId": "putHrDocumentsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackEmployeeDocumentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records a paper, or edits one.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hrdocument:manage"
        ]
      }
    },
    "/api/v1/hr/documents/{id}/verify": {
      "post": {
        "description": "**Permission:** `hrdocument:manage`",
        "operationId": "postHrDocumentsIdVerify",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records that somebody has seen the original.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hrdocument:manage"
        ]
      }
    },
    "/api/v1/hr/employment-events": {
      "get": {
        "description": "**From the router:** Joining and leaving. Onboarding and offboarding are both a list of employment events with dates and names against them, so they read the same endpoint and differ only by which event types they ask for. The exit-type list is SERVED rather than hard-coded in the client, so the reasons on the form are the reasons hr-service accepts.\n\n**Permission:** `hr:read`",
        "operationId": "getHrEmploymentEvents",
        "parameters": [
          {
            "in": "query",
            "name": "event_type",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 0,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "staff_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists what has happened, across everybody or for one person.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hr:read"
        ]
      }
    },
    "/api/v1/hr/employment/confirm": {
      "post": {
        "description": "**Permission:** `employment:manage`",
        "operationId": "postHrEmploymentConfirm",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackConfirmInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Ends probation.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "employment:manage"
        ]
      }
    },
    "/api/v1/hr/employment/reinstate": {
      "post": {
        "description": "**Permission:** `employment:manage`",
        "operationId": "postHrEmploymentReinstate",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackReinstateInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns somebody to duty.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "employment:manage"
        ]
      }
    },
    "/api/v1/hr/employment/suspend": {
      "post": {
        "description": "**Permission:** `employment:manage`",
        "operationId": "postHrEmploymentSuspend",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackSuspendInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Takes somebody off duty.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "employment:manage"
        ]
      }
    },
    "/api/v1/hr/employment/terminate": {
      "post": {
        "description": "**Permission:** `employment:manage`",
        "operationId": "postHrEmploymentTerminate",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackTerminateInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records that somebody has left.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "employment:manage"
        ]
      }
    },
    "/api/v1/hr/employment/transfer": {
      "post": {
        "description": "**Permission:** `employment:manage`",
        "operationId": "postHrEmploymentTransfer",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackTransferInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records a move, a promotion or a redeployment.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "employment:manage"
        ]
      }
    },
    "/api/v1/hr/exit-types": {
      "get": {
        "description": "Served rather than hard-coded in the client so the choices on the form are the choices hr-service will actually accept. A dropdown offering a reason the service refuses is a form that cannot be submitted and does not say why.\n\n**Permission:** `hr:read`",
        "operationId": "getHrExitTypes",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is the list of exit types the console offers.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hr:read"
        ]
      }
    },
    "/api/v1/hr/leave": {
      "get": {
        "description": "**Permission:** `leave:read`",
        "operationId": "getHrLeave",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "staff_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns applications.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "leave:read"
        ]
      },
      "post": {
        "description": "**Permission:** `leave:request`",
        "operationId": "postHrLeave",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackLeaveInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records an application.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "leave:request"
        ]
      }
    },
    "/api/v1/hr/leave/balances": {
      "get": {
        "description": "**Permission:** `leave:read`",
        "operationId": "getHrLeaveBalances",
        "parameters": [
          {
            "in": "query",
            "name": "department",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "staff_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "year",
            "required": false,
            "schema": {
              "default": 0,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Computes entitlement against what has been taken.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "leave:read"
        ]
      }
    },
    "/api/v1/hr/leave/entitlements": {
      "post": {
        "description": "**Permission:** `leave:approve`",
        "operationId": "postHrLeaveEntitlements",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "carried_over": {
                    "type": "number"
                  },
                  "days": {
                    "type": "number"
                  },
                  "leave_type": {
                    "type": "string"
                  },
                  "staff_id": {
                    "type": "string"
                  },
                  "year": {
                    "type": "integer"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Sets what somebody is entitled to.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "leave:approve"
        ]
      }
    },
    "/api/v1/hr/leave/{id}/decide": {
      "post": {
        "description": "The repository refuses to let anybody approve their own. That is not a permission question — it is the point of an approval.\n\n**Permission:** `leave:approve`",
        "operationId": "postHrLeaveIdDecide",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "note": {
                    "type": "string"
                  },
                  "status": {
                    "enum": [
                      "APPROVED",
                      "REJECTED"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Approves or rejects.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "leave:approve"
        ]
      }
    },
    "/api/v1/hr/leavers": {
      "get": {
        "description": "A separate call from the employment history because the two answer different questions: the history is a timeline of acts, this is the current state of everybody who has gone — and it is the only one that carries whether the hospital would have them back.\n\n**Permission:** `hr:read`",
        "operationId": "getHrLeavers",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists everybody who has left, with the exit detail.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hr:read"
        ]
      }
    },
    "/api/v1/hr/payroll": {
      "get": {
        "description": "**Permission:** `payroll:read`",
        "operationId": "getHrPayroll",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 24,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the runs.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "payroll:read"
        ]
      },
      "post": {
        "description": "**Permission:** `payroll:manage`",
        "operationId": "postHrPayroll",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "month": {
                    "type": "integer"
                  },
                  "year": {
                    "type": "integer"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Builds a month and computes it.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "payroll:manage"
        ]
      }
    },
    "/api/v1/hr/payroll/{id}": {
      "get": {
        "description": "**Permission:** `payroll:read`",
        "operationId": "getHrPayrollId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one run with its register.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "payroll:read"
        ]
      }
    },
    "/api/v1/hr/payroll/{id}/compute": {
      "post": {
        "description": "SAFE TO PRESS TWICE. Each computation undoes the previous one -- including the instalments it took off everybody's salary advances -- which is the whole reason this is a service's job and not a screen's.\n\n**Permission:** `payroll:manage`",
        "operationId": "postHrPayrollIdCompute",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Works a draft month out again.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "payroll:manage"
        ]
      }
    },
    "/api/v1/hr/payroll/{id}/status": {
      "post": {
        "description": "**Permission:** `payroll:approve`",
        "operationId": "postHrPayrollIdStatus",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  },
                  "status": {
                    "enum": [
                      "APPROVED",
                      "PAID"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Approves, pays or cancels.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "payroll:approve"
        ]
      }
    },
    "/api/v1/hr/payslips": {
      "get": {
        "description": "**Permission:** `payroll:read`",
        "operationId": "getHrPayslips",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "run_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "staff_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns a run's register, or one person's history.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "payroll:read"
        ]
      }
    },
    "/api/v1/hr/payslips/{id}/pdf": {
      "get": {
        "description": "WHOEVER MAY READ PAYROLL MAY PRINT IT. There is no separate print permission, because a payslip on a screen and the same payslip on paper carry exactly the same information — a gate on one and not the other protects nothing and merely stops somebody doing their job at the printer.\n\nIt uses the payment_voucher template, and that is not a compromise: a payslip IS a voucher for a payment, with the gross as lines, the statutory deductions as negative lines, and the net as the amount. Drawing it from the same template as everything else the institution pays out means one letterhead, one signature block, and one place to change them.\n\n**From the router:** The payslip on paper. Same permission as the payslip on a screen: they carry identical information, and gating one and not the other protects nothing while stopping somebody at the printer.\n\n**Permission:** `payroll:read`",
        "operationId": "getHrPayslipsIdPdf",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "language",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/pdf": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "The document, as a PDF."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Draws one payslip.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "payroll:read"
        ]
      }
    },
    "/api/v1/hr/performance/objectives": {
      "get": {
        "description": "**Permission:** `appraisal:read`",
        "operationId": "getHrPerformanceObjectives",
        "parameters": [
          {
            "in": "query",
            "name": "appraisal_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "open",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "staff_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns goals.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "appraisal:read"
        ]
      },
      "post": {
        "description": "**Permission:** `appraisal:manage`",
        "operationId": "postHrPerformanceObjectives",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackObjectiveInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Sets a goal, or edits one.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "appraisal:manage"
        ]
      }
    },
    "/api/v1/hr/performance/objectives/{id}": {
      "delete": {
        "description": "**Permission:** `appraisal:manage`",
        "operationId": "deleteHrPerformanceObjectivesId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Withdraws a goal.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "appraisal:manage"
        ]
      },
      "put": {
        "description": "**Permission:** `appraisal:manage`",
        "operationId": "putHrPerformanceObjectivesId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackObjectiveInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Sets a goal, or edits one.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "appraisal:manage"
        ]
      }
    },
    "/api/v1/hr/performance/reviews": {
      "get": {
        "description": "**Permission:** `appraisal:read`",
        "operationId": "getHrPerformanceReviews",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "overdue",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "period",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "staff_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns reviews.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "appraisal:read"
        ]
      },
      "post": {
        "description": "**Permission:** `appraisal:manage`",
        "operationId": "postHrPerformanceReviews",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackAppraisalInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Opens a review, or edits one.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "appraisal:manage"
        ]
      }
    },
    "/api/v1/hr/performance/reviews/{id}": {
      "delete": {
        "description": "**Permission:** `appraisal:manage`",
        "operationId": "deleteHrPerformanceReviewsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Removes a review that was never acknowledged.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "appraisal:manage"
        ]
      },
      "get": {
        "description": "**Permission:** `appraisal:read`",
        "operationId": "getHrPerformanceReviewsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Reads one review with its objectives.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "appraisal:read"
        ]
      },
      "put": {
        "description": "**Permission:** `appraisal:manage`",
        "operationId": "putHrPerformanceReviewsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackAppraisalInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Opens a review, or edits one.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "appraisal:manage"
        ]
      }
    },
    "/api/v1/hr/performance/reviews/{id}/status": {
      "post": {
        "description": "A SEPARATE ROUTE FROM THE EDIT. Editing changes what the appraisal says; moving it changes who has seen it. One form doing both would let a save meant to fix a typo also put the document in front of somebody.\n\n**Permission:** `appraisal:manage`",
        "operationId": "postHrPerformanceReviewsIdStatus",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "status": {
                    "enum": [
                      "submitted",
                      "acknowledged"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Puts a review to the employee, or records that they have seen it.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "appraisal:manage"
        ]
      }
    },
    "/api/v1/hr/performance/summary": {
      "get": {
        "description": "**From the router:** Appraisals. `/summary` is registered before `/reviews/:id` could shadow it, and moving a review is its own route: editing changes what the appraisal says, moving it changes who has seen it.\n\n**Permission:** `appraisal:read`",
        "operationId": "getHrPerformanceSummary",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Counts the appraisals and objectives.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "appraisal:read"
        ]
      }
    },
    "/api/v1/hr/positions": {
      "get": {
        "description": "**Permission:** `position:read`",
        "operationId": "getHrPositions",
        "parameters": [
          {
            "in": "query",
            "name": "department_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "vacant",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the established posts.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "position:read"
        ]
      },
      "post": {
        "description": "**Permission:** `position:manage`",
        "operationId": "postHrPositions",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackJobPositionInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Opens a post, or edits one.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "position:manage"
        ]
      }
    },
    "/api/v1/hr/positions/{id}": {
      "delete": {
        "description": "**Permission:** `position:manage`",
        "operationId": "deleteHrPositionsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Abolishes a post.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "position:manage"
        ]
      },
      "put": {
        "description": "**Permission:** `position:manage`",
        "operationId": "putHrPositionsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackJobPositionInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Opens a post, or edits one.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "position:manage"
        ]
      }
    },
    "/api/v1/hr/roster": {
      "get": {
        "description": "**Permission:** `hr:read`",
        "operationId": "getHrRoster",
        "parameters": [
          {
            "in": "query",
            "name": "department",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns shifts, staffed or not.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hr:read"
        ]
      }
    },
    "/api/v1/hr/roster/shifts": {
      "post": {
        "description": "FOR THAT WEEKDAY, NOT THAT DATE. hr-service keeps the requirement as policy — \"maternity nights need three\" — rather than as a row per date, so a matron declares it once instead of every week. The screen says so.\n\n**Permission:** `hr:record`",
        "operationId": "postHrRosterShifts",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackShiftInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Declares how many people a slot needs.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hr:record"
        ]
      }
    },
    "/api/v1/hr/roster/shifts/{id}/assign": {
      "post": {
        "description": "**Permission:** `hr:record`",
        "operationId": "postHrRosterShiftsIdAssign",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "role": {
                    "type": "string"
                  },
                  "staff_id": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Puts somebody on a shift.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hr:record"
        ]
      }
    },
    "/api/v1/hr/roster/shifts/{id}/assign/{staff}": {
      "delete": {
        "description": "**Permission:** `hr:record`",
        "operationId": "deleteHrRosterShiftsIdAssignStaff",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "staff",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Takes somebody off.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hr:record"
        ]
      }
    },
    "/api/v1/hr/salaries": {
      "get": {
        "description": "Behind `payroll:read`, which is the most sensitive read in the system: it is every salary in the hospital on one screen.\n\n**From the router:** What people are paid, and the table it is taxed by. Both are `payroll:manage`: they are what a run is BUILT from, and the person who builds a run is not the person who signs it off.\n\n**Permission:** `payroll:read`",
        "operationId": "getHrSalaries",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is everybody's current pay.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "payroll:read"
        ]
      },
      "post": {
        "description": "A REASON IS REQUIRED. It is the question every HR manager is asked about a salary they did not set, and nothing else on the record can answer it.\n\n**Permission:** `payroll:manage`",
        "operationId": "postHrSalaries",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "basic_salary": {
                    "type": "number"
                  },
                  "effective_from": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  },
                  "staff_id": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Writes what one member of staff is paid.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "payroll:manage"
        ]
      }
    },
    "/api/v1/hr/salary-grades": {
      "get": {
        "description": "**Permission:** `position:read`",
        "operationId": "getHrSalaryGrades",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the pay bands.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "position:read"
        ]
      },
      "post": {
        "description": "**Permission:** `position:manage`",
        "operationId": "postHrSalaryGrades",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackSalaryGradeInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Opens a pay band, or edits one.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "position:manage"
        ]
      }
    },
    "/api/v1/hr/salary-grades/{id}": {
      "delete": {
        "description": "**Permission:** `position:manage`",
        "operationId": "deleteHrSalaryGradesId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Retires a pay band.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "position:manage"
        ]
      },
      "put": {
        "description": "**Permission:** `position:manage`",
        "operationId": "putHrSalaryGradesId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackSalaryGradeInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Opens a pay band, or edits one.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "position:manage"
        ]
      }
    },
    "/api/v1/hr/settings": {
      "get": {
        "description": "**From the router:** The coded lists. `/settings/adopt` is registered BEFORE `/settings/:kind`, because gin would otherwise match \"adopt\" as a catalogue name and the button that sets up a fresh deployment would 400 on the word it posts to.\n\n**Permission:** `hrsetting:read`",
        "operationId": "getHrSettings",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the kinds, and what adopting the defaults offers.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hrsetting:read"
        ]
      }
    },
    "/api/v1/hr/settings/adopt": {
      "post": {
        "description": "**Permission:** `hrsetting:manage`",
        "operationId": "postHrSettingsAdopt",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "kinds": {
                    "description": "Which lists to fill with the defaults — stack.HRCatalogueKinds.",
                    "enum": [
                      "employment-types",
                      "document-types",
                      "leave-types",
                      "shift-types",
                      "salary-components",
                      "holidays"
                    ],
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Writes the suggested defaults into the catalogues.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hrsetting:manage"
        ]
      }
    },
    "/api/v1/hr/settings/values": {
      "get": {
        "description": "The keys ride along with the values deliberately. A screen that received the values alone would have to carry its own copy of the key list — label, type, default, the sentence explaining what reads it — and that copy would go stale the first time hr-service added a rule. Sent together, a new rule appears on the screen without a console release.\n\n**From the router:** The rules, as opposed to the lists: when the leave year starts, which day people are paid, what an overtime hour is worth. Static segments before the :kind ones below, which is also how gin reads them — /settings/values is not a catalogue called \"values\".\n\n**Permission:** `hrsetting:read`",
        "operationId": "getHrSettingsValues",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the institution's employment rules, and the rules it may set, in one answer.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hrsetting:read"
        ]
      },
      "put": {
        "description": "Only what the form edited is sent, which is what keeps \"not decided\" a state the institution can be in. See the note on SaveHRPolicySettings.\n\n**Permission:** `hrsetting:manage`",
        "operationId": "putHrSettingsValues",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "values": {
                    "additionalProperties": {
                      "type": "string"
                    },
                    "type": "object"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Writes the rules that changed.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hrsetting:manage"
        ]
      }
    },
    "/api/v1/hr/settings/{kind}": {
      "get": {
        "description": "**Permission:** `hrsetting:read`",
        "operationId": "getHrSettingsKind",
        "parameters": [
          {
            "in": "path",
            "name": "kind",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one catalogue.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hrsetting:read"
        ]
      },
      "post": {
        "description": "**Permission:** `hrsetting:manage`",
        "operationId": "postHrSettingsKind",
        "parameters": [
          {
            "in": "path",
            "name": "kind",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackHRSettingInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds an entry to a catalogue, or edits one.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hrsetting:manage"
        ]
      }
    },
    "/api/v1/hr/settings/{kind}/{id}": {
      "delete": {
        "description": "**Permission:** `hrsetting:manage`",
        "operationId": "deleteHrSettingsKindId",
        "parameters": [
          {
            "in": "path",
            "name": "kind",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Withdraws an entry.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hrsetting:manage"
        ]
      },
      "put": {
        "description": "**Permission:** `hrsetting:manage`",
        "operationId": "putHrSettingsKindId",
        "parameters": [
          {
            "in": "path",
            "name": "kind",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackHRSettingInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds an entry to a catalogue, or edits one.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hrsetting:manage"
        ]
      }
    },
    "/api/v1/hr/summary": {
      "get": {
        "description": "**Permission:** `hr:read`",
        "operationId": "getHrSummary",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is the overview.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hr:read"
        ]
      }
    },
    "/api/v1/hr/tax-bands": {
      "get": {
        "description": "AN EMPTY TABLE IS A REAL ANSWER, not a fault. No deployment ships with tax rates -- they are set by law and changed by budget speeches -- so an empty list means this year's have not been entered, and the payroll run says so in words the person approving it will read.\n\n**Permission:** `payroll:read`",
        "operationId": "getHrTaxBands",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is the PAYE table in force.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "payroll:read"
        ]
      },
      "put": {
        "description": "THE WHOLE TABLE AT ONCE. The bands only make sense together, and a table half-way between last year's and this year's computes a figure that was never lawful in either. The old table is not deleted: it stays in force up to the day before, which is what lets a re-computed March run produce March's tax.\n\n**Permission:** `payroll:manage`",
        "operationId": "putHrTaxBands",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "bands": {
                    "items": {
                      "$ref": "#/components/schemas/StackTaxBand"
                    },
                    "type": "array"
                  },
                  "effective_from": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Replaces the whole PAYE table from a date.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "payroll:manage"
        ]
      }
    },
    "/api/v1/hr/training": {
      "get": {
        "description": "**Permission:** `hr:read`",
        "operationId": "getHrTraining",
        "parameters": [
          {
            "in": "query",
            "name": "expiring",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 200,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "mandatory",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "staff_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the CPD register.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hr:read"
        ]
      },
      "post": {
        "description": "**Permission:** `hr:record`",
        "operationId": "postHrTraining",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HrTrainingInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records a course.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hr:record"
        ]
      }
    },
    "/api/v1/hr/training/{id}": {
      "put": {
        "description": "**Permission:** `hr:record`",
        "operationId": "putHrTrainingId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HrTrainingChange"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Corrects a course on the record.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hr:record"
        ]
      }
    },
    "/api/v1/hr/turnover": {
      "get": {
        "description": "**Permission:** `hr:read`",
        "operationId": "getHrTurnover",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is the leaving report.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "hr:read"
        ]
      }
    },
    "/api/v1/hr/vacancies": {
      "get": {
        "description": "**Permission:** `recruitment:read`",
        "operationId": "getHrVacancies",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns open posts with their pipelines.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "recruitment:read"
        ]
      },
      "post": {
        "description": "**Permission:** `recruitment:manage`",
        "operationId": "postHrVacancies",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HrVacancy"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Posts or edits one.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "recruitment:manage"
        ]
      }
    },
    "/api/v1/hr/vacancies/{id}": {
      "put": {
        "description": "**Permission:** `recruitment:manage`",
        "operationId": "putHrVacanciesId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HrVacancy"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Posts or edits one.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "recruitment:manage"
        ]
      }
    },
    "/api/v1/hr/vacancies/{id}/status": {
      "post": {
        "description": "**Permission:** `recruitment:manage`",
        "operationId": "postHrVacanciesIdStatus",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  },
                  "status": {
                    "enum": [
                      "OPEN",
                      "CLOSED",
                      "FILLED",
                      "CANCELLED"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Closes or fills a post.",
        "tags": [
          "hr"
        ],
        "x-permissions": [
          "recruitment:manage"
        ]
      }
    },
    "/api/v1/inpatient/admissions": {
      "get": {
        "description": "**Permission:** `admission:read`",
        "operationId": "getInpatientAdmissions",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "ward_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the ward register.",
        "tags": [
          "inpatient"
        ],
        "x-permissions": [
          "admission:read"
        ]
      },
      "post": {
        "description": "**Permission:** `admission:create`",
        "operationId": "postInpatientAdmissions",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InpatientAdmissionInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Takes a patient onto a ward.",
        "tags": [
          "inpatient"
        ],
        "x-permissions": [
          "admission:create"
        ]
      }
    },
    "/api/v1/inpatient/admissions/{id}": {
      "get": {
        "description": "**Permission:** `admission:read`",
        "operationId": "getInpatientAdmissionsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one stay.",
        "tags": [
          "inpatient"
        ],
        "x-permissions": [
          "admission:read"
        ]
      }
    },
    "/api/v1/inpatient/admissions/{id}/discharge": {
      "post": {
        "description": "**Permission:** `admission:discharge`",
        "operationId": "postInpatientAdmissionsIdDischarge",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "summary": {
                    "type": "string"
                  },
                  "type": {
                    "description": "How the stay ended — admissions.discharge_type.",
                    "enum": [
                      "Recovered",
                      "Improved",
                      "Referred",
                      "Against advice",
                      "Absconded",
                      "Died"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Closes a stay and frees the bed.",
        "tags": [
          "inpatient"
        ],
        "x-permissions": [
          "admission:discharge"
        ]
      }
    },
    "/api/v1/inpatient/admissions/{id}/journey": {
      "get": {
        "description": "Asked after an infection is traced: \"which bed was she in on the 14th\".\n\n**Permission:** `admission:read`",
        "operationId": "getInpatientAdmissionsIdJourney",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns every bed a stay has occupied.",
        "tags": [
          "inpatient"
        ],
        "x-permissions": [
          "admission:read"
        ]
      }
    },
    "/api/v1/inpatient/admissions/{id}/sign": {
      "post": {
        "description": "Its own permission: a ward clerk types the summary, a clinician signs it. One permission for both would make the signature meaningless.\n\n**Permission:** `admission:sign`",
        "operationId": "postInpatientAdmissionsIdSign",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Signs the discharge summary, once.",
        "tags": [
          "inpatient"
        ],
        "x-permissions": [
          "admission:sign"
        ]
      }
    },
    "/api/v1/inpatient/admissions/{id}/summary": {
      "put": {
        "description": "**Permission:** `admission:update`",
        "operationId": "putInpatientAdmissionsIdSummary",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "summary": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Writes or edits the discharge summary, before it is signed.",
        "tags": [
          "inpatient"
        ],
        "x-permissions": [
          "admission:update"
        ]
      }
    },
    "/api/v1/inpatient/admissions/{id}/transfer": {
      "post": {
        "description": "**Permission:** `admission:update`",
        "operationId": "postInpatientAdmissionsIdTransfer",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "bed_id": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Moves a patient to another bed.",
        "tags": [
          "inpatient"
        ],
        "x-permissions": [
          "admission:update"
        ]
      }
    },
    "/api/v1/inpatient/beds": {
      "get": {
        "description": "**Permission:** `ward:read`",
        "operationId": "getInpatientBeds",
        "parameters": [
          {
            "in": "query",
            "name": "ward_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the bed board.",
        "tags": [
          "inpatient"
        ],
        "x-permissions": [
          "ward:read"
        ]
      }
    },
    "/api/v1/inpatient/beds/{id}": {
      "put": {
        "description": "**Permission:** `ward:manage`",
        "operationId": "putInpatientBedsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InpatientBedInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds a bed or changes its state.",
        "tags": [
          "inpatient"
        ],
        "x-permissions": [
          "ward:manage"
        ]
      }
    },
    "/api/v1/inpatient/summary": {
      "get": {
        "description": "**Permission:** `ward:read`",
        "operationId": "getInpatientSummary",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Counts the wards.",
        "tags": [
          "inpatient"
        ],
        "x-permissions": [
          "ward:read"
        ]
      }
    },
    "/api/v1/inpatient/wards": {
      "get": {
        "description": "**Permission:** `ward:read`",
        "operationId": "getInpatientWards",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the wards with live occupancy.",
        "tags": [
          "inpatient"
        ],
        "x-permissions": [
          "ward:read"
        ]
      },
      "post": {
        "description": "**Permission:** `ward:manage`",
        "operationId": "postInpatientWards",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InpatientWardInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Opens or edits a ward.",
        "tags": [
          "inpatient"
        ],
        "x-permissions": [
          "ward:manage"
        ]
      }
    },
    "/api/v1/inpatient/wards/{id}": {
      "put": {
        "description": "**Permission:** `ward:manage`",
        "operationId": "putInpatientWardsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InpatientWardInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Opens or edits a ward.",
        "tags": [
          "inpatient"
        ],
        "x-permissions": [
          "ward:manage"
        ]
      }
    },
    "/api/v1/inpatient/wards/{id}/beds": {
      "post": {
        "description": "**Permission:** `ward:manage`",
        "operationId": "postInpatientWardsIdBeds",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InpatientBedInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds a bed or changes its state.",
        "tags": [
          "inpatient"
        ],
        "x-permissions": [
          "ward:manage"
        ]
      }
    },
    "/api/v1/inventory/batches": {
      "get": {
        "description": "**Permission:** `inventory:read`",
        "operationId": "getInventoryBatches",
        "parameters": [
          {
            "in": "query",
            "name": "expiring",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "product_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns what is on the shelf, first to expire first.",
        "tags": [
          "inventory"
        ],
        "x-permissions": [
          "inventory:read"
        ]
      }
    },
    "/api/v1/inventory/batches/{id}/quarantine": {
      "post": {
        "description": "**Permission:** `stock:issue`",
        "operationId": "postInventoryBatchesIdQuarantine",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Withdraws a batch — a recall, damage in transit.",
        "tags": [
          "inventory"
        ],
        "x-permissions": [
          "stock:issue"
        ]
      }
    },
    "/api/v1/inventory/movements": {
      "get": {
        "description": "**Permission:** `inventory:read`",
        "operationId": "getInventoryMovements",
        "parameters": [
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "kind",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 200,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "product_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the ledger.",
        "tags": [
          "inventory"
        ],
        "x-permissions": [
          "inventory:read"
        ]
      },
      "post": {
        "description": "**Permission:** `stock:issue`",
        "operationId": "postInventoryMovements",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InventoryMovementInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Issues, writes off, returns or adjusts.",
        "tags": [
          "inventory"
        ],
        "x-permissions": [
          "stock:issue"
        ]
      }
    },
    "/api/v1/inventory/preferences": {
      "get": {
        "description": "**Permission:** `inventory:read`",
        "operationId": "getInventoryPreferences",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the one row of catalogue settings.",
        "tags": [
          "inventory"
        ],
        "x-permissions": [
          "inventory:read"
        ]
      },
      "put": {
        "description": "**Permission:** `inventory:manage`",
        "operationId": "putInventoryPreferences",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InventoryCataloguePreferencesInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Edits them.",
        "tags": [
          "inventory"
        ],
        "x-permissions": [
          "inventory:manage"
        ]
      }
    },
    "/api/v1/inventory/products": {
      "get": {
        "description": "**Permission:** `inventory:read`",
        "operationId": "getInventoryProducts",
        "parameters": [
          {
            "in": "query",
            "name": "category",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "kind",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "low",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "default": 1,
              "type": "integer"
            }
          },
          {
            "description": "Capped at 200. `page_size` is accepted as an alias.",
            "in": "query",
            "name": "per_page",
            "required": false,
            "schema": {
              "default": 50,
              "type": "integer"
            }
          },
          {
            "description": "Free-text filter.",
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "stockable",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PagedEnvelope"
                }
              }
            },
            "description": "A page of rows, with `meta` carrying the counts."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the catalogue with live stock figures.",
        "tags": [
          "inventory"
        ],
        "x-permissions": [
          "inventory:read"
        ]
      },
      "post": {
        "description": "**Permission:** `inventory:manage`",
        "operationId": "postInventoryProducts",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InventoryProductInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits a catalogue entry.",
        "tags": [
          "inventory"
        ],
        "x-permissions": [
          "inventory:manage"
        ]
      }
    },
    "/api/v1/inventory/products/{id}": {
      "put": {
        "description": "**Permission:** `inventory:manage`",
        "operationId": "putInventoryProductsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InventoryProductInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits a catalogue entry.",
        "tags": [
          "inventory"
        ],
        "x-permissions": [
          "inventory:manage"
        ]
      }
    },
    "/api/v1/inventory/products/{id}/variants": {
      "get": {
        "description": "**Permission:** `inventory:read`",
        "operationId": "getInventoryProductsIdVariants",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns what a product comes in.",
        "tags": [
          "inventory"
        ],
        "x-permissions": [
          "inventory:read"
        ]
      },
      "post": {
        "description": "**Permission:** `inventory:manage`",
        "operationId": "postInventoryProductsIdVariants",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InventoryVariantInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds a variant or edits one.",
        "tags": [
          "inventory"
        ],
        "x-permissions": [
          "inventory:manage"
        ]
      }
    },
    "/api/v1/inventory/receipts": {
      "post": {
        "description": "**Permission:** `stock:receive`",
        "operationId": "postInventoryReceipts",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InventoryReceiptInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Books a delivery in.",
        "tags": [
          "inventory"
        ],
        "x-permissions": [
          "stock:receive"
        ]
      }
    },
    "/api/v1/inventory/settings": {
      "get": {
        "description": "**From the router:** The catalogue's own lists. One endpoint keyed on `:kind`, the same shape the HR catalogues use — three near-identical endpoints is three places to fix the next time a list gains a column. `/settings/adopt` is registered BEFORE `/settings/:kind`, or the wildcard swallows it and \"adopt\" is read as the name of a list.\n\n**Permission:** `inventory:read`",
        "operationId": "getInventorySettings",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Names the lists, so a settings screen can draw its tabs before it has fetched anything.",
        "tags": [
          "inventory"
        ],
        "x-permissions": [
          "inventory:read"
        ]
      }
    },
    "/api/v1/inventory/settings/adopt": {
      "post": {
        "description": "SAFE TO RUN TWICE, and the answer says why: it reports what it created and what it found already there. It only ever adds — nothing existing is renamed, reparented or retired.\n\n`kind` scopes it to one list, because the button lives on each list's own screen and one on the Units page that silently writes fifteen categories is a button people stop pressing.\n\n**Permission:** `inventory:manage`",
        "operationId": "postInventorySettingsAdopt",
        "parameters": [
          {
            "in": "query",
            "name": "kind",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Generates the entries a list needs.",
        "tags": [
          "inventory"
        ],
        "x-permissions": [
          "inventory:manage"
        ]
      }
    },
    "/api/v1/inventory/settings/{kind}": {
      "get": {
        "description": "**Permission:** `inventory:read`",
        "operationId": "getInventorySettingsKind",
        "parameters": [
          {
            "in": "path",
            "name": "kind",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "inactive",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "default": 1,
              "type": "integer"
            }
          },
          {
            "description": "Capped at 200. `page_size` is accepted as an alias.",
            "in": "query",
            "name": "per_page",
            "required": false,
            "schema": {
              "default": 50,
              "type": "integer"
            }
          },
          {
            "description": "Free-text filter.",
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PagedEnvelope"
                }
              }
            },
            "description": "A page of rows, with `meta` carrying the counts."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists one of them.",
        "tags": [
          "inventory"
        ],
        "x-permissions": [
          "inventory:read"
        ]
      },
      "post": {
        "description": "**Permission:** `inventory:manage`",
        "operationId": "postInventorySettingsKind",
        "parameters": [
          {
            "in": "path",
            "name": "kind",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InventoryCatalogueInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds an entry or edits one.",
        "tags": [
          "inventory"
        ],
        "x-permissions": [
          "inventory:manage"
        ]
      }
    },
    "/api/v1/inventory/settings/{kind}/{id}": {
      "delete": {
        "description": "Not a delete: a product filed under a category that no longer exists is a product nobody can explain.\n\n**Permission:** `inventory:manage`",
        "operationId": "deleteInventorySettingsKindId",
        "parameters": [
          {
            "in": "path",
            "name": "kind",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Withdraws one.",
        "tags": [
          "inventory"
        ],
        "x-permissions": [
          "inventory:manage"
        ]
      },
      "put": {
        "description": "**Permission:** `inventory:manage`",
        "operationId": "putInventorySettingsKindId",
        "parameters": [
          {
            "in": "path",
            "name": "kind",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InventoryCatalogueInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds an entry or edits one.",
        "tags": [
          "inventory"
        ],
        "x-permissions": [
          "inventory:manage"
        ]
      }
    },
    "/api/v1/inventory/summary": {
      "get": {
        "description": "**Permission:** `inventory:read`",
        "operationId": "getInventorySummary",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Counts the store.",
        "tags": [
          "inventory"
        ],
        "x-permissions": [
          "inventory:read"
        ]
      }
    },
    "/api/v1/inventory/suppliers": {
      "get": {
        "description": "**Permission:** `inventory:read`",
        "operationId": "getInventorySuppliers",
        "parameters": [
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "default": 1,
              "type": "integer"
            }
          },
          {
            "description": "Capped at 200. `page_size` is accepted as an alias.",
            "in": "query",
            "name": "per_page",
            "required": false,
            "schema": {
              "default": 50,
              "type": "integer"
            }
          },
          {
            "description": "Free-text filter.",
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PagedEnvelope"
                }
              }
            },
            "description": "A page of rows, with `meta` carrying the counts."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns who stock is bought from.",
        "tags": [
          "inventory"
        ],
        "x-permissions": [
          "inventory:read"
        ]
      },
      "post": {
        "description": "**Permission:** `inventory:manage`",
        "operationId": "postInventorySuppliers",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InventorySupplierInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits a supplier.",
        "tags": [
          "inventory"
        ],
        "x-permissions": [
          "inventory:manage"
        ]
      }
    },
    "/api/v1/inventory/suppliers/{id}": {
      "put": {
        "description": "**Permission:** `inventory:manage`",
        "operationId": "putInventorySuppliersId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InventorySupplierInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits a supplier.",
        "tags": [
          "inventory"
        ],
        "x-permissions": [
          "inventory:manage"
        ]
      }
    },
    "/api/v1/inventory/variants/{id}": {
      "put": {
        "description": "**Permission:** `inventory:manage`",
        "operationId": "putInventoryVariantsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InventoryVariantInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds a variant or edits one.",
        "tags": [
          "inventory"
        ],
        "x-permissions": [
          "inventory:manage"
        ]
      }
    },
    "/api/v1/licence": {
      "get": {
        "description": "TWO AUDIENCES, ONE ROUTE. A clerk sees the state and the message; somebody holding licence:manage also sees the dates, the counts and the fingerprint. The alternative — a second route for administrators — is two things to keep in step, and the screen would have to know which to call before it knows what the person may see.\n\n**From the router:** Readable by anybody signed in: a clerk who cannot record a payment has to be able to see why. What they see is the state and the message; the dates, the counts and the fingerprint need licence:manage, and the handler decides that.\n\n**Access:** any signed-in account. No further permission.",
        "operationId": "getLicence",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Answers GET /api/v1/licence.",
        "tags": [
          "licence"
        ]
      }
    },
    "/api/v1/licence/install": {
      "post": {
        "description": "This is the offline path: somebody carried a file from the vendor on a memory stick. The token is verified, and its machine binding is checked against THIS machine, before anything is stored — a node that stored first and checked later would be a node running on somebody else's licence until the next restart.\n\n**Permission:** `licence:manage`",
        "operationId": "postLicenceInstall",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "node_token": {
                    "type": "string"
                  },
                  "token": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Answers POST /api/v1/licence/install.",
        "tags": [
          "licence"
        ],
        "x-permissions": [
          "licence:manage"
        ]
      }
    },
    "/api/v1/messaging/conversations": {
      "get": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "getMessagingConversations",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists this person's threads.",
        "tags": [
          "messaging"
        ]
      },
      "post": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "postMessagingConversations",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "with": {
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Opens one with a colleague.",
        "tags": [
          "messaging"
        ]
      }
    },
    "/api/v1/messaging/conversations/{id}/attachments": {
      "post": {
        "description": "TWO STEPS, NOT ONE. The bytes go to file-service here; the LINE is written by SendMessage afterwards, carrying the handle this returns. A single step would mean an upload that succeeded and a message that failed leaves a file nobody can see and no way to retry without sending it twice.\n\nTHE GATE IS MEMBERSHIP, not a permission. Messaging is deliberately behind no permission — one every member of staff would have to hold is not a permission — so what decides who may put a file in a thread is whether the thread is theirs, which only the chat service knows.\n\n**From the router:** Files in a thread. The conversation is in the path on both, because membership of it is the gate — see the handlers.\n\n**Access:** any signed-in account. No further permission.",
        "operationId": "postMessagingConversationsIdAttachments",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "properties": {
                  "entity_id": {
                    "type": "string"
                  },
                  "entity_type": {
                    "type": "string"
                  },
                  "file": {
                    "format": "binary",
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Stores a file for one thread and hands back its handle.",
        "tags": [
          "messaging"
        ]
      }
    },
    "/api/v1/messaging/conversations/{id}/attachments/{file}": {
      "get": {
        "description": "The conversation is in the path so that membership can be checked BEFORE the file is fetched. A route that took only the file id would have to trust whoever knew it.\n\n**Access:** any signed-in account. No further permission.",
        "operationId": "getMessagingConversationsIdAttachmentsFile",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "file",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/octet-stream": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "The stored file, with its own content type."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Streams a file back out of a thread.",
        "tags": [
          "messaging"
        ]
      }
    },
    "/api/v1/messaging/conversations/{id}/messages": {
      "get": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "getMessagingConversationsIdMessages",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Reads a thread.",
        "tags": [
          "messaging"
        ]
      },
      "post": {
        "description": "{\"body\": \"…\", \"file_id\": \"…\", \"file_name\": \"…\", \"file_size\": 0, \"mime_type\": \"…\"}\n\nThe file fields are what UploadConversationFile answered. They are optional, and a line may be a file with no words — a photograph of a request form says what it says.\n\n**Access:** any signed-in account. No further permission.",
        "operationId": "postMessagingConversationsIdMessages",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "body": {
                    "type": "string"
                  },
                  "file_id": {
                    "type": "string"
                  },
                  "file_name": {
                    "type": "string"
                  },
                  "file_size": {
                    "format": "int64",
                    "type": "integer"
                  },
                  "mime_type": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds a line to a thread.",
        "tags": [
          "messaging"
        ]
      }
    },
    "/api/v1/node/hello": {
      "get": {
        "description": "# THE ONLY OTHER ROUTE THAT ANSWERS WITHOUT A TOKEN\n\nThe desktop application calls it first, before anybody has signed in, to answer three questions a person cannot answer for themselves: is this address really a Selanim Medix node, which hospital is it, and does this workstation need activating. Everything in it is what a visitor reads off the front of the building — plus a fingerprint, which is not a secret either: it is a hash, and it is what somebody reads out to the vendor to get an offline licence.\n\nNO LICENCE DETAIL AND NO COUNTS. How long the licence runs and how many workstations are in use is the hospital's business, and this route has no idea who is asking.\n\n**From the router:** What this NODE is, and which workstations may call it. TWO MORE OPEN ROUTES, and they are the only additions to the six the route table test knows about. `node/hello` is how the desktop application answers three questions before anybody has signed in: is this address really a node, which hospital is it, and does this workstation need activating. Nothing in it is secret — it is what a visitor reads off the front of the building, plus a fingerprint, which is a hash somebody reads out to the vendor to get an offline licence. `devices/activate` cannot require a token BY NECESSITY: the activation screen comes before the login screen, because a machine that is not on the register has no business being trusted with a password. The activation key is the credential — one-time, expiring, and refused off the hospital's own network. Its ceiling is FIVE AN HOUR per address, which is far more than an installer needs and far less than a script guessing keys wants.\n\n**Access:** open — no token required.\n\n**Rate limit:** 600 per minute per client address.",
        "operationId": "getNodeHello",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Too many requests from this address."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [],
        "summary": "Answers GET /api/v1/node/hello.",
        "tags": [
          "node"
        ],
        "x-rate-limit": "600 per minute"
      }
    },
    "/api/v1/notifications": {
      "get": {
        "description": "Always the caller's own — the account comes from the token, never a query.\n\n**Access:** any signed-in account. No further permission.",
        "operationId": "getNotifications",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 50,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "unread",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns what THIS person has been sent.",
        "tags": [
          "notifications"
        ]
      }
    },
    "/api/v1/notifications/read-all": {
      "post": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "postNotificationsReadAll",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Marks everything this person can see as read.",
        "tags": [
          "notifications"
        ]
      }
    },
    "/api/v1/notifications/{id}/read": {
      "post": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "postNotificationsIdRead",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records that this person has read one.",
        "tags": [
          "notifications"
        ]
      }
    },
    "/api/v1/ops/backups": {
      "get": {
        "description": "There is deliberately no POST. Rows are written by the job that took the backup — a button that writes \"succeeded\" without a backup having happened is a false assurance discovered on the day of the restore.\n\n**Permission:** `backup:manage`",
        "operationId": "getOpsBackups",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 50,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the backup history.",
        "tags": [
          "ops"
        ],
        "x-permissions": [
          "backup:manage"
        ]
      }
    },
    "/api/v1/ops/backups/{id}/verify": {
      "post": {
        "description": "**Permission:** `backup:manage`",
        "operationId": "postOpsBackupsIdVerify",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "notes": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records that a restore was actually tested from a backup.",
        "tags": [
          "ops"
        ],
        "x-permissions": [
          "backup:manage"
        ]
      }
    },
    "/api/v1/ops/cases": {
      "get": {
        "description": "**Permission:** `report:idsr`",
        "operationId": "getOpsCases",
        "parameters": [
          {
            "in": "query",
            "name": "classification",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 200,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "unnotified",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns notifiable cases.",
        "tags": [
          "ops"
        ],
        "x-permissions": [
          "report:idsr"
        ]
      },
      "post": {
        "description": "**Permission:** `idsr:record`",
        "operationId": "postOpsCases",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OperationsCaseInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Writes a notifiable case.",
        "tags": [
          "ops"
        ],
        "x-permissions": [
          "idsr:record"
        ]
      }
    },
    "/api/v1/ops/cases/{id}": {
      "put": {
        "description": "A discarded case is not deleted. It stays, so the proportion of suspected cases that were confirmed can still be worked out.\n\n**Permission:** `idsr:record`",
        "operationId": "putOpsCasesId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "classification": {
                    "enum": [
                      "SUSPECTED",
                      "PROBABLE",
                      "CONFIRMED",
                      "DISCARDED"
                    ],
                    "type": "string"
                  },
                  "lab_confirmed": {
                    "nullable": true,
                    "type": "boolean"
                  },
                  "outcome": {
                    "enum": [
                      "UNDER_TREATMENT",
                      "RECOVERED",
                      "REFERRED",
                      "DIED",
                      "UNKNOWN"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Changes the classification or outcome.",
        "tags": [
          "ops"
        ],
        "x-permissions": [
          "idsr:record"
        ]
      }
    },
    "/api/v1/ops/cases/{id}/notify": {
      "post": {
        "description": "**Permission:** `idsr:record`",
        "operationId": "postOpsCasesIdNotify",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records that the district has been told.",
        "tags": [
          "ops"
        ],
        "x-permissions": [
          "idsr:record"
        ]
      }
    },
    "/api/v1/ops/conditions": {
      "get": {
        "description": "**Permission:** `report:idsr`",
        "operationId": "getOpsConditions",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the notifiable conditions.",
        "tags": [
          "ops"
        ],
        "x-permissions": [
          "report:idsr"
        ]
      },
      "post": {
        "description": "**Permission:** `idsr:record`",
        "operationId": "postOpsConditions",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OperationsCondition"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits a condition.",
        "tags": [
          "ops"
        ],
        "x-permissions": [
          "idsr:record"
        ]
      }
    },
    "/api/v1/ops/hmis": {
      "get": {
        "description": "Counted from the operational tables. Every indicator this deployment has no source for is NAMED rather than returned as nought — a zero means \"none happened\", and sending that when the truth is \"we do not collect this\" is how a facility reports something untrue to a ministry.\n\n**Permission:** `report:hmis`",
        "operationId": "getOpsHmis",
        "parameters": [
          {
            "in": "query",
            "name": "month",
            "required": false,
            "schema": {
              "default": 0,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "year",
            "required": false,
            "schema": {
              "default": 0,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Builds a monthly national return.",
        "tags": [
          "ops"
        ],
        "x-permissions": [
          "report:hmis"
        ]
      }
    },
    "/api/v1/ops/integrations": {
      "get": {
        "description": "The credential VALUE is never read and never returned — only whether the named secret currently resolves to anything.\n\n**Permission:** `integration:manage`",
        "operationId": "getOpsIntegrations",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the outside connections.",
        "tags": [
          "ops"
        ],
        "x-permissions": [
          "integration:manage"
        ]
      },
      "post": {
        "description": "**Permission:** `integration:manage`",
        "operationId": "postOpsIntegrations",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OperationsIntegration"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits a connection.",
        "tags": [
          "ops"
        ],
        "x-permissions": [
          "integration:manage"
        ]
      }
    },
    "/api/v1/ops/integrations/{id}": {
      "put": {
        "description": "**Permission:** `integration:manage`",
        "operationId": "putOpsIntegrationsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OperationsIntegration"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits a connection.",
        "tags": [
          "ops"
        ],
        "x-permissions": [
          "integration:manage"
        ]
      }
    },
    "/api/v1/ops/integrations/{id}/result": {
      "post": {
        "description": "**Permission:** `integration:manage`",
        "operationId": "postOpsIntegrationsIdResult",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "error": {
                    "type": "string"
                  },
                  "ok": {
                    "type": "boolean"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Writes what was last actually seen.",
        "tags": [
          "ops"
        ],
        "x-permissions": [
          "integration:manage"
        ]
      }
    },
    "/api/v1/ops/messages": {
      "get": {
        "description": "**Permission:** `communication:read`",
        "operationId": "getOpsMessages",
        "parameters": [
          {
            "in": "query",
            "name": "channel",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 200,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "patient_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the delivery log.",
        "tags": [
          "ops"
        ],
        "x-permissions": [
          "communication:read"
        ]
      },
      "post": {
        "description": "IT USED TO BE QUEUED AND NOTHING ELSE. The row said QUEUED, the comment said \"whatever holds the gateway credentials moves it on\", and nothing did: the patient was never told, and the log said \"waiting\" for ever — which reads as somebody's fault rather than nobody's.\n\nIt is now written first and sent second, in that order, so a message that went out is never missing from the log. The status is what actually happened: SENT only when notification-service accepted it, FAILED with the gateway's own reason when it did not, and QUEUED when the service could not be reached at all — which the sweep every ten minutes then retries.\n\n**Permission:** `communication:send`",
        "operationId": "postOpsMessages",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OperationsMessageInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records a message and tries to send it.",
        "tags": [
          "ops"
        ],
        "x-permissions": [
          "communication:send"
        ]
      }
    },
    "/api/v1/ops/messages/{id}/status": {
      "post": {
        "description": "**Permission:** `communication:send`",
        "operationId": "postOpsMessagesIdStatus",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "error": {
                    "type": "string"
                  },
                  "provider_ref": {
                    "type": "string"
                  },
                  "status": {
                    "enum": [
                      "SENT",
                      "DELIVERED",
                      "FAILED",
                      "CANCELLED"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records what the gateway said.",
        "tags": [
          "ops"
        ],
        "x-permissions": [
          "communication:send"
        ]
      }
    },
    "/api/v1/ops/messaging/summary": {
      "get": {
        "description": "**Permission:** `communication:read`",
        "operationId": "getOpsMessagingSummary",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Counts the log.",
        "tags": [
          "ops"
        ],
        "x-permissions": [
          "communication:read"
        ]
      }
    },
    "/api/v1/ops/surveillance/summary": {
      "get": {
        "description": "**Permission:** `report:idsr`",
        "operationId": "getOpsSurveillanceSummary",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Counts the week.",
        "tags": [
          "ops"
        ],
        "x-permissions": [
          "report:idsr"
        ]
      }
    },
    "/api/v1/ops/templates": {
      "get": {
        "description": "**Permission:** `communication:read`",
        "operationId": "getOpsTemplates",
        "parameters": [
          {
            "in": "query",
            "name": "inactive",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the message templates.",
        "tags": [
          "ops"
        ],
        "x-permissions": [
          "communication:read"
        ]
      },
      "post": {
        "description": "**Permission:** `communication:send`",
        "operationId": "postOpsTemplates",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OperationsTemplate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits a template.",
        "tags": [
          "ops"
        ],
        "x-permissions": [
          "communication:send"
        ]
      }
    },
    "/api/v1/ops/templates/{id}": {
      "put": {
        "description": "**Permission:** `communication:send`",
        "operationId": "putOpsTemplatesId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OperationsTemplate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits a template.",
        "tags": [
          "ops"
        ],
        "x-permissions": [
          "communication:send"
        ]
      }
    },
    "/api/v1/organisation": {
      "get": {
        "description": "**Permission:** `organisation:read`",
        "operationId": "getOrganisation",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the deployment's owner.",
        "tags": [
          "organisation"
        ],
        "x-permissions": [
          "organisation:read"
        ]
      },
      "put": {
        "description": "**Permission:** `organisation:update`",
        "operationId": "putOrganisation",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrganizationOrganizationInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Edits it.",
        "tags": [
          "organisation"
        ],
        "x-permissions": [
          "organisation:update"
        ]
      }
    },
    "/api/v1/organisation/departments": {
      "get": {
        "description": "**Permission:** `department:read`",
        "operationId": "getOrganisationDepartments",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns a branch's cost centres.",
        "tags": [
          "organisation"
        ],
        "x-permissions": [
          "department:read"
        ]
      },
      "post": {
        "description": "**Permission:** `department:manage`",
        "operationId": "postOrganisationDepartments",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrganizationDepartmentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Opens a cost centre.",
        "tags": [
          "organisation"
        ],
        "x-permissions": [
          "department:manage"
        ]
      }
    },
    "/api/v1/organisation/departments/{id}": {
      "delete": {
        "description": "**Permission:** `department:manage`",
        "operationId": "deleteOrganisationDepartmentsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Closes a cost centre.",
        "tags": [
          "organisation"
        ],
        "x-permissions": [
          "department:manage"
        ]
      },
      "put": {
        "description": "**Permission:** `department:manage`",
        "operationId": "putOrganisationDepartmentsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrganizationDepartmentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Edits a cost centre.",
        "tags": [
          "organisation"
        ],
        "x-permissions": [
          "department:manage"
        ]
      }
    },
    "/api/v1/organisation/facilities": {
      "get": {
        "description": "**Permission:** `facility:read`",
        "operationId": "getOrganisationFacilities",
        "parameters": [
          {
            "in": "query",
            "name": "include_inactive",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns every branch.",
        "tags": [
          "organisation"
        ],
        "x-permissions": [
          "facility:read"
        ]
      },
      "post": {
        "description": "**Permission:** `facility:create`",
        "operationId": "postOrganisationFacilities",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrganizationFacilityInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Opens a branch.",
        "tags": [
          "organisation"
        ],
        "x-permissions": [
          "facility:create"
        ]
      }
    },
    "/api/v1/organisation/facilities/{id}": {
      "delete": {
        "description": "**Permission:** `facility:delete`",
        "operationId": "deleteOrganisationFacilitiesId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Closes a branch. Soft — its patients, visits and bills all reference it.",
        "tags": [
          "organisation"
        ],
        "x-permissions": [
          "facility:delete"
        ]
      },
      "get": {
        "description": "**Permission:** `facility:read`",
        "operationId": "getOrganisationFacilitiesId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one branch.",
        "tags": [
          "organisation"
        ],
        "x-permissions": [
          "facility:read"
        ]
      },
      "put": {
        "description": "**Permission:** `facility:update`",
        "operationId": "putOrganisationFacilitiesId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrganizationFacilityInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Edits a branch.",
        "tags": [
          "organisation"
        ],
        "x-permissions": [
          "facility:update"
        ]
      }
    },
    "/api/v1/organisation/facilities/{id}/modules": {
      "post": {
        "description": "**From the router:** Switching a module off at a branch is its own permission. It removes a screen from everybody who works there, which is a bigger act than correcting the branch's phone number.\n\n**Permission:** `module:manage`",
        "operationId": "postOrganisationFacilitiesIdModules",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "enabled": {
                    "type": "boolean"
                  },
                  "module_id": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Creates or acts on /api/v1/organisation/facilities/:id/modules.",
        "tags": [
          "organisation"
        ],
        "x-permissions": [
          "module:manage"
        ]
      }
    },
    "/api/v1/organisation/locations": {
      "get": {
        "description": "**Permission:** `location:read`",
        "operationId": "getOrganisationLocations",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "kind",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns a branch's rooms, counters, wards and stores.",
        "tags": [
          "organisation"
        ],
        "x-permissions": [
          "location:read"
        ]
      },
      "post": {
        "description": "**Permission:** `location:manage`",
        "operationId": "postOrganisationLocations",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrganizationLocationInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Opens a place.",
        "tags": [
          "organisation"
        ],
        "x-permissions": [
          "location:manage"
        ]
      }
    },
    "/api/v1/organisation/locations/{id}": {
      "delete": {
        "description": "**Permission:** `location:manage`",
        "operationId": "deleteOrganisationLocationsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Closes a place.",
        "tags": [
          "organisation"
        ],
        "x-permissions": [
          "location:manage"
        ]
      },
      "put": {
        "description": "**Permission:** `location:manage`",
        "operationId": "putOrganisationLocationsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrganizationLocationInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Edits a place.",
        "tags": [
          "organisation"
        ],
        "x-permissions": [
          "location:manage"
        ]
      }
    },
    "/api/v1/patients": {
      "get": {
        "description": "**Permission:** `patient:read`",
        "operationId": "getPatients",
        "parameters": [
          {
            "in": "query",
            "name": "gender",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "insured",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "default": 1,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "page_size",
            "required": false,
            "schema": {
              "default": 20,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "payer",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PagedEnvelope"
                }
              }
            },
            "description": "A page of rows, with `meta` carrying the counts."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns a page of the register.",
        "tags": [
          "patients"
        ],
        "x-permissions": [
          "patient:read"
        ]
      },
      "post": {
        "description": "**Permission:** `patient:create`",
        "operationId": "postPatients",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatientsInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Opens a file.",
        "tags": [
          "patients"
        ],
        "x-permissions": [
          "patient:create"
        ]
      }
    },
    "/api/v1/patients/summary": {
      "get": {
        "description": "Separate from the list because the tiles must count EVERY file: a total that changes as you page is not a total.\n\n**Permission:** `patient:read`",
        "operationId": "getPatientsSummary",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Counts the register as a whole, and lists the payers in use.",
        "tags": [
          "patients"
        ],
        "x-permissions": [
          "patient:read"
        ]
      }
    },
    "/api/v1/patients/{id}": {
      "delete": {
        "description": "**Permission:** `patient:delete`",
        "operationId": "deletePatientsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Closes a file. Soft — a patient record is a legal document.",
        "tags": [
          "patients"
        ],
        "x-permissions": [
          "patient:delete"
        ]
      },
      "get": {
        "description": "**Permission:** `patient:read`",
        "operationId": "getPatientsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one file.",
        "tags": [
          "patients"
        ],
        "x-permissions": [
          "patient:read"
        ]
      },
      "put": {
        "description": "**Permission:** `patient:update`",
        "operationId": "putPatientsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PatientsInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Corrects a file.",
        "tags": [
          "patients"
        ],
        "x-permissions": [
          "patient:update"
        ]
      }
    },
    "/api/v1/patients/{id}/appointments": {
      "get": {
        "description": "**Permission:** `appointment:read`",
        "operationId": "getPatientsIdAppointments",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 50,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one patient's diary.",
        "tags": [
          "patients"
        ],
        "x-permissions": [
          "appointment:read"
        ]
      }
    },
    "/api/v1/patients/{id}/bills": {
      "get": {
        "description": "**Permission:** `bill:read`",
        "operationId": "getPatientsIdBills",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 50,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one patient's accounts.",
        "tags": [
          "patients"
        ],
        "x-permissions": [
          "bill:read"
        ]
      }
    },
    "/api/v1/patients/{id}/consents": {
      "get": {
        "description": "Every purpose the caller may read is returned, INCLUDING the ones with nothing recorded — a list that showed only what had been asked would make a patient nobody has asked look like a patient with nothing outstanding.\n\n**From the router:** What this patient has agreed to. The permission depends on WHICH consent — a theatre consent and a records-release consent are read by different people — so it is checked per purpose inside the handler.\n\n**Access:** any signed-in account. No further permission.",
        "operationId": "getPatientsIdConsents",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Reports what is on file for one patient.",
        "tags": [
          "patients"
        ]
      },
      "post": {
        "description": "A WITHDRAWAL IS A NEW RECORD, NOT A DELETION. That it was granted on Tuesday and withdrawn on Thursday is the part that matters afterwards, and a system that overwrote the first would be unable to say what was true on Wednesday.\n\n**Access:** any signed-in account. No further permission.",
        "operationId": "postPatientsIdConsents",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "granted": {
                    "type": "boolean"
                  },
                  "purpose": {
                    "description": "What is being consented to — the keys of consentPurposes.",
                    "enum": [
                      "procedure",
                      "records_release",
                      "portal"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Writes a decision.",
        "tags": [
          "patients"
        ]
      }
    },
    "/api/v1/patients/{id}/diagnostics": {
      "get": {
        "description": "**Permission:** `lab:read`",
        "operationId": "getPatientsIdDiagnostics",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 30,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one patient's diagnostics history.",
        "tags": [
          "patients"
        ],
        "x-permissions": [
          "lab:read"
        ]
      }
    },
    "/api/v1/patients/{id}/diagnostics/trend": {
      "get": {
        "description": "The join that makes a result mean something: a potassium of 5.4 is a different conversation depending on whether last month's was 5.3 or 3.9.\n\n**Permission:** `lab:read`",
        "operationId": "getPatientsIdDiagnosticsTrend",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "code",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 24,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one test's values for one patient over time.",
        "tags": [
          "patients"
        ],
        "x-permissions": [
          "lab:read"
        ]
      }
    },
    "/api/v1/patients/{id}/prescriptions": {
      "get": {
        "description": "**Permission:** `prescription:read`",
        "operationId": "getPatientsIdPrescriptions",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 50,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one patient's medicines history.",
        "tags": [
          "patients"
        ],
        "x-permissions": [
          "prescription:read"
        ]
      }
    },
    "/api/v1/patients/{id}/visits": {
      "get": {
        "description": "**From the router:** One patient's attendances and observations. Gated on the VISIT permission, not the patient one: knowing who somebody is and knowing what they have been treated for are different questions, and a cashier needs the first without the second.\n\n**Permission:** `visit:read`",
        "operationId": "getPatientsIdVisits",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 50,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one patient's attendance history, newest first.",
        "tags": [
          "patients"
        ],
        "x-permissions": [
          "visit:read"
        ]
      }
    },
    "/api/v1/patients/{id}/vitals": {
      "get": {
        "description": "**Permission:** `visit:read`",
        "operationId": "getPatientsIdVitals",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 50,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns a patient's observations, newest first — the series a clinician reads to see whether somebody is improving.",
        "tags": [
          "patients"
        ],
        "x-permissions": [
          "visit:read"
        ]
      }
    },
    "/api/v1/pharmacy/prescriptions": {
      "get": {
        "description": "**Permission:** `prescription:read`",
        "operationId": "getPharmacyPrescriptions",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "pending",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the pharmacy queue or the register.",
        "tags": [
          "pharmacy"
        ],
        "x-permissions": [
          "prescription:read"
        ]
      },
      "post": {
        "description": "**Permission:** `prescription:write`",
        "operationId": "postPharmacyPrescriptions",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InventoryPrescriptionInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Writes a prescription.",
        "tags": [
          "pharmacy"
        ],
        "x-permissions": [
          "prescription:write"
        ]
      }
    },
    "/api/v1/pharmacy/prescriptions/{id}": {
      "get": {
        "description": "**Permission:** `prescription:read`",
        "operationId": "getPharmacyPrescriptionsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one, with its lines and live stock.",
        "tags": [
          "pharmacy"
        ],
        "x-permissions": [
          "prescription:read"
        ]
      }
    },
    "/api/v1/pharmacy/prescriptions/{id}/cancel": {
      "post": {
        "description": "**Permission:** `prescription:write`",
        "operationId": "postPharmacyPrescriptionsIdCancel",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Voids one, with a reason.",
        "tags": [
          "pharmacy"
        ],
        "x-permissions": [
          "prescription:write"
        ]
      }
    },
    "/api/v1/pharmacy/prescriptions/{id}/dispense": {
      "post": {
        "description": "**Permission:** `dispense:create`",
        "operationId": "postPharmacyPrescriptionsIdDispense",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "lines": {
                    "items": {
                      "$ref": "#/components/schemas/InventoryDispenseInput"
                    },
                    "type": "array"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Hands medicine over and takes it out of stock.",
        "tags": [
          "pharmacy"
        ],
        "x-permissions": [
          "dispense:create"
        ]
      }
    },
    "/api/v1/photos/{subject}/{id}": {
      "get": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "getPhotosSubjectId",
        "parameters": [
          {
            "in": "path",
            "name": "subject",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "size",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/octet-stream": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "The stored file, with its own content type."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one rendered size.",
        "tags": [
          "photos"
        ]
      },
      "put": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "putPhotosSubjectId",
        "parameters": [
          {
            "in": "path",
            "name": "subject",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "properties": {
                  "photo": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Stores a new photograph against a record.",
        "tags": [
          "photos"
        ]
      }
    },
    "/api/v1/platform/billing-settings": {
      "get": {
        "description": "**Permission:** `platform:operate`",
        "operationId": "getPlatformBillingSettings",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Are the trial, grace, retention and reminder days.",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      },
      "put": {
        "description": "**Permission:** `platform:operate`",
        "operationId": "putPlatformBillingSettings",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": {},
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Changes them.",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      }
    },
    "/api/v1/platform/email": {
      "get": {
        "description": "**From the router:** The service's own mail server: sign-up codes, welcomes, receipts and the subscription notices go out from it. The same handlers as a hospital's Settings → Email; RequirePlatform has stripped the tenant, so they read and write the platform's settings.\n\n**Permission:** `platform:operate`",
        "operationId": "getPlatformEmail",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the SMTP server the hospital sends from.",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      },
      "put": {
        "description": "The password arrives as the placeholder when it has not been retyped, and notification-service reads that as \"keep what is stored\" — so editing the port does not silently wipe the password.\n\n**Permission:** `platform:operate`",
        "operationId": "putPlatformEmail",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "config": {
                    "$ref": "#/components/schemas/HandlersEmailConfigBody"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Changes it.",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      }
    },
    "/api/v1/platform/email/test": {
      "post": {
        "description": "IT TESTS WHAT IS IN THE REQUEST, NOT WHAT IS STORED, which is the only order that helps: the question somebody has at this moment is \"is this password right\", and answering it after the password has been saved is answering it too late.\n\nA refusal here is an ANSWER, in the mail server's own words — \"authentication failed\", \"connection refused\". It is not a fault and is not logged as one.\n\n**Permission:** `platform:operate`",
        "operationId": "postPlatformEmailTest",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "config": {
                    "$ref": "#/components/schemas/HandlersEmailConfigBody"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Dials the mail server with the settings on screen.",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      }
    },
    "/api/v1/platform/email/test-send": {
      "post": {
        "description": "WHY THIS IS NOT `TestEmailSettings`. That one dials the server and authenticates: it answers \"is this password right\", before saving. This one answers a different question — \"does a message actually arrive\" — and only a message somebody receives can answer it. A server that accepts a login can still refuse to relay, reject the From address, or have the mail filed as spam.\n\n**Permission:** `platform:operate`",
        "operationId": "postPlatformEmailTestSend",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "to": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Sends a real message to an address somebody types, using the SAVED settings.",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      }
    },
    "/api/v1/platform/invoices": {
      "get": {
        "description": "**Permission:** `platform:operate`",
        "operationId": "getPlatformInvoices",
        "parameters": [
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "page_size",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "tenant_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists invoices, every hospital's.",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      }
    },
    "/api/v1/platform/invoices/{id}/pdf": {
      "get": {
        "description": "**Permission:** `platform:operate`",
        "operationId": "getPlatformInvoicesIdPdf",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "language",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/pdf": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "The document, as a PDF."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Draws any hospital's invoice.",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      }
    },
    "/api/v1/platform/invoices/{id}/refund": {
      "post": {
        "description": "**Permission:** `platform:operate`",
        "operationId": "postPlatformInvoicesIdRefund",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Gives a paid invoice's money back through PayPal and marks it refunded. What happens to the hospital's period is decided separately (suspend, or leave it).",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      }
    },
    "/api/v1/platform/invoices/{id}/void": {
      "post": {
        "description": "**Permission:** `platform:operate`",
        "operationId": "postPlatformInvoicesIdVoid",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "note": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Cancels an invoice nobody paid.",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      }
    },
    "/api/v1/platform/jobs/{job}": {
      "post": {
        "description": "**Permission:** `platform:operate`",
        "operationId": "postPlatformJobsJob",
        "parameters": [
          {
            "in": "path",
            "name": "job",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Runs one of the hosted service's sweeps now, rather than at its next scheduled time.",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      }
    },
    "/api/v1/platform/metrics": {
      "get": {
        "description": "**Permission:** `platform:operate`",
        "operationId": "getPlatformMetrics",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is the dashboard's figures.",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      }
    },
    "/api/v1/platform/operators": {
      "get": {
        "description": "**Permission:** `platform:operate`",
        "operationId": "getPlatformOperators",
        "parameters": [
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists the service's own accounts — only those: an account listing without a hospital is the platform's.",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      },
      "post": {
        "description": "**Permission:** `platform:operate`",
        "operationId": "postPlatformOperators",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "email": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  },
                  "phone": {
                    "type": "string"
                  },
                  "role": {
                    "type": "string"
                  },
                  "username": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Makes an operator account with one of the operator roles. They add their authenticator app at their first sign-in.",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      }
    },
    "/api/v1/platform/operators/{id}/status": {
      "post": {
        "description": "**Permission:** `platform:operate`",
        "operationId": "postPlatformOperatorsIdStatus",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "status": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Switches an operator off or on. Not oneself: the last owner locking themselves out has nobody to let them back in.",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      }
    },
    "/api/v1/platform/paypal": {
      "get": {
        "description": "**Permission:** `platform:operate`",
        "operationId": "getPlatformPaypal",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is the PayPal account's settings; the secret is never sent.",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      },
      "put": {
        "description": "**Permission:** `platform:operate`",
        "operationId": "putPlatformPaypal",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "brand_name": {
                    "type": "string"
                  },
                  "client_id": {
                    "type": "string"
                  },
                  "environment": {
                    "type": "string"
                  },
                  "secret": {
                    "nullable": true,
                    "type": "string"
                  },
                  "totp_code": {
                    "type": "string"
                  },
                  "webhook_id": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Changes them. Moving to the live account takes a code from the operator's authenticator app, whatever the session: real money starts moving on the next checkout.",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      }
    },
    "/api/v1/platform/paypal/test": {
      "post": {
        "description": "**Permission:** `platform:operate`",
        "operationId": "postPlatformPaypalTest",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Asks PayPal for a token with the saved credentials.",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      }
    },
    "/api/v1/platform/plans": {
      "get": {
        "description": "**Permission:** `platform:operate`",
        "operationId": "getPlatformPlans",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists every plan, the ones not on sale included.",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      }
    },
    "/api/v1/platform/plans/{code}": {
      "put": {
        "description": "**Permission:** `platform:operate`",
        "operationId": "putPlatformPlansCode",
        "parameters": [
          {
            "in": "path",
            "name": "code",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": {},
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Changes a plan: its prices, modules and limits. A price change applies from each hospital's next period.",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      }
    },
    "/api/v1/platform/subscriptions": {
      "get": {
        "description": "**Permission:** `platform:operate`",
        "operationId": "getPlatformSubscriptions",
        "parameters": [
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists every subscription and the state it is in.",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      }
    },
    "/api/v1/platform/tenants": {
      "get": {
        "description": "**Permission:** `platform:operate`",
        "operationId": "getPlatformTenants",
        "parameters": [
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "page_size",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists the hospitals.",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      }
    },
    "/api/v1/platform/tenants/{id}": {
      "get": {
        "description": "**Permission:** `platform:operate`",
        "operationId": "getPlatformTenantsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is one hospital: its registry entry, its subscription and its invoices.",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      }
    },
    "/api/v1/platform/tenants/{id}/{action}": {
      "post": {
        "description": "**Permission:** `platform:operate`",
        "operationId": "postPlatformTenantsIdAction",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "action",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": {},
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Suspends, resumes, extends or comps a hospital's subscription. The body is passed through: suspend takes {\"reason\":…}, extend {\"days\":…,\"note\":…}, comp {\"plan_code\":…,\"branches\":…,\"months\":…,\"note\":…}.",
        "tags": [
          "platform"
        ],
        "x-permissions": [
          "platform:operate"
        ]
      }
    },
    "/api/v1/portal/appointments": {
      "get": {
        "description": "**Permission:** `portal:use`",
        "operationId": "getPortalAppointments",
        "parameters": [
          {
            "in": "query",
            "name": "patient_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the diary.",
        "tags": [
          "portal"
        ],
        "x-permissions": [
          "portal:use"
        ]
      },
      "post": {
        "description": "It is BOOKED, not confirmed. Somebody choosing a slot on their phone has not been triaged, and a clinic that treats a self-service booking as a firm commitment ends up with a list nobody has looked at.\n\n**Permission:** `portal:use`",
        "operationId": "postPortalAppointments",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "department": {
                    "type": "string"
                  },
                  "patient_id": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  },
                  "scheduled_for": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Requests an appointment.",
        "tags": [
          "portal"
        ],
        "x-permissions": [
          "portal:use"
        ]
      }
    },
    "/api/v1/portal/appointments/{id}/cancel": {
      "post": {
        "description": "**Permission:** `portal:use`",
        "operationId": "postPortalAppointmentsIdCancel",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Cancels a booking.",
        "tags": [
          "portal"
        ],
        "x-permissions": [
          "portal:use"
        ]
      }
    },
    "/api/v1/portal/bills": {
      "get": {
        "description": "**Permission:** `portal:use`",
        "operationId": "getPortalBills",
        "parameters": [
          {
            "in": "query",
            "name": "patient_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns bills.",
        "tags": [
          "portal"
        ],
        "x-permissions": [
          "portal:use"
        ]
      }
    },
    "/api/v1/portal/home": {
      "get": {
        "description": "**Permission:** `portal:use`",
        "operationId": "getPortalHome",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is everything the landing page shows, in one request.",
        "tags": [
          "portal"
        ],
        "x-permissions": [
          "portal:use"
        ]
      }
    },
    "/api/v1/portal/immunisations": {
      "get": {
        "description": "**Permission:** `portal:use`",
        "operationId": "getPortalImmunisations",
        "parameters": [
          {
            "in": "query",
            "name": "patient_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns a child's card.",
        "tags": [
          "portal"
        ],
        "x-permissions": [
          "portal:use"
        ]
      }
    },
    "/api/v1/portal/me": {
      "get": {
        "description": "**Permission:** `portal:use`",
        "operationId": "getPortalMe",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the signed-in patient's own profile.",
        "tags": [
          "portal"
        ],
        "x-permissions": [
          "portal:use"
        ]
      }
    },
    "/api/v1/portal/messages": {
      "get": {
        "description": "**Permission:** `portal:use`",
        "operationId": "getPortalMessages",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns conversations with the clinic.",
        "tags": [
          "portal"
        ],
        "x-permissions": [
          "portal:use"
        ]
      },
      "post": {
        "description": "**Permission:** `portal:use`",
        "operationId": "postPortalMessages",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "body": {
                    "type": "string"
                  },
                  "category": {
                    "type": "string"
                  },
                  "patient_id": {
                    "type": "string"
                  },
                  "subject": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Opens a thread.",
        "tags": [
          "portal"
        ],
        "x-permissions": [
          "portal:use"
        ]
      }
    },
    "/api/v1/portal/messages/{id}/read": {
      "post": {
        "description": "**Permission:** `portal:use`",
        "operationId": "postPortalMessagesIdRead",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Marks the clinic's messages in a thread as read.",
        "tags": [
          "portal"
        ],
        "x-permissions": [
          "portal:use"
        ]
      }
    },
    "/api/v1/portal/messages/{id}/reply": {
      "post": {
        "description": "**Permission:** `portal:use`",
        "operationId": "postPortalMessagesIdReply",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "body": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds a message to a thread.",
        "tags": [
          "portal"
        ],
        "x-permissions": [
          "portal:use"
        ]
      }
    },
    "/api/v1/portal/prescriptions": {
      "get": {
        "description": "**Permission:** `portal:use`",
        "operationId": "getPortalPrescriptions",
        "parameters": [
          {
            "in": "query",
            "name": "patient_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns medicines.",
        "tags": [
          "portal"
        ],
        "x-permissions": [
          "portal:use"
        ]
      }
    },
    "/api/v1/portal/results": {
      "get": {
        "description": "**Permission:** `portal:use`",
        "operationId": "getPortalResults",
        "parameters": [
          {
            "in": "query",
            "name": "patient_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns results, released ones only carrying values.",
        "tags": [
          "portal"
        ],
        "x-permissions": [
          "portal:use"
        ]
      }
    },
    "/api/v1/portal/visits": {
      "get": {
        "description": "**Permission:** `portal:use`",
        "operationId": "getPortalVisits",
        "parameters": [
          {
            "in": "query",
            "name": "patient_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns attendances.",
        "tags": [
          "portal"
        ],
        "x-permissions": [
          "portal:use"
        ]
      }
    },
    "/api/v1/procurement/invoices": {
      "get": {
        "description": "**Permission:** `purchase:read`",
        "operationId": "getProcurementInvoices",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "supplier_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "unpaid",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns what the hospital has been billed.",
        "tags": [
          "procurement"
        ],
        "x-permissions": [
          "purchase:read"
        ]
      },
      "post": {
        "description": "**Permission:** `purchase:invoice`",
        "operationId": "postProcurementInvoices",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProcurementInvoiceInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Enters one as a draft.",
        "tags": [
          "procurement"
        ],
        "x-permissions": [
          "purchase:invoice"
        ]
      }
    },
    "/api/v1/procurement/invoices/{id}": {
      "get": {
        "description": "**Permission:** `purchase:read`",
        "operationId": "getProcurementInvoicesId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one with its lines.",
        "tags": [
          "procurement"
        ],
        "x-permissions": [
          "purchase:read"
        ]
      }
    },
    "/api/v1/procurement/invoices/{id}/approve": {
      "post": {
        "description": "**Permission:** `purchase:approve`",
        "operationId": "postProcurementInvoicesIdApprove",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Turns a draft into a debt.",
        "tags": [
          "procurement"
        ],
        "x-permissions": [
          "purchase:approve"
        ]
      }
    },
    "/api/v1/procurement/invoices/{id}/dispute": {
      "post": {
        "description": "**Permission:** `purchase:invoice`",
        "operationId": "postProcurementInvoicesIdDispute",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Holds one with a reason.",
        "tags": [
          "procurement"
        ],
        "x-permissions": [
          "purchase:invoice"
        ]
      }
    },
    "/api/v1/procurement/invoices/{id}/pay": {
      "post": {
        "description": "**Permission:** `purchase:pay`",
        "operationId": "postProcurementInvoicesIdPay",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProcurementPaymentInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Releases money against an approved invoice.",
        "tags": [
          "procurement"
        ],
        "x-permissions": [
          "purchase:pay"
        ]
      }
    },
    "/api/v1/procurement/orders": {
      "get": {
        "description": "**Permission:** `purchase:read`",
        "operationId": "getProcurementOrders",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "supplier_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the order register.",
        "tags": [
          "procurement"
        ],
        "x-permissions": [
          "purchase:read"
        ]
      },
      "post": {
        "description": "**Permission:** `purchase:order`",
        "operationId": "postProcurementOrders",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProcurementOrderInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Writes a draft order.",
        "tags": [
          "procurement"
        ],
        "x-permissions": [
          "purchase:order"
        ]
      }
    },
    "/api/v1/procurement/orders/{id}": {
      "get": {
        "description": "**Permission:** `purchase:read`",
        "operationId": "getProcurementOrdersId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one with its lines and what has arrived.",
        "tags": [
          "procurement"
        ],
        "x-permissions": [
          "purchase:read"
        ]
      },
      "put": {
        "description": "**Permission:** `purchase:order`",
        "operationId": "putProcurementOrdersId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProcurementOrderInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Replaces the lines of a draft.",
        "tags": [
          "procurement"
        ],
        "x-permissions": [
          "purchase:order"
        ]
      }
    },
    "/api/v1/procurement/orders/{id}/cancel": {
      "post": {
        "description": "**Permission:** `purchase:order`",
        "operationId": "postProcurementOrdersIdCancel",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Closes an order with a reason.",
        "tags": [
          "procurement"
        ],
        "x-permissions": [
          "purchase:order"
        ]
      }
    },
    "/api/v1/procurement/orders/{id}/pdf": {
      "get": {
        "description": "THE ONE DOCUMENT HERE WHERE THE HOSPITAL IS THE BUYER. It says deliver this, not pay us, so it carries no payment block — and the handler clears the accounts explicitly rather than relying on the template, because a shared sheet that happened to print \"how to pay\" on an order would be telling a supplier where to send money the hospital is about to send them.\n\nPRICES ARE ON IT BECAUSE THEY WERE AGREED. An order without them is a request, and a supplier delivering at a price it chose itself is a cost nobody authorised and an invoice nobody can check.\n\n**From the router:** The order as the supplier receives it.\n\n**Permission:** `purchase:read`",
        "operationId": "getProcurementOrdersIdPdf",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "language",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/pdf": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "The document, as a PDF."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Draws the order the hospital sends a supplier.",
        "tags": [
          "procurement"
        ],
        "x-permissions": [
          "purchase:read"
        ]
      }
    },
    "/api/v1/procurement/orders/{id}/send": {
      "post": {
        "description": "**Permission:** `purchase:order`",
        "operationId": "postProcurementOrdersIdSend",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Places a draft with the supplier.",
        "tags": [
          "procurement"
        ],
        "x-permissions": [
          "purchase:order"
        ]
      }
    },
    "/api/v1/procurement/payments": {
      "get": {
        "description": "**Permission:** `purchase:read`",
        "operationId": "getProcurementPayments",
        "parameters": [
          {
            "in": "query",
            "name": "invoice_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns what has been paid out.",
        "tags": [
          "procurement"
        ],
        "x-permissions": [
          "purchase:read"
        ]
      }
    },
    "/api/v1/procurement/payments/{id}/pdf": {
      "get": {
        "description": "WHAT IT IS FOR. A supplier receives a bank transfer with a reference and no explanation, and has to guess which of its invoices was settled. Half the disputes in a payables ledger are that guess going wrong. This says which invoice, for how much, on what date — and it is the document the hospital keeps to prove it said so.\n\nA REVERSAL PRINTS AND SAYS SO, exactly as a reversed receipt does. Whoever is holding the original advice needs the paper that contradicts it.\n\n**From the router:** The advice that goes with the money, so a supplier is not left guessing which invoice a bank transfer settled.\n\n**Permission:** `purchase:read`",
        "operationId": "getProcurementPaymentsIdPdf",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "language",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/pdf": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "The document, as a PDF."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Draws the advice that goes with money sent to a supplier.",
        "tags": [
          "procurement"
        ],
        "x-permissions": [
          "purchase:read"
        ]
      }
    },
    "/api/v1/procurement/payments/{id}/reverse": {
      "post": {
        "description": "**Permission:** `purchase:pay`",
        "operationId": "postProcurementPaymentsIdReverse",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Cancels a payment with its mirror.",
        "tags": [
          "procurement"
        ],
        "x-permissions": [
          "purchase:pay"
        ]
      }
    },
    "/api/v1/procurement/receipts": {
      "get": {
        "description": "**From the router:** Booking a delivery in IS booking stock in, so it is the same permission. A separate one would let somebody receive goods they are not trusted to put on a shelf.\n\n**Permission:** `purchase:read`",
        "operationId": "getProcurementReceipts",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "order_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "supplier_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns delivery notes.",
        "tags": [
          "procurement"
        ],
        "x-permissions": [
          "purchase:read"
        ]
      },
      "post": {
        "description": "**Permission:** `stock:receive`",
        "operationId": "postProcurementReceipts",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProcurementReceiptInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records a delivery and books its stock in.",
        "tags": [
          "procurement"
        ],
        "x-permissions": [
          "stock:receive"
        ]
      }
    },
    "/api/v1/procurement/receipts/{id}/lines": {
      "get": {
        "description": "**Permission:** `purchase:read`",
        "operationId": "getProcurementReceiptsIdLines",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one delivery's lines and how much has been billed.",
        "tags": [
          "procurement"
        ],
        "x-permissions": [
          "purchase:read"
        ]
      }
    },
    "/api/v1/procurement/summary": {
      "get": {
        "description": "**Permission:** `purchase:read`",
        "operationId": "getProcurementSummary",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is the tiles: on order, owed, overdue.",
        "tags": [
          "procurement"
        ],
        "x-permissions": [
          "purchase:read"
        ]
      }
    },
    "/api/v1/programs/enrolments": {
      "get": {
        "description": "**Permission:** `program:read`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `tb`, `ctc`, `ncd`.",
        "operationId": "getProgramsEnrolments",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "overdue",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "program",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns a cohort.",
        "tags": [
          "programs"
        ],
        "x-modules": [
          "tb",
          "ctc",
          "ncd"
        ],
        "x-permissions": [
          "program:read"
        ]
      },
      "post": {
        "description": "**Permission:** `program:manage`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `tb`, `ctc`, `ncd`.",
        "operationId": "postProgramsEnrolments",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProgramsEnrolInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Starts an enrolment.",
        "tags": [
          "programs"
        ],
        "x-modules": [
          "tb",
          "ctc",
          "ncd"
        ],
        "x-permissions": [
          "program:manage"
        ]
      }
    },
    "/api/v1/programs/enrolments/{id}": {
      "get": {
        "description": "**Permission:** `program:read`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `tb`, `ctc`, `ncd`.",
        "operationId": "getProgramsEnrolmentsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one record with its visits and results.",
        "tags": [
          "programs"
        ],
        "x-modules": [
          "tb",
          "ctc",
          "ncd"
        ],
        "x-permissions": [
          "program:read"
        ]
      },
      "put": {
        "description": "**Permission:** `program:manage`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `tb`, `ctc`, `ncd`.",
        "operationId": "putProgramsEnrolmentsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProgramsEnrolInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Changes the regimen, phase or next appointment.",
        "tags": [
          "programs"
        ],
        "x-modules": [
          "tb",
          "ctc",
          "ncd"
        ],
        "x-permissions": [
          "program:manage"
        ]
      }
    },
    "/api/v1/programs/enrolments/{id}/close": {
      "post": {
        "description": "The database refuses a close without an outcome. An enrolment that just stops has silently become \"lost to follow-up\" without anybody deciding it.\n\n**Permission:** `program:manage`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `tb`, `ctc`, `ncd`.",
        "operationId": "postProgramsEnrolmentsIdClose",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "note": {
                    "type": "string"
                  },
                  "outcome": {
                    "description": "The programs.OUTCOMES a cohort report counts.",
                    "enum": [
                      "Cured",
                      "Treatment completed",
                      "Treatment failed",
                      "Died",
                      "Lost to follow-up",
                      "Transferred out",
                      "Stopped"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Ends an enrolment with an outcome.",
        "tags": [
          "programs"
        ],
        "x-modules": [
          "tb",
          "ctc",
          "ncd"
        ],
        "x-permissions": [
          "program:manage"
        ]
      }
    },
    "/api/v1/programs/enrolments/{id}/results": {
      "post": {
        "description": "**Permission:** `program:record`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `tb`, `ctc`, `ncd`.",
        "operationId": "postProgramsEnrolmentsIdResults",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProgramsResultInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Writes a measurement.",
        "tags": [
          "programs"
        ],
        "x-modules": [
          "tb",
          "ctc",
          "ncd"
        ],
        "x-permissions": [
          "program:record"
        ]
      }
    },
    "/api/v1/programs/enrolments/{id}/visits": {
      "post": {
        "description": "**Permission:** `program:record`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `tb`, `ctc`, `ncd`.",
        "operationId": "postProgramsEnrolmentsIdVisits",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProgramsVisitInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Writes a clinic contact.",
        "tags": [
          "programs"
        ],
        "x-modules": [
          "tb",
          "ctc",
          "ncd"
        ],
        "x-permissions": [
          "program:record"
        ]
      }
    },
    "/api/v1/programs/summary": {
      "get": {
        "description": "**Permission:** `program:read`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `tb`, `ctc`, `ncd`.",
        "operationId": "getProgramsSummary",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Counts each cohort.",
        "tags": [
          "programs"
        ],
        "x-modules": [
          "tb",
          "ctc",
          "ncd"
        ],
        "x-permissions": [
          "program:read"
        ]
      }
    },
    "/api/v1/public/feedback/{id}": {
      "get": {
        "description": "**Access:** open — no token required.\n\n**Rate limit:** 60 per minute per client address.",
        "operationId": "getPublicFeedbackId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Too many requests from this address."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [],
        "summary": "Serves a published form to somebody holding the link.",
        "tags": [
          "public"
        ],
        "x-rate-limit": "60 per minute"
      },
      "post": {
        "description": "**Access:** open — no token required.\n\n**Rate limit:** 60 per minute per client address.",
        "operationId": "postPublicFeedbackId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "answers": {
                    "items": {
                      "$ref": "#/components/schemas/StackFormAnswer"
                    },
                    "type": "array"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Too many requests from this address."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [],
        "summary": "Records a patient's answers.",
        "tags": [
          "public"
        ],
        "x-rate-limit": "60 per minute"
      }
    },
    "/api/v1/rch/anc": {
      "get": {
        "description": "**Permission:** `rch:read`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `anc`, `delivery`, `pnc`, `family-planning`, `immunization`, `growth`.",
        "operationId": "getRchAnc",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "overdue",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the antenatal register.",
        "tags": [
          "rch"
        ],
        "x-modules": [
          "anc",
          "delivery",
          "pnc",
          "family-planning",
          "immunization",
          "growth"
        ],
        "x-permissions": [
          "rch:read"
        ]
      },
      "post": {
        "description": "**Permission:** `rch:manage`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `anc`, `delivery`, `pnc`, `family-planning`, `immunization`, `growth`.",
        "operationId": "postRchAnc",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RchANCInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Opens a pregnancy and generates the schedule.",
        "tags": [
          "rch"
        ],
        "x-modules": [
          "anc",
          "delivery",
          "pnc",
          "family-planning",
          "immunization",
          "growth"
        ],
        "x-permissions": [
          "rch:manage"
        ]
      }
    },
    "/api/v1/rch/anc/{id}": {
      "get": {
        "description": "**Permission:** `rch:read`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `anc`, `delivery`, `pnc`, `family-planning`, `immunization`, `growth`.",
        "operationId": "getRchAncId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one pregnancy with its schedule.",
        "tags": [
          "rch"
        ],
        "x-modules": [
          "anc",
          "delivery",
          "pnc",
          "family-planning",
          "immunization",
          "growth"
        ],
        "x-permissions": [
          "rch:read"
        ]
      }
    },
    "/api/v1/rch/anc/{id}/close": {
      "post": {
        "description": "**Permission:** `rch:manage`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `anc`, `delivery`, `pnc`, `family-planning`, `immunization`, `growth`.",
        "operationId": "postRchAncIdClose",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  },
                  "status": {
                    "enum": [
                      "DELIVERED",
                      "TRANSFERRED",
                      "LOST",
                      "ENDED"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Ends a pregnancy record.",
        "tags": [
          "rch"
        ],
        "x-modules": [
          "anc",
          "delivery",
          "pnc",
          "family-planning",
          "immunization",
          "growth"
        ],
        "x-permissions": [
          "rch:manage"
        ]
      }
    },
    "/api/v1/rch/anc/{id}/visits/{visit}": {
      "post": {
        "description": "**Permission:** `rch:record`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `anc`, `delivery`, `pnc`, `family-planning`, `immunization`, `growth`.",
        "operationId": "postRchAncIdVisitsVisit",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "visit",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RchANCVisitInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Attends a contact.",
        "tags": [
          "rch"
        ],
        "x-modules": [
          "anc",
          "delivery",
          "pnc",
          "family-planning",
          "immunization",
          "growth"
        ],
        "x-permissions": [
          "rch:record"
        ]
      }
    },
    "/api/v1/rch/deliveries": {
      "get": {
        "description": "**Permission:** `rch:read`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `anc`, `delivery`, `pnc`, `family-planning`, `immunization`, `growth`.",
        "operationId": "getRchDeliveries",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the labour ward.",
        "tags": [
          "rch"
        ],
        "x-modules": [
          "anc",
          "delivery",
          "pnc",
          "family-planning",
          "immunization",
          "growth"
        ],
        "x-permissions": [
          "rch:read"
        ]
      },
      "post": {
        "description": "**Permission:** `rch:manage`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `anc`, `delivery`, `pnc`, `family-planning`, `immunization`, `growth`.",
        "operationId": "postRchDeliveries",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RchDeliveryInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Opens a delivery record.",
        "tags": [
          "rch"
        ],
        "x-modules": [
          "anc",
          "delivery",
          "pnc",
          "family-planning",
          "immunization",
          "growth"
        ],
        "x-permissions": [
          "rch:manage"
        ]
      }
    },
    "/api/v1/rch/deliveries/{id}/births": {
      "post": {
        "description": "A twin delivery is two calls. One record with \"twins\" written on it cannot give the second twin an Apgar score of its own.\n\n**Permission:** `rch:record`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `anc`, `delivery`, `pnc`, `family-planning`, `immunization`, `growth`.",
        "operationId": "postRchDeliveriesIdBirths",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RchBirthInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds a baby.",
        "tags": [
          "rch"
        ],
        "x-modules": [
          "anc",
          "delivery",
          "pnc",
          "family-planning",
          "immunization",
          "growth"
        ],
        "x-permissions": [
          "rch:record"
        ]
      }
    },
    "/api/v1/rch/deliveries/{id}/outcome": {
      "post": {
        "description": "**Permission:** `rch:record`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `anc`, `delivery`, `pnc`, `family-planning`, `immunization`, `growth`.",
        "operationId": "postRchDeliveriesIdOutcome",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RchDeliveryOutcomeInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Closes a delivery and schedules the postnatal contacts.",
        "tags": [
          "rch"
        ],
        "x-modules": [
          "anc",
          "delivery",
          "pnc",
          "family-planning",
          "immunization",
          "growth"
        ],
        "x-permissions": [
          "rch:record"
        ]
      }
    },
    "/api/v1/rch/family-planning": {
      "get": {
        "description": "**Permission:** `rch:read`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `anc`, `delivery`, `pnc`, `family-planning`, `immunization`, `growth`.",
        "operationId": "getRchFamilyPlanning",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "overdue",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns who is on what.",
        "tags": [
          "rch"
        ],
        "x-modules": [
          "anc",
          "delivery",
          "pnc",
          "family-planning",
          "immunization",
          "growth"
        ],
        "x-permissions": [
          "rch:read"
        ]
      },
      "post": {
        "description": "**Permission:** `rch:record`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `anc`, `delivery`, `pnc`, `family-planning`, `immunization`, `growth`.",
        "operationId": "postRchFamilyPlanning",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RchFPInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records a method.",
        "tags": [
          "rch"
        ],
        "x-modules": [
          "anc",
          "delivery",
          "pnc",
          "family-planning",
          "immunization",
          "growth"
        ],
        "x-permissions": [
          "rch:record"
        ]
      }
    },
    "/api/v1/rch/family-planning/{id}/discontinue": {
      "post": {
        "description": "**Permission:** `rch:record`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `anc`, `delivery`, `pnc`, `family-planning`, `immunization`, `growth`.",
        "operationId": "postRchFamilyPlanningIdDiscontinue",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  },
                  "status": {
                    "description": "What became of the method.",
                    "enum": [
                      "DISCONTINUED",
                      "SWITCHED",
                      "LOST"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Stops a method, with a reason.",
        "tags": [
          "rch"
        ],
        "x-modules": [
          "anc",
          "delivery",
          "pnc",
          "family-planning",
          "immunization",
          "growth"
        ],
        "x-permissions": [
          "rch:record"
        ]
      }
    },
    "/api/v1/rch/family-planning/{id}/resupply": {
      "post": {
        "description": "**Permission:** `rch:record`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `anc`, `delivery`, `pnc`, `family-planning`, `immunization`, `growth`.",
        "operationId": "postRchFamilyPlanningIdResupply",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "next_due_on": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records a resupply and moves the next due date.",
        "tags": [
          "rch"
        ],
        "x-modules": [
          "anc",
          "delivery",
          "pnc",
          "family-planning",
          "immunization",
          "growth"
        ],
        "x-permissions": [
          "rch:record"
        ]
      }
    },
    "/api/v1/rch/growth": {
      "get": {
        "description": "**Permission:** `rch:read`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `anc`, `delivery`, `pnc`, `family-planning`, `immunization`, `growth`.",
        "operationId": "getRchGrowth",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "malnourished",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "patient_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns weighings.",
        "tags": [
          "rch"
        ],
        "x-modules": [
          "anc",
          "delivery",
          "pnc",
          "family-planning",
          "immunization",
          "growth"
        ],
        "x-permissions": [
          "rch:read"
        ]
      },
      "post": {
        "description": "**Permission:** `rch:record`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `anc`, `delivery`, `pnc`, `family-planning`, `immunization`, `growth`.",
        "operationId": "postRchGrowth",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RchGrowthInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Writes a weighing.",
        "tags": [
          "rch"
        ],
        "x-modules": [
          "anc",
          "delivery",
          "pnc",
          "family-planning",
          "immunization",
          "growth"
        ],
        "x-permissions": [
          "rch:record"
        ]
      }
    },
    "/api/v1/rch/immunisation": {
      "get": {
        "description": "**Permission:** `rch:read`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `anc`, `delivery`, `pnc`, `family-planning`, `immunization`, `growth`.",
        "operationId": "getRchImmunisation",
        "parameters": [
          {
            "in": "query",
            "name": "due",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 200,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "patient_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns doses, due or given.",
        "tags": [
          "rch"
        ],
        "x-modules": [
          "anc",
          "delivery",
          "pnc",
          "family-planning",
          "immunization",
          "growth"
        ],
        "x-permissions": [
          "rch:read"
        ]
      }
    },
    "/api/v1/rch/immunisation/enrol": {
      "post": {
        "description": "**Permission:** `rch:manage`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `anc`, `delivery`, `pnc`, `family-planning`, `immunization`, `growth`.",
        "operationId": "postRchImmunisationEnrol",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "patient_id": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Generates a child's immunisation schedule.",
        "tags": [
          "rch"
        ],
        "x-modules": [
          "anc",
          "delivery",
          "pnc",
          "family-planning",
          "immunization",
          "growth"
        ],
        "x-permissions": [
          "rch:manage"
        ]
      }
    },
    "/api/v1/rch/immunisation/schedule": {
      "get": {
        "description": "**Permission:** `rch:read`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `anc`, `delivery`, `pnc`, `family-planning`, `immunization`, `growth`.",
        "operationId": "getRchImmunisationSchedule",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the published schedule.",
        "tags": [
          "rch"
        ],
        "x-modules": [
          "anc",
          "delivery",
          "pnc",
          "family-planning",
          "immunization",
          "growth"
        ],
        "x-permissions": [
          "rch:read"
        ]
      },
      "post": {
        "description": "Behind rch:manage rather than rch:record: every due date in the register is generated from this table, so an accidental edit moves everybody.\n\n**Permission:** `rch:manage`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `anc`, `delivery`, `pnc`, `family-planning`, `immunization`, `growth`.",
        "operationId": "postRchImmunisationSchedule",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "antigen": {
                    "type": "string"
                  },
                  "counts_for_coverage": {
                    "type": "boolean"
                  },
                  "dose_number": {
                    "type": "integer"
                  },
                  "due_weeks": {
                    "type": "integer"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Edits the schedule.",
        "tags": [
          "rch"
        ],
        "x-modules": [
          "anc",
          "delivery",
          "pnc",
          "family-planning",
          "immunization",
          "growth"
        ],
        "x-permissions": [
          "rch:manage"
        ]
      }
    },
    "/api/v1/rch/immunisation/{id}/give": {
      "post": {
        "description": "**Permission:** `rch:record`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `anc`, `delivery`, `pnc`, `family-planning`, `immunization`, `growth`.",
        "operationId": "postRchImmunisationIdGive",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "batch_number": {
                    "type": "string"
                  },
                  "given_by": {
                    "type": "string"
                  },
                  "not_given_reason": {
                    "type": "string"
                  },
                  "site": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records a dose, or why it was not given.",
        "tags": [
          "rch"
        ],
        "x-modules": [
          "anc",
          "delivery",
          "pnc",
          "family-planning",
          "immunization",
          "growth"
        ],
        "x-permissions": [
          "rch:record"
        ]
      }
    },
    "/api/v1/rch/pnc": {
      "get": {
        "description": "**Permission:** `rch:read`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `anc`, `delivery`, `pnc`, `family-planning`, `immunization`, `growth`.",
        "operationId": "getRchPnc",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "overdue",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "in": "query",
            "name": "patient_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the postnatal schedule.",
        "tags": [
          "rch"
        ],
        "x-modules": [
          "anc",
          "delivery",
          "pnc",
          "family-planning",
          "immunization",
          "growth"
        ],
        "x-permissions": [
          "rch:read"
        ]
      }
    },
    "/api/v1/rch/pnc/{id}": {
      "post": {
        "description": "**Permission:** `rch:record`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `anc`, `delivery`, `pnc`, `family-planning`, `immunization`, `growth`.",
        "operationId": "postRchPncId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RchPNCInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Attends a postnatal contact.",
        "tags": [
          "rch"
        ],
        "x-modules": [
          "anc",
          "delivery",
          "pnc",
          "family-planning",
          "immunization",
          "growth"
        ],
        "x-permissions": [
          "rch:record"
        ]
      }
    },
    "/api/v1/rch/summary": {
      "get": {
        "description": "**Permission:** `rch:read`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `anc`, `delivery`, `pnc`, `family-planning`, `immunization`, `growth`.",
        "operationId": "getRchSummary",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Counts the services.",
        "tags": [
          "rch"
        ],
        "x-modules": [
          "anc",
          "delivery",
          "pnc",
          "family-planning",
          "immunization",
          "growth"
        ],
        "x-permissions": [
          "rch:read"
        ]
      }
    },
    "/api/v1/search": {
      "get": {
        "description": "GATED ON BEING SIGNED IN, NOT ON A PERMISSION. There is no single permission that means \"may search\", because the question spans three registers a caller may hold different rights over. The gate is applied to the RESULTS instead: each kind is dropped unless the caller holds the permission for that register, so a cashier searching a surname finds the patient and not the nurse's staff record. Filtering in the browser would have shipped the row first and merely hidden it.\n\nA caller who may read none of the registers gets an empty list rather than a 403 — they are allowed to ask, there is simply nothing they may be told.\n\n**From the router:** Your own notifications. Behind no permission beyond being signed in: they are addressed to you, and read state is yours. A permission every account had to hold would not be a permission. The account comes from the token, never from a query. One search box. Gated on being signed in; the RESULTS are filtered by what the caller may read, register by register. There is no single \"may search\" permission because the question spans three registers with three different rights over them.\n\n**Access:** any signed-in account. No further permission.",
        "operationId": "getSearch",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 20,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "q",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Answers the one search box: patients, staff and filed documents together.",
        "tags": [
          "search"
        ]
      }
    },
    "/api/v1/services": {
      "get": {
        "description": "It is separate from StackHealth because it answers instantly: the catalogue is configuration, and reading it does not wait on 33 network round trips.\n\n**Permission:** `platform:health`",
        "operationId": "getServices",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists the service catalogue — every microservice the backend is configured to reach, and the gRPC address it reaches it on.",
        "tags": [
          "services"
        ],
        "x-permissions": [
          "platform:health"
        ]
      }
    },
    "/api/v1/settings/documents/preview": {
      "get": {
        "description": "WHY A SPECIMEN AND NOT A REAL BILL. Somebody adjusting the wording on the hospital's paper needs to see the effect, and the alternative — find a bill, print it, look, come back, change a word, find the bill again — is a loop nobody completes, so the terms get typed once and never checked. It is also the only safe way to do it: a settings screen that could print any patient's invoice would be a way to read billing without holding bill:read.\n\nTHE FIGURES ARE OBVIOUSLY NOT REAL, and that is deliberate. A specimen that looked like a genuine invoice is one that ends up in front of a patient, so it is drawn for a patient who does not exist, stamped SPECIMEN, and never stored in the document register.\n\n**From the router:** A specimen invoice drawn from the settings as they stand, so somebody editing the wording can see it. Gated with the rest of this screen and NOT on bill:read — it draws an invented patient, so it is not a way to read billing without the permission for it.\n\n**Access:** any signed-in account. No further permission.",
        "operationId": "getSettingsDocumentsPreview",
        "parameters": [
          {
            "in": "query",
            "name": "language",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/pdf": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "The document, as a PDF."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Draws a specimen invoice using the settings as they stand.",
        "tags": [
          "settings"
        ]
      }
    },
    "/api/v1/settings/email": {
      "get": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "getSettingsEmail",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the SMTP server the hospital sends from.",
        "tags": [
          "settings"
        ]
      },
      "put": {
        "description": "The password arrives as the placeholder when it has not been retyped, and notification-service reads that as \"keep what is stored\" — so editing the port does not silently wipe the password.\n\n**Access:** any signed-in account. No further permission.",
        "operationId": "putSettingsEmail",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "config": {
                    "$ref": "#/components/schemas/HandlersEmailConfigBody"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Changes it.",
        "tags": [
          "settings"
        ]
      }
    },
    "/api/v1/settings/email/test": {
      "post": {
        "description": "IT TESTS WHAT IS IN THE REQUEST, NOT WHAT IS STORED, which is the only order that helps: the question somebody has at this moment is \"is this password right\", and answering it after the password has been saved is answering it too late.\n\nA refusal here is an ANSWER, in the mail server's own words — \"authentication failed\", \"connection refused\". It is not a fault and is not logged as one.\n\n**Access:** any signed-in account. No further permission.",
        "operationId": "postSettingsEmailTest",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "config": {
                    "$ref": "#/components/schemas/HandlersEmailConfigBody"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Dials the mail server with the settings on screen.",
        "tags": [
          "settings"
        ]
      }
    },
    "/api/v1/settings/email/test-send": {
      "post": {
        "description": "WHY THIS IS NOT `TestEmailSettings`. That one dials the server and authenticates: it answers \"is this password right\", before saving. This one answers a different question — \"does a message actually arrive\" — and only a message somebody receives can answer it. A server that accepts a login can still refuse to relay, reject the From address, or have the mail filed as spam.\n\n**From the router:** Sending a real test message is a SEPARATE route from testing the settings, because they answer different questions: one is \"is this password right\", the other is \"does a message actually arrive\".\n\n**Access:** any signed-in account. No further permission.",
        "operationId": "postSettingsEmailTestSend",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "to": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Sends a real message to an address somebody types, using the SAVED settings.",
        "tags": [
          "settings"
        ]
      }
    },
    "/api/v1/settings/sms": {
      "get": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "getSettingsSms",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists the gateways that can carry a message to a patient's phone.",
        "tags": [
          "settings"
        ]
      }
    },
    "/api/v1/settings/sms/test-send": {
      "post": {
        "description": "IT COSTS MONEY AND ARRIVES ON A HANDSET. That is the point — a gateway that accepts credentials is not a gateway that delivers — and it is why the number is typed here rather than picked from the patient register.\n\nTHE NUMBER MUST CARRY ITS COUNTRY CODE. Gateways route on it, and a national number sent without one is either refused or delivered to whoever holds that number in the gateway's own country. The refusal names the shape wanted.\n\n**Access:** any signed-in account. No further permission.",
        "operationId": "postSettingsSmsTestSend",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "phone": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Sends a real text message to a number somebody types.",
        "tags": [
          "settings"
        ]
      }
    },
    "/api/v1/settings/sms/{code}": {
      "patch": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "patchSettingsSmsCode",
        "parameters": [
          {
            "in": "path",
            "name": "code",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackServiceProviderPatch"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Switches a gateway on, makes it the default, or changes its credentials.",
        "tags": [
          "settings"
        ]
      }
    },
    "/api/v1/settings/storage": {
      "get": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "getSettingsStorage",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists every storage backend, with credentials masked.",
        "tags": [
          "settings"
        ]
      }
    },
    "/api/v1/settings/storage/{code}": {
      "patch": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "patchSettingsStorageCode",
        "parameters": [
          {
            "in": "path",
            "name": "code",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StackServiceProviderPatch"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Switches a provider on, makes it the default, or changes its credentials.",
        "tags": [
          "settings"
        ]
      }
    },
    "/api/v1/settings/system": {
      "get": {
        "description": "**From the router:** What this installation is. The hospital's name, logo, colour and country. Read is OPEN because the sign-in screen carries the name and the logo, and there is no account yet when it is drawn; nothing in it is secret — it is what any visitor reads off the front of the building. ITS OWN, MUCH LOOSER CEILING. The feedback limit above is 60 a minute because one patient answers one form once. This is asked for by every browser tab in the hospital on every page load, and a hospital arrives from ONE address: 60 would refuse the second half of a morning shift. The answer is cached both here and in front of config-service, so the cost of a request is close to nothing.\n\n**Access:** open — no token required.\n\n**Rate limit:** 600 per minute per client address.",
        "operationId": "getSettingsSystem",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Too many requests from this address."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [],
        "summary": "Returns what this installation is.",
        "tags": [
          "settings"
        ],
        "x-rate-limit": "600 per minute"
      },
      "put": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "putSettingsSystem",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HandlersSystemSettingsInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Changes them.",
        "tags": [
          "settings"
        ]
      }
    },
    "/api/v1/settings/system/image/{kind}": {
      "delete": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "deleteSettingsSystemImageKind",
        "parameters": [
          {
            "in": "path",
            "name": "kind",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Removes it, and the file behind it.",
        "tags": [
          "settings"
        ]
      },
      "get": {
        "description": "OPEN, like the settings themselves: the sign-in screen carries the hospital's logo and there is no account yet when it is drawn. It is the picture on the front of the building.\n\nThe bytes come through the backend rather than from a link straight into storage, for the same reason every other file does — file-service will serve an asset to anybody holding its id, and an id in a page's HTML is an id everybody holds.\n\n**From the router:** The logo and the tab icon, for the same reason and under the same ceiling: the sign-in screen draws them before anybody has an account.\n\n**Access:** open — no token required.\n\n**Rate limit:** 600 per minute per client address.",
        "operationId": "getSettingsSystemImageKind",
        "parameters": [
          {
            "in": "path",
            "name": "kind",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/octet-stream": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "The stored file, with its own content type."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Too many requests from this address."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [],
        "summary": "Serves the logo or the tab icon.",
        "tags": [
          "settings"
        ],
        "x-rate-limit": "600 per minute"
      },
      "post": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "postSettingsSystemImageKind",
        "parameters": [
          {
            "in": "path",
            "name": "kind",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "properties": {
                  "entity_id": {
                    "type": "string"
                  },
                  "entity_type": {
                    "type": "string"
                  },
                  "file": {
                    "format": "binary",
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Stores the hospital's logo or tab icon.",
        "tags": [
          "settings"
        ]
      }
    },
    "/api/v1/support/assets": {
      "get": {
        "description": "**Permission:** `asset:read`",
        "operationId": "getSupportAssets",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the equipment register.",
        "tags": [
          "support"
        ],
        "x-permissions": [
          "asset:read"
        ]
      },
      "post": {
        "description": "**Permission:** `asset:manage`",
        "operationId": "postSupportAssets",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportAssetInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits equipment.",
        "tags": [
          "support"
        ],
        "x-permissions": [
          "asset:manage"
        ]
      }
    },
    "/api/v1/support/assets/{id}": {
      "put": {
        "description": "**Permission:** `asset:manage`",
        "operationId": "putSupportAssetsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportAssetInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits equipment.",
        "tags": [
          "support"
        ],
        "x-permissions": [
          "asset:manage"
        ]
      }
    },
    "/api/v1/support/assets/{id}/assignment": {
      "post": {
        "description": "Gated on `asset:manage`, the same code that adds a machine to the register: handing a laptop to somebody and writing down that it exists are the same kind of act on the same register, and a separate code would suggest they are separate registers.\n\n**From the router:** Issuing a laptop and booking in a defibrillator are the same register. See the note on the handler.\n\n**Permission:** `asset:manage`",
        "operationId": "postSupportAssetsIdAssignment",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportAssetAssignment"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Issues equipment to somebody, or records it coming back.",
        "tags": [
          "support"
        ],
        "x-permissions": [
          "asset:manage"
        ]
      }
    },
    "/api/v1/support/assets/{id}/events": {
      "post": {
        "description": "**Permission:** `asset:manage`",
        "operationId": "postSupportAssetsIdEvents",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportAssetEventInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records a service, repair or breakdown.",
        "tags": [
          "support"
        ],
        "x-permissions": [
          "asset:manage"
        ]
      }
    },
    "/api/v1/support/assets/{id}/history": {
      "get": {
        "description": "**Permission:** `asset:read`",
        "operationId": "getSupportAssetsIdHistory",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns what has happened to a machine.",
        "tags": [
          "support"
        ],
        "x-permissions": [
          "asset:read"
        ]
      }
    },
    "/api/v1/support/blood/requests": {
      "get": {
        "description": "**Permission:** `bloodbank:read`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `blood-bank`.",
        "operationId": "getSupportBloodRequests",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns what the wards have asked for.",
        "tags": [
          "support"
        ],
        "x-modules": [
          "blood-bank"
        ],
        "x-permissions": [
          "bloodbank:read"
        ]
      },
      "post": {
        "description": "**Permission:** `bloodbank:read`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `blood-bank`.",
        "operationId": "postSupportBloodRequests",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportBloodRequestInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Asks the bank for blood.",
        "tags": [
          "support"
        ],
        "x-modules": [
          "blood-bank"
        ],
        "x-permissions": [
          "bloodbank:read"
        ]
      }
    },
    "/api/v1/support/blood/requests/{id}/status": {
      "post": {
        "description": "**Permission:** `bloodbank:manage`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `blood-bank`.",
        "operationId": "postSupportBloodRequestsIdStatus",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  },
                  "status": {
                    "enum": [
                      "REQUESTED",
                      "CROSSMATCHING",
                      "READY",
                      "ISSUED",
                      "CANCELLED"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Advances a request.",
        "tags": [
          "support"
        ],
        "x-modules": [
          "blood-bank"
        ],
        "x-permissions": [
          "bloodbank:manage"
        ]
      }
    },
    "/api/v1/support/blood/units": {
      "get": {
        "description": "**Permission:** `bloodbank:read`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `blood-bank`.",
        "operationId": "getSupportBloodUnits",
        "parameters": [
          {
            "in": "query",
            "name": "group",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the fridge.",
        "tags": [
          "support"
        ],
        "x-modules": [
          "blood-bank"
        ],
        "x-permissions": [
          "bloodbank:read"
        ]
      },
      "post": {
        "description": "Unscreened blood goes to quarantine, not to the shelf.\n\n**Permission:** `bloodbank:manage`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `blood-bank`.",
        "operationId": "postSupportBloodUnits",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportBloodUnitInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Books a unit in.",
        "tags": [
          "support"
        ],
        "x-modules": [
          "blood-bank"
        ],
        "x-permissions": [
          "bloodbank:manage"
        ]
      }
    },
    "/api/v1/support/blood/units/{id}/crossmatch": {
      "post": {
        "description": "**Permission:** `bloodbank:manage`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `blood-bank`.",
        "operationId": "postSupportBloodUnitsIdCrossmatch",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "patient_id": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Reserves a unit for one patient.",
        "tags": [
          "support"
        ],
        "x-modules": [
          "blood-bank"
        ],
        "x-permissions": [
          "bloodbank:manage"
        ]
      }
    },
    "/api/v1/support/blood/units/{id}/discard": {
      "post": {
        "description": "**Permission:** `bloodbank:manage`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `blood-bank`.",
        "operationId": "postSupportBloodUnitsIdDiscard",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Takes a unit out of stock.",
        "tags": [
          "support"
        ],
        "x-modules": [
          "blood-bank"
        ],
        "x-permissions": [
          "bloodbank:manage"
        ]
      }
    },
    "/api/v1/support/blood/units/{id}/issue": {
      "post": {
        "description": "**Permission:** `bloodbank:issue`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `blood-bank`.",
        "operationId": "postSupportBloodUnitsIdIssue",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "patient_id": {
                    "type": "string"
                  },
                  "to": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Hands a unit over, to the patient it was matched for.",
        "tags": [
          "support"
        ],
        "x-modules": [
          "blood-bank"
        ],
        "x-permissions": [
          "bloodbank:issue"
        ]
      }
    },
    "/api/v1/support/blood/units/{id}/screen": {
      "post": {
        "description": "**Permission:** `bloodbank:manage`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `blood-bank`.",
        "operationId": "postSupportBloodUnitsIdScreen",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "notes": {
                    "type": "string"
                  },
                  "passed": {
                    "type": "boolean"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records screening and moves the unit onto the shelf.",
        "tags": [
          "support"
        ],
        "x-modules": [
          "blood-bank"
        ],
        "x-permissions": [
          "bloodbank:manage"
        ]
      }
    },
    "/api/v1/support/fleet/drivers": {
      "get": {
        "description": "**Permission:** `fleet:dispatch`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `ambulance`.",
        "operationId": "getSupportFleetDrivers",
        "parameters": [
          {
            "in": "query",
            "name": "zone_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists who could take a trip now.",
        "tags": [
          "support"
        ],
        "x-modules": [
          "ambulance"
        ],
        "x-permissions": [
          "fleet:dispatch"
        ]
      }
    },
    "/api/v1/support/fleet/settings": {
      "get": {
        "description": "**Permission:** `fleet:manage`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `ambulance`.",
        "operationId": "getSupportFleetSettings",
        "parameters": [
          {
            "in": "query",
            "name": "category",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one category of tunable numbers.",
        "tags": [
          "support"
        ],
        "x-modules": [
          "ambulance"
        ],
        "x-permissions": [
          "fleet:manage"
        ]
      }
    },
    "/api/v1/support/fleet/settings/{key}": {
      "put": {
        "description": "The bounds are the service's, not this handler's. A timeout of zero seconds is wrong whether the console or a script asked for it, so the check belongs where both go through.\n\n**Permission:** `fleet:manage`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `ambulance`.",
        "operationId": "putSupportFleetSettingsKey",
        "parameters": [
          {
            "in": "path",
            "name": "key",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "value": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Changes one.",
        "tags": [
          "support"
        ],
        "x-modules": [
          "ambulance"
        ],
        "x-permissions": [
          "fleet:manage"
        ]
      }
    },
    "/api/v1/support/fleet/trips": {
      "get": {
        "description": "**Permission:** `fleet:read`",
        "operationId": "getSupportFleetTrips",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the dispatch log.",
        "tags": [
          "support"
        ],
        "x-permissions": [
          "fleet:read"
        ]
      },
      "post": {
        "description": "**Permission:** `fleet:dispatch`",
        "operationId": "postSupportFleetTrips",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportTripInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Sends a vehicle out.",
        "tags": [
          "support"
        ],
        "x-permissions": [
          "fleet:dispatch"
        ]
      }
    },
    "/api/v1/support/fleet/trips/{id}/status": {
      "post": {
        "description": "**Permission:** `fleet:dispatch`",
        "operationId": "postSupportFleetTripsIdStatus",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "distance_km": {
                    "nullable": true,
                    "type": "integer"
                  },
                  "reason": {
                    "type": "string"
                  },
                  "status": {
                    "enum": [
                      "DISPATCHED",
                      "ON_SCENE",
                      "RETURNING",
                      "COMPLETED",
                      "ABORTED"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Advances a trip and frees the vehicle when it comes back.",
        "tags": [
          "support"
        ],
        "x-permissions": [
          "fleet:dispatch"
        ]
      }
    },
    "/api/v1/support/fleet/vehicles": {
      "get": {
        "description": "**From the router:** THE REGISTER IS NOT THE DISPATCH DESK, and only one of them is optional. A branch that owns a vehicle records trips for it whether or not it runs a dispatch operation, so the register and the trip log stay open to anybody with `fleet:read`.\n\n**Permission:** `fleet:read`",
        "operationId": "getSupportFleetVehicles",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the fleet.",
        "tags": [
          "support"
        ],
        "x-permissions": [
          "fleet:read"
        ]
      },
      "post": {
        "description": "**Permission:** `fleet:manage`",
        "operationId": "postSupportFleetVehicles",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportVehicleInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits a vehicle.",
        "tags": [
          "support"
        ],
        "x-permissions": [
          "fleet:manage"
        ]
      }
    },
    "/api/v1/support/fleet/vehicles/{id}": {
      "put": {
        "description": "**Permission:** `fleet:manage`",
        "operationId": "putSupportFleetVehiclesId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportVehicleInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits a vehicle.",
        "tags": [
          "support"
        ],
        "x-permissions": [
          "fleet:manage"
        ]
      }
    },
    "/api/v1/support/fleet/vehicles/{id}/position": {
      "get": {
        "description": "THE TIME IS ALWAYS RETURNED WITH IT. A position with no time on it is a position somebody trusts for longer than they should: an ambulance that reported forty minutes ago is not where the map says it is, and a dispatcher deciding which vehicle is nearest needs to know that.\n\n**Permission:** `fleet:read`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `ambulance`.",
        "operationId": "getSupportFleetVehiclesIdPosition",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns where an ambulance was last seen.",
        "tags": [
          "support"
        ],
        "x-modules": [
          "ambulance"
        ],
        "x-permissions": [
          "fleet:read"
        ]
      },
      "put": {
        "description": "Gated on fleet:dispatch rather than fleet:manage: this is reported BY the people running trips, from a handset in the vehicle, not by whoever maintains the register.\n\n**Permission:** `fleet:dispatch`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `ambulance`.",
        "operationId": "putSupportFleetVehiclesIdPosition",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "latitude": {
                    "type": "number"
                  },
                  "longitude": {
                    "type": "number"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records where a vehicle is now.",
        "tags": [
          "support"
        ],
        "x-modules": [
          "ambulance"
        ],
        "x-permissions": [
          "fleet:dispatch"
        ]
      }
    },
    "/api/v1/support/fleet/zones": {
      "get": {
        "description": "**Permission:** `fleet:read`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `ambulance`.",
        "operationId": "getSupportFleetZones",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists the areas covered.",
        "tags": [
          "support"
        ],
        "x-modules": [
          "ambulance"
        ],
        "x-permissions": [
          "fleet:read"
        ]
      }
    },
    "/api/v1/support/mortuary/bays": {
      "get": {
        "description": "**Permission:** `mortuary:read`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `mortuary`.",
        "operationId": "getSupportMortuaryBays",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the storage bays.",
        "tags": [
          "support"
        ],
        "x-modules": [
          "mortuary"
        ],
        "x-permissions": [
          "mortuary:read"
        ]
      },
      "post": {
        "description": "**Permission:** `mortuary:manage`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `mortuary`.",
        "operationId": "postSupportMortuaryBays",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "kind": {
                    "enum": [
                      "REFRIGERATED",
                      "FREEZER",
                      "HOLDING"
                    ],
                    "type": "string"
                  },
                  "label": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds a storage bay.",
        "tags": [
          "support"
        ],
        "x-modules": [
          "mortuary"
        ],
        "x-permissions": [
          "mortuary:manage"
        ]
      }
    },
    "/api/v1/support/mortuary/bodies": {
      "get": {
        "description": "**Permission:** `mortuary:read`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `mortuary`.",
        "operationId": "getSupportMortuaryBodies",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the mortuary register.",
        "tags": [
          "support"
        ],
        "x-modules": [
          "mortuary"
        ],
        "x-permissions": [
          "mortuary:read"
        ]
      },
      "post": {
        "description": "**Permission:** `mortuary:manage`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `mortuary`.",
        "operationId": "postSupportMortuaryBodies",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportBodyInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Books a body in.",
        "tags": [
          "support"
        ],
        "x-modules": [
          "mortuary"
        ],
        "x-permissions": [
          "mortuary:manage"
        ]
      }
    },
    "/api/v1/support/mortuary/bodies/{id}/release": {
      "post": {
        "description": "Its own permission: this is the moment something irreversible leaves the building, and the record of who took it is the only thing anybody has afterwards.\n\n**Permission:** `mortuary:release`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `mortuary`.",
        "operationId": "postSupportMortuaryBodiesIdRelease",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SupportReleaseInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Releases a body to a named person.",
        "tags": [
          "support"
        ],
        "x-modules": [
          "mortuary"
        ],
        "x-permissions": [
          "mortuary:release"
        ]
      }
    },
    "/api/v1/support/queue": {
      "get": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "getSupportQueue",
        "parameters": [
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Is every open ticket. IT only.",
        "tags": [
          "support"
        ]
      }
    },
    "/api/v1/support/summary": {
      "get": {
        "description": "**Permission:** `asset:read`",
        "operationId": "getSupportSummary",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Counts the specialist registers.",
        "tags": [
          "support"
        ],
        "x-permissions": [
          "asset:read"
        ]
      }
    },
    "/api/v1/support/tickets": {
      "get": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "getSupportTickets",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists what this person has reported.",
        "tags": [
          "support"
        ]
      },
      "post": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "postSupportTickets",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "body": {
                    "type": "string"
                  },
                  "category": {
                    "type": "string"
                  },
                  "priority": {
                    "description": "The helpdesk is support_service, and its priorities are its own — this database's `priority` belongs to a laboratory and reads ROUTINE, URGENT, STAT.",
                    "enum": [
                      "low",
                      "normal",
                      "high",
                      "urgent"
                    ],
                    "type": "string"
                  },
                  "subject": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Asks IT for help.",
        "tags": [
          "support"
        ]
      }
    },
    "/api/v1/support/tickets/{id}": {
      "get": {
        "description": "An agent's view carries the internal notes; a requester's does not. Which is used is decided by the permission, not by anything the browser asks for.\n\n**Access:** any signed-in account. No further permission.",
        "operationId": "getSupportTicketsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one, with the conversation on it.",
        "tags": [
          "support"
        ]
      }
    },
    "/api/v1/support/tickets/{id}/messages": {
      "post": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "postSupportTicketsIdMessages",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "body": {
                    "type": "string"
                  },
                  "internal": {
                    "description": "Internal notes are between IT staff.",
                    "type": "boolean"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds a line.",
        "tags": [
          "support"
        ]
      }
    },
    "/api/v1/support/tickets/{id}/status": {
      "post": {
        "description": "**Access:** any signed-in account. No further permission.",
        "operationId": "postSupportTicketsIdStatus",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "status": {
                    "description": "support-service's own vocabulary, which it refuses anything outside.",
                    "enum": [
                      "open",
                      "pending",
                      "resolved",
                      "closed"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Moves a ticket along. IT only.",
        "tags": [
          "support"
        ]
      }
    },
    "/api/v1/sync/nudge": {
      "post": {
        "description": "# WHY A WORKSTATION IS ALLOWED TO ASK\n\n\"Open the app and today's work is there\" is one of the four things this whole design was asked for. A five-minute timer would make it \"open the app, wait five minutes\". So the desktop client asks for a round when it starts, and the agent runs one.\n\nIt cannot be abused into a denial of service: the request only ever sets a flag on a channel of one, so a hundred workstations asking at once is one round.\n\n**Access:** any signed-in account. No further permission.",
        "operationId": "postSyncNudge",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Answers POST /sync/nudge — a round now, rather than at the next tick.",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/v1/sync/quarantine": {
      "get": {
        "description": "**Permission:** `platform:health`",
        "operationId": "getSyncQuarantine",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Answers GET /sync/quarantine — what could not be applied.",
        "tags": [
          "sync"
        ],
        "x-permissions": [
          "platform:health"
        ]
      }
    },
    "/api/v1/sync/quarantine/{id}/retry": {
      "post": {
        "description": "It does not re-apply the change here. It clears the record so that the next batch carrying it is tried again — which resolves the common case by itself, because the common case is a parent row that has since arrived.\n\n**From the router:** Clearing a quarantined change is a decision about the record, so it needs the permission that owns the record's integrity rather than the one that reads a dashboard.\n\n**Permission:** `backup:manage`",
        "operationId": "postSyncQuarantineIdRetry",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "note": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Answers POST /sync/quarantine/:id/retry.",
        "tags": [
          "sync"
        ],
        "x-permissions": [
          "backup:manage"
        ]
      }
    },
    "/api/v1/sync/status": {
      "get": {
        "description": "THE ONE SCREEN THAT MAKES THIS DESIGN HONEST. A synchroniser that has been failing for a week and says nothing is worse than one that is not running, because the second is obvious. Pending rows that only ever grow, a quarantine that is not empty, a last success that is yesterday — each is a number somebody can act on.\n\n**Permission:** `platform:health`",
        "operationId": "getSyncStatus",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Answers GET /sync/status — is the mirror working?",
        "tags": [
          "sync"
        ],
        "x-permissions": [
          "platform:health"
        ]
      }
    },
    "/api/v1/sync/v1/pull": {
      "get": {
        "description": "WHAT A NODE IS GIVEN. Changes that did not come from that node, on tables that travel downwards. A hospital's node has no business receiving another hospital's rows, and the origin filter is what makes that true rather than hoped for.\n\n**Access:** the internal `X-API-Key`. Called by scheduler-service, never by a user-facing client.",
        "operationId": "getSyncPull",
        "parameters": [
          {
            "in": "query",
            "name": "after",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "node",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Missing or wrong `X-API-Key`."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [
          {
            "internalKey": []
          }
        ],
        "summary": "Answers GET /sync/v1/pull — the cloud handing a node what is for it.",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/v1/sync/v1/push": {
      "post": {
        "description": "GZIP IS ACCEPTED because the agent sends it: a day's journal is JSON full of repeated column names and compresses to about a tenth, which on a 3G dongle is the difference between a hospital catching up in the evening and never catching up at all.\n\n**Access:** the internal `X-API-Key`. Called by scheduler-service, never by a user-facing client.",
        "operationId": "postSyncPush",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Missing or wrong `X-API-Key`."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [
          {
            "internalKey": []
          }
        ],
        "summary": "Answers POST /sync/v1/push — the cloud receiving a node's work.",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/v1/theatre/list": {
      "get": {
        "description": "**Permission:** `theatre:read`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `theatre`.",
        "operationId": "getTheatreList",
        "parameters": [
          {
            "in": "query",
            "name": "date",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the operating list.",
        "tags": [
          "theatre"
        ],
        "x-modules": [
          "theatre"
        ],
        "x-permissions": [
          "theatre:read"
        ]
      }
    },
    "/api/v1/theatre/rooms": {
      "get": {
        "description": "**Permission:** `theatre:read`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `theatre`.",
        "operationId": "getTheatreRooms",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the theatres, with what is in each.",
        "tags": [
          "theatre"
        ],
        "x-modules": [
          "theatre"
        ],
        "x-permissions": [
          "theatre:read"
        ]
      },
      "post": {
        "description": "**Permission:** `theatre:schedule`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `theatre`.",
        "operationId": "postTheatreRooms",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TheatreRoomInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits a theatre.",
        "tags": [
          "theatre"
        ],
        "x-modules": [
          "theatre"
        ],
        "x-permissions": [
          "theatre:schedule"
        ]
      }
    },
    "/api/v1/theatre/rooms/{id}": {
      "put": {
        "description": "**Permission:** `theatre:schedule`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `theatre`.",
        "operationId": "putTheatreRoomsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TheatreRoomInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Adds or edits a theatre.",
        "tags": [
          "theatre"
        ],
        "x-modules": [
          "theatre"
        ],
        "x-permissions": [
          "theatre:schedule"
        ]
      }
    },
    "/api/v1/theatre/summary": {
      "get": {
        "description": "**Permission:** `theatre:read`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `theatre`.",
        "operationId": "getTheatreSummary",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Counts the day.",
        "tags": [
          "theatre"
        ],
        "x-modules": [
          "theatre"
        ],
        "x-permissions": [
          "theatre:read"
        ]
      }
    },
    "/api/v1/theatre/surgeries": {
      "post": {
        "description": "**Permission:** `theatre:schedule`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `theatre`.",
        "operationId": "postTheatreSurgeries",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TheatreSurgeryInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Puts an operation on the list.",
        "tags": [
          "theatre"
        ],
        "x-modules": [
          "theatre"
        ],
        "x-permissions": [
          "theatre:schedule"
        ]
      }
    },
    "/api/v1/theatre/surgeries/{id}": {
      "get": {
        "description": "**Permission:** `theatre:read`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `theatre`.",
        "operationId": "getTheatreSurgeriesId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one operation.",
        "tags": [
          "theatre"
        ],
        "x-modules": [
          "theatre"
        ],
        "x-permissions": [
          "theatre:read"
        ]
      }
    },
    "/api/v1/theatre/surgeries/{id}/checklist": {
      "post": {
        "description": "**Permission:** `theatre:record`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `theatre`.",
        "operationId": "postTheatreSurgeriesIdChecklist",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TheatreChecklistInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records one stage of the surgical safety checklist.",
        "tags": [
          "theatre"
        ],
        "x-modules": [
          "theatre"
        ],
        "x-permissions": [
          "theatre:record"
        ]
      }
    },
    "/api/v1/theatre/surgeries/{id}/outcome": {
      "put": {
        "description": "**Permission:** `theatre:record`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `theatre`.",
        "operationId": "putTheatreSurgeriesIdOutcome",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TheatreOutcomeInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Writes up what was found.",
        "tags": [
          "theatre"
        ],
        "x-modules": [
          "theatre"
        ],
        "x-permissions": [
          "theatre:record"
        ]
      }
    },
    "/api/v1/theatre/surgeries/{id}/status": {
      "post": {
        "description": "**Permission:** `theatre:record`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `theatre`.",
        "operationId": "postTheatreSurgeriesIdStatus",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason": {
                    "type": "string"
                  },
                  "status": {
                    "enum": [
                      "SCHEDULED",
                      "CONFIRMED",
                      "IN_THEATRE",
                      "IN_PROGRESS",
                      "COMPLETED",
                      "CANCELLED",
                      "POSTPONED"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Changes the status of an operation.",
        "tags": [
          "theatre"
        ],
        "x-modules": [
          "theatre"
        ],
        "x-permissions": [
          "theatre:record"
        ]
      }
    },
    "/api/v1/theatre/surgeries/{id}/team": {
      "post": {
        "description": "**Permission:** `theatre:record`\n\n**Module switch:** closed with 403 when the caller's branch has switched off every one of `theatre`.",
        "operationId": "postTheatreSurgeriesIdTeam",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "role": {
                    "description": "surgery_team.role.",
                    "enum": [
                      "SURGEON",
                      "ASSISTANT",
                      "ANAESTHETIST",
                      "SCRUB_NURSE",
                      "CIRCULATING_NURSE",
                      "ODP",
                      "OBSERVER"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records who was in the room.",
        "tags": [
          "theatre"
        ],
        "x-modules": [
          "theatre"
        ],
        "x-permissions": [
          "theatre:record"
        ]
      }
    },
    "/api/v1/visits": {
      "get": {
        "description": "Defaults to everybody still in the building, ordered sickest-first: that is what a queue board is opened for, and requiring a filter to get it would make the common case the awkward one.\n\n**Permission:** `visit:read`",
        "operationId": "getVisits",
        "parameters": [
          {
            "in": "query",
            "name": "date",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "department",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "search",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the queue, or the register for a chosen day.",
        "tags": [
          "visits"
        ],
        "x-permissions": [
          "visit:read"
        ]
      },
      "post": {
        "description": "**Permission:** `visit:create`",
        "operationId": "postVisits",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VisitsInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Opens an attendance.",
        "tags": [
          "visits"
        ],
        "x-permissions": [
          "visit:create"
        ]
      }
    },
    "/api/v1/visits/summary": {
      "get": {
        "description": "**Permission:** `visit:read`",
        "operationId": "getVisitsSummary",
        "parameters": [
          {
            "in": "query",
            "name": "facility_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Counts the day for the queue tiles.",
        "tags": [
          "visits"
        ],
        "x-permissions": [
          "visit:read"
        ]
      }
    },
    "/api/v1/visits/transitions": {
      "get": {
        "description": "**Permission:** `visit:read`",
        "operationId": "getVisitsTransitions",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Lists the moves the journey allows.",
        "tags": [
          "visits"
        ],
        "x-permissions": [
          "visit:read"
        ]
      }
    },
    "/api/v1/visits/{id}": {
      "get": {
        "description": "**Permission:** `visit:read`",
        "operationId": "getVisitsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns one attendance.",
        "tags": [
          "visits"
        ],
        "x-permissions": [
          "visit:read"
        ]
      },
      "put": {
        "description": "**Permission:** `visit:update`",
        "operationId": "putVisitsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VisitsInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Writes up a consultation.",
        "tags": [
          "visits"
        ],
        "x-permissions": [
          "visit:update"
        ]
      }
    },
    "/api/v1/visits/{id}/advance": {
      "post": {
        "description": "Its own permission, and its own route, because moving somebody is a different act from writing on their record — see the note at the top of this file.\n\n**Permission:** `visit:advance`",
        "operationId": "postVisitsIdAdvance",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "label": {
                    "type": "string"
                  },
                  "status": {
                    "enum": [
                      "REGISTERED",
                      "WAITING_PAYMENT",
                      "PAID",
                      "WAITING_TRIAGE",
                      "IN_TRIAGE",
                      "WAITING_DOCTOR",
                      "IN_CONSULTATION",
                      "WAITING_LAB",
                      "LAB_PROCESSING",
                      "LAB_COMPLETED",
                      "WAITING_DOCTOR_REVIEW",
                      "WAITING_PHARMACY",
                      "ADMITTED",
                      "COMPLETED",
                      "CANCELLED"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Moves a visit along the queue and records the move.",
        "tags": [
          "visits"
        ],
        "x-permissions": [
          "visit:advance"
        ]
      }
    },
    "/api/v1/visits/{id}/notes": {
      "post": {
        "description": "**Permission:** `visit:advance`",
        "operationId": "postVisitsIdNotes",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "note": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Records something that happened without moving the patient.",
        "tags": [
          "visits"
        ],
        "x-permissions": [
          "visit:advance"
        ]
      }
    },
    "/api/v1/visits/{id}/timeline": {
      "get": {
        "description": "Gated on `visit:read` rather than a permission of its own: somebody who may see the visit may see how long it took. The wait is not more sensitive than the attendance it belongs to.\n\n**Permission:** `visit:read`",
        "operationId": "getVisitsIdTimeline",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Returns the journey, with the gap between each step.",
        "tags": [
          "visits"
        ],
        "x-permissions": [
          "visit:read"
        ]
      }
    },
    "/api/v1/visits/{id}/vitals": {
      "post": {
        "description": "Gated on `vitals:record`, held by nurses and clinical officers who do not necessarily hold `visit:update`: taking observations is not writing up a consultation, and a triage nurse must be able to do the first without the second.\n\n**From the router:** Taking observations is not writing up a consultation. A triage nurse must be able to do the first without the second.\n\n**Permission:** `vitals:record`",
        "operationId": "postVisitsIdVitals",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VisitsVitalsInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No token, an invalid one, or an expired one. Refresh and retry, or sign in again."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Signed in, but not permitted — either the permission is not held, or the branch has the module switched off."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "summary": "Writes one set of observations against a visit.",
        "tags": [
          "visits"
        ],
        "x-permissions": [
          "vitals:record"
        ]
      }
    },
    "/api/v1/webhooks/paypal": {
      "post": {
        "description": "PayPal retries anything that is not 2xx, for days. So the answers are chosen for that: 200 once the notification is verified and recorded (a duplicate included — it was already handled), 400 for one that did not verify (a retry will not verify either), and 503 when payment-service could not be reached, which is exactly when a retry is wanted.\n\n**From the router:** PayPal's notifications. OPEN BECAUSE PAYPAL HOLDS NO TOKEN, and safe because nothing is believed on arrival: the body and PayPal's transmission headers go to payment-service untouched, which asks PayPal itself whether it sent them before anything is written. A forgery is answered 400 and changes nothing. This is the only way a notification reaches payment-service, which publishes no route of its own to the internet.\n\n**Access:** open — no token required.\n\n**Rate limit:** 600 per minute per client address.",
        "operationId": "postWebhooksPaypal",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Too many requests from this address."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [],
        "summary": "Receives a PayPal notification.",
        "tags": [
          "webhooks"
        ],
        "x-rate-limit": "600 per minute"
      }
    },
    "/healthz": {
      "get": {
        "description": "This is the one route that does NOT use the response envelope: a probe is read by Docker, not by the console, and Docker only looks at the status code.\n\n**Access:** open — no token required.",
        "operationId": "getHealthz",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [],
        "summary": "Answers the container health probe. It only reports that this process is up — it never depends on downstream services, so a single slow microservice can't flap the backend's own health.",
        "tags": [
          "meta"
        ]
      }
    },
    "/internal/jobs/appointment-reminders": {
      "post": {
        "description": "The facility's own name goes into the message, because \"you have an appointment tomorrow\" from an unidentified number is a message people delete. It is read from the organisation record rather than configured separately, so a hospital that corrects its name corrects its texts — and in the hosted service it is read per hospital, so each one's texts carry its own.\n\n**Access:** the internal `X-API-Key`. Called by scheduler-service, never by a user-facing client.",
        "operationId": "postInternalJobsAppointmentReminders",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Missing or wrong `X-API-Key`."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [
          {
            "internalKey": []
          }
        ],
        "summary": "Texts tomorrow's patients.",
        "tags": [
          "internal-jobs"
        ]
      }
    },
    "/internal/jobs/bed-charges": {
      "post": {
        "description": "Overnight, and idempotent by construction: a bed charge's source id is derived from the admission and the DATE, so the same night cannot be billed twice however many times this runs. A sweep that had to remember where it got to would lose that memory exactly once, on the night nobody was watching.\n\n**Access:** the internal `X-API-Key`. Called by scheduler-service, never by a user-facing client.",
        "operationId": "postInternalJobsBedCharges",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Missing or wrong `X-API-Key`."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [
          {
            "internalKey": []
          }
        ],
        "summary": "Bills every night that has been occupied and not yet charged.",
        "tags": [
          "internal-jobs"
        ]
      }
    },
    "/internal/jobs/ledger-backfill": {
      "post": {
        "description": "A job rather than a button, because it can take minutes on a year of trading and nobody should be watching a spinner for that. Safe to run repeatedly: every posting is idempotent, so a run that fails half way is fixed by the next one, and a run against an already-complete ledger does nothing and says so.\n\n**Access:** the internal `X-API-Key`. Called by scheduler-service, never by a user-facing client.",
        "operationId": "postInternalJobsLedgerBackfill",
        "parameters": [
          {
            "in": "query",
            "name": "batch",
            "required": false,
            "schema": {
              "default": 500,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Missing or wrong `X-API-Key`."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [
          {
            "internalKey": []
          }
        ],
        "summary": "Posts every bill line and receipt the ledger does not have.",
        "tags": [
          "internal-jobs"
        ]
      }
    },
    "/internal/jobs/licence-expiry": {
      "post": {
        "description": "**Access:** the internal `X-API-Key`. Called by scheduler-service, never by a user-facing client.",
        "operationId": "postInternalJobsLicenceExpiry",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Missing or wrong `X-API-Key`."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [
          {
            "internalKey": []
          }
        ],
        "summary": "Warns about professional licences about to lapse.",
        "tags": [
          "internal-jobs"
        ]
      }
    },
    "/internal/jobs/payments-reconcile": {
      "post": {
        "description": "**Access:** the internal `X-API-Key`. Called by scheduler-service, never by a user-facing client.",
        "operationId": "postInternalJobsPaymentsReconcile",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Missing or wrong `X-API-Key`."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [
          {
            "internalKey": []
          }
        ],
        "summary": "Finishes payments nobody finished: approved and never captured because the payer closed the tab, and no notification arrived. Every payment it finds complete is applied to its invoice.",
        "tags": [
          "internal-jobs"
        ]
      }
    },
    "/internal/jobs/provisioning": {
      "post": {
        "description": "**Access:** the internal `X-API-Key`. Called by scheduler-service, never by a user-facing client.",
        "operationId": "postInternalJobsProvisioning",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Missing or wrong `X-API-Key`."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [
          {
            "internalKey": []
          }
        ],
        "summary": "Finishes hospitals left half made.",
        "tags": [
          "internal-jobs"
        ]
      }
    },
    "/internal/jobs/search-reindex": {
      "post": {
        "description": "**Access:** the internal `X-API-Key`. Called by scheduler-service, never by a user-facing client.",
        "operationId": "postInternalJobsSearchReindex",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Missing or wrong `X-API-Key`."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [
          {
            "internalKey": []
          }
        ],
        "summary": "Rebuilds the search index from the registers.",
        "tags": [
          "internal-jobs"
        ]
      }
    },
    "/internal/jobs/send-messages": {
      "post": {
        "description": "Every ten minutes, not nightly. A result-ready text that arrives tomorrow morning is a text that was not worth sending, and the whole point of the queue is that a message the gateway refused once is tried again soon.\n\n**Access:** the internal `X-API-Key`. Called by scheduler-service, never by a user-facing client.",
        "operationId": "postInternalJobsSendMessages",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Missing or wrong `X-API-Key`."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [
          {
            "internalKey": []
          }
        ],
        "summary": "Drains the outbound message queue.",
        "tags": [
          "internal-jobs"
        ]
      }
    },
    "/internal/jobs/stock-expiry": {
      "post": {
        "description": "**Access:** the internal `X-API-Key`. Called by scheduler-service, never by a user-facing client.",
        "operationId": "postInternalJobsStockExpiry",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Missing or wrong `X-API-Key`."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [
          {
            "internalKey": []
          }
        ],
        "summary": "Warns about stock about to go out of date.",
        "tags": [
          "internal-jobs"
        ]
      }
    },
    "/internal/jobs/subscriptions": {
      "post": {
        "description": "**Access:** the internal `X-API-Key`. Called by scheduler-service, never by a user-facing client.",
        "operationId": "postInternalJobsSubscriptions",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Missing or wrong `X-API-Key`."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [
          {
            "internalKey": []
          }
        ],
        "summary": "Moves every subscription along — a change bought for the next period begins, a trial ends, grace runs out — and sends the notices that are due. Each notice is recorded by subscription-service before it is returned, so a notice is sent once however often this runs.",
        "tags": [
          "internal-jobs"
        ]
      }
    },
    "/internal/jobs/sync-health": {
      "post": {
        "description": "There is a screen that shows all four. This exists because the failure being guarded against is precisely the one nobody is looking at.\n\n**Access:** the internal `X-API-Key`. Called by scheduler-service, never by a user-facing client.",
        "operationId": "postInternalJobsSyncHealth",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            },
            "description": "Success"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The request could not be read, or a required field is missing."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Missing or wrong `X-API-Key`."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Something failed on the server. The message says what could not be done."
          }
        },
        "security": [
          {
            "internalKey": []
          }
        ],
        "summary": "Raises the four things about a node that nobody would otherwise find out: a mirror that has stopped, a change that could not be applied, a reserve of numbers running down, and a backup that failed.",
        "tags": [
          "internal-jobs"
        ]
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "servers": [
    {
      "description": "api-gateway — the only public port when the stack runs locally",
      "url": "http://localhost:4000"
    },
    {
      "description": "backend direct HTTP — development and the container's liveness probe",
      "url": "http://localhost:8080"
    },
    {
      "description": "A deployed hospital. The console's nginx proxies /api to the gateway.",
      "url": "https://{host}",
      "variables": {
        "host": {
          "default": "hospital.example.org"
        }
      }
    }
  ],
  "tags": [
    {
      "description": "Service metadata · Taarifa za mfumo",
      "name": "meta"
    },
    {
      "description": "Sync\n\nIs the mirror working?. READ BY THE PEOPLE WHO HAVE TO ANSWER FOR IT. A synchroniser that has been failing for a week and says nothing is worse than one that is not running, because the second is obvious. The nudge is open to anybody signed in on purpose: \"open the app and today's work is there\" is one of the four things this design exists for, and a five-minute timer would make it \"open the app and wait five minutes\". It cannot be abused — a hundred workstations asking at once is one round, because the request only sets a flag.",
      "name": "sync"
    },
    {
      "description": "Scheduled jobs · Kazi za ratiba",
      "name": "internal-jobs"
    },
    {
      "description": "Open endpoints · Njia zilizo wazi",
      "name": "public"
    },
    {
      "description": "Installation settings · Mipangilio ya usakinishaji\n\nSetting a deployment up. Two permissions, because they are two jobs. What the hospital IS — its name, logo and country — is `organisation:update`, held by whoever runs the hospital. What it is WIRED TO — storage, mail server, SMS gateway — is `integration:manage`, held by whoever installs it. Those are rarely the same person, and the credentials behind the second are not the first's to read.",
      "name": "settings"
    },
    {
      "description": "Node",
      "name": "node"
    },
    {
      "description": "Devices",
      "name": "devices"
    },
    {
      "description": "Webhooks",
      "name": "webhooks"
    },
    {
      "description": "Account\n\nSigning a hospital up (the hosted service only). OPEN BECAUSE THE PERSON HAS NO ACCOUNT YET — that is what they are here to make. Each has its own ceiling, the one that sends email hardest: ten codes an hour from one address is a person trying again, and a hundred is somebody using the service to send mail. On an install every one of them answers 404.",
      "name": "account"
    },
    {
      "description": "Platform\n\nThe owner of the hosted service. The admin app's API. An operator belongs to no hospital, holds platform:operate and has an authenticator app; a hospital's administrator is refused whatever they hold (RequirePlatform). Money also needs platform:finance. No patient record is reachable from here.",
      "name": "platform"
    },
    {
      "description": "Licence",
      "name": "licence"
    },
    {
      "description": "Stack health · Afya ya mfumo",
      "name": "health"
    },
    {
      "description": "Service catalogue · Orodha ya huduma",
      "name": "services"
    },
    {
      "description": "Authentication · Kuingia kwenye mfumo\n\nAuthentication. Public: you cannot present a token before you have one.",
      "name": "auth"
    },
    {
      "description": "Search · Utafutaji",
      "name": "search"
    },
    {
      "description": "Photographs · Picha\n\nAttachments. One surface for every kind of record. Gated on being signed in here; the real gate is inside, and it is the permission of the RECORD the file hangs off — whoever may read the patient may read their referral letter. Naming a permission on the route instead would mean one code that opened every scan in the building. Photographs. The subject decides the permission, inside the handler: whoever may open a patient may see the patient's face. media-service would serve the image to anybody holding its asset id, so the id stays inside the backend and every read comes through here.",
      "name": "photos"
    },
    {
      "description": "Attachments · Viambatisho",
      "name": "attachments"
    },
    {
      "description": "Support and specialist registers · Msaada na madaftari maalum\n\nAsking IT for help, and talking to each other. Behind no permission beyond being signed in, deliberately. A permission to message a colleague is one every member of staff would have to hold, which is not a permission — and the person who most needs to report a frozen ward terminal is the one least likely to have been granted anything. Working the QUEUE is the gated half, and support-service makes that check itself against the caller's own token.",
      "name": "support"
    },
    {
      "description": "Staff messaging · Mawasiliano ya wafanyakazi",
      "name": "messaging"
    },
    {
      "description": "Notifications · Arifa",
      "name": "notifications"
    },
    {
      "description": "Patient register · Daftari la wagonjwa\n\nThe patient register. The root of the clinical domain. Reading is granted widely — a nurse, a cashier and a lab technician all need to know who the patient is — while opening and correcting a file stay with the people accountable for the register.",
      "name": "patients"
    },
    {
      "description": "Visits and the queue · Mahudhurio na foleni\n\nVisits, the queue. Moving somebody along the queue and writing up their consultation are separate permissions on purpose. A receptionist calls the next patient all day and never writes a clinical word; collapsing the two would mean granting one to grant the other.",
      "name": "visits"
    },
    {
      "description": "Organisation and branches · Taasisi na matawi\n\nThe organisation and its branches. Reading the branch list is separate from editing it, and editing the organisation itself is separate again: a ward clerk picking a branch from a dropdown is not somebody who may change the licence number.",
      "name": "organisation"
    },
    {
      "description": "Billing and payments · Ankara na malipo\n\nMoney. The finest-grained gates in the system, because the acts are genuinely different jobs. `bill:discount` and `payment:reverse` are the two that matter most: both are ways for money to legitimately leave, and both are ways for it to leave illegitimately. Neither belongs to whoever happens to be able to raise an invoice.",
      "name": "billing"
    },
    {
      "description": "Laboratory and imaging · Maabara na picha\n\nDiagnostics. Entering a result and RELEASING one are separate permissions, and the repository refuses a release by whoever entered every value even if somebody holds both. Two pairs of eyes is the control; a system that lets one person do both has it written on a wall, not implemented.",
      "name": "diagnostics"
    },
    {
      "description": "Stock and the store · Bidhaa na ghala\n\nStock: the pharmacy and the store. One stock system, two workflows. Moving stock is separate from editing the catalogue: a storekeeper moves stock all day and never touches the catalogue, and whoever decides what the catalogue contains is not thereby somebody who should be writing stock off.",
      "name": "inventory"
    },
    {
      "description": "Pharmacy counter · Dawa na utoaji\n\nThe pharmacy counter. Prescribing and dispensing are different people doing different things. A clinician writes; a pharmacist hands over and the stock leaves the shelf in the same transaction.",
      "name": "pharmacy"
    },
    {
      "description": "Wards and admissions · Wodi na kulazwa\n\nInpatient: wards, beds and admissions. Signing a discharge summary is its own permission. A ward clerk types the summary; a clinician signs it. One permission for both would make the signature meaningless.",
      "name": "inpatient"
    },
    {
      "description": "Clinical floor · Huduma za kliniki\n\nThe clinical floor. Triage and treatment are separate permissions because they are done by different people at different moments: a nurse categorises at the door, a clinician treats inside. Collapsing them would mean either a triage nurse who can write treatment, or a doctor who cannot re-categorise somebody who has deteriorated in the waiting room.",
      "name": "clinical"
    },
    {
      "description": "Operating theatre · Chumba cha upasuaji\n\nThe operating theatre. There is deliberately no permission for CLOSING an operation. It is gated on whether the checklist is complete and the counts balance, and the database refuses regardless of who is asking — a stronger control than a role, and one that cannot be worked around by somebody senior enough. Behind the module as well as the permission: a branch that has told the system it has no operating theatre should not be able to schedule a surgery into it from a saved address.",
      "name": "theatre"
    },
    {
      "description": "Reproductive and child health · Afya ya uzazi na mtoto\n\nReproductive and child health. Every service here is a schedule somebody can fall off, so every list takes ?overdue=true and the defaulter list is one query rather than a report somebody has to remember to run. `rch:record` is separate from `rch:manage`: the person who weighs a baby and gives the dose is not usually the person who books a pregnancy or edits the immunisation schedule — and every due date in the register is generated from that schedule, so an accidental edit moves everybody. One gate for the whole register, listing every menu entry it serves: the request does not say which screen the caller came from, so this closes only for a branch that has switched off ALL of maternal and child health. Switching off deliveries alone still leaves antenatal working, which is the point.",
      "name": "rch"
    },
    {
      "description": "Programme clinics · Kliniki za programu\n\nProgramme clinics. TB, HIV care and treatment, and non-communicable disease share one set of routes: they differ in vocabulary, not in shape, and three copies would be three defaulter queries to get subtly different. Closing is behind `program:manage` rather than `program:record` because the outcome IS the cohort report — \"cured\" and \"lost to follow-up\" are the numbers the programme is judged on nationally. TB and HIV care run at DESIGNATED sites, so both are off until a branch says it is one. NCD is not — diabetes and hypertension follow-up happens everywhere — which is why one entry keeps this group open.",
      "name": "programs"
    },
    {
      "description": "Patient feedback · Maoni ya wagonjwa\n\nPatient feedback. Reading what patients said and writing the form they say it on are different jobs: one is management, the other is whoever runs quality. There is no route that returns individual responses. On an anonymous form those are the one thing nobody in the hospital should read, and a route for them would be used the week somebody wanted to know who complained.",
      "name": "feedback"
    },
    {
      "description": "Human resources · Rasilimali watu\n\nHuman resources. PAYROLL HAS THREE CODES, not one. Seeing what people are paid, building a run and signing it off are three different jobs, and the person who assembles the numbers must not be the person who approves them — that is the whole control. `payroll:read` is the most sensitive read in the API: it is every salary in the hospital. Leave is split the same way for a smaller reason: everybody applies for leave, and almost nobody approves it.",
      "name": "hr"
    },
    {
      "description": "Procurement · Manunuzi\n\nAccounting. THERE IS NO EDIT AND NO DELETE FOR A POSTED ENTRY. A mistake is corrected by posting the mirror image and then the right entry, so both stay on the record — a ledger whose history can be edited cannot be audited, and \"we fixed it\" and \"it was always like that\" become the same thing. `ledger:reverse` is separate from `ledger:post` for the same reason an approval is separate from a request: the person who made the entry should not always be the person who unwinds it. And `account:manage` is separate again, because moving an account between types silently moves money between the income statement and the balance sheet. Procurement: order → deliver → invoice → pay. Five permissions across four steps, because the three-way match is only a control when different people hold its ends. One person who can order, receive, invoice and pay can pay a supplier for goods that never arrived, and no database constraint will notice.",
      "name": "procurement"
    },
    {
      "description": "Accounting · Uhasibu",
      "name": "accounting"
    },
    {
      "description": "Analytics · Takwimu\n\nFunding accounts — the money the branch actually holds Three permissions, because these are three jobs. A cashier reads the accounts and moves money between them all day; deciding what accounts EXIST, and which one a payment method routes into, is configuration and belongs with whoever owns the chart. Every route is scoped to the caller's own branch by the handler. Nothing here trusts a facility in the request body. The branch's money, read-only: the dashboard totals and the one transaction list that Transactions, Transfers, Deposits and Withdrawals all render with a different filter. Analytics — what the hospital did, and what its staff did in the console. Two sources behind one screen; see handlers/analytics.go for which figures are exact and which are not.",
      "name": "analytics"
    },
    {
      "description": "Funding accounts · Akaunti za fedha",
      "name": "accounts"
    },
    {
      "description": "Clients and sales · Wateja na mauzo\n\nThe commercial side. THERE IS NO TILL ENDPOINT HERE. A counter sale is a bill and a payment in /billing, plus a stock movement in /inventory. A second place where money is taken means two day-end figures that disagree, and the one that gets banked is whichever somebody printed. There is also no way to edit the contact log — what somebody was told on the phone in June is not editable in July, and a log that can be revised is worth nothing in a dispute. `salesreturn:decide` is separate from `salesreturn:manage`: a return puts money back and stock on a shelf, and the person handing over the refund should not be the person authorising it.",
      "name": "commercial"
    },
    {
      "description": "Operations and reporting · Uendeshaji na ripoti\n\nOperations. THERE IS NO POST FOR BACKUPS. Rows are written by whatever took the backup; a button that writes \"backup succeeded\" without a backup having happened is a false assurance, and it is discovered on the day of the restore. The only write is marking one as actually restored from. AND NOTHING HERE SENDS. Queueing writes a row saying a message is waiting; whatever holds the gateway credentials moves it on and calls back on /status with what happened. Writing \"sent\" from a handler that never contacted anybody is the exact lie the log exists to prevent.",
      "name": "ops"
    },
    {
      "description": "Patient portal · Mlango wa mgonjwa\n\nThe patient portal. EVERY ROUTE HERE RESOLVES THE PATIENT FROM THE TOKEN. Not one of them accepts a patient id as the SUBJECT of the request — where `patient_id` appears it names a dependant, and the repository checks a live, unexpired, unrevoked grant before returning anything. An endpoint that trusted the browser about whose record to serve would be a data breach with a query parameter. `portal:use` is the ONLY permission a patient account holds, and it grants nothing anywhere else in this API. A patient must not be able to reach a staff endpoint by holding the wrong role, and a member of staff reading their own record uses these same routes.",
      "name": "portal"
    },
    {
      "description": "Dashboard",
      "name": "dashboard"
    },
    {
      "description": "Administration · Utawala",
      "name": "admin"
    },
    {
      "description": "Accounts, roles and permissions · Watumiaji na majukumu\n\nAccounts, roles and permissions. The strictest gates in the API, and the ones that make every other permission grantable. `user:assign_role` is separate from `user:update` on purpose: somebody who can suspend a leaver's account is not thereby somebody who can make themselves an administrator.",
      "name": "access"
    }
  ]
}
