From 0b4092a34442ac67f2d76fd443b6a6886f4ba1a0 Mon Sep 17 00:00:00 2001 From: sunsetsystems Date: Tue, 3 Feb 2009 23:26:11 +0000 Subject: [PATCH] various updates --- interface/reports/ippf_statistics.php | 72 ++++++++++++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 6 deletions(-) diff --git a/interface/reports/ippf_statistics.php b/interface/reports/ippf_statistics.php index 7bfee1f82..74bc29386 100644 --- a/interface/reports/ippf_statistics.php +++ b/interface/reports/ippf_statistics.php @@ -122,6 +122,7 @@ function genEndRow() { } } +/********************************************************************* function genAnyCell($data, $right=false, $class='') { global $cellcount; if ($_POST['form_csvexport']) { @@ -136,6 +137,29 @@ function genAnyCell($data, $right=false, $class='') { } ++$cellcount; } +*********************************************************************/ + +// Usually this generates one cell, but allows for two or more. +// +function genAnyCell($data, $right=false, $class='') { + global $cellcount; + if (!is_array($data)) { + $data = array(0 => $data); + } + foreach ($data as $datum) { + if ($_POST['form_csvexport']) { + if ($cellcount) echo ','; + echo '"' . $datum . '"'; + } + else { + echo " $datum\n"; + } + ++$cellcount; + } +} function genHeadCell($data, $right=false) { genAnyCell($data, $right, 'dehead'); @@ -268,7 +292,7 @@ function getGcacClientStatus($row) { // Helper function called after the reporting key is determined for a row. // function loadColumnData($key, $row) { - global $areport, $arr_titles, $form_cors; + global $areport, $arr_titles, $form_cors, $from_date, $to_date; // global $previous_pid; // if ($form_cors == '2' && $row['pid'] == $previous_pid) return; @@ -292,6 +316,17 @@ function loadColumnData($key, $row) { // Skip this key if we are counting unique patients and the key // has already seen this patient. if ($form_cors == '2' && $row['pid'] == $areport[$key]['prp']) return; + + // If we are counting new acceptors, then require a unique patient + // whose contraceptive start date is within the reporting period. + if ($form_cors == '3') { + if ($row['pid'] == $areport[$key]['prp']) return; + // Check contraceptive start date. + if (!$row['contrastart'] || $row['contrastart'] < $from_date || + $row['contrastart'] > $to_date) return; + } + + // Flag this patient as having been encountered for this report row. $areport[$key]['prp'] = $row['pid']; /******************************************************************* @@ -668,7 +703,7 @@ function process_referral($row) {