コード例 #1
0
ファイル: MedicalController.php プロジェクト: EyeStorm/kedon
 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');
 }
コード例 #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));
 }