/**
  * Show the form for editing the specified prescription.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $prescription = Prescription::where('appointment_id', $id)->get()->first();
     $medicines = Medicine::all()->lists('name', 'id');
     $old_medicines = explode(',', $prescription->medicines);
     return View::make('prescriptions.edit', compact('old_medicines', 'prescription', 'medicines'));
 }
示例#2
0
 public function newPrescription()
 {
     $input = Input::all();
     $pres = Prescription::where(DB::raw('DATE(created_at)'), '=', date('Y-m-d'))->where('patient', '=', $input['patient'])->first();
     $flagDetail = true;
     if (!Until::isNull($pres)) {
         if (Input::has('listDelete')) {
             PrescriptionDetail::whereIn('id', explode(",", $input['listDelete']))->delete();
         } else {
             if ($input['presSelect'] != $pres->id) {
                 PrescriptionDetail::where('prescription', '=', $pres->id)->delete();
                 $flagDetail = false;
             }
         }
     } else {
         $pres = new Prescription();
         $pres->is_no_drug = false;
         $flagDetail = false;
     }
     $pres->patient = $input['patient'];
     $pres->disease = $input['disease'];
     $pres->note = $input['note'];
     $pres->day = $input['dosage'];
     $pres->is_repres = $input['isRe'] == "false" ? 0 : 1;
     $pres->save();
     $inputDrug = json_decode($input['drugs']);
     foreach ($inputDrug as $drug) {
         $detail = new PrescriptionDetail();
         if (!Until::isNull($drug->idDetail) && $flagDetail) {
             $detail = PrescriptionDetail::where('id', '=', $drug->idDetail)->first();
         }
         $detail->prescription = $pres->id;
         $detail->drug = $drug->drugId;
         $detail->price = Drug::where('id', '=', $drug->drugId)->first()->price;
         switch ($drug->type) {
             case 1:
                 $detail->morning = $drug->morning;
                 $detail->lunch = $drug->lunch;
                 $detail->afternoon = $drug->afternoon;
                 $detail->night = $drug->night;
                 $detail->total = $drug->total;
                 break;
             case 2:
                 $detail->special = $drug->dosage;
             case 3:
             case 4:
                 $detail->total = $drug->fixed;
                 break;
         }
         $detail->save();
     }
     $pres = $this->createDataPrint($pres);
     return Response::json(array('pres' => $pres));
 }
示例#3
0
 public function printPres($id)
 {
     $pres = Prescription::where('id', $id)->first();
     $pres->detail;
     foreach ($pres->detail as $key => $value) {
         $pres->detail[$key]->getDrug;
         $pres->detail[$key]->get_drug->getUnit;
     }
     $pres->getPatient;
     $pres->get_patient->add;
     $pres->disease = implode(", ", Disease::whereIn('id', explode(',', $pres->disease))->lists('name'));
     $bill = $pres->is_free == 0 ? Config::get('constants.bill', 50000) : 0;
     $objPdf = new SellPDF();
     $objPdf->create($pres);
     $objPdf->Output();
     flush();
 }
示例#4
0
 public function newPrescription()
 {
     $input = Input::all();
     $pres = Prescription::where(DB::raw('DATE(created_at)'), '=', date('Y-m-d'))->where('patient', '=', $input['patient'])->first();
     $isSell = 0;
     if (!Until::isNull($pres)) {
         if (Input::has('listDelete')) {
             PrescriptionDetail::whereIn('id', $input['listDelete'])->delete();
         } else {
             if ($input['presSelect'] != $pres->id) {
                 PrescriptionDetail::where('prescription', '=', $pres->id)->delete();
             }
         }
         $isSell = $pres->is_sell;
     } else {
         $pres = new Prescription();
         $pres->is_no_drug = false;
     }
     $pres->patient = $input['patient'];
     $pres->disease = $input['disease'];
     $pres->note = $input['note'];
     $pres->day = $input['dosage'];
     $pres->is_free = Until::isNull($input['isFree']) ? 0 : 1;
     $pres->is_repres = Until::isNull($input['isRe']) ? 1 : 0;
     $pres->is_sell = $isSell;
     $pres->save();
     foreach ($input['drugs'] as $drug) {
         $detail = new PrescriptionDetail();
         if (!Until::isNull($drug['idDetail'])) {
             $detail = PrescriptionDetail::where('id', '=', $drug['idDetail'])->first();
         }
         $detail->prescription = $pres->id;
         $detail->drug = $drug['drugId'];
         $detail->price = Drug::where('id', '=', $drug['drugId'])->first()->price;
         switch ($drug['type']) {
             case 1:
                 $detail->morning = $drug['morning'];
                 $detail->lunch = $drug['lunch'];
                 $detail->afternoon = $drug['afternoon'];
                 $detail->night = $drug['night'];
                 $detail->total = $drug['total'];
                 break;
             case 3:
                 $detail->special = $drug['dosage'];
                 $detail->total = $drug['fixed'];
             case 2:
             case 4:
                 $detail->total = $drug['fixed'];
                 break;
         }
         $detail->save();
     }
     return Response::json('true');
 }