protected function _createVisit($appointmentId) { $ret = 0; if ($appointmentId > 0) { $appointment = new Appointment(); $appointment->appointmentId = $appointmentId; $appointment->populate(); $personId = (int) $appointment->patientId; $insuredRelationship = new InsuredRelationship(); $insuredRelationship->personId = $personId; $visit = new Visit(); $visit->patientId = $personId; $visit->activePayerId = $insuredRelationship->defaultActivePayer; $visit->roomId = $appointment->roomId; $visit->practiceId = $appointment->practiceId; $room = new Room(); $room->roomId = $visit->roomId; $room->populate(); $visit->buildingId = $room->buildingId; $visit->createdByUserId = $appointment->creatorId; $visit->lastChangeUserId = $appointment->lastChangeId; $visit->treatingPersonId = $appointment->providerId; $visit->encounterReason = $appointment->reason; $visit->dateOfTreatment = $appointment->start; $visit->timestamp = date('Y-m-d H:i:s'); $visit->appointmentId = $appointment->appointmentId; $visit->persist(); $visitId = (int) $visit->visitId; $payment = new Payment(); foreach ($payment->getIteratorByAppointmentId($appointmentId) as $row) { $row->visitId = $visitId; $row->persist(); } $miscCharge = new MiscCharge(); foreach ($miscCharge->getIteratorByAppointmentId($appointmentId) as $row) { $row->visitId = $visitId; $row->persist(); } $ret = $visitId; } return $ret; }
public function listChargesAction() { $appointmentId = (int) $this->_getParam('appointmentId'); $rows = array(); $miscCharge = new MiscCharge(); foreach ($miscCharge->getIteratorByAppointmentId($appointmentId) as $row) { $rows[] = $this->_generateMiscChargeRowData($row); } $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct(array('rows' => $rows)); }