Skip to content

Commit a6b1469

Browse files
committed
feat(patient-full-dob): Allow adding full birthday in patient registration
1 parent 4732b4c commit a6b1469

File tree

5 files changed

+56
-3
lines changed

5 files changed

+56
-3
lines changed

src/hooks/api/patientHooks.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ export const useRegisterPatient = () => {
146146
hospital_id: params.hospital.value,
147147
full_name: `${params.firstName}${params.middleName ? " " + params.middleName : ""} ${params.lastName}`,
148148
year_of_birth: params.yearOfBirth,
149+
month_of_birth: params.monthOfBirth,
150+
day_of_birth: params.dayOfBirth,
149151
age: params.age,
150152
national_id: params.nationalId,
151153
patient_hospital_id: params.patientHospitalId,

src/models/apiTypes.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ export interface RegisterPatientPayload {
152152
patient_hospital_id: number;
153153
age: number;
154154
year_of_birth: number;
155+
month_of_birth: number;
156+
day_of_birth: number;
155157
hospital_id: number;
156158
gender: string;
157159
phone_1: number;

src/pages/RegisterPatient/components/RegisterPatientForm/RegisterPatientForm.style.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import styled from '@emotion/styled';
2+
import { grid } from '@orfium/ictinus/dist/theme/functions';
23

34
import { scrollBar } from '../../../../common.style';
45

@@ -19,6 +20,14 @@ export const FormContainer = styled.div<{ isDesktop: boolean }>`
1920
${scrollBar};
2021
`;
2122

23+
export const BirthdayFieldsContainer = styled.div<{ withMargin?: boolean }>`
24+
${grid};
25+
column-gap: 8px;
26+
grid-template-columns: 1fr 1fr 1fr 1fr;
27+
margin-bottom: ${(props) => (props.withMargin ? '24px' : null)};
28+
row-gap: 8px;
29+
`;
30+
2231
export const SelectWrapper = styled.div`
2332
& > div > div {
2433
max-width: unset;

src/pages/RegisterPatient/components/RegisterPatientForm/RegisterPatientForm.tsx

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { useResponsiveLayout } from '../../../../hooks/useResponsiveSidebar';
1717
import { HospitalsAPI } from '../../../../models/apiTypes';
1818
import { RegisterPatientFormType } from '../../types';
1919
import { getHospitalOptions } from '../../utils';
20-
import { FormContainer, FormHeadingContainer, SelectWrapper } from './RegisterPatientForm.style';
20+
import { FormContainer, FormHeadingContainer, SelectWrapper, BirthdayFieldsContainer } from './RegisterPatientForm.style';
2121

2222
type Props = {
2323
values: RegisterPatientFormType;
@@ -118,7 +118,7 @@ const RegisterPatientForm: React.FC<Props> = ({ values, hospitals }) => {
118118
}}
119119
</Field>
120120
</FieldWrapper>
121-
<FieldsContainer>
121+
<BirthdayFieldsContainer>
122122
<Field name="age">
123123
{({ input: { onChange } }) => (
124124
<OnBlur name="yearOfBirth">
@@ -149,6 +149,44 @@ const RegisterPatientForm: React.FC<Props> = ({ values, hospitals }) => {
149149
}}
150150
</Field>
151151
</FieldWrapper>
152+
<FieldWrapper>
153+
<Field name="monthOfBirth" parse={(value) => value}>
154+
{(props) => {
155+
const hasError = props.meta.touched && props.meta.invalid && !props.meta.active;
156+
return (
157+
<TextField
158+
id="month_of_birth"
159+
label="Month Of Birth"
160+
styleType="outlined"
161+
type="number"
162+
size="sm"
163+
status={hasError ? 'error' : 'hint'}
164+
hintMsg={hasError ? props.meta.error : undefined}
165+
{...props.input}
166+
/>
167+
);
168+
}}
169+
</Field>
170+
</FieldWrapper>
171+
<FieldWrapper>
172+
<Field name="dayOfBirth" parse={(value) => value}>
173+
{(props) => {
174+
const hasError = props.meta.touched && props.meta.invalid && !props.meta.active;
175+
return (
176+
<TextField
177+
id="day_of_birth"
178+
label="Day Of Birth"
179+
styleType="outlined"
180+
type="number"
181+
size="sm"
182+
status={hasError ? 'error' : 'hint'}
183+
hintMsg={hasError ? props.meta.error : undefined}
184+
{...props.input}
185+
/>
186+
);
187+
}}
188+
</Field>
189+
</FieldWrapper>
152190
<FieldWrapper>
153191
<Field name="age" parse={(value) => value}>
154192
{(props) => {
@@ -166,7 +204,7 @@ const RegisterPatientForm: React.FC<Props> = ({ values, hospitals }) => {
166204
}}
167205
</Field>
168206
</FieldWrapper>
169-
</FieldsContainer>
207+
</BirthdayFieldsContainer>
170208
<FieldWrapper>
171209
<Field name="nationalId" parse={parseOnlyNumbers}>
172210
{(props) => {

src/pages/RegisterPatient/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export type RegisterPatientFormType = {
88
patientHospitalId: number;
99
nationalId: number;
1010
yearOfBirth: number;
11+
monthOfBirth: number;
12+
dayOfBirth: number;
1113
age: number;
1214
gender: 'male' | 'female';
1315
phone1: number;

0 commit comments

Comments
 (0)