Skip to content
This repository was archived by the owner on Jun 26, 2025. It is now read-only.

Expose BookedDate and StartDate #885

@iaindillingham

Description

@iaindillingham

We need to make Appointment.BookedDate and Appointment.StartDate available through patients.with_gp_consultations for an upcoming study that @LisaHopcroft is coordinating.

At present, only Appointment.SeenDate is made available through this function, so we need to add a new argument that allows a user to select the column they wish to query. Precedents:

  • Several functions, such as patients.address_as_of, accept a returning argument that allows a user to select a column.
  • patients.with_these_decision_support_values accepts an algorithm argument, which allows the user to select an algorithm (spoiler: only the Electronic Frailty Index is available).

Lisa and I have undertaken some curation work on these columns; a notebook has been released to the appointments-short-data-report workspace. However, I see that we restrict the values in the status column to these

valid_states = [
AppointmentStatus.ARRIVED,
AppointmentStatus.WAITING,
AppointmentStatus.IN_PROGRESS,
AppointmentStatus.FINISHED,
AppointmentStatus.PATIENT_WALKED_OUT,
AppointmentStatus.VISIT,
]
valid_states_str = codelist_to_sql(map(int, valid_states))

from these

class AppointmentStatus(enum.IntEnum):
BOOKED = 0
ARRIVED = 1
DID_NOT_ATTEND = 2
IN_PROGRESS = 3
FINISHED = 4
REQUESTED = 5
BLOCKED = 6
VISIT = 8
WAITING = 9
CANCELLED_BY_PATIENT = 10
CANCELLED_BY_UNIT = 11
CANCELLED_BY_OTHER_SERVICE = 12
NO_ACCESS_VISIT = 14
CANCELLED_DUE_TO_DEATH = 15
PATIENT_WALKED_OUT = 16

in cohort-extractor. Our curation work hasn't explored the status column, so I'd tentatively advocate allowing a user to disable this restriction.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions