From 7c5f28b71953d3732ddb6827c27a1efae94d2eec Mon Sep 17 00:00:00 2001 From: harshitg927 Date: Thu, 9 Jan 2025 01:00:27 +0530 Subject: [PATCH 1/6] Fix: Prevent negative age input values in New Patient form, along with some formatting of frontend code --- frontend/cypress/pages/ModifyOrderPage.js | 6 +++--- .../src/components/patient/CreatePatientForm.js | 13 +++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/frontend/cypress/pages/ModifyOrderPage.js b/frontend/cypress/pages/ModifyOrderPage.js index efddfb1e1..759586679 100644 --- a/frontend/cypress/pages/ModifyOrderPage.js +++ b/frontend/cypress/pages/ModifyOrderPage.js @@ -41,9 +41,9 @@ class ModifyOrderPage { clickRespectivePatient() { return cy - .get('tbody tr') - .first() - .find('.cds--radio-button__appearance') + .get("tbody tr") + .first() + .find(".cds--radio-button__appearance") .click(); } } diff --git a/frontend/src/components/patient/CreatePatientForm.js b/frontend/src/components/patient/CreatePatientForm.js index 1f16d7efe..2ae4e3103 100644 --- a/frontend/src/components/patient/CreatePatientForm.js +++ b/frontend/src/components/patient/CreatePatientForm.js @@ -143,8 +143,16 @@ function CreatePatientForm(props) { }; function handleYearsChange(e, values) { - setPatientDetails(values); - let years = e.target.value; + // Ensure years is not negative + const years = Math.max(0, Number(e.target.value)); + + // Update form values with the validated years + setPatientDetails({ + ...values, + // Update the specific field that contains years to ensure the form shows the corrected value + [e.target.name]: years, + }); + let dobFormatter = { ...dateOfBirthFormatter, years: years, @@ -625,6 +633,7 @@ function CreatePatientForm(props) { })} id="years" type="number" + min="0" onChange={(e) => handleYearsChange(e, values)} placeholder={intl.formatMessage({ id: "patient.information.age", From 6e8ec488f7949d383d8e0a0d6125cf97cff7acce Mon Sep 17 00:00:00 2001 From: root Date: Thu, 9 Jan 2025 18:18:31 +0400 Subject: [PATCH 2/6] additional labs column in csv routine expoert --- .../reportBeans/CIRoutineColumnBuilder.java | 1 + .../reportBeans/CSVRoutineColumnBuilder.java | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CIRoutineColumnBuilder.java b/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CIRoutineColumnBuilder.java index 236884983..1867938a4 100644 --- a/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CIRoutineColumnBuilder.java +++ b/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CIRoutineColumnBuilder.java @@ -120,6 +120,7 @@ protected void appendOtherDiseaseCrosstab(Date lowDate, Date highDate, SQLConsta protected void defineBasicColumns() { add("accession_number", "LABNO", NONE); + add("lab_unit", "LAB_UNIT", NONE); add("national_id", "IDENTIFIER", NONE); add("gender", "SEX", NONE); add("birth_date", "BIRTHDATE", DATE); diff --git a/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CSVRoutineColumnBuilder.java b/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CSVRoutineColumnBuilder.java index fa26b9961..3b64b16e9 100644 --- a/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CSVRoutineColumnBuilder.java +++ b/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CSVRoutineColumnBuilder.java @@ -539,6 +539,7 @@ protected void appendResultCrosstab(java.sql.Date lowDate, java.sql.Date highDat + " join clinlims.sample AS s on s.id = si.samp_id \n" + " join clinlims.test_result AS tr on r.test_result_id = tr.id \n" + " join clinlims.test AS t on tr.test_id = t.id \n" + + " join clinlims.test_section ts on t.test_section_id = ts.id \n" // lab units column + " left join sample_projects sp on si.samp_id = sp.samp_id \n" + "\n" + " WHERE sp.id IS NULL AND s.entered_date >= date(''" + formatDateForDatabaseSql(lowDate) + "'') AND s.entered_date <= date(''" + formatDateForDatabaseSql(highDate) + " '') " + "\n " @@ -631,7 +632,15 @@ protected void appendObservationHistoryCrosstab(java.sql.Date lowDate, java.sql. } protected void appendCrosstabPreamble(SQLConstant listName) { - query.append(", \n\n ( SELECT s.id AS samp_id, " + listName + ".* " + " FROM sample AS s LEFT JOIN \n "); + query.append(", \n\n ( SELECT s.id AS samp_id, " + + " (SELECT ts.name FROM clinlims.test_section ts " // Modify subquery to get test section name + + " JOIN clinlims.test t ON t.test_section_id = ts.id " + + " JOIN clinlims.analysis a ON a.test_id = t.id " + + " WHERE a.sampitem_id = si.id LIMIT 1) as lab_unit, " // Link back to sample item + + listName + ".* " + + " FROM sample AS s " + + " LEFT JOIN sample_item si ON s.id = si.samp_id " // Add sample_item join + + " LEFT JOIN \n "); } protected void appendCrosstabPostfix(java.sql.Date lowDate, java.sql.Date highDate, SQLConstant listName) { From fc0f57a6c0df1d67fa810f9df5e33ad34785a3fc Mon Sep 17 00:00:00 2001 From: root Date: Thu, 9 Jan 2025 18:39:42 +0400 Subject: [PATCH 3/6] code formatting --- .../reportBeans/CSVRoutineColumnBuilder.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CSVRoutineColumnBuilder.java b/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CSVRoutineColumnBuilder.java index 3b64b16e9..bc642e944 100644 --- a/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CSVRoutineColumnBuilder.java +++ b/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CSVRoutineColumnBuilder.java @@ -632,14 +632,18 @@ protected void appendObservationHistoryCrosstab(java.sql.Date lowDate, java.sql. } protected void appendCrosstabPreamble(SQLConstant listName) { - query.append(", \n\n ( SELECT s.id AS samp_id, " - + " (SELECT ts.name FROM clinlims.test_section ts " // Modify subquery to get test section name + query.append(", \n\n ( SELECT s.id AS samp_id, " + " (SELECT ts.name FROM clinlims.test_section ts " // Modify + // subquery + // to get + // test + // section + // name + " JOIN clinlims.test t ON t.test_section_id = ts.id " + " JOIN clinlims.analysis a ON a.test_id = t.id " + " WHERE a.sampitem_id = si.id LIMIT 1) as lab_unit, " // Link back to sample item - + listName + ".* " - + " FROM sample AS s " - + " LEFT JOIN sample_item si ON s.id = si.samp_id " // Add sample_item join + + listName + ".* " + " FROM sample AS s " + " LEFT JOIN sample_item si ON s.id = si.samp_id " // Add + // sample_item + // join + " LEFT JOIN \n "); } From 207f025cfbf4e2af38b1f9fafde49660492ab377 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 9 Jan 2025 19:00:12 +0400 Subject: [PATCH 4/6] additional formatting and removing unnecessary comments --- .../reportBeans/CSVRoutineColumnBuilder.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CSVRoutineColumnBuilder.java b/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CSVRoutineColumnBuilder.java index bc642e944..a4884985e 100644 --- a/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CSVRoutineColumnBuilder.java +++ b/src/main/java/org/openelisglobal/reports/action/implementation/reportBeans/CSVRoutineColumnBuilder.java @@ -539,7 +539,7 @@ protected void appendResultCrosstab(java.sql.Date lowDate, java.sql.Date highDat + " join clinlims.sample AS s on s.id = si.samp_id \n" + " join clinlims.test_result AS tr on r.test_result_id = tr.id \n" + " join clinlims.test AS t on tr.test_id = t.id \n" - + " join clinlims.test_section ts on t.test_section_id = ts.id \n" // lab units column + + " join clinlims.test_section ts on t.test_section_id = ts.id \n" + " left join sample_projects sp on si.samp_id = sp.samp_id \n" + "\n" + " WHERE sp.id IS NULL AND s.entered_date >= date(''" + formatDateForDatabaseSql(lowDate) + "'') AND s.entered_date <= date(''" + formatDateForDatabaseSql(highDate) + " '') " + "\n " @@ -632,19 +632,11 @@ protected void appendObservationHistoryCrosstab(java.sql.Date lowDate, java.sql. } protected void appendCrosstabPreamble(SQLConstant listName) { - query.append(", \n\n ( SELECT s.id AS samp_id, " + " (SELECT ts.name FROM clinlims.test_section ts " // Modify - // subquery - // to get - // test - // section - // name + query.append(", \n\n ( SELECT s.id AS samp_id, " + " (SELECT ts.name FROM clinlims.test_section ts " + " JOIN clinlims.test t ON t.test_section_id = ts.id " + " JOIN clinlims.analysis a ON a.test_id = t.id " - + " WHERE a.sampitem_id = si.id LIMIT 1) as lab_unit, " // Link back to sample item - + listName + ".* " + " FROM sample AS s " + " LEFT JOIN sample_item si ON s.id = si.samp_id " // Add - // sample_item - // join - + " LEFT JOIN \n "); + + " WHERE a.sampitem_id = si.id LIMIT 1) as lab_unit, " + listName + ".* " + " FROM sample AS s " + + " LEFT JOIN sample_item si ON s.id = si.samp_id " + " LEFT JOIN \n "); } protected void appendCrosstabPostfix(java.sql.Date lowDate, java.sql.Date highDate, SQLConstant listName) { From 5317a1d8aa836228fdf8c56fa8ac34f4ec230c5c Mon Sep 17 00:00:00 2001 From: mozzy11 Date: Thu, 9 Jan 2025 18:28:04 +0300 Subject: [PATCH 5/6] bump fix version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 03ab4c4f9..9f1628c75 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ 1 0 - 0 + 1 UTF-8 ${project.basedir}/liquibase/liquibase.properties 1.4.1 From 6b52f5f9bda67ea1a6259e37907238d0b7f8f5a3 Mon Sep 17 00:00:00 2001 From: harshitg927 Date: Thu, 9 Jan 2025 01:00:27 +0530 Subject: [PATCH 6/6] Fix: Prevent negative age input values in New Patient form, along with some formatting of frontend code --- .../components/patient/CreatePatientForm.js | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/patient/CreatePatientForm.js b/frontend/src/components/patient/CreatePatientForm.js index 2ae4e3103..f9de1bd7c 100644 --- a/frontend/src/components/patient/CreatePatientForm.js +++ b/frontend/src/components/patient/CreatePatientForm.js @@ -161,8 +161,16 @@ function CreatePatientForm(props) { } function handleMonthsChange(e, values) { - setPatientDetails(values); - let months = e.target.value; + // Ensure months is not negative + const months = Math.max(0, Number(e.target.value)); + + // Update form values with the validated months + setPatientDetails({ + ...values, + // Update the specific field that contains months to ensure the form shows the corrected value + [e.target.name]: months, + }); + let dobFormatter = { ...dateOfBirthFormatter, months: months, @@ -171,8 +179,16 @@ function CreatePatientForm(props) { } function handleDaysChange(e, values) { - setPatientDetails(values); - let days = e.target.value; + // Ensure days is not negative + const days = Math.max(0, Number(e.target.value)); + + // Update form values with the validated days + setPatientDetails({ + ...values, + // Update the specific field that contains days to ensure the form shows the corrected value + [e.target.name]: days, + }); + let dobFormatter = { ...dateOfBirthFormatter, days: days, @@ -646,6 +662,7 @@ function CreatePatientForm(props) { name="months" labelText={intl.formatMessage({ id: "patient.age.months" })} type="number" + min="0" onChange={(e) => handleMonthsChange(e, values)} id="months" placeholder={intl.formatMessage({ @@ -658,6 +675,7 @@ function CreatePatientForm(props) { value={dateOfBirthFormatter.days} name="days" type="number" + min="0" onChange={(e) => handleDaysChange(e, values)} labelText={intl.formatMessage({ id: "patient.age.days" })} id="days"