From 014e2421a009fe5856d2b22ffff1b2768a72f3d2 Mon Sep 17 00:00:00 2001 From: vinay-easwaran Date: Fri, 23 Feb 2024 05:20:54 +0000 Subject: [PATCH 01/20] javascript to export table data as .xls file --- htdocs/reports/reports_dailypatients.php | 20 ++++++++++++++++++++ htdocs/reports/reports_dailyspecimens.php | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/htdocs/reports/reports_dailypatients.php b/htdocs/reports/reports_dailypatients.php index 5b1b35e5e..dc1cb5c99 100644 --- a/htdocs/reports/reports_dailypatients.php +++ b/htdocs/reports/reports_dailypatients.php @@ -53,6 +53,8 @@ $margin_list[$i] = ($SCREEN_WIDTH * $margin_list[$i] / 100); } ?> + + + @@ -2962,7 +2971,7 @@ function exportExcel_updateTestTypes() { '; + echo ' + getOutputFieldOptions(); + } + ?> + +
+ + + + From 7e192d8db56f7d4681560dfd6a874440b6d3f7ec Mon Sep 17 00:00:00 2001 From: vinay-easwaran Date: Thu, 7 Mar 2024 20:19:30 +0000 Subject: [PATCH 03/20] updated query in export file --- htdocs/export/export_to_excel_get_output_fields.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/export/export_to_excel_get_output_fields.php b/htdocs/export/export_to_excel_get_output_fields.php index fd613c553..04624eac3 100644 --- a/htdocs/export/export_to_excel_get_output_fields.php +++ b/htdocs/export/export_to_excel_get_output_fields.php @@ -48,9 +48,12 @@ db_change($db_name); -$output_fields_query = "(SELECT column_name FROM Information_schema.columns WHERE -table_name = 'patient') UNION (SELECT column_name -FROM Information_schema.columns WHERE table_name = 'specimen');"; +$output_fields_query = "(SELECT CONCAT(table_name, ':', column_name) as field_name, CONCAT(table_name, '.', column_name) as location FROM +information_schema.columns WHERE table_name = 'patient') UNION +(SELECT CONCAT(table_name, ':', column_name) as field_name, CONCAT(table_name, '.', column_name) as location +FROM information_schema.columns WHERE table_name = 'specimen') UNION +(SELECT CONCAT(table_name, ':', column_name) as field_name, CONCAT(table_name, '.', column_name) as location FROM +information_schema.columns WHERE table_name = 'specimen_type');"; $output_fields = query_associative_all($output_fields_query); // Send the resulting JSON directly to the browser @@ -61,8 +64,8 @@ echo "[\n"; foreach($output_fields as $idx => $row) { - echo '{ "field": "'.$row['column_name'].'" }'; - if ($idx < count($test_types) - 1) { + echo '{ "location": '.$row['location'].', "field_name": "'.$row['field_name'].'" }'; + if ($idx < count($output_fields) - 1) { echo ",\n"; } } From d19c8283288071e77ff53401f3b1860c461fdfa8 Mon Sep 17 00:00:00 2001 From: vinay-easwaran Date: Fri, 8 Mar 2024 06:06:08 +0000 Subject: [PATCH 04/20] patient custom fields selectable --- htdocs/Language/default.php | 4 +++- htdocs/Language/en.php | 4 +++- htdocs/includes/page_elems.php | 21 +++++++++++++++++++++ htdocs/reports/reports.php | 6 +++--- local/langdata_127/default.php | 4 +++- local/langdata_127/en.php | 4 +++- 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/htdocs/Language/default.php b/htdocs/Language/default.php index 06bf57f98..82611d472 100644 --- a/htdocs/Language/default.php +++ b/htdocs/Language/default.php @@ -217,7 +217,9 @@ "HEIGHT" => "Height", "FONT_SIZE" => "Font Size", "COL_COUNT" => "Column-Count", - "CMD_REFRESH" => "Refresh" + "CMD_REFRESH" => "Refresh", + "SPECIMEN_CUSTOM_FIELDS" => "Specimen Custom Fields", + "PATIENT_CUSTOM_FIELDS" => "Patient Custom Fields" ) , "header" => array ( "TITLE" => "", diff --git a/htdocs/Language/en.php b/htdocs/Language/en.php index 06bf57f98..82611d472 100644 --- a/htdocs/Language/en.php +++ b/htdocs/Language/en.php @@ -217,7 +217,9 @@ "HEIGHT" => "Height", "FONT_SIZE" => "Font Size", "COL_COUNT" => "Column-Count", - "CMD_REFRESH" => "Refresh" + "CMD_REFRESH" => "Refresh", + "SPECIMEN_CUSTOM_FIELDS" => "Specimen Custom Fields", + "PATIENT_CUSTOM_FIELDS" => "Patient Custom Fields" ) , "header" => array ( "TITLE" => "", diff --git a/htdocs/includes/page_elems.php b/htdocs/includes/page_elems.php index da3c11c1b..02376ea55 100644 --- a/htdocs/includes/page_elems.php +++ b/htdocs/includes/page_elems.php @@ -833,6 +833,27 @@ public function getOutputFieldOptions() } + + public function getCustomPatientFieldOptions($lab_config_id) + { + # Returns accessible sites for drop down + diff --git a/local/langdata_127/default.php b/local/langdata_127/default.php index 06bf57f98..82611d472 100644 --- a/local/langdata_127/default.php +++ b/local/langdata_127/default.php @@ -217,7 +217,9 @@ "HEIGHT" => "Height", "FONT_SIZE" => "Font Size", "COL_COUNT" => "Column-Count", - "CMD_REFRESH" => "Refresh" + "CMD_REFRESH" => "Refresh", + "SPECIMEN_CUSTOM_FIELDS" => "Specimen Custom Fields", + "PATIENT_CUSTOM_FIELDS" => "Patient Custom Fields" ) , "header" => array ( "TITLE" => "", diff --git a/local/langdata_127/en.php b/local/langdata_127/en.php index 06bf57f98..82611d472 100644 --- a/local/langdata_127/en.php +++ b/local/langdata_127/en.php @@ -217,7 +217,9 @@ "HEIGHT" => "Height", "FONT_SIZE" => "Font Size", "COL_COUNT" => "Column-Count", - "CMD_REFRESH" => "Refresh" + "CMD_REFRESH" => "Refresh", + "SPECIMEN_CUSTOM_FIELDS" => "Specimen Custom Fields", + "PATIENT_CUSTOM_FIELDS" => "Patient Custom Fields" ) , "header" => array ( "TITLE" => "", From eaa531e21df3d4cd05bad7032e85992764120371 Mon Sep 17 00:00:00 2001 From: vinay-easwaran Date: Fri, 8 Mar 2024 06:21:37 +0000 Subject: [PATCH 05/20] get field list outside if condition --- htdocs/includes/page_elems.php | 8 ++++---- htdocs/reports/reports.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/includes/page_elems.php b/htdocs/includes/page_elems.php index 02376ea55..66e518da1 100644 --- a/htdocs/includes/page_elems.php +++ b/htdocs/includes/page_elems.php @@ -834,20 +834,20 @@ public function getOutputFieldOptions() } - public function getCustomPatientFieldOptions($lab_config_id) + public function getCustomPatientFieldOptions() { # Returns accessible sites for drop down From 9e4ea4326330caa864ecfe0fd178b9f6ef1cab68 Mon Sep 17 00:00:00 2001 From: vinay-easwaran Date: Fri, 8 Mar 2024 06:37:10 +0000 Subject: [PATCH 06/20] reinstated old patient fields --- htdocs/export/export_to_excel.php | 90 +++++++++++++++---------------- htdocs/reports/reports.php | 5 +- 2 files changed, 47 insertions(+), 48 deletions(-) diff --git a/htdocs/export/export_to_excel.php b/htdocs/export/export_to_excel.php index 6d5952b67..f6d7c613d 100644 --- a/htdocs/export/export_to_excel.php +++ b/htdocs/export/export_to_excel.php @@ -55,51 +55,51 @@ $end_date = intval($_REQUEST['yyyy_to'])."-".intval($_REQUEST['mm_to'])."-".intval($_REQUEST['dd_to']); $test_type_ids = $_REQUEST['test_types']; -$output_fields = $_REQUEST['output_fields']; +$patient_custom_fields = $_REQUEST['patient_custom_fields']; -// $include_name = ($_REQUEST["include_patient_name"] == "true"); -// $include_sex = ($_REQUEST["include_patient_sex"] == "true"); -// $include_dob = ($_REQUEST["include_patient_birthday"] == "true"); -// $include_pid = ($_REQUEST["include_patient_id"] == "true"); +$include_name = ($_REQUEST["include_patient_name"] == "true"); +$include_sex = ($_REQUEST["include_patient_sex"] == "true"); +$include_dob = ($_REQUEST["include_patient_birthday"] == "true"); +$include_pid = ($_REQUEST["include_patient_id"] == "true"); // Okay... let's build the SQL query // The headers for the spreadsheet must match the order of the columns/fields -$headers = $output_fields; -$fields = $output_fields; - -// if ($include_name) { -// $headers[] = "Patient Name"; -// $fields[] = "p.name AS patient_name"; -// } - -// if ($include_sex) { -// $headers[] = "Sex"; -// $fields[] = "p.sex"; -// } - -// if ($include_dob) { -// $headers[] = "Date of Birth"; -// $fields[] = "p.dob AS patient_dob"; -// } - -// if ($include_pid) { -// $headers[] = "Patient ID"; -// $fields[] = "p.surr_id"; -// } - -// array_push($headers, -// "Specimen Type", -// "Date Collected", -// "Date Received", -// "Result Entry Date" -// ); -// array_push($fields, -// "st.name AS specimen_type", -// "s.date_collected AS specimen_collected", -// "s.date_recvd AS specimen_date_received", -// "t.ts AS test_timestamp" -// ); +$headers = array(); +$fields = array(); + +if ($include_name) { + $headers[] = "Patient Name"; + $fields[] = "p.name AS patient_name"; +} + +if ($include_sex) { + $headers[] = "Sex"; + $fields[] = "p.sex"; +} + +if ($include_dob) { + $headers[] = "Date of Birth"; + $fields[] = "p.dob AS patient_dob"; +} + +if ($include_pid) { + $headers[] = "Patient ID"; + $fields[] = "p.surr_id"; +} + +array_push($headers, + "Specimen Type", + "Date Collected", + "Date Received", + "Result Entry Date" +); +array_push($fields, + "st.name AS specimen_type", + "s.date_collected AS specimen_collected", + "s.date_recvd AS specimen_date_received", + "t.ts AS test_timestamp" +); // Push additional field for test result - the headers for this will be generated separately // Must be the last field! There is logic in the loop below that depends on it. @@ -115,11 +115,11 @@ // It will break if not indented this way I think... $query = << - + From e4f6ab38a8268ab3a2dada49ff5e0b14e862a1d7 Mon Sep 17 00:00:00 2001 From: vinay-easwaran Date: Fri, 8 Mar 2024 06:56:02 +0000 Subject: [PATCH 07/20] new form for specimen custom fields with .php file for facilty based update --- htdocs/export/export_to_excel.php | 1 + ...rt_to_excel_get_custom_patient_fields.php} | 26 ++------- ...rt_to_excel_get_custom_specimen_fields.php | 55 +++++++++++++++++++ htdocs/includes/page_elems.php | 20 +++++++ htdocs/reports/reports.php | 39 ++++++++++--- 5 files changed, 112 insertions(+), 29 deletions(-) rename htdocs/export/{export_to_excel_get_output_fields.php => export_to_excel_get_custom_patient_fields.php} (56%) create mode 100644 htdocs/export/export_to_excel_get_custom_specimen_fields.php diff --git a/htdocs/export/export_to_excel.php b/htdocs/export/export_to_excel.php index f6d7c613d..3f849d40c 100644 --- a/htdocs/export/export_to_excel.php +++ b/htdocs/export/export_to_excel.php @@ -56,6 +56,7 @@ $test_type_ids = $_REQUEST['test_types']; $patient_custom_fields = $_REQUEST['patient_custom_fields']; +$specimen_custom_fields = $_REQUEST['patient_custom_fields']; $include_name = ($_REQUEST["include_patient_name"] == "true"); $include_sex = ($_REQUEST["include_patient_sex"] == "true"); diff --git a/htdocs/export/export_to_excel_get_output_fields.php b/htdocs/export/export_to_excel_get_custom_patient_fields.php similarity index 56% rename from htdocs/export/export_to_excel_get_output_fields.php rename to htdocs/export/export_to_excel_get_custom_patient_fields.php index 04624eac3..ddade2907 100644 --- a/htdocs/export/export_to_excel_get_output_fields.php +++ b/htdocs/export/export_to_excel_get_custom_patient_fields.php @@ -41,30 +41,12 @@ exit; } -DbUtil::switchToGlobal(); -$lab_db_name_query = "SELECT db_name FROM lab_config WHERE lab_config_id = $lab_id"; -$db_name_res = query_associative_one($lab_db_name_query); -$db_name = $db_name_res['db_name']; -db_change($db_name); +$lab_config = LabConfig::getById($_REQUEST['lab_config_id']); +$custom_field_list = $lab_config->getPatientCustomFields(); -$output_fields_query = "(SELECT CONCAT(table_name, ':', column_name) as field_name, CONCAT(table_name, '.', column_name) as location FROM -information_schema.columns WHERE table_name = 'patient') UNION -(SELECT CONCAT(table_name, ':', column_name) as field_name, CONCAT(table_name, '.', column_name) as location -FROM information_schema.columns WHERE table_name = 'specimen') UNION -(SELECT CONCAT(table_name, ':', column_name) as field_name, CONCAT(table_name, '.', column_name) as location FROM -information_schema.columns WHERE table_name = 'specimen_type');"; -$output_fields = query_associative_all($output_fields_query); - -// Send the resulting JSON directly to the browser -// Do not echo() or output anything else below this line! - -header('Content-Type: application/json'); - -echo "[\n"; - -foreach($output_fields as $idx => $row) { - echo '{ "location": '.$row['location'].', "field_name": "'.$row['field_name'].'" }'; +foreach($custom_field_list as $idx => $custom_field) { + echo '{ "id": '.$custom_field->id.', "fieldName": "'.$custom_field->fieldName.'" }'; if ($idx < count($output_fields) - 1) { echo ",\n"; } diff --git a/htdocs/export/export_to_excel_get_custom_specimen_fields.php b/htdocs/export/export_to_excel_get_custom_specimen_fields.php new file mode 100644 index 000000000..b207a0444 --- /dev/null +++ b/htdocs/export/export_to_excel_get_custom_specimen_fields.php @@ -0,0 +1,55 @@ +labConfigId && is_admin($current_user)) { + $unauthorized = false; + } +} + +if ($unauthorized) { + header('HTTP/1.1 401 Unauthorized', true, 401); + echo "You do not have permission to view this page."; + exit; +} + + +$lab_config = LabConfig::getById($_REQUEST['lab_config_id']); +$custom_field_list = $lab_config->getSpecimenCustomFields(); + +foreach($custom_field_list as $idx => $custom_field) { + echo '{ "id": '.$custom_field->id.', "fieldName": "'.$custom_field->fieldName.'" }'; + if ($idx < count($output_fields) - 1) { + echo ",\n"; + } +} + +echo "\n]"; diff --git a/htdocs/includes/page_elems.php b/htdocs/includes/page_elems.php index 66e518da1..b63eaee8f 100644 --- a/htdocs/includes/page_elems.php +++ b/htdocs/includes/page_elems.php @@ -854,6 +854,26 @@ public function getCustomPatientFieldOptions() } + public function getCustomSpecimenFieldOptions() + { + # Returns accessible sites for drop down '; echo ''; $lab_config_list_imported = get_lab_configs_imported(); @@ -3008,7 +3017,7 @@ function exportExcel_updateTestTypesAndFieldNames() { - + + + + +
+ + + From 796ca7f358ecaf177efc873972431c629b3b1b92 Mon Sep 17 00:00:00 2001 From: Mobolaji Moronfolu Date: Fri, 8 Mar 2024 01:10:50 -0600 Subject: [PATCH 08/20] export to excel --- htdocs/export/export_to_excel.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/htdocs/export/export_to_excel.php b/htdocs/export/export_to_excel.php index 3f849d40c..559c5d3f4 100644 --- a/htdocs/export/export_to_excel.php +++ b/htdocs/export/export_to_excel.php @@ -62,7 +62,7 @@ $include_sex = ($_REQUEST["include_patient_sex"] == "true"); $include_dob = ($_REQUEST["include_patient_birthday"] == "true"); $include_pid = ($_REQUEST["include_patient_id"] == "true"); - +$arr = array(); // Okay... let's build the SQL query // The headers for the spreadsheet must match the order of the columns/fields @@ -101,7 +101,16 @@ "s.date_recvd AS specimen_date_received", "t.ts AS test_timestamp" ); - +foreach($patient_custom_fields as $custom_field) +{ + $field_name = $custom_field; + array_push($headers,$field_name); +} +foreach($specimen_custom_fields as $custom_field) +{ + $field_name = $custom_field; + array_push($headers,$field_name); +} // Push additional field for test result - the headers for this will be generated separately // Must be the last field! There is logic in the loop below that depends on it. array_push($fields, "t.result AS test_result"); From 8dc169d1cc17c718b5ce57b26545278ef8311a3c Mon Sep 17 00:00:00 2001 From: Mobolaji Moronfolu Date: Fri, 8 Mar 2024 01:18:09 -0600 Subject: [PATCH 09/20] Revert "export to excel" This reverts commit 796ca7f358ecaf177efc873972431c629b3b1b92. --- htdocs/export/export_to_excel.php | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/htdocs/export/export_to_excel.php b/htdocs/export/export_to_excel.php index 559c5d3f4..3f849d40c 100644 --- a/htdocs/export/export_to_excel.php +++ b/htdocs/export/export_to_excel.php @@ -62,7 +62,7 @@ $include_sex = ($_REQUEST["include_patient_sex"] == "true"); $include_dob = ($_REQUEST["include_patient_birthday"] == "true"); $include_pid = ($_REQUEST["include_patient_id"] == "true"); -$arr = array(); + // Okay... let's build the SQL query // The headers for the spreadsheet must match the order of the columns/fields @@ -101,16 +101,7 @@ "s.date_recvd AS specimen_date_received", "t.ts AS test_timestamp" ); -foreach($patient_custom_fields as $custom_field) -{ - $field_name = $custom_field; - array_push($headers,$field_name); -} -foreach($specimen_custom_fields as $custom_field) -{ - $field_name = $custom_field; - array_push($headers,$field_name); -} + // Push additional field for test result - the headers for this will be generated separately // Must be the last field! There is logic in the loop below that depends on it. array_push($fields, "t.result AS test_result"); From 27eecc41d412f35c3f5c099d56101dd000a5b015 Mon Sep 17 00:00:00 2001 From: vinay-easwaran Date: Fri, 8 Mar 2024 07:37:53 +0000 Subject: [PATCH 10/20] push custom fields to headers --- htdocs/export/export_to_excel.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/export/export_to_excel.php b/htdocs/export/export_to_excel.php index 3f849d40c..6ffcd6956 100644 --- a/htdocs/export/export_to_excel.php +++ b/htdocs/export/export_to_excel.php @@ -102,6 +102,15 @@ "t.ts AS test_timestamp" ); +foreach($patient_custom_fields as $patient_custom_field_id) { + $query_string = + "SELECT field_name FROM patient_custom_field ". + "WHERE id='$patient_custom_field_id' LIMIT 1"; + $record = query_associative_one($query_string); + array_push($headers, $record['field_name']); + array_push($fields, "pcd.field_value"); +} + // Push additional field for test result - the headers for this will be generated separately // Must be the last field! There is logic in the loop below that depends on it. array_push($fields, "t.result AS test_result"); @@ -120,6 +129,8 @@ INNER JOIN specimen_type AS st ON s.specimen_type_id = st.specimen_type_id INNER JOIN test AS t ON s.specimen_id = t.specimen_id INNER JOIN patient AS p ON s.patient_id = p.patient_id + INNER JOIN patient_custom_data AS pcd on p.patient_id = pcd.patient_id + INNER JOIN specimen_custom_data as scd on s.specimen_id = scd.specimen_id WHERE s.date_collected BETWEEN '$start_date' AND '$end_date' AND t.test_type_id = '$test_type_id'; EOQ; From ccdbda5053dc0c3777eee0ff32f90a10d3cea5b5 Mon Sep 17 00:00:00 2001 From: vinay-easwaran Date: Fri, 8 Mar 2024 08:14:06 +0000 Subject: [PATCH 11/20] push custom field name and value to header and rows --- htdocs/export/export_to_excel.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/htdocs/export/export_to_excel.php b/htdocs/export/export_to_excel.php index 6ffcd6956..6b64756b8 100644 --- a/htdocs/export/export_to_excel.php +++ b/htdocs/export/export_to_excel.php @@ -56,7 +56,7 @@ $test_type_ids = $_REQUEST['test_types']; $patient_custom_fields = $_REQUEST['patient_custom_fields']; -$specimen_custom_fields = $_REQUEST['patient_custom_fields']; +$specimen_custom_fields = $_REQUEST['specimen_custom_fields']; $include_name = ($_REQUEST["include_patient_name"] == "true"); $include_sex = ($_REQUEST["include_patient_sex"] == "true"); @@ -102,15 +102,20 @@ "t.ts AS test_timestamp" ); +db_change($lab['db_name']); + foreach($patient_custom_fields as $patient_custom_field_id) { - $query_string = - "SELECT field_name FROM patient_custom_field ". - "WHERE id='$patient_custom_field_id' LIMIT 1"; - $record = query_associative_one($query_string); - array_push($headers, $record['field_name']); + $field_name = get_custom_field_name_patient($patient_custom_field_id); + array_push($headers, $field_name); array_push($fields, "pcd.field_value"); } +foreach($specimen_custom_fields as $specimen_custom_field_id) { + $field_name = get_custom_field_name_specimen($specimen_custom_field_id); + array_push($headers, $field_name); + array_push($fields, "scd.field_value"); +} + // Push additional field for test result - the headers for this will be generated separately // Must be the last field! There is logic in the loop below that depends on it. array_push($fields, "t.result AS test_result"); @@ -138,8 +143,6 @@ $sheet = $objPHPExcel->createSheet(); - db_change($lab['db_name']); - // Grab all the measures for this test type from the database. $test_type = TestType::getById($test_type_id, $lab['lab_config_id']); From a0e342d9a40029f93f680ec10eb01a4f84fe817a Mon Sep 17 00:00:00 2001 From: vinay-easwaran Date: Fri, 8 Mar 2024 08:42:48 +0000 Subject: [PATCH 12/20] field name obfuscation --- htdocs/export/export_to_excel.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/export/export_to_excel.php b/htdocs/export/export_to_excel.php index 6b64756b8..056968e98 100644 --- a/htdocs/export/export_to_excel.php +++ b/htdocs/export/export_to_excel.php @@ -107,13 +107,13 @@ foreach($patient_custom_fields as $patient_custom_field_id) { $field_name = get_custom_field_name_patient($patient_custom_field_id); array_push($headers, $field_name); - array_push($fields, "pcd.field_value"); + array_push($fields, "p.patient_id"); } foreach($specimen_custom_fields as $specimen_custom_field_id) { $field_name = get_custom_field_name_specimen($specimen_custom_field_id); array_push($headers, $field_name); - array_push($fields, "scd.field_value"); + array_push($fields, "p.patient_id"); } // Push additional field for test result - the headers for this will be generated separately @@ -134,8 +134,6 @@ INNER JOIN specimen_type AS st ON s.specimen_type_id = st.specimen_type_id INNER JOIN test AS t ON s.specimen_id = t.specimen_id INNER JOIN patient AS p ON s.patient_id = p.patient_id - INNER JOIN patient_custom_data AS pcd on p.patient_id = pcd.patient_id - INNER JOIN specimen_custom_data as scd on s.specimen_id = scd.specimen_id WHERE s.date_collected BETWEEN '$start_date' AND '$end_date' AND t.test_type_id = '$test_type_id'; EOQ; From 6d855be5a34a0bd753cab94d0dc75eee1a28d2da Mon Sep 17 00:00:00 2001 From: vinay-easwaran Date: Wed, 13 Mar 2024 19:41:58 -0400 Subject: [PATCH 13/20] Update htdocs/export/export_to_excel_get_custom_patient_fields.php Co-authored-by: Mitchell Rysavy --- htdocs/export/export_to_excel_get_custom_patient_fields.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/htdocs/export/export_to_excel_get_custom_patient_fields.php b/htdocs/export/export_to_excel_get_custom_patient_fields.php index ddade2907..a1d9cabac 100644 --- a/htdocs/export/export_to_excel_get_custom_patient_fields.php +++ b/htdocs/export/export_to_excel_get_custom_patient_fields.php @@ -1,11 +1,5 @@ Date: Wed, 13 Mar 2024 19:42:23 -0400 Subject: [PATCH 14/20] Update htdocs/export/export_to_excel_get_custom_patient_fields.php Co-authored-by: Mitchell Rysavy --- htdocs/export/export_to_excel_get_custom_patient_fields.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/export/export_to_excel_get_custom_patient_fields.php b/htdocs/export/export_to_excel_get_custom_patient_fields.php index a1d9cabac..2368fd60d 100644 --- a/htdocs/export/export_to_excel_get_custom_patient_fields.php +++ b/htdocs/export/export_to_excel_get_custom_patient_fields.php @@ -24,7 +24,7 @@ if ($unauthorized) { // If the user is not a super admin or country director, they should only // be able to access data for their own lab, and only if they are an admin. - if (count($lab_ids) == 1 && $lab_ids[0] == $current_user->labConfigId && is_admin($current_user)) { + if ($lab_id == $current_user->labConfigId && is_admin($current_user)) { $unauthorized = false; } } From 661910aa3847dde786c1cd906b3b16d156e2853a Mon Sep 17 00:00:00 2001 From: vinay-easwaran Date: Wed, 13 Mar 2024 19:42:30 -0400 Subject: [PATCH 15/20] Update htdocs/export/export_to_excel_get_custom_patient_fields.php Co-authored-by: Mitchell Rysavy --- htdocs/export/export_to_excel_get_custom_patient_fields.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/export/export_to_excel_get_custom_patient_fields.php b/htdocs/export/export_to_excel_get_custom_patient_fields.php index 2368fd60d..bcc8336fa 100644 --- a/htdocs/export/export_to_excel_get_custom_patient_fields.php +++ b/htdocs/export/export_to_excel_get_custom_patient_fields.php @@ -36,7 +36,7 @@ } -$lab_config = LabConfig::getById($_REQUEST['lab_config_id']); +$lab_config = LabConfig::getById($lab_id); $custom_field_list = $lab_config->getPatientCustomFields(); foreach($custom_field_list as $idx => $custom_field) { From b2865994f133c207632dd7bf5d04f3c71729772b Mon Sep 17 00:00:00 2001 From: vinay-easwaran Date: Thu, 14 Mar 2024 04:13:43 +0000 Subject: [PATCH 16/20] demo feedback and updated sql --- htdocs/export/export_to_excel.php | 6 ++- htdocs/includes/page_elems.php | 63 ++++--------------------------- htdocs/reports/reports.php | 40 ++++---------------- 3 files changed, 20 insertions(+), 89 deletions(-) diff --git a/htdocs/export/export_to_excel.php b/htdocs/export/export_to_excel.php index 056968e98..25d1e8b78 100644 --- a/htdocs/export/export_to_excel.php +++ b/htdocs/export/export_to_excel.php @@ -107,13 +107,13 @@ foreach($patient_custom_fields as $patient_custom_field_id) { $field_name = get_custom_field_name_patient($patient_custom_field_id); array_push($headers, $field_name); - array_push($fields, "p.patient_id"); + array_push($fields, "pcd.field_value"); } foreach($specimen_custom_fields as $specimen_custom_field_id) { $field_name = get_custom_field_name_specimen($specimen_custom_field_id); array_push($headers, $field_name); - array_push($fields, "p.patient_id"); + array_push($fields, "scd.field_value"); } // Push additional field for test result - the headers for this will be generated separately @@ -134,6 +134,8 @@ INNER JOIN specimen_type AS st ON s.specimen_type_id = st.specimen_type_id INNER JOIN test AS t ON s.specimen_id = t.specimen_id INNER JOIN patient AS p ON s.patient_id = p.patient_id + LEFT JOIN patient_custom_data AS pcd ON p.patient_id = pcd.patient_id + LEFT JOIN specimen_custom_data AS scd ON s.specimen_id = scd.specimen_id WHERE s.date_collected BETWEEN '$start_date' AND '$end_date' AND t.test_type_id = '$test_type_id'; EOQ; diff --git a/htdocs/includes/page_elems.php b/htdocs/includes/page_elems.php index b63eaee8f..6ef4c377b 100644 --- a/htdocs/includes/page_elems.php +++ b/htdocs/includes/page_elems.php @@ -797,81 +797,34 @@ public function getLabUserTypeOptions($selected_value="") } - public function getOutputFieldOptions() + public function getCustomPatientFieldCheckBoxes() { - # Returns accessible sites for drop down Include ". $custom_field->fieldName."
"; } - ?>s + ?> boxes - # TODO: Link the hard-coded values below to includes/user_lib.php $lab_config = LabConfig::getById($_SESSION['lab_config_id']); $custom_field_list = $lab_config->getSpecimenCustomFields(); if ( $lab_config ) { ?> id."'"; - if($selected_value == $custom_field->id) - echo " selected "; - echo ">". $custom_field->fieldName.""; + echo 'Include ". $custom_field->fieldName."
"; } - ?>s + ?> - - - - -
- - - - - - - -
- - - @@ -3053,6 +3021,14 @@ function exportExcel_updateTestTypesAndCustomFields() {


+ getCustomPatientFieldCheckBoxes(); + $page_elems->getCustomSpecimenFieldCheckBoxes(); + } + ?> From 92bcda343d4dee867852549a47109849961aa917 Mon Sep 17 00:00:00 2001 From: vinay-easwaran Date: Thu, 14 Mar 2024 23:07:27 +0000 Subject: [PATCH 17/20] moved the tip to a tip box --- htdocs/reports/reports.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/reports/reports.php b/htdocs/reports/reports.php index 33f3d5778..9b2267018 100644 --- a/htdocs/reports/reports.php +++ b/htdocs/reports/reports.php @@ -176,6 +176,13 @@ $page_elems->getSideTip(LangUtil::$generalTerms['TIPS'], $tips_string); ?> + +