PatientVisit:
  type: object
  properties:
    InternalPVID:
      type: integer
      description: Primary key (auto-generated)
    PVID:
      type: string
      description: Visit ID (auto-generated with DV prefix if not provided)
    InternalPID:
      type: integer
      description: Reference to patient
    EpisodeID:
      type: string
      description: Episode identifier
    SiteID:
      type: integer
      description: Site reference
    LastLocation:
      type: string
      description: Full name of the last/current location from patvisitadt
    CreateDate:
      type: string
      format: date-time
    EndDate:
      type: string
      format: date-time
    ArchivedDate:
      type: string
      format: date-time
    DelDate:
      type: string
      format: date-time
    PatDiag:
      type: object
      description: Diagnosis information (optional)
      properties:
        DiagCode:
          type: string
        Diagnosis:
          type: string
    PatVisitADT:
      type: object
      description: ADT (Admission/Discharge/Transfer) information (optional)
      properties:
        ADTCode:
          type: string
          enum: [A01, A02, A03, A04, A08]
        LocationID:
          type: integer
        AttDoc:
          type: integer
          description: Attending physician ContactID
        RefDoc:
          type: integer
          description: Referring physician ContactID
        AdmDoc:
          type: integer
          description: Admitting physician ContactID
        CnsDoc:
          type: integer
          description: Consulting physician ContactID

PatVisitADT:
  type: object
  properties:
    PVADTID:
      type: integer
      description: Primary key (auto-generated)
    InternalPVID:
      type: integer
      description: Reference to patient visit
    ADTCode:
      type: string
      enum: [A01, A02, A03, A04, A08]
      description: |
        A01: Admit
        A02: Transfer
        A03: Discharge
        A04: Register
        A08: Update
    LocationID:
      type: integer
      description: Location/ward reference
    AttDoc:
      type: integer
      description: Attending physician ContactID
    RefDoc:
      type: integer
      description: Referring physician ContactID
    AdmDoc:
      type: integer
      description: Admitting physician ContactID
    CnsDoc:
      type: integer
      description: Consulting physician ContactID
    CreateDate:
      type: string
      format: date-time
    EndDate:
      type: string
      format: date-time
    ArchivedDate:
      type: string
      format: date-time
    DelDate:
      type: string
      format: date-time
