Skip to content

Commit

Permalink
Fix : Minimum value in forms should be greater than 0 (#7273)
Browse files Browse the repository at this point in the history
* Triage Form Fix

* Added Validation for Negative Values in forms

* Update src/Components/Facility/ConsultationForm.tsx

Co-authored-by: Khavin Shankar <khavinshankar@gmail.com>

* fix lint

---------

Co-authored-by: Ashesh <3626859+Ashesh3@users.noreply.github.com>
Co-authored-by: Mohammed Nihal <57055998+nihal467@users.noreply.github.com>
Co-authored-by: Rithvik Nishad <rithvikn2001@gmail.com>
Co-authored-by: Khavin Shankar <khavinshankar@gmail.com>
Co-authored-by: Rithvik Nishad <mail@rithviknishad.dev>
  • Loading branch information
6 people committed May 7, 2024
1 parent ca4040e commit 9a1c337
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Components/Facility/ConsultationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,18 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => {
}
return;
}
case "weight":
case "height": {
if (state.form.suggestion !== "DD") {
const value = state.form[field];
if (!value || parseFloat(value) <= 0) {
errors[field] = `Please enter a valid ${field}`;
invalidForm = true;
break;
}
}
return;
}

default:
return;
Expand Down
36 changes: 36 additions & 0 deletions src/Components/Facility/TriageForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,42 @@ export const TriageForm = ({ facilityId, id }: Props) => {
invalidForm = true;
}
return;
case "num_patients_visited":
if (state.form[field] < 0) {
errors[field] =
"Number of patients visited must be greater than or equal to 0";
invalidForm = true;
}
return;
case "num_patients_home_quarantine":
if (state.form[field] < 0) {
errors[field] =
"Number of patients in Home Qurantine must be greater than or equal to 0";
invalidForm = true;
}
return;
case "num_patients_isolation":
if (state.form[field] < 0) {
errors[field] =
"Number of patients in Isolation must be greater than or equal to 0";
invalidForm = true;
}
return;
case "num_patient_referred":
if (state.form[field] < 0) {
errors[field] =
"Number of patients referred must be greater than or equal to 0";
invalidForm = true;
}
return;
case "num_patient_confirmed_positive":
if (state.form[field] < 0) {
errors[field] =
"Number of patients confirmed positive must be greater than or equal to 0";
invalidForm = true;
}
return;

default:
return;
}
Expand Down
10 changes: 10 additions & 0 deletions src/Components/Patient/PatientRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,16 @@ export const PatientRegister = (props: PatientRegisterProps) => {
errors[field] = "Please select a blood group";
}
return;
case "number_of_primary_contacts":
if (form[field] < 0) {
errors[field] = "Number of primary contacts cannot be negative";
}
return;
case "number_of_secondary_contacts":
if (form[field] < 0) {
errors[field] = "Number of secondary contacts cannot be negative";
}
return;

case "is_vaccinated":
if (form.is_vaccinated === "true") {
Expand Down

0 comments on commit 9a1c337

Please sign in to comment.