From 12b49330ad207c954998c3ec32cc9cca6c35ec4a Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Wed, 8 May 2024 13:55:21 +0530 Subject: [PATCH 1/2] Fixes issue with negative value checks for nullable fields (#7775) --- src/Components/Facility/ConsultationForm.tsx | 2 +- src/Components/Facility/TriageForm.tsx | 29 ++------------------ src/Components/Patient/PatientRegister.tsx | 8 ++---- 3 files changed, 5 insertions(+), 34 deletions(-) diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx index e4b3f4a195f..ba248b8db6f 100644 --- a/src/Components/Facility/ConsultationForm.tsx +++ b/src/Components/Facility/ConsultationForm.tsx @@ -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}`; diff --git a/src/Components/Facility/TriageForm.tsx b/src/Components/Facility/TriageForm.tsx index 1efe22e66a4..6ad9fdd0e08 100644 --- a/src/Components/Facility/TriageForm.tsx +++ b/src/Components/Facility/TriageForm.tsx @@ -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; diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index d036c3c0067..4309044fba2 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -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; From 2d9d6d922e4a7f9d8ca6433c65d38366536487b8 Mon Sep 17 00:00:00 2001 From: Harsh Gupta <97297407+609harsh@users.noreply.github.com> Date: Wed, 8 May 2024 13:55:57 +0530 Subject: [PATCH 2/2] occupation field options are in alphabetical order (#7746) * fix: occupation field options are in alphabetical order * fix: changed the occupationTypes order in constants.tsx --- src/Common/constants.tsx | 91 +++++++++++++++++++++++++++------------- 1 file changed, 61 insertions(+), 30 deletions(-) diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx index 4e9298422c9..fd19ca85dc1 100644 --- a/src/Common/constants.tsx +++ b/src/Common/constants.tsx @@ -1254,60 +1254,91 @@ export const CONSENT_PATIENT_CODE_STATUS_CHOICES = [ { id: 4, text: "Active treatment (Default)" }, ]; export const OCCUPATION_TYPES = [ - { id: 1, text: "Student", value: "STUDENT" }, { - id: 2, - text: "Businessman", - value: "BUSINESSMAN", + id: 27, + text: "Aircraft Pilot or Flight Engineer", + value: "PILOT_FLIGHT", }, - { id: 3, text: "Healthcare Worker", value: "HEALTH_CARE_WORKER" }, - { id: 4, text: "Healthcare Lab Worker", value: "HEALTH_CARE_LAB_WORKER" }, { id: 5, text: "Animal Handler", value: "ANIMAL_HANDLER" }, - { id: 6, text: "Others", value: "OTHERS" }, - { id: 7, text: "Healthcare Practitioner", value: "HEALTHCARE_PRACTITIONER" }, - { id: 8, text: "Paramedics", value: "PARADEMICS" }, { id: 9, text: "Business or Finance related Occupations", value: "BUSINESS_RELATED", }, + { id: 2, text: "Businessman", value: "BUSINESSMAN" }, + { id: 14, text: "Chef or Head Cook", value: "CHEF" }, + { + id: 24, + text: "Construction and Extraction Worker", + value: "CONSTRUCTION_EXTRACTION", + }, + { id: 17, text: "Custodial Occupations", value: "CUSTODIAL" }, + { + id: 18, + text: "Customer Service Occupations", + value: "CUSTOMER_SERVICE", + }, { id: 10, text: "Engineer", value: "ENGINEER" }, - { id: 11, text: "Teacher", value: "TEACHER" }, { - id: 12, - text: "Other Professional Occupations", - value: "OTHER_PROFESSIONAL_OCCUPATIONS", + id: 25, + text: "Farming, Fishing and Forestry", + value: "AGRI_NATURAL", + }, + { + id: 4, + text: "Healthcare Lab Worker", + value: "HEALTH_CARE_LAB_WORKER", + }, + { + id: 7, + text: "Healthcare Practitioner", + value: "HEALTHCARE_PRACTITIONER", + }, + { id: 3, text: "Healthcare Worker", value: "HEALTH_CARE_WORKER" }, + { id: 30, text: "Homemaker", value: "HOMEMAKER" }, + { + id: 16, + text: "Hospitality Service Occupations", + value: "HOSPITALITY", + }, + { + id: 21, + text: "Insurance Sales Agent", + value: "INSURANCE_SALES_AGENT", }, + { id: 29, text: "Military", value: "MILITARY" }, { id: 13, text: "Office and Administrative Support Occupations", value: "OFFICE_ADMINISTRATIVE", }, - { id: 14, text: "Chef or Head Cook", value: "CHEF" }, + { + id: 12, + text: "Other Professional Occupations", + value: "OTHER_PROFESSIONAL_OCCUPATIONS", + }, + { id: 8, text: "Paramedics", value: "PARADEMICS" }, + { + id: 26, + text: "Production Occupations", + value: "PRODUCTION_OCCUPATION", + }, { id: 15, text: "Protective Service Occupations", value: "PROTECTIVE_SERVICE", }, - { id: 16, text: "Hospitality Service Occupations", value: "HOSPITALITY" }, - { id: 17, text: "Custodial Occupations", value: "CUSTODIAL" }, - { id: 18, text: "Customer Service Occupations", value: "CUSTOMER_SERVICE" }, - { id: 19, text: "Sales Supervisor", value: "SALES_SUPERVISOR" }, - { id: 20, text: "Retail Sales Worker", value: "RETAIL_SALES_WORKER" }, - { id: 21, text: "Insurance Sales Agent", value: "INSURANCE_SALES_AGENT" }, - { id: 22, text: "Sales Representative", value: "SALES_REPRESENTATIVE" }, { id: 23, text: "Real Estate Sales Agent", value: "REAL_ESTATE" }, + { id: 20, text: "Retail Sales Worker", value: "RETAIL_SALES_WORKER" }, { - id: 24, - text: "Construction and Extraction Worker", - value: "CONSTRUCTION_EXTRACTION", + id: 22, + text: "Sales Representative", + value: "SALES_REPRESENTATIVE", }, - { id: 25, text: "Farming, Fishing and Forestry", value: "AGRI_NATURAL" }, - { id: 26, text: "Production Occupations", value: "PRODUCTION_OCCUPATION" }, - { id: 27, text: "Aircraft Pilot or Flight Engineer", value: "PILOT_FLIGHT" }, + { id: 19, text: "Sales Supervisor", value: "SALES_SUPERVISOR" }, + { id: 1, text: "Student", value: "STUDENT" }, + { id: 11, text: "Teacher", value: "TEACHER" }, { id: 28, text: "Vehicle Driver", value: "VEHICLE_DRIVER" }, - { id: 29, text: "Military", value: "MILITARY" }, - { id: 30, text: "Homemaker", value: "HOMEMAKER" }, - { id: 31, text: "Don't Know", value: "UNKNOWN" }, + { id: 6, text: "Others", value: "OTHERS" }, { id: 32, text: "Not Applicable", value: "NOT_APPLICABLE" }, ];