- |
- Discussion |
- Edit |
- History
Patient Status
We need the ability to track patients through a workflow or state diagram. This could be used for studies, therapeutic plans, and any other process that needs to track patients through states.
The model and API should support:
- Patient-centric states
- A way to define simple state diagrams (workflows)
- Name
- List of valid states
- For each state, list of valid "next" states (valid transitions)
- Method to get current state for a patient:
myWorkflow.getPatientStatus(myPatient)
- Method to get all patients within a given state:
myWorkflow.getAllPatients(status) myWorkflow.getAllPatients(status, fromDate, toDate)
Tables (a work in progress):
create table program ( program_id int not null, name varchar(255), description mediumtext, creator int not null, /* FK to users */ date_created datetime not null, voided boolean, voided_by int, /* FK to users */ void_reason varchar(255), date_voided datetime );
create program_workflow ( patient_workflow_id int not null primary key, program_id not null, /* FK to program */ name varchar(255), description mediumtext, creator int not null, /* FK to users */ date_created datetime not null, voided boolean, voided_by int, /* FK to users */ void_reason varchar(255), date_voided datetime );
create table program_workflow_state ( program_workflow_id int not null, /* FK to program_workflow */ status_id not null, /* FK to concept */ name varchar(255) creator int not null, /* FK to users */ date_created datetime not null, voided boolean, voided_by int, /* FK to users */ void_reason varchar(255), date_voided datetime );
create table program_workflow_transition ( from_state int not null, /* FK to program_workflow_state */ to_state int not null, /* FK to program_workflow_state */ creator int not null, /* FK to users */ date_created datetime not null, voided boolean, voided_by int, /* FK to users */ void_reason varchar(255), date_voided datetime );
create table patient_program ( patient_program_id int not null, /* primary key (autonumber) */ program_id int not null, /* FK to program */ patient_id int not null /* FK to patient */ date_started datetime not null, date_completed datetime creator int not null, /* FK to users */ date_created datetime not null, voided boolean, voided_by int, /* FK to users */ void_reason varchar(255), date_voided datetime )
create table patient_status ( patient_status_id int not null primary key, patient_program_id int not null, /* FK to patient_program */ program_workflow_id int not null, /* FK to program_workflow */ status_id not null, /* FK to concept */ creator int not null, /* FK to users */ date_created datetime not null, voided boolean, voided_by int, /* FK to users */ void_reason varchar(255), date_voided datetime )
We could live without fully described workflows in the model for now (let that knowledge live in the code for the moment), but it would be nice to have a concept or something to define different types of state "groupings" rather than one big glom of states attached to patients. Also, the method calls are critical
See ticket
There's a good article about state machines on Wikipedia
[edit]
Service
PatientStatusService:
/* Get patient's state at any given time */ public ProgramWorkflowStatus getPatientStatus(Patient p, Program program, Date onDate);
/* Return all patients within a specific state during a date range */ public Patient[] getPatients(Program program, ProgramWorkflowStatus status, Date fromDate, Date toDate);
