Vetspire.Schedule.Appointment (vetspire v3.0.0)

View Source

An appointment is an event on the schedule. Appointments can either be appointments with a patient or a block on the schedule. Blocks do not contain patient information.

Example:

  • Fluffy (a patient) has an appointment at 5pm on August 12th, 2020 with Dr. Test Dummy. This would appear on the schedule for the clinic to view.
  • The clinic has a block with a note, "Lunch" that repeats everyday at 12pm. This wold appear on the schedule but would not contain any patient information.

Summary

Types

location_display()

@type location_display() :: %{
  name: String.t() | nil,
  display_name: String.t() | nil,
  address: String.t(),
  field_service?: boolean()
}

t()

@type t() :: %Vetspire.Schedule.Appointment{
  __meta__: term(),
  additional_providers: term(),
  admitted_at: term(),
  appointment_patient_locations: term(),
  appointment_recurrence_id: term(),
  appointment_type: term(),
  appointment_type_id: term(),
  arrival_time_at: term(),
  booked_online: term(),
  booking_source: term(),
  cage: term(),
  cage_id: term(),
  checked_in_at: term(),
  checked_out_at: term(),
  checking_out_at: term(),
  comments: term(),
  completed_at: term(),
  confirmed_at: term(),
  creator: term(),
  creator_id: term(),
  custom_fields: term(),
  deleted: term(),
  deleted_by: term(),
  deleted_by_id: term(),
  deletion_reason: term(),
  department: term(),
  department_id: term(),
  drop_off_end: term(),
  drop_off_start: term(),
  duration: term(),
  encounters: term(),
  field_service_address: term(),
  field_service_address_id: term(),
  field_service_client_address: term(),
  field_service_client_address_id: term(),
  group: term(),
  group_id: term(),
  historical_id: term(),
  id: term(),
  inserted_at: term(),
  intake: term(),
  is_confirmed: term(),
  is_exception: term(),
  location: term(),
  location_id: term(),
  note: term(),
  org: term(),
  org_id: term(),
  original_start: term(),
  outlook_id: term(),
  patient: term(),
  patient_id: term(),
  patient_locations: term(),
  pickup_time: term(),
  position: term(),
  previous_encounter: term(),
  previous_encounter_id: term(),
  provider: term(),
  provider_id: term(),
  ready_at: term(),
  reason: term(),
  reason_category: term(),
  reason_category_id: term(),
  recurrence: term(),
  repeat_interval_seconds: term(),
  repeating_event: term(),
  reviewed: term(),
  room: term(),
  schedule: term(),
  schedule_id: term(),
  self_check_in_sent: term(),
  self_checked_in: term(),
  sent_pickup: term(),
  start: term(),
  started_at: term(),
  status: term(),
  tele_session_created: term(),
  updated_at: term(),
  visit_type: term(),
  vitals: term(),
  vitals_id: term(),
  waited_at: term(),
  zone_color_hex: term(),
  zone_id: term(),
  zone_name: term()
}

Functions

active_statuses()

changeset(appt, attrs, opts \\ [])

Builds a changeset for an appointment.

Options

  • :skip_field_service_address_validation - skips the Repo.exists?/1 ownership checks on field_service_address_id and field_service_client_address_id. Only safe to pass when the caller has already validated that exact (address_id, patient_id) pair itself - e.g. batch callers that resolve the same address once for a whole series and would otherwise repeat an identical query per occurrence. Defaults to false. The visit-type-driven clearing step and the alternatives-resolution step still run regardless, since which value they land on can legitimately differ per appointment.
  • :skip_travel_zone_snapshot - skips deriving zone_name/zone_color_hex from the TravelZone referenced by zone_id, trusting whatever values were cast in from attrs instead. Only safe to pass when the caller has already resolved that same zone_id for the series and included its zone_name/zone_color_hex in attrs - e.g. batch callers that would otherwise repeat an identical lookup once per occurrence. Defaults to false.

checkin_changeset(appt, attrs)

filter_appointment_type_ids(query, appointment_type_ids)

inactive_statuses()

join_appointment_type(query)

join_location(query)

location_display(appointment)

@spec location_display(t()) :: location_display()

preload_appointment_type(query, bool)

upcoming?(appt, opts \\ [])

Returns true if appointment:

  1. has not been deleted
  2. has a start date
  3. start datetime is after the given minimum time (defaults to utc_now)

NOTE: appointment.start should always be a datetime, but there are instances of bad data in our DB where it is nil.

where_appointment_type_reminders_enabled(query)

where_is_exam(query)

where_location_id(query, location_id)

where_location_reminders_enabled(query)

where_not_confirmed(query)

Excludes appointments the client has already confirmed.

Confirmation is recorded two different ways: the schedule's confirm button only sets is_confirmed, while the SMS autoconfirm reply also moves status to :confirmed, so both have to be checked.

where_not_deleted(query)

where_org_id(query, org_id)

where_patient_id(query, patient_id)

where_start_within_range(query, start_range, end_range)

where_status_not_in(query, statuses)

where_within_date_range(query, start_range, end_range)