Ejemplo n.º 1
0
 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);
     }
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      VisitMedicine $value A VisitMedicine object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(VisitMedicine $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }