diff --git a/htdocs/Language/default.php b/htdocs/Language/default.php
index 06bf57f98..4b0cf37e3 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" => "",
@@ -563,7 +565,7 @@
"TIPS_SPECIMEN" => "Select Specimen to view Report of all tests done on it",
"TIPS_TESTRECORDS" => "Select Site, Test Type, Date Interval and Fields to print Test Records.",
"TIPS_PENDINGTESTS" => "Select Site and Test Type to view tests pending at the site.",
- "TIPS_DAILYLOGS" => "Print all records handled on a given day.",
+ "TIPS_DAILYLOGS" => "View/Print all records handled on a given day.",
"TIPS_INFECTIONSUMMARY" => "Select facility and date range to view infection graph and prevalence rates.",
"TIPS_COUNTS" => "Select Site and Date Interval to view number of Specimens or Tests Handled over the specified duration.",
"TIPS_TAT" => "Select Site and Date Interval to view average test-wise Turn around Times over the specified duration.",
diff --git a/htdocs/Language/en.php b/htdocs/Language/en.php
index 06bf57f98..4b0cf37e3 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" => "",
@@ -563,7 +565,7 @@
"TIPS_SPECIMEN" => "Select Specimen to view Report of all tests done on it",
"TIPS_TESTRECORDS" => "Select Site, Test Type, Date Interval and Fields to print Test Records.",
"TIPS_PENDINGTESTS" => "Select Site and Test Type to view tests pending at the site.",
- "TIPS_DAILYLOGS" => "Print all records handled on a given day.",
+ "TIPS_DAILYLOGS" => "View/Print all records handled on a given day.",
"TIPS_INFECTIONSUMMARY" => "Select facility and date range to view infection graph and prevalence rates.",
"TIPS_COUNTS" => "Select Site and Date Interval to view number of Specimens or Tests Handled over the specified duration.",
"TIPS_TAT" => "Select Site and Date Interval to view average test-wise Turn around Times over the specified duration.",
diff --git a/htdocs/export/export_to_excel.php b/htdocs/export/export_to_excel.php
index bc24b6c0c..25d1e8b78 100644
--- a/htdocs/export/export_to_excel.php
+++ b/htdocs/export/export_to_excel.php
@@ -55,6 +55,8 @@
$end_date = intval($_REQUEST['yyyy_to'])."-".intval($_REQUEST['mm_to'])."-".intval($_REQUEST['dd_to']);
$test_type_ids = $_REQUEST['test_types'];
+$patient_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");
@@ -100,6 +102,20 @@
"t.ts AS test_timestamp"
);
+db_change($lab['db_name']);
+
+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");
+}
+
+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");
@@ -118,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;
@@ -125,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']);
diff --git a/htdocs/export/export_to_excel_get_custom_patient_fields.php b/htdocs/export/export_to_excel_get_custom_patient_fields.php
new file mode 100644
index 000000000..bcc8336fa
--- /dev/null
+++ b/htdocs/export/export_to_excel_get_custom_patient_fields.php
@@ -0,0 +1,49 @@
+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($lab_id);
+$custom_field_list = $lab_config->getPatientCustomFields();
+
+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/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..efc186a00
--- /dev/null
+++ b/htdocs/export/export_to_excel_get_custom_specimen_fields.php
@@ -0,0 +1,49 @@
+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/header.php b/htdocs/includes/header.php
index 2ce8980eb..5486f6c88 100644
--- a/htdocs/includes/header.php
+++ b/htdocs/includes/header.php
@@ -113,23 +113,47 @@
if (isset($top_menu_options)) {
foreach ($top_menu_options as $key => $value) {
//echo "hello "."
";
-
- echo "