Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose BookedDate and StartDate #885

Open
iaindillingham opened this issue Nov 15, 2022 · 0 comments
Open

Expose BookedDate and StartDate #885

iaindillingham opened this issue Nov 15, 2022 · 0 comments

Comments

@iaindillingham
Copy link
Member

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.

inglesp added a commit that referenced this issue Nov 16, 2022
There are several date columns on the Appointments table in TPP.  Until
now, we have only exposed the SeenDate column.  That is, only this
column was used for filtering, and the value in this column was returned
when the `returning` parameter was "date".

We have now added support for filtering on and returning the BookedDate
and StartDate.

Note that we do not support filtering on one column and returning the
value of another, so eg you cannot find the SeenDate of all appointments
with a BookedDate in a given range.  This would be possible to do.

Addresses part of #885.
inglesp added a commit that referenced this issue Nov 16, 2022
TPP's Appointments table has a Status column.  Until now, we have
filtered out all records whose status does not match one of the
following:

        * AppointmentStatus.ARRIVED
        * AppointmentStatus.WAITING
        * AppointmentStatus.IN_PROGRESS
        * AppointmentStatus.FINISHED
        * AppointmentStatus.PATIENT_WALKED_OUT
        * AppointmentStatus.VISIT

This commit adds a parameter to patients.with_gp_consultations to allow
the default to be overridden.

Addresses part of #885.
@inglesp inglesp self-assigned this Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants