Permalink
Browse files

More refinements! Now does patients per day!!

  • Loading branch information...
1 parent 7e994a8 commit 0e080fd72b71e26799c88b3832d994bb5e156adf @tareko committed Oct 20, 2012
Showing with 19 additions and 2 deletions.
  1. +8 −2 app/Controller/BillingsController.php
  2. +1 −0 app/Model/Billing.php
  3. +10 −0 app/Model/BillingsItem.php
@@ -8,6 +8,11 @@ class BillingsController extends AppController {
function index() {
+ $this->loadModel('BillingsItem');
+ debug($this->BillingsItem->distinctShiftsPerDay());
+ $log = $this->BillingsItem->getDataSource()->getLog(false, false);
+ debug($log);
+
$this->render();
}
/* Upload function
@@ -30,10 +35,11 @@ function upload() {
}
function export() {
+ //set_time_limit(300);
// Find fields needed without recursing through associated models
$data = $this->Billing->find('all', array(
- 'limit' => 100,
- 'BillingsItem'));
+ 'BillingsItem',
+ 'limit' => 1000));
$data = $this->Billing->recombineBilling($data);
// Define column headers for CSV file, in same array format as the data itself
$headers = array(
View
@@ -197,4 +197,5 @@ public function recombineBilling ($data) {
}
return $output;
}
+
}
View
@@ -51,4 +51,14 @@ public function beforeValidate($options = array()) {
public function dateFormatBeforeSave($dateString) {
return date('Y-m-d', strtotime($dateString));
}
+
+ public function distinctShiftsPerDay ($conditions = array()) {
+ $data = $this->find('all', array(
+ 'fields' => array('Billing.healthcare_provider', 'service_date', 'COUNT(DISTINCT billing_id)'),
+ 'conditions' => $conditions,
+ 'group' => array('Billing.healthcare_provider', 'service_date')
+ )
+ );
+ return $data;
+ }
}

0 comments on commit 0e080fd

Please sign in to comment.