Ejemplo n.º 1
0
 public function processImport2xFacilitiesAction()
 {
     $import = (int) $this->_getParam('import');
     $parentId = (int) $this->_getParam('parentId');
     $data = false;
     if ($import > 0 && $parentId > 0) {
         $db = Zend_Registry::get('dbAdapter');
         $enumClosure = new EnumerationsClosure();
         $sql = 'SELECT * FROM practices';
         $practices = $db->fetchAll($sql);
         $ctr = 1;
         foreach ($practices as $practice) {
             $p = new Practice();
             $p->name = $practice['name'];
             $p->website = $practice['website'];
             $p->identifier = $practice['identifier'];
             //$p->persist();
             // add addresses (primary = 4, secondary = 5)
             $sql = 'SELECT * FROM practice_address AS pa INNER JOIN address a ON a.address_id=pa.address_id WHERE pa.practice_id=' . $practice['id'] . ' AND (pa.address_type=4 OR pa.address_type=5)';
             $addresses = $db->fetchAll($sql);
             foreach ($addresses as $address) {
                 if ($address['address_type'] == 4) {
                     $addr = $p->primaryAddress;
                 } else {
                     if ($address['address_type'] == 5) {
                         $addr = $p->secondaryAddress;
                     } else {
                         continue;
                     }
                 }
                 $addr->populateWithArray($address);
                 $addr->addressId = 0;
                 $addr->type = $address['address_type'];
                 $addr->active = 1;
                 $addr->practiceId = $practice['id'];
                 //$addr->persist();
             }
             // add phones (main = 3, secondary = 1, fax = 5)
             $sql = 'SELECT * FROM practice_number AS pn INNER JOIN number n ON n.number_id=pn.number_id WHERE pn.practice_id=' . $practice['id'] . ' AND (n.number_type=1 OR n.number_type=3 OR n.number_type=5)';
             $phones = $db->fetchAll($sql);
             foreach ($phones as $phone) {
                 $pn = new PhoneNumber();
                 $pn->populateWithArray($phone);
                 $pn->type = $phone['number_type'];
                 $pn->numberId = 0;
                 //$pn->persist();
             }
             //$practiceId = $p->practiceId;
             $practiceId = $practice['id'];
             $params = array();
             $params['name'] = $practice['name'];
             $params['key'] = $ctr++;
             $params['active'] = '1';
             $params['ormClass'] = 'Practice';
             $params['ormId'] = $practiceId;
             $params['ormEditMethod'] = 'ormEditMethod';
             $buildingParentId = $enumClosure->insertEnumeration($params, $parentId);
             $sql = 'SELECT * FROM buildings WHERE practice_id=' . $practice['id'];
             $buildings = $db->fetchAll($sql);
             foreach ($buildings as $building) {
                 $b = new Building();
                 $b->description = $building['description'];
                 $b->name = $building['name'];
                 $b->practiceId = $p->practiceId;
                 $b->identifier = $building['identifier'];
                 $b->facilityCodeId = $building['facility_code_id'];
                 //$b->phoneNumber = $building[''];
                 //$b->persist();
                 //$buildingId = $b->buildingId;
                 $buildingId = $building['id'];
                 $params = array();
                 $params['name'] = $building['name'];
                 $params['key'] = $ctr++;
                 $params['active'] = '1';
                 $params['ormClass'] = 'Building';
                 $params['ormId'] = $buildingId;
                 $params['ormEditMethod'] = 'ormEditMethod';
                 $roomParentId = $enumClosure->insertEnumeration($params, $buildingParentId);
                 // add phone number
                 // add address
                 $sql = 'SELECT * FROM building_address AS ba INNER JOIN address a ON a.address_id=ba.address_id WHERE ba.building_id=' . $building['id'];
                 $addresses = $db->fetchAll($sql);
                 foreach ($addresses as $address) {
                     $addr = new Address();
                     $addr->populateWithArray($address);
                     $addr->addressId = 0;
                     $addr->type = $address['address_type'];
                     $addr->active = 1;
                     $addr->practiceId = $practice['id'];
                     //$addr->persist();
                 }
                 $sql = 'SELECT * FROM rooms WHERE building_id=' . $building['id'];
                 $rooms = $db->fetchAll($sql);
                 foreach ($rooms as $room) {
                     $r = new Room();
                     $r->populateWithArray($room);
                     $r->roomId = 0;
                     //$r->persist();
                     //$roomId = $r->roomId;
                     $roomId = $room['id'];
                     $params = array();
                     $params['name'] = $room['name'];
                     $params['key'] = $ctr++;
                     $params['active'] = '1';
                     $params['ormClass'] = 'Room';
                     $params['ormId'] = $roomId;
                     $params['ormEditMethod'] = 'ormEditMethod';
                     $enumerationId = $enumClosure->insertEnumeration($params, $roomParentId);
                 }
             }
         }
         $data = true;
     }
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($data);
 }
Ejemplo n.º 2
0
 public function processNewPatientAction()
 {
     $params = $this->_getParam('patient');
     $patient = new Patient();
     $patient->populateWithArray($params);
     if (!strlen($patient->recordNumber) > 0) {
         $patient->recordNumber = WebVista_Model_ORM::nextSequenceId('record_sequence');
     }
     $patient->persist();
     $personId = (int) $patient->personId;
     // save addresses and phones
     $addresses = $this->_getParam('addresses');
     if (is_array($addresses)) {
         foreach ($addresses as $row) {
             $address = new Address();
             $address->populateWithArray($row);
             $address->personId = $personId;
             $address->persist();
         }
     }
     $phones = $this->_getParam('phones');
     if (is_array($phones)) {
         foreach ($phones as $row) {
             $phone = new PhoneNumber();
             $phone->populateWithArray($row);
             $phone->personId = $personId;
             $phone->persist();
         }
     }
     $ret = array();
     $ret['msg'] = 'Record Saved for Patient: ' . ucfirst($patient->firstName) . ' ' . ucfirst($patient->lastName);
     $ret['personId'] = $personId;
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($ret);
 }