Skip to content

Commit 58b943c

Browse files
ArnaudFofouArnaudFofou
andauthored
OH2-459 | Fix Error on edit patient examination form (#722)
* fix error on patient examination form during editing some fields * revert changes on index.tsx * remove the check for undefine field * remove console.log --------- Co-authored-by: ArnaudFofou <gui.fofou@umi2growcameroun.com>
1 parent 713ef2a commit 58b943c

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

src/components/accessories/patientTriage/PatientTriage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ const PatientTriage: FC = () => {
116116
triage.patientCode = patientDataCode ?? -1;
117117
if (triageToEdit.pex_ID) triage.pex_ID = triageToEdit.pex_ID;
118118
if (!creationMode && triageToEdit.pex_ID) {
119+
triage.lock = triageToEdit.lock;
119120
dispatch(
120121
updateExamination({
121122
id: triageToEdit.pex_ID,
@@ -145,8 +146,7 @@ const PatientTriage: FC = () => {
145146
}
146147
};
147148

148-
const onEdit = (row: any) => {
149-
row.pex_date = row.date;
149+
const onEdit = (row: PatientExaminationDTO) => {
150150
setTriageToEdit(row);
151151
setCreationMode(false);
152152
scrollToElement(null);

src/components/accessories/patientTriage/patientTriageTable/PatientTriageTable.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ const PatientTriageTable: FunctionComponent<IOwnProps> = ({
5757
dispatch(examinationsByPatientId(patientCode));
5858
}, [dispatch, patientCode, shouldUpdateTable]);
5959

60+
const onEdit = (row: PatientExaminationDTO) => {
61+
const pex = data.find((item) => item.pex_ID === row.pex_ID);
62+
handleEdit(pex!);
63+
};
6064
const formatDataToDisplay = (data: PatientExaminationDTO[]) => {
6165
return data.map((item) => {
6266
return {
@@ -119,7 +123,7 @@ const PatientTriageTable: FunctionComponent<IOwnProps> = ({
119123
labelData={label}
120124
columnsOrder={order}
121125
rowsPerPage={5}
122-
onEdit={canUpdate ? handleEdit : undefined}
126+
onEdit={canUpdate ? onEdit : undefined}
123127
isCollapsabile={true}
124128
showEmptyCell={false}
125129
/>

src/libraries/formDataHandling/functions.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ export const getFromFields = (
2828
fieldAddress: TFieldAddress
2929
): Record<string, any> => {
3030
return Object.keys(fields).reduce((acc: Record<string, any>, key) => {
31+
if (fields[key].type === "number" && fields[key][fieldAddress] === null) {
32+
acc[key] = "";
33+
return acc;
34+
}
3135
if (fieldAddress === "value") {
3236
acc[key] = fields[key].isArray
3337
? JSON.parse(fields[key][fieldAddress])

0 commit comments

Comments
 (0)