Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix : Minimum value in forms should be greater than 0 #7273

Merged
merged 9 commits into from
May 7, 2024
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
Loading