public function executeCheckup(sfWebRequest $request) { if ($request->isMethod('POST')) { $visit_id = $this->getRequestParameter('visit_id'); $patient_id = $this->getRequestParameter('patient_id'); $meds = $this->getRequestParameter('med'); $dose = $this->getRequestParameter('dose'); $quantity = $this->getRequestParameter('quantity'); $tests = $this->getRequestParameter('test'); $total_cost = 0; //Saving Medicines for Current Visit foreach ($meds as $i => $med) { $pharma = PharmaPeer::retrieveByPk($med[0]); $med_price = $pharma->getPrice(); $visit_med = new VisitMedicine(); $visit_med->setPatientId($patient_id); $visit_med->setVisitId($visit_id); $visit_med->setPharmaId($med[0]); $visit_med->setDosageId($dose[$i]); $visit_med->setQuantity($quantity[$i]); $visit_med->setPrice($quantity[$i] * $med_price); $visit_med->save(); $total_cost = $quantity[$i] * $med_price + $total_cost; } //Saving Lab Tests for Current Visit foreach ($tests as $j => $test) { $lab_test = LabTestPeer::retrieveByPk($test[0]); $test_price = $lab_test->getPrice(); $visit_test = new LabReport(); $visit_test->setPatientId($patient_id); $visit_test->setVisitId($visit_id); $visit_test->setLabTestId($test[0]); $visit_test->setPrice($test_price); $visit_test->setStatus(Constant::RECORD_STATUS_ACTIVE); $visit_test->save(); $total_cost = $test_price + $total_cost; } //Saving Current Visit $visit = VisitPeer::retrieveByPk($visit_id); $doc_id = $visit->getDoctorId(); $doc = EmployeePeer::retrieveByPk($doc_id); $doc_fee = $doc->getVisitFee(); $total_cost = $total_cost + $doc_fee; $visit->setBp($this->getRequestParameter('bp')); $visit->setPulse($this->getRequestParameter('pulse')); $visit->setTemp($this->getRequestParameter('temp')); $visit->setDiet($this->getRequestParameter('diet')); $visit->setDescription($this->getRequestParameter('description')); $visit->setFee($total_cost); $visit->setFeePaid(Constant::VISIT_FEE_NOT_PAID); $visit->setStatus(Constant::VISIT_DONE); $visit->save(); $this->getUser()->setFlash('SUCCESS_MESSAGE', 'Patient Visit saves Successfully'); $this->redirect('Visit/docList'); } else { $patient_id = Utility::DecryptQueryString($request->getParameter('patient')); $visit_id = Utility::DecryptQueryString($request->getParameter('visit')); $this->patient = PatientPeer::retrieveByPk($patient_id); $this->visit = VisitPeer::retrieveByPk($visit_id); $c = new Criteria(); $c->add(PharmaPeer::STATUS, Constant::RECORD_STATUS_ACTIVE); $c->addAscendingOrderByColumn(PharmaPeer::NAME); $this->medicines = PharmaPeer::doSelect($c); $d = new Criteria(); $d->add(LabTestPeer::STATUS, Constant::RECORD_STATUS_ACTIVE); $d->addAscendingOrderByColumn(LabTestPeer::TITLE); $this->tests = LabTestPeer::doSelect($d); } }
public function executeVisitDetail(sfWebRequest $request) { $this->visit = VisitPeer::retrieveByPk(Utility::DecryptQueryString($request->getParameter('visit'))); $visit = VisitPeer::retrieveByPk(Utility::DecryptQueryString($request->getParameter('visit'))); $visit_id = $visit->getId(); $c = new Criteria(); //$c->add(LabReportPeer::STATUS, Constant::RECORD_STATUS_DELETED, Criteria::NOT_EQUAL); $c->add(LabReportPeer::VISIT_ID, $visit_id); $this->tests = LabReportPeer::doSelect($c); $d = new Criteria(); //$d->add(VisitMedicinePeer::STATUS, Constant::RECORD_STATUS_DELETED, Criteria::NOT_EQUAL); $d->add(VisitMedicinePeer::VISIT_ID, $visit_id); $this->medicines = VisitMedicinePeer::doSelect($d); }