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

Fixes issue with negative value checks for nullable fields #7775

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Components/Facility/ConsultationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ export const ConsultationForm = ({ facilityId, patientId, id }: Props) => {
}
case "weight":
case "height": {
if (state.form.suggestion !== "DD") {
if (state.form[field] && state.form.suggestion !== "DD") {
const value = state.form[field];
if (!value || parseFloat(value) <= 0) {
errors[field] = `Please enter a valid ${field}`;
Expand Down
29 changes: 2 additions & 27 deletions src/Components/Facility/TriageForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,37 +103,12 @@ export const TriageForm = ({ facilityId, id }: Props) => {
}
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";
if (state.form[field] != null && state.form[field] < 0) {
errors[field] = "Value must be greater than or equal to 0";
invalidForm = true;
}
return;
Expand Down
8 changes: 2 additions & 6 deletions src/Components/Patient/PatientRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -656,13 +656,9 @@ export const PatientRegister = (props: PatientRegisterProps) => {
}
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";
if (form[field] && form[field] < 0) {
errors[field] = "Value cannot be negative";
}
return;

Expand Down
Loading