Skip to content

Commit

Permalink
chore: Merge in changes from Brodie's post-meeting modification branch
Browse files Browse the repository at this point in the history
  • Loading branch information
ezrajames committed Jul 19, 2022
2 parents c387d58 + d7e7e9d commit 467d2e8
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 91 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""Update user and form entry properties
Revision ID: 6f36efa69a00
Revision ID: b28b9c211ee0
Revises: d14ecfcd7ffa
Create Date: 2022-07-19 15:29:55.961731
Create Date: 2022-07-19 15:59:33.955393
"""

# revision identifiers, used by Alembic.
revision = '6f36efa69a00'
revision = 'b28b9c211ee0'
down_revision = 'd14ecfcd7ffa'

from alembic import op
Expand All @@ -33,6 +33,8 @@ def schema_upgrades():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('patient_encounters', sa.Column('deleted', sa.Boolean(), nullable=True))
op.add_column('patient_encounters', sa.Column('patient_encounter_uuid', postgresql.UUID(as_uuid=True), nullable=True))
op.add_column('patient_encounters', sa.Column('age', sa.Integer(), nullable=True))
op.add_column('patient_encounters', sa.Column('gender', sa.String(), nullable=True))
op.drop_constraint('patient_encounters_patient_incident_uuid_key', 'patient_encounters', type_='unique')
op.drop_constraint('patient_encounters_user_uuid_key', 'patient_encounters', type_='unique')
op.create_unique_constraint(None, 'patient_encounters', ['patient_encounter_uuid'])
Expand All @@ -49,6 +51,8 @@ def schema_downgrades():
op.drop_constraint(None, 'patient_encounters', type_='unique')
op.create_unique_constraint('patient_encounters_user_uuid_key', 'patient_encounters', ['user_uuid'])
op.create_unique_constraint('patient_encounters_patient_incident_uuid_key', 'patient_encounters', ['patient_incident_uuid'])
op.drop_column('patient_encounters', 'gender')
op.drop_column('patient_encounters', 'age')
op.drop_column('patient_encounters', 'patient_encounter_uuid')
op.drop_column('patient_encounters', 'deleted')
# ### end Alembic commands ###
Expand Down
2 changes: 2 additions & 0 deletions app/api/models/patient_encounter.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class PatientEncounter(Base, BasicMetrics):
date = Column(DateTime)
handover_too = Column(String)
comment = Column(String, nullable=True)
age = Column(Integer, nullable=True)
gender = Column(String, nullable=True)


def get_patient_encounter_by_id(db: Session, id: int) -> Optional[PatientEncounter]:
Expand Down
4 changes: 3 additions & 1 deletion app/api/schemas/patient_encounter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class PatientEncounterSchema(BaseModel):
"""
An encounter with a given patient.
"""
age: Optional[int]
arrival_method: str
arrival_time: datetime
chief_complaints: str
Expand All @@ -16,14 +17,15 @@ class PatientEncounterSchema(BaseModel):
departure_time: datetime
departure_dest: str
document_num: str
gender: Optional[str]
handover_from: Optional[str]
handover_too: str
location: str
on_shift: bool
patient_rfid: Optional[str]
qr_code: Optional[str]
triage_acuity: str

class Config:
orm_mode = True

Expand Down
196 changes: 109 additions & 87 deletions app/web/pages/forms/form.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import Link from 'next/link';
import { FormGroup, Container, Grid, Autocomplete, Checkbox, TextField,
import { FormGroup, Container, Grid, ListItemText, Checkbox, TextField, OutlinedInput, MenuProps,
RadioGroup, Radio, FormControlLabel, InputLabel, Select, MenuItem, Button } from '@mui/material';
import { TimePicker } from '@mui/x-date-pickers/TimePicker';
import { MobileDatePicker } from '@mui/x-date-pickers/MobileDatePicker';
Expand All @@ -20,6 +20,8 @@ import { submitPatientEncounterForm } from "../../utils/api";
date: new Date,
arrival_time: new Date,
triage_acuity: '',
age: new Number,
gender: '',
on_shift: '',
chief_complaints: [],
arrival_method: '',
Expand All @@ -29,8 +31,29 @@ import { submitPatientEncounterForm } from "../../utils/api";
comment: '',
}

const chiefComplaints = [
'Nausea/Vomiting',
'Dizziness/Presyncope/Lightheaded',
'Loss of Consciousness',
'Seizure',
'Adverse Drug Effect',
'Agitation' ,
'Bizarre Behaviour' ,
'Hallucinations' ,
'Anxiety' ,
'Abdominal Pain',
'Chest Pain' ,
'Headache' ,
'Other Pain' ,
'Shortness of Breath' ,
'Allergic Reaction' ,
'Trauma' ,
];

function MFPEForm() {
const [formValues, setFormValues] = React.useState(MFPEFormData);
const [complaints, setComplaints] = React.useState([]);


const handleChange = (event) => {
const { name, value } = event.target;
Expand All @@ -40,7 +63,13 @@ function MFPEForm() {
});
};

const handleChiefComplaintsFieldChange = (event, value) => {
const handleChiefComplaintsFieldChange = (event) => {
const {
target: { value },
} = event;
setComplaints(
typeof value === 'string' ? value.split(',') : value,
);
setFormValues({
...formValues,
["chief_complaints"]: value,
Expand Down Expand Up @@ -110,66 +139,75 @@ function MFPEForm() {
value={formValues.document_num}
onChange={handleChange} />
</Grid>
<Grid item xs={6}>
<Grid item xs={12}>
<InputLabel id="location-select-label">Location</InputLabel>
<Select
labelId="location-select-label"
name="location"
defaultValue="Main Medical"
label="Location"
disabled
required
value={formValues.location}
onChange={handleChange}>
<MenuItem value="Main Medical">Main Medical</MenuItem>
<MenuItem value="Main Medical" required={true}>Main Medical</MenuItem>
</Select>
</Grid>
<Grid item xs={6}>
<InputLabel>Handover From: </InputLabel>
<TextField
name="handover_from"
label="Who brought the patient"
variant="outlined"
value={formValues.handover_from}
onChange={handleChange}
/>
</Grid>
<Grid item xs={6}>
<LocalizationProvider dateAdapter={AdapterDateFns}>
<InputLabel>Date: </InputLabel>
<MobileDatePicker
inputFormat="MM/dd/yyyy"
required
name="date"
value={formValues.date}
onChange={handleArrivalTimeChange}
renderInput={(params) => <TextField {...params} />}
renderInput={(params) => <TextField {...params} required={true}/>}
/>
</LocalizationProvider>
</Grid>
<Grid item xs={6}>
<LocalizationProvider dateAdapter={AdapterDateFns}>
<InputLabel>Arrival Time: </InputLabel>
<TimePicker
required
ampm={false}
name="arrival_time"
value={formValues.arrival_time}
onChange={handleArrivalTimeChange}
renderInput={(params) => <TextField {...params} />}
renderInput={(params) => <TextField {...params} required={true}/>}
/>
</LocalizationProvider>
</Grid>
<Grid item xs={7}>
<InputLabel>Gender: </InputLabel>
<RadioGroup
aria-labelledby="gender"
name="gender"
row
value={formValues.gender}
onChange={handleChange}>
<FormControlLabel value="male" control={<Radio />} label="Male" />
<FormControlLabel value="female" control={<Radio />} label="Female" />
<FormControlLabel value="other" control={<Radio />} label="Other" />
</RadioGroup>
</Grid>
<Grid item xs={5}>
<TextField
type="number"
name="age"
label="age"
variant="outlined"
value={formValues.age}
onChange={handleChange}
/>
</Grid>
<Grid item xs={12}>
<InputLabel>Triage Acuity: </InputLabel>
<RadioGroup
aria-labelledby="triage-acuity"
name="triage_acuity"
row
required
value={formValues.triage_acuity}
onChange={handleChange}>
<FormControlLabel value="white" control={<Radio />} label="White" />
<FormControlLabel value="white" control={<Radio required={true}/>} label="White" />
<FormControlLabel value="green" control={<Radio />} label="Green" />
<FormControlLabel value="yellow" control={<Radio />} label="Yellow" />
<FormControlLabel value="red" control={<Radio />} label="Red" />
Expand All @@ -181,86 +219,68 @@ function MFPEForm() {
aria-labelledby="patient-Occupation"
name="on_shift"
row
required
value={formValues.on_shift}
onChange={handleChange}>
<FormControlLabel value="staff-yes" control={<Radio />} label="Yes" />
<FormControlLabel value="staff-yes" control={<Radio required={true}/>} label="Yes" />
<FormControlLabel value="staff-no" control={<Radio />} label="No" />
</RadioGroup>
</Grid>
<Grid item xs={12}>
<InputLabel>Chief Complaint: </InputLabel>
<Autocomplete
multiple
required
options={chiefComplaints}
disableCloseOnSelect
getOptionLabel={(option) => option.label}
renderOption={(props, option, { selected }) => (
<li {...props}>
<Checkbox
checked={selected}
/>
{option.label}
</li>
)}
renderInput={(params) => <TextField {...params}
name="chief_complaints"
label="Select Complaint(s)"
value={formValues.chief_complaints}/>}
<Select
required={true}
fullWidth={true}
multiple={true}
name="chief_complaints"
label="Select Complaint(s)"
value={complaints}
onChange={handleChiefComplaintsFieldChange}

/>
input={<OutlinedInput label="Tag" />}
renderValue={(selected) => selected.join(', ')}
MenuProps={MenuProps}
>
{chiefComplaints.map((complaint) => (
<MenuItem key={complaint} value={complaint}>
<Checkbox checked={complaints.indexOf(complaint) > -1} />
<ListItemText primary={complaint} />
</MenuItem>
))}
</Select>
</Grid>
<Grid item xs={12}>
<InputLabel>Arrival Method: </InputLabel>
<RadioGroup
aria-labelledby="arrival-method"
name="arrival_method"
row
required
value={formValues.arrival_method}
onChange={handleChange}>
<FormControlLabel value="self-presented" control={<Radio />} label="Self Presented" />
<FormControlLabel value="self-presented" control={<Radio required={true}/>} label="Self Presented" />
<FormControlLabel value="med-transport" control={<Radio />} label="Medical Transport" />
<FormControlLabel value="security" control={<Radio />} label="Brought by Security" />
<FormControlLabel value="harm-reduction" control={<Radio />} label="Brought by Harm Reduction" />
<FormControlLabel value="other" control={<Radio />} label="Other (Please explain in the comment section)"/>
</RadioGroup>
</Grid>
<Grid item xs={6}>
<InputLabel>Handover To: </InputLabel>
<InputLabel>Handover From: </InputLabel>
<TextField
name="handover_too"
label="Patient is going with..."
variant="outlined"
value={formValues.handover_too}
onChange={handleChange} />
</Grid>
<br/>
<Grid item xs={6}>
<LocalizationProvider dateAdapter={AdapterDateFns}>
<InputLabel>Departure Time: </InputLabel>
<TimePicker
required
ampm={false}
name="departure_time"
value={formValues.departure_time}
onChange={handleDepartureTimeChange}
renderInput={(params) => <TextField {...params} />}
/>
</LocalizationProvider>
name="handover_from"
label="Who brought the patient"
variant="outlined"
value={formValues.handover_from}
onChange={handleChange}
/>
</Grid>
<Grid item xs={12}>
<InputLabel>Departure Destination: </InputLabel>
<RadioGroup
required
aria-labelledby="departure-destination"
name="departure_dest"
row
value={formValues.departure_dest}
onChange={handleChange}>
<FormControlLabel value="lwbs" control={<Radio />} label="LWBS" />
<FormControlLabel value="lwbs" control={<Radio required={true}/>} label="LWBS" />
<FormControlLabel value="left-ama" control={<Radio />} label="Left AMA" />
<FormControlLabel value="return-to-event" control={<Radio />} label="Sanctuary" />
<FormControlLabel value="security" control={<Radio />} label="Security" />
Expand All @@ -269,11 +289,32 @@ function MFPEForm() {
<FormControlLabel value="other" control={<Radio />} label="Other (Please explain in the comment section)" />
</RadioGroup>
</Grid>
<Grid item xs={6}>
<LocalizationProvider dateAdapter={AdapterDateFns}>
<InputLabel>Departure Time: </InputLabel>
<TimePicker
ampm={false}
name="departure_time"
value={formValues.departure_time}
onChange={handleDepartureTimeChange}
renderInput={(params) => <TextField {...params} />}
/>
</LocalizationProvider>
</Grid>
<Grid item xs={6}>
<InputLabel>Handover To: </InputLabel>
<TextField
name="handover_too"
label="Patient is going with..."
variant="outlined"
value={formValues.handover_too}
onChange={handleChange} />
</Grid>
<Grid item xs={12}>
<InputLabel>Comments: </InputLabel>
<TextField
name="comment"
label="enter comments here..."
label="Enter comments here..."
variant="outlined"
fullWidth={true}
value={formValues.comment}
Expand All @@ -291,23 +332,4 @@ function MFPEForm() {
);
}

const chiefComplaints = [
{ label: 'Nausea/Vomiting', id: 1 },
{ label: 'Dizziness/Presyncope/Lightheaded', id: 2 },
{ label: 'Loss of Consciousness', id: 3 },
{ label: 'Seizure', id: 4 },
{ label: 'Adverse Drug Effect', id: 5 },
{ label: 'Agitation' , id: 6 },
{ label: 'Bizarre Behaviour' , id: 7 },
{ label: 'Hallucinations' , id: 8 },
{ label: 'Anxiety' , id: 9 },
{ label: 'Abdominal Pain' , id: 10 },
{ label: 'Chest Pain' , id: 11 },
{ label: 'Headache' , id: 12 },
{ label: 'Other Pain' , id: 13 },
{ label: 'Shortness of Breath' , id: 14 },
{ label: 'Allergic Reaction' , id: 15 },
{ label: 'Trauma' , id: 16 },
];

export default ProtectedRoute(MFPEForm);
Loading

0 comments on commit 467d2e8

Please sign in to comment.