Skip to content

Commit a7f3152

Browse files
diogenis-sidpapaspyrospanvourtsiselektracodes
authored
Release 2023/05/17 (#238)
* add new choices * feat(patient-middle-name): Add optional middle name in patient registration * feat(patient-full-dob): Allow adding full birthday in patient registration * fix(episode-choices-value-fix): Fix overlapping values in episode choices * fix: adding Prophylactic antibiotics and fix checkboxes for forms (#236) * fix: adding Prophylactic antibiotics and fix checkboxes for forms * feat: adding new logic for form field on discharge and follow up forms * fix: change label of infection to Post-operative complications (#237) * feat(): added none value checkbox and made it required field * fix(): always show the comment box in follow up form --------- Co-authored-by: Dimitris Papaspyros <[email protected]> Co-authored-by: Panagiotis Vourtsis <[email protected]> Co-authored-by: Elektra Bilali Simou <[email protected]>
1 parent 1fdf550 commit a7f3152

File tree

15 files changed

+379
-93
lines changed

15 files changed

+379
-93
lines changed

src/common.style.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const PageWrapper = styled.div<{ isDesktop: boolean }>`
1515
isDesktop &&
1616
`
1717
justify-content: flex-start;
18-
18+
1919
`}
2020
`;
2121

@@ -26,6 +26,12 @@ export const CheckBoxContainer = styled.div<{ error?: boolean; checked?: boolean
2626
fill: white;
2727
}
2828
`;
29+
export const CheckBoxWrapper = styled.div<{ error?: boolean; checked?: boolean }>`
30+
display: flex;
31+
flex-direction: row;
32+
margin-top: 10px;
33+
position: relative;
34+
`;
2935

3036
export const FieldsContainer = styled.div<{ withMargin?: boolean }>`
3137
${grid};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import styled from '@emotion/styled';
2+
3+
export const Wrapper = styled.div`
4+
display: flex;
5+
margin-right: 10px;
6+
7+
input {
8+
height: 20px;
9+
margin-right: 10px;
10+
width: 20px;
11+
}
12+
`;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
3+
import { FieldRenderProps } from 'react-final-form';
4+
5+
import { Wrapper } from './Checkbox.style';
6+
7+
const Checkbox = ({ input, label, disabled }: FieldRenderProps<string | number, HTMLElement>) => {
8+
return (
9+
<Wrapper>
10+
<input
11+
type={'checkbox'}
12+
onChange={input.onChange}
13+
checked={input.checked}
14+
disabled={disabled}
15+
/>
16+
<label>{label}</label>
17+
</Wrapper>
18+
);
19+
};
20+
21+
export default Checkbox;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './Checkbox';

src/hooks/api/patientHooks.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,12 @@ export const useRegisterPatient = () => {
144144
(params) => {
145145
const { request } = patientsAPI.single.registerPatient({
146146
hospital_id: params.hospital.value,
147-
full_name: `${params.firstName} ${params.lastName}`,
147+
full_name: `${params.firstName}${params.middleName ? ' ' + params.middleName : ''} ${
148+
params.lastName
149+
}`,
148150
year_of_birth: params.yearOfBirth,
151+
month_of_birth: params.monthOfBirth,
152+
day_of_birth: params.dayOfBirth,
149153
age: params.age,
150154
national_id: params.nationalId,
151155
patient_hospital_id: params.patientHospitalId,
@@ -261,8 +265,10 @@ export const useDischarge = (episodeID: string) => {
261265
const payload = {
262266
episode_id: parseInt(episodeID),
263267
date: params?.date,
268+
discharge_duration: params?.discharge_duration,
264269
aware_of_mesh: params?.aware_of_mesh.label === 'Yes',
265-
infection: params?.infection.label === 'Yes',
270+
comments: params?.comments,
271+
infection: params?.infection || '',
266272
};
267273

268274
const { request } = patientsAPI.single.dischargePatient(payload);
@@ -292,6 +298,8 @@ export const useFollowUp = (episodeID: string) => {
292298
infection: params?.infection.label === 'Yes',
293299
numbness: params?.numbness.label === 'Yes',
294300
pain_severity: params?.pain_severity.label,
301+
further_surgery_need: params?.further_surgery_need.label === 'Yes',
302+
surgery_comments_box: params?.surgery_comments_box,
295303
};
296304

297305
const { request } = patientsAPI.single.followUpPatient(payload);

src/models/apiTypes.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ export type FollowUpAPI = {
7575
seroma: boolean;
7676
infection: boolean;
7777
numbness: boolean;
78+
further_surgery_need: boolean;
79+
surgery_comments_box?: string;
7880
};
7981

8082
export type FollowUpPayload = {
@@ -98,28 +100,34 @@ export type FollowUpForm = {
98100
seroma: SelectOption;
99101
infection: SelectOption;
100102
numbness: SelectOption;
103+
further_surgery_need: SelectOption;
104+
surgery_comments_box?: string;
101105
};
102106

103107
export type DischargeAPI = {
104108
id: number;
105109
episode: EpisodesAPI;
106110
date: string;
107111
aware_of_mesh: boolean;
108-
infection: boolean;
112+
infection: string;
113+
discharge_duration?: string;
114+
comments?: string;
109115
};
110116

111117
export type DischargePayload = {
112118
episode_id: number;
113119
date: string;
114120
aware_of_mesh: boolean;
115-
infection: boolean;
121+
infection: string;
116122
};
117123

118124
export type DischargeForm = {
119125
episode_id: number;
120126
date: string;
127+
discharge_duration?: string;
121128
aware_of_mesh: SelectOption;
122-
infection: SelectOption;
129+
infection?: string;
130+
comments?: string;
123131
};
124132

125133
export type RegisterEpisodePayload = {
@@ -152,6 +160,8 @@ export interface RegisterPatientPayload {
152160
patient_hospital_id: number;
153161
age: number;
154162
year_of_birth: number;
163+
month_of_birth: number;
164+
day_of_birth: number;
155165
hospital_id: number;
156166
gender: string;
157167
phone_1: number;

src/pages/EpisodeDetails/components/ExpandableContainer/components/Discharge.tsx

Lines changed: 109 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
/** @jsxImportSource @emotion/react */
22
import React, { FC } from 'react';
33

4-
import { Button, Select, TextField } from '@orfium/ictinus';
4+
import { Button, Select, TextArea, TextField } from '@orfium/ictinus';
55
import { omit } from 'lodash';
66
import { Field, Form } from 'react-final-form';
77
import { useRouteMatch } from 'react-router-dom';
88

9+
import { CheckBoxWrapper } from '../../../../../common.style';
10+
import Checkbox from '../../../../../components/FormElements/Checkbox';
911
import { useDischarge } from '../../../../../hooks/api/patientHooks';
10-
import { DischargeAPI, DischargeForm } from '../../../../../models/apiTypes';
12+
import { DischargeAPI, SelectOption } from '../../../../../models/apiTypes';
1113
import {
1214
FormHeadingContainer,
1315
SelectWrapper,
@@ -16,6 +18,15 @@ import { BOOLEAN_OPTIONS } from '../../../../RegisterEpisode/constants';
1618
import { InternalContainer } from '../style';
1719
import { FieldWrapper } from './style';
1820

21+
const POST_OPERATIVE_COMPLICATIONS = [
22+
{ label: 'Bleeding' },
23+
{ label: 'Haematoma' },
24+
{ label: 'Urinary Retention' },
25+
{ label: 'Return to theatre' },
26+
{ label: 'Death' },
27+
{ label: 'None' },
28+
];
29+
1930
const Discharge: FC<{
2031
isOpen: boolean;
2132
discharge: DischargeAPI;
@@ -24,16 +35,37 @@ const Discharge: FC<{
2435
const { episodeID } = match.params;
2536
const { mutate, isLoading } = useDischarge(episodeID);
2637

27-
const handleSubmit = (form: DischargeForm) => {
38+
const handleSubmit = (form: {
39+
date: string;
40+
aware_of_mesh: SelectOption;
41+
infection: string;
42+
episode_id: number;
43+
comments?: string;
44+
discharge_duration?: string;
45+
}) => {
2846
mutate(form);
2947
};
3048

31-
const canSubmit = discharge?.infection === undefined;
49+
const canSubmit = discharge?.infection == undefined;
3250

3351
return (
3452
<InternalContainer isOpen={isOpen} aria-expanded={isOpen}>
35-
<Form onSubmit={handleSubmit}>
36-
{({ handleSubmit }) => {
53+
<Form
54+
onSubmit={(values) => {
55+
const newValues = {
56+
...values,
57+
infection: (values.infection ? values.infection.join(',') : 'none') as string,
58+
};
59+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
60+
// @ts-ignore
61+
handleSubmit(newValues);
62+
}}
63+
initialValues={{
64+
...discharge,
65+
infection: discharge && discharge.infection ? discharge.infection?.split(',') : undefined,
66+
}}
67+
>
68+
{({ handleSubmit, values }) => {
3769
return (
3870
<form
3971
onSubmit={handleSubmit}
@@ -89,17 +121,25 @@ const Discharge: FC<{
89121
<Select
90122
locked={!canSubmit}
91123
id="aware_of_mesh"
92-
label="Mesh"
124+
label="Antibiotics given on discharge"
93125
styleType="outlined"
94126
size="md"
95127
required={canSubmit}
96128
status={hasError ? 'error' : 'hint'}
97129
hintMsg={hasError ? props.meta.error : undefined}
98130
options={BOOLEAN_OPTIONS}
99131
{...omit(props.input, ['onFocus'])}
100-
selectedOption={BOOLEAN_OPTIONS.find(
101-
(option) => option.value === props.input.value.value
102-
)}
132+
selectedOption={
133+
discharge?.aware_of_mesh !== undefined
134+
? BOOLEAN_OPTIONS.find((option) =>
135+
discharge?.aware_of_mesh
136+
? option.label === 'Yes'
137+
: option.label === 'No'
138+
)
139+
: BOOLEAN_OPTIONS.find(
140+
(option) => option.value === props.input.value.value
141+
)
142+
}
103143
handleSelectedOption={props.input.onChange}
104144
/>
105145
</SelectWrapper>
@@ -108,40 +148,69 @@ const Discharge: FC<{
108148
</Field>
109149
</FieldWrapper>
110150

111-
<FieldWrapper>
112-
<Field
113-
name="infection"
114-
initialValue={
115-
discharge?.infection !== undefined
116-
? BOOLEAN_OPTIONS.find((option) =>
117-
discharge?.infection ? option.label === 'Yes' : option.label === 'No'
118-
)
119-
: undefined
120-
}
121-
>
122-
{(props) => {
123-
const hasError =
124-
props.meta.touched && props.meta.invalid && !props.meta.active;
125-
126-
return (
127-
<SelectWrapper>
128-
<Select
129-
id="infection"
130-
label="Infection"
131-
styleType="outlined"
132-
size="md"
151+
{values?.aware_of_mesh?.value === 0 && (
152+
<FieldWrapper>
153+
<Field
154+
name="discharge_duration"
155+
initialValue={discharge?.discharge_duration}
156+
parse={(value) => value}
157+
>
158+
{(props) => {
159+
const hasError =
160+
props.meta.touched && props.meta.invalid && !props.meta.active;
161+
return (
162+
<TextField
163+
id="discharge_duration"
133164
locked={!canSubmit}
165+
label={'Duration (days)'}
134166
required={canSubmit}
167+
styleType="outlined"
168+
size="md"
135169
status={hasError ? 'error' : 'hint'}
136170
hintMsg={hasError ? props.meta.error : undefined}
137-
options={BOOLEAN_OPTIONS}
138-
{...omit(props.input, ['onFocus'])}
139-
selectedOption={BOOLEAN_OPTIONS.find(
140-
(option) => option.value === props.input.value.value
141-
)}
142-
handleSelectedOption={props.input.onChange}
171+
{...props.input}
143172
/>
144-
</SelectWrapper>
173+
);
174+
}}
175+
</Field>
176+
</FieldWrapper>
177+
)}
178+
179+
<FieldWrapper>
180+
<label>Post-operative complications</label>
181+
<CheckBoxWrapper>
182+
{POST_OPERATIVE_COMPLICATIONS.map((option) => (
183+
<div key={option.label}>
184+
<Field
185+
name={`infection`}
186+
type="checkbox"
187+
value={option.label}
188+
label={option.label}
189+
component={Checkbox}
190+
required={canSubmit}
191+
disabled={!canSubmit}
192+
/>
193+
</div>
194+
))}
195+
</CheckBoxWrapper>
196+
</FieldWrapper>
197+
198+
<FieldWrapper>
199+
<label>Comments</label>
200+
<Field name="comments" initialValue={discharge?.comments}>
201+
{(props) => {
202+
const hasError =
203+
props.meta.touched && props.meta.invalid && !props.meta.active;
204+
return (
205+
<TextArea
206+
id="comments"
207+
required={canSubmit}
208+
styleType="outlined"
209+
status={hasError ? 'error' : 'hint'}
210+
hintMsg={hasError ? props.meta.error : undefined}
211+
disabled={!canSubmit}
212+
{...props.input}
213+
/>
145214
);
146215
}}
147216
</Field>
@@ -151,7 +220,7 @@ const Discharge: FC<{
151220
color={'blue-200'}
152221
buttonType="button"
153222
onClick={handleSubmit}
154-
disabled={isLoading || !canSubmit}
223+
disabled={isLoading || !canSubmit || !values.infection}
155224
block
156225
size="md"
157226
>

0 commit comments

Comments
 (0)