Inheritance: extends DbObject
Ejemplo n.º 1
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $drugs = Drug::orderBy('name')->get();
     //Get the organism
     $organism = Organism::find($id);
     //Open the Edit View and pass to it the $organism
     return View::make('organism.edit')->with('organism', $organism)->with('drugs', $drugs);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $action = Input::get('action');
     $user_id = Auth::user()->id;
     $test = Input::get('test');
     $organism = Input::get('organism');
     $drug = Input::get('drug');
     $zone = Input::get('zone');
     $interpretation = Input::get('interpretation');
     for ($i = 0; $i < count($test); $i++) {
         $sensitivity = Susceptibility::getDrugSusceptibility($test[$i], $organism[$i], $drug[$i]);
         if (count($sensitivity) > 0) {
             $drugSusceptibility = Susceptibility::find($sensitivity->id);
             $drugSusceptibility->user_id = $user_id;
             $drugSusceptibility->test_id = $test[$i];
             $drugSusceptibility->organism_id = $organism[$i];
             $drugSusceptibility->drug_id = $drug[$i];
             $drugSusceptibility->zone = $zone[$i];
             $drugSusceptibility->interpretation = $interpretation[$i];
             $drugSusceptibility->save();
         } else {
             $drugSusceptibility = new Susceptibility();
             $drugSusceptibility->user_id = $user_id;
             $drugSusceptibility->test_id = $test[$i];
             $drugSusceptibility->organism_id = $organism[$i];
             $drugSusceptibility->drug_id = $drug[$i];
             $drugSusceptibility->zone = $zone[$i];
             $drugSusceptibility->interpretation = $interpretation[$i];
             $drugSusceptibility->save();
         }
     }
     if ($action == "results") {
         $test_id = Input::get('testId');
         $organism_id = Input::get('organismId');
         $susceptibility = Susceptibility::where('test_id', $test_id)->where('organism_id', $organism_id)->where('zone', '!=', 0)->get();
         foreach ($susceptibility as $drugSusceptibility) {
             $drugSusceptibility->drugName = Drug::find($drugSusceptibility->drug_id)->name;
             $drugSusceptibility->pathogen = Organism::find($drugSusceptibility->organism_id)->name;
             if ($drugSusceptibility->interpretation == 'I') {
                 $drugSusceptibility->sensitivity = 'Intermediate';
             } else {
                 if ($drugSusceptibility->interpretation == 'R') {
                     $drugSusceptibility->sensitivity = 'Resistant';
                 } else {
                     if ($drugSusceptibility->interpretation == 'S') {
                         $drugSusceptibility->sensitivity = 'Sestitive';
                     }
                 }
             }
         }
         return json_encode($susceptibility);
     }
 }
 public function actionFindDrug()
 {
     $return = array();
     if (isset($_GET['term']) && ($term = $_GET['term'])) {
         $criteria = new CDbCriteria();
         $criteria->compare('LOWER(name)', strtolower($term), true, 'OR');
         $criteria->compare('LOWER(aliases)', strtolower($term), true, 'OR');
         foreach (Drug::model()->active()->findAll($criteria) as $drug) {
             $return[] = array('label' => $drug->tallmanlabel, 'value' => $drug->id);
         }
     }
     echo json_encode($return);
 }
Ejemplo n.º 4
0
 /**
  * Tests the update function in the DrugController
  * @param  void
  * @return void
  */
 public function testUpdate()
 {
     // Update the Drug
     Input::replace($this->drugData);
     $drug = new DrugController();
     $drug->store();
     $drugStored = Drug::orderBy('id', 'desc')->take(1)->get()->toArray();
     Input::replace($this->drugUpdate);
     $drug->update($drugStored[0]['id']);
     $drugSaved = Drug::find($drugStored[0]['id']);
     $this->assertEquals($drugSaved->name, $this->drugUpdate['name']);
     $this->assertEquals($drugSaved->description, $this->drugUpdate['description']);
 }
Ejemplo n.º 5
0
 public function district_order_details($delivery, $facility_code = null, $for_facility = null, $rejected_order = null, $view = null)
 {
     $data['title'] = "Order detail View";
     $data['content_view'] = isset($for_facility) ? "facility/facility_data/facility_orders/facility_update_order_v" : "district/moh_orderdetail_v";
     $data['banner_text'] = "Order detail View";
     $data['link'] = "home";
     $data['view'] = $view;
     $data['rejected_order'] = $rejected_order;
     $data['drug_name'] = Drug::get_drug_name();
     $data['quick_link'] = "moh_order_v";
     $data['order_details'] = ordertbl::get_details($delivery)->toArray();
     $data['detail_list'] = Orderdetails::get_order($delivery);
     $this->load->view("template", $data);
 }
Ejemplo n.º 6
0
 public function new_order($note = NULL)
 {
     if (isset($note)) {
         $facility_c = $this->session->userdata('news');
         $data['title'] = "New Order";
         $data['content_view'] = "facility/facility_data/facility_orders/new_order_v";
         $data['banner_text'] = "New Order";
         $data['link'] = "order_management";
         $data['drug_name'] = Drug::getAll();
         $data['facility_order'] = Facility_Transaction_Table::get_commodities_for_ordering($facility_c);
         $data['quick_link'] = "new_order";
         $this->load->view("template", $data);
     } else {
         redirect("stock_management/stock_level/c0N123");
     }
 }
Ejemplo n.º 7
0
 public function actionEditDrug($id)
 {
     return;
     //disabled OE-4474
     if (!($drug = Drug::model()->findByPk($id))) {
         throw new Exception("Drug not found: {$id}");
     }
     $drug->scenario = 'update';
     if (!empty($_POST)) {
         $drug->attributes = $_POST['Drug'];
         if (!$drug->validate()) {
             $errors = $drug->getErrors();
         } else {
             if (!$drug->save()) {
                 throw new Exception("Unable to save drug: " . print_r($drug->getErrors(), true));
             }
             $posted_allergy_ids = array();
             if (isset($_POST['allergies'])) {
                 $posted_allergy_ids = $_POST['allergies'];
             }
             $criteria = new CDbCriteria();
             $criteria->compare('drug_id', $drug->id);
             $allergy_assignments = DrugAllergyAssignment::model()->findAll($criteria);
             $allergy_assignment_ids = array();
             foreach ($allergy_assignments as $allergy_assignment) {
                 $allergy_assignment_ids[] = $allergy_assignment->allergy_id;
             }
             $allergy_assignment_ids_to_delete = array_diff($allergy_assignment_ids, $posted_allergy_ids);
             $posted_allergy_ids_to_assign = array_diff($posted_allergy_ids, $allergy_assignment_ids);
             //add new allergy mappings
             foreach ($posted_allergy_ids_to_assign as $asign) {
                 $allergy_assignment = new DrugAllergyAssignment();
                 $allergy_assignment->drug_id = $drug->id;
                 $allergy_assignment->allergy_id = $asign;
                 $allergy_assignment->save();
             }
             //delete redundant allergy mappings
             foreach ($allergy_assignments as $asigned) {
                 if (in_array($asigned->allergy_id, $allergy_assignment_ids_to_delete)) {
                     $asigned->delete();
                 }
             }
             $this->redirect('/admin/drugs/' . ceil($drug->id / $this->items_per_page));
         }
     }
     $this->render('/admin/editdrug', array('drug' => $drug, 'errors' => @$errors));
 }
Ejemplo n.º 8
0
 public function commoditieshtml()
 {
     $from = $_POST['fromcommodity'];
     $to = $_POST['tocommodity'];
     $facility_Code = $_POST['facilitycode'];
     $id = $this->session->userdata('identity');
     //echo "$from";
     $req_data = array('from' => $from, 'to' => $to);
     $this->session->set_userdata($req_data);
     //$data['title'] = "Commodity Issues Summary";
     $mycount = count(Facility_Issues::getcissues());
     if ($mycount > 0) {
         $data['reports'] = Facility_Issues::getcissues();
         $data['names'] = User::getsome($id);
         $data['drugs'] = Drug::getAll();
         $this->load->view("commodityIssues", $data);
     } else {
         echo '<div class="norecord"></div>';
     }
 }
Ejemplo n.º 9
0
 public function Insert_test()
 {
     $ids = $_POST['kemsaCode'];
     $Available = $_POST['AvStck'];
     $batchN = $_POST['batchNo'];
     $Expiry = $_POST['Exp'];
     //$sNo=$_POST['s11N'];
     $qty = $_POST['Qtyissued'];
     $thedate = $_POST['datepicker'];
     $serviceP = $_POST['Servicepoint'];
     $j = sizeof($ids);
     $count = 0;
     $facilityCode = $facility_c = $this->session->userdata('news');
     $usernow = $this->session->userdata('identity');
     for ($me = 0; $me < $j; $me++) {
         if ($qty[$me] > 0) {
             $count++;
             $mydata = array('facility_code' => $facilityCode, 'kemsa_code' => $ids[$me], 's11_No' => "internal issue", 'batch_no' => $batchN[$me], 'expiry_date' => $Expiry[$me], 'qty_issued' => $qty[$me], 'issued_to' => $serviceP, 'balanceAsof' => $Available[$me], 'date_issued' => date('y-m-d', strtotime($thedate[$me])), 'issued_by' => $usernow);
             $u = new Facility_Issues();
             $u->fromArray($mydata);
             $u->save();
             //echo "$xraws records inserted";
             $q = Doctrine_Query::create()->update('Facility_Stock')->set('balance', '?', $Available[$me])->where("kemsa_code='{$ids[$me]}' AND batch_no='{$batchN[$me]}' and facility_code ='{$facilityCode}'");
             $q->execute();
             $inserttransaction = Doctrine_Manager::getInstance()->getCurrentConnection();
             $inserttransaction->execute("UPDATE `facility_transaction_table` SET total_issues = (SELECT SUM(qty_issued) \n\t\t\tFROM facility_issues WHERE kemsa_code = '{$ids[$me]}' and availability='1' and facility_code='{$facilityCode}')\n                                          WHERE `kemsa_code`= '{$ids[$me]}' and availability='1' and facility_code='{$facilityCode}'; ");
             //echo "$numrows records updated";
             $inserttransaction1 = Doctrine_Manager::getInstance()->getCurrentConnection();
             $inserttransaction1->execute("UPDATE `facility_transaction_table` SET closing_stock = (SELECT SUM(balance)\n\t\t\t FROM facility_stock WHERE kemsa_code = '{$ids[$me]}' and availability='1' and facility_code='{$facilityCode}')\n                                          WHERE `kemsa_code`= '{$ids[$me]}' and availability='1' and facility_code ='{$facilityCode}'; ");
         }
         $data['title'] = "Stock";
         $data['drugs'] = Drug::getAll();
         $data['popout'] = "You have issued {$count} item(s)";
         $data['content_view'] = "issuesnRecpt";
         $data['banner_text'] = "Stock Control Card";
         $data['link'] = "order_management";
         $data['quick_link'] = "stockcontrol_c";
         $this->load->view("template", $data);
     }
 }
 /**
  * Searches across MedicationDrug and Drug models for the given term. If the term only matches
  * on an alias, the alias will be included in the returned label for that entry.
  *
  * Distinguishes between the data types to ensure relationship defined correctly.
  */
 public function actionFindDrug()
 {
     $return = array();
     if (isset($_GET['term']) && ($term = strtolower($_GET['term']))) {
         $criteria = new CDbCriteria();
         $criteria->compare('LOWER(name)', $term, true, 'OR');
         $criteria->compare('LOWER(aliases)', $term, true, 'OR');
         foreach (MedicationDrug::model()->findAll($criteria) as $md) {
             $label = $md->name;
             if (strpos(strtolower($md->name), $term) === false) {
                 $label .= " (" . $md->aliases . ")";
             }
             $return[] = array('name' => $md->name, 'label' => $label, 'value' => $md->id, 'type' => 'md');
         }
         foreach (Drug::model()->active()->findAll($criteria) as $drug) {
             $label = $drug->tallmanlabel;
             if (strpos(strtolower($drug->name), $term) === false) {
                 $label .= " (" . $drug->aliases . ")";
             }
             $return[] = array('name' => $drug->tallmanlabel, 'label' => $label, 'value' => $drug->id, 'type' => 'd');
         }
     }
     echo json_encode($return);
 }
Ejemplo n.º 11
0
echo $form->columns('field');
?>
">

			<input type="hidden" name="drug_id" value="<?php 
echo $medication->drug_id;
?>
"/>
			<div class="field-row data-value" id="medication_drug_name"><?php 
echo $medication->drug_id ? CHtml::encode($medication->drug->label) : "";
?>
</div>

			<div class="field-row">
				<?php 
echo CHtml::dropDownList('drug_select', '', Drug::model()->listBySubspecialty($firm->getSubspecialtyID()), array('empty' => '- Select -'));
?>
			</div>

			<div class="field-row">
				<div class="label"></div>
				<?php 
$this->widget('zii.widgets.jui.CJuiAutoComplete', array('name' => 'drug_autocomplete', 'source' => new CJavaScriptExpression('function (req, res) { $.getJSON(' . json_encode($this->createUrl('medication/finddrug')) . ', req, res); }'), 'options' => array('minLength' => 3, 'focus' => "js:function(e,ui) {\n\t\t\t\t\t\t\t\t\$('#drug_autocomplete').val(ui.item.label);\n\t\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\t}"), 'htmlOptions' => array('placeholder' => 'or search formulary')));
?>
			</div>
		</div>
	</div>

	<?php 
$form->widget('application.widgets.TextField', array('element' => $medication, 'field' => 'dose', 'name' => 'dose'));
?>
Ejemplo n.º 12
0
 /**
  * @param $subspecialty_id
  * @return array
  */
 public function listBySubspecialtyWithCommonMedications($subspecialty_id)
 {
     $criteria = new CDbCriteria();
     $criteria->compare('subspecialty_id', $subspecialty_id);
     $drugs = Drug::model()->with('subspecialtyAssignments')->findAll($criteria);
     $common_medication_drugs = CommonMedications::model()->with('medication_drug')->findAll();
     $return = array();
     foreach ($drugs as $drug) {
         $return[] = array('label' => $drug->name, 'value' => $drug->name, 'id' => $drug->id);
     }
     foreach ($common_medication_drugs as $common_medication_drug) {
         $return[] = array('label' => $common_medication_drug->medication_drug->name, 'value' => $common_medication_drug->medication_drug->name, 'id' => $common_medication_drug->medication_drug->id . '@@M');
     }
     asort($return);
     return CHtml::listData($return, 'id', 'label');
 }
Ejemplo n.º 13
0
 public function index()
 {
     return View::make('statistics.statistics', array('drugs' => Drug::all()));
 }
Ejemplo n.º 14
0
 /**
  * @covers Drug::listBySubspecialty
  * @todo	Implement testListBySubspecialty().
  */
 public function testListBySubspecialty()
 {
     $result = $this->model->listBySubspecialty('1');
     $expected = $this->drugs('drug1')->listBySubspecialty('1');
     $this->assertEquals($result, $expected);
 }
    public function get_expiry()
    {
        //$option=$this->uri->segment(3);
        $i = $_POST['interval'];
        $facility = $this->session->userdata('news');
        $drug_name = Drug::get_drug_name();
        $title = 'test';
        switch ($i) {
            case '6_months':
                //for 6 months
                $date = date('Y-m-d', strtotime('+6 months'));
                $date1 = date('Y-m-d');
                $report = Facility_Stock::getStockouts($date, $facility, $date1);
                $report_name = "Drugs Expiring in next 6 Months ";
                break;
            case '2_months':
                //for 3 months
                $date = date('Y-m-d', strtotime('+2 month'));
                $date1 = date('Y-m-d');
                $report = Facility_Stock::getStockouts($date, $facility, $date1);
                $report_name = "Drugs Expiring in next 2 Months ";
                break;
            case '12_months':
                //for a year
                $date = date('Y-m-d', strtotime('+12 month'));
                $date1 = date('Y-m-d');
                $report = Facility_Stock::getStockouts($date, $facility, $date1);
                $report_name = "Drugs Expiring in next 1 Year ";
                break;
            default:
                $data['stockouts'] = Facility_Stock::expiries($facility);
                $report_name = "Drugs Expiring in next 1 Year ";
        }
        /**************************************set the style for the table****************************************/
        $html_data = '<style>table.data-table {border: 1px solid #DDD;margin: 10px auto;border-spacing: 0px;}
table.data-table th {border: none;color: #036;text-align: center;background-color: #F5F5F5;border: 1px solid #DDD;border-top: none;max-width: 450px;}
table.data-table td, table th {padding: 4px;}
table.data-table td {border: none;border-left: 1px solid #DDD;border-right: 1px solid #DDD;height: 30px;margin: 0px;border-bottom: 1px solid #DDD;}
.col5{background:#C9C299;}</style>';
        $html_data1 = '';
        /*****************************setting up the report*******************************************/
        $html_data1 .= '<table class="data-table"><thead>

			<tr > <th ><strong>Kemsa Code</strong></th>
			<th><strong>Description</strong></th>
			<th><strong>Unit size</strong></th>
			<th><strong>Unit Cost</strong></th>
			<th><strong>Batch No</strong></th>
			<th><strong>Expiry Date</strong></th>
			<th ><strong><b>Units</b></strong></th>
			<th ><strong><b>Stock Worth(Ksh)</b></strong></th>

</tr> </thead><tbody>';
        /*******************************begin adding data to the report*****************************************/
        foreach ($report as $drug) {
            foreach ($drug->Code as $d) {
                $name = $d->Drug_Name;
                $code = $d->Kemsa_Code;
                $unitS = $d->Unit_Size;
                $unitC = $d->Unit_Cost;
            }
            $calc = $drug->balance;
            $html_data1 .= '<tr><td>' . $code . '</td>
							<td>' . $name . '</td>
							<td>' . $unitS . '</td>
							<td>' . $unitC . '</td>
							<td >' . $drug->batch_no . '</td>
							<td>' . $drug->expiry_date . '</td>
							<td >' . $drug->balance . '</td>
							<td >' . $calc * $unitC . '</td>
							</tr>';
            /***********************************************************************************************/
        }
        $html_data1 .= '</tbody></table>';
        $html_data .= $html_data1;
        //$this->generate_pdf($report_name,$title,$html_data);
        $this->getpdf($report_name, $title, $html_data);
    }
Ejemplo n.º 16
0
 public function listBySubspecialty($subspecialty_id)
 {
     $criteria = new CDbCriteria();
     $criteria->compare('subspecialty_id', $subspecialty_id);
     return CHtml::listData(Drug::model()->with('subspecialtyAssignments')->findAll($criteria), 'id', 'label');
 }
Ejemplo n.º 17
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');
 }
 /**
  * Get the common drugs for session firm.
  *
  * @TODO: move this out of the model - it's not the right place for it as it's relying on session information
  *
  * @return Drug[]
  */
 public function commonDrugs()
 {
     $firm = Firm::model()->findByPk(Yii::app()->session['selected_firm_id']);
     $subspecialty_id = $firm->serviceSubspecialtyAssignment->subspecialty_id;
     $site_id = Yii::app()->session['selected_site_id'];
     $params = array(':subSpecialtyId' => $subspecialty_id, ':siteId' => $site_id);
     return Drug::model()->active()->findAll(array('condition' => 'ssd.subspecialty_id = :subSpecialtyId AND ssd.site_id = :siteId', 'join' => 'JOIN site_subspecialty_drug ssd ON ssd.drug_id = t.id', 'order' => 'name', 'params' => $params));
 }
Ejemplo n.º 19
0
    <table class="mt20 mytable" style="width:90%;margin-left:5%">
        <tr>
            <td class="left" style="background-color: #FAE1B3">类别</td>
            <td class="right" style="background-color: #FAE1B3">内容</td>
        </tr>
        <tr>
            <td class="left">批准文号</td>
            <td class="right"><?php 
echo $drug->medicineAccurateNum;
?>
</td>
        </tr>
        <tr>
            <td class="left">药品类别</td>
            <td class="right"><?php 
echo empty($drug->productType) ? '无' : Drug::typeDef()[$drug->productType];
?>
</td>
        </tr>
        <tr>
            <td class="left">通用名称</td>
            <td class="right"><?php 
echo $drug->commonName->name;
?>
</td>
        </tr>
        <tr>
            <td class="left">商品名称</td>
            <td class="right"><?php 
echo $drug->name;
?>
Ejemplo n.º 20
0
 /**
  * Ajax action to search for drugs.
  */
 public function actionDrugList()
 {
     if (Yii::app()->request->isAjaxRequest) {
         $criteria = new CDbCriteria();
         if (isset($_GET['term']) && strlen($term = $_GET['term']) > 0) {
             $criteria->addCondition(array('LOWER(name) LIKE :term', 'LOWER(aliases) LIKE :term'), 'OR');
             $params[':term'] = '%' . strtolower(strtr($term, array('%' => '\\%'))) . '%';
         }
         if (isset($_GET['type_id']) && ($type_id = $_GET['type_id'])) {
             $criteria->addCondition('type_id = :type_id');
             $params[':type_id'] = $type_id;
         }
         if (isset($_GET['preservative_free']) && ($preservative_free = $_GET['preservative_free'])) {
             $criteria->addCondition('preservative_free = 1');
         }
         $criteria->order = 'name';
         // we don't need 'select *' here
         $criteria->select = 'id, tallman, preservative_free';
         $criteria->params = $params;
         $drugs = Drug::model()->active()->findAll($criteria);
         $return = array();
         foreach ($drugs as $drug) {
             $return[] = array('label' => $drug->tallmanlabel, 'value' => $drug->tallman, 'id' => $drug->id);
         }
         echo CJSON::encode($return);
     }
 }
 public function testPositionalParams()
 {
     Drug::model()->updateAll(array('name' => 'foo'), 'id = ?', array(1));
     $this->assertEquals('foo', Drug::model()->findByPk(1)->name);
 }
Ejemplo n.º 22
0
 /**
  * Remove the specified resource from storage (soft delete).
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     //Soft delete the drug
     $drug = Drug::find($id);
     /*$testCategoryInUse = TestType::where('test_category_id', '=', $id)->first();
     		if (empty($testCategoryInUse)) {
     		    // The test category is not in use
     			$testcategory->delete();
     		} else {
     		    // The test category is in use
     		    $url = Session::get('SOURCE_URL');
                 
                 return Redirect::to($url)
     		    	->with('message', trans('messages.failure-test-category-in-use'));
     		}*/
     // redirect
     $url = Session::get('SOURCE_URL');
     return Redirect::to($url)->with('message', trans('messages.success-deleting-drug'));
 }
Ejemplo n.º 23
0
 /**
  * @param integer $drug_id
  * @return boolean Is patient allergic?
  */
 public function hasDrugAllergy($drug_id = null)
 {
     if ($drug_id) {
         if ($this->allergies) {
             $criteria = new CDbCriteria();
             $criteria->select = 't.id';
             $criteria->condition = 'paa.patient_id = :patient_id';
             $join = array();
             $join[] = 'JOIN drug_allergy_assignment daa ON daa.drug_id = t.id';
             $join[] = 'JOIN patient_allergy_assignment paa ON paa.allergy_id = daa.allergy_id';
             $criteria->join = implode(' ', $join);
             $criteria->params = array(':patient_id' => $this->id);
             return (bool) Drug::model()->findByPk($drug_id, $criteria);
         } else {
             return false;
         }
     } else {
         return (bool) $this->allergies;
     }
 }
 public function run()
 {
     //Seed for drugs
     $penicillin = Drug::create(array('name' => "PENICILLIN"));
     $ampicillin = Drug::create(array('name' => "AMPICILLIN"));
     $clindamycin = Drug::create(array('name' => "CLINDAMYCIN"));
     $tetracycline = Drug::create(array('name' => "TETRACYCLINE"));
     $ciprofloxacin = Drug::create(array('name' => "CIPROFLOXACIN"));
     $trimeth = Drug::create(array('name' => "TRIMETHOPRIM/SULFA"));
     $nitrofurantoin = Drug::create(array('name' => "NITROFURANTOIN"));
     $chloramphenicol = Drug::create(array('name' => "CHLORAMPHENICOL"));
     $cefazolin = Drug::create(array('name' => "CEFAZOLIN"));
     $gentamicin = Drug::create(array('name' => "GENTAMICIN"));
     $amoxicillin = Drug::create(array('name' => "AMOXICILLIN-CLAV"));
     $cephalothin = Drug::create(array('name' => "CEPHALOTHIN"));
     $cefuroxime = Drug::create(array('name' => "CEFUROXIME"));
     $cefotaxime = Drug::create(array('name' => "CEFOTAXIME"));
     $piperacillin = Drug::create(array('name' => "PIPERACILLIN"));
     $cefixime = Drug::create(array('name' => "CEFIXIME"));
     $ceftazidime = Drug::create(array('name' => "CEFTAZIDIME"));
     $cefriaxone = Drug::create(array('name' => "CEFRIAXONE"));
     $levofloxacin = Drug::create(array('name' => "LEVOFLOXACIN"));
     $merodenem = Drug::create(array('name' => "MERODENEM"));
     $tazo = Drug::create(array('name' => "PIPERACILLIN/TAZO"));
     $imedenem = Drug::create(array('name' => "IMEDENEM"));
     $oxacillin = Drug::create(array('name' => "OXACILLIN (CEFOXITIN)"));
     $erythromycin = Drug::create(array('name' => "ERYTHROMYCIN"));
     $vancomycin = Drug::create(array('name' => "VANCOMYCIN"));
     $cefoxitin = Drug::create(array('name' => "CEFOXITIN"));
     $tobramycin = Drug::create(array('name' => "TOBRAMYCIN"));
     $sulbactam = Drug::create(array('name' => "AMPICILLIN-SULBACTAM"));
     $this->command->info('Drugs table seeded');
     //Seed for organisims
     $staphylococci = Organism::create(array('name' => "Staphylococci species"));
     $gramnegative = Organism::create(array('name' => "Gram negative cocci"));
     $pseudomonas = Organism::create(array('name' => "Pseudomonas aeruginosa"));
     $enterococcus = Organism::create(array('name' => "Enterococcus species"));
     $pneumoniae = Organism::create(array('name' => "Streptococcus pneumoniae"));
     $streptococcus = Organism::create(array('name' => "Streptococcus species viridans group"));
     $beta = Organism::create(array('name' => "Beta-haemolytic streptococci"));
     $haemophilus = Organism::create(array('name' => "Haemophilus influenzae"));
     $naisseria = Organism::create(array('name' => "Naisseria menengitidis"));
     $salmonella = Organism::create(array('name' => "Salmonella species"));
     $shigella = Organism::create(array('name' => "Shigella"));
     $vibrio = Organism::create(array('name' => "Vibrio cholerae"));
     $grampositive = Organism::create(array('name' => "Gram positive cocci"));
     $this->command->info('Organisms table seeded');
     //  Seed for organism_drugs
     //  Staphylococci species
     DB::table('organism_drugs')->insert(array("organism_id" => $staphylococci->id, "drug_id" => $penicillin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $staphylococci->id, "drug_id" => $oxacillin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $staphylococci->id, "drug_id" => $cefoxitin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $staphylococci->id, "drug_id" => $erythromycin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $staphylococci->id, "drug_id" => $clindamycin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $staphylococci->id, "drug_id" => $trimeth->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $staphylococci->id, "drug_id" => $cefazolin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $staphylococci->id, "drug_id" => $cephalothin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $staphylococci->id, "drug_id" => $chloramphenicol->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $staphylococci->id, "drug_id" => $nitrofurantoin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $staphylococci->id, "drug_id" => $tetracycline->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $staphylococci->id, "drug_id" => $vancomycin->id));
     $this->command->info('Staphylococci species seeded');
     //  Gram negative cocci
     DB::table('organism_drugs')->insert(array("organism_id" => $gramnegative->id, "drug_id" => $ampicillin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $gramnegative->id, "drug_id" => $cefazolin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $gramnegative->id, "drug_id" => $gentamicin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $gramnegative->id, "drug_id" => $amoxicillin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $gramnegative->id, "drug_id" => $cephalothin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $gramnegative->id, "drug_id" => $cefuroxime->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $gramnegative->id, "drug_id" => $cefotaxime->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $gramnegative->id, "drug_id" => $ciprofloxacin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $gramnegative->id, "drug_id" => $trimeth->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $gramnegative->id, "drug_id" => $nitrofurantoin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $gramnegative->id, "drug_id" => $chloramphenicol->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $gramnegative->id, "drug_id" => $tetracycline->id));
     $this->command->info('Gram negative cocci seeded');
     //  Pseudomonas aeruginosa
     DB::table('organism_drugs')->insert(array("organism_id" => $pseudomonas->id, "drug_id" => $ceftazidime->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $pseudomonas->id, "drug_id" => $gentamicin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $pseudomonas->id, "drug_id" => $tobramycin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $pseudomonas->id, "drug_id" => $piperacillin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $pseudomonas->id, "drug_id" => $ciprofloxacin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $pseudomonas->id, "drug_id" => $merodenem->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $pseudomonas->id, "drug_id" => $tazo->id));
     $this->command->info('Pseudomonas aeruginosa seeded');
     //  Enterococcus species
     DB::table('organism_drugs')->insert(array("organism_id" => $enterococcus->id, "drug_id" => $ampicillin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $enterococcus->id, "drug_id" => $gentamicin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $enterococcus->id, "drug_id" => $nitrofurantoin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $enterococcus->id, "drug_id" => $ciprofloxacin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $enterococcus->id, "drug_id" => $tetracycline->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $enterococcus->id, "drug_id" => $chloramphenicol->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $enterococcus->id, "drug_id" => $vancomycin->id));
     $this->command->info('Enterococcus species seeded');
     //  Streptococcus pneumoniae
     DB::table('organism_drugs')->insert(array("organism_id" => $pneumoniae->id, "drug_id" => $penicillin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $pneumoniae->id, "drug_id" => $cefriaxone->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $pneumoniae->id, "drug_id" => $cefuroxime->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $pneumoniae->id, "drug_id" => $erythromycin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $pneumoniae->id, "drug_id" => $trimeth->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $pneumoniae->id, "drug_id" => $chloramphenicol->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $pneumoniae->id, "drug_id" => $tetracycline->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $pneumoniae->id, "drug_id" => $levofloxacin->id));
     $this->command->info('Streptococcus pneumoniae seeded');
     //  Streptococcus species viridans group
     DB::table('organism_drugs')->insert(array("organism_id" => $streptococcus->id, "drug_id" => $penicillin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $streptococcus->id, "drug_id" => $cefriaxone->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $streptococcus->id, "drug_id" => $vancomycin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $streptococcus->id, "drug_id" => $chloramphenicol->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $streptococcus->id, "drug_id" => $clindamycin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $streptococcus->id, "drug_id" => $erythromycin->id));
     $this->command->info('Streptococcus species viridans group seeded');
     //  Beta-haemolytic streptococci
     DB::table('organism_drugs')->insert(array("organism_id" => $beta->id, "drug_id" => $penicillin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $beta->id, "drug_id" => $erythromycin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $beta->id, "drug_id" => $clindamycin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $beta->id, "drug_id" => $cefriaxone->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $beta->id, "drug_id" => $chloramphenicol->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $beta->id, "drug_id" => $vancomycin->id));
     $this->command->info('Beta-haemolytic streptococci seeded');
     //  Haemophilus influenzae
     DB::table('organism_drugs')->insert(array("organism_id" => $haemophilus->id, "drug_id" => $ampicillin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $haemophilus->id, "drug_id" => $trimeth->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $haemophilus->id, "drug_id" => $sulbactam->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $haemophilus->id, "drug_id" => $cefriaxone->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $haemophilus->id, "drug_id" => $chloramphenicol->id));
     $this->command->info('Haemophilus influenzae seeded');
     //  Naisseria menengitidis
     DB::table('organism_drugs')->insert(array("organism_id" => $naisseria->id, "drug_id" => $penicillin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $naisseria->id, "drug_id" => $cefriaxone->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $naisseria->id, "drug_id" => $chloramphenicol->id));
     $this->command->info('Neisseria menengitidis seeded');
     //  Salmonella species
     DB::table('organism_drugs')->insert(array("organism_id" => $salmonella->id, "drug_id" => $ampicillin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $salmonella->id, "drug_id" => $ciprofloxacin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $salmonella->id, "drug_id" => $trimeth->id));
     $this->command->info('Salmonella species seeded');
     //  Shigella
     DB::table('organism_drugs')->insert(array("organism_id" => $shigella->id, "drug_id" => $ampicillin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $shigella->id, "drug_id" => $ciprofloxacin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $shigella->id, "drug_id" => $trimeth->id));
     $this->command->info('Shigella seeded');
     //  Vibrio cholerae
     DB::table('organism_drugs')->insert(array("organism_id" => $vibrio->id, "drug_id" => $ampicillin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $vibrio->id, "drug_id" => $ciprofloxacin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $vibrio->id, "drug_id" => $trimeth->id));
     $this->command->info('Vibrio cholerae seeded');
     //  Gram positive cocci
     DB::table('organism_drugs')->insert(array("organism_id" => $grampositive->id, "drug_id" => $cefoxitin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $grampositive->id, "drug_id" => $clindamycin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $grampositive->id, "drug_id" => $erythromycin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $grampositive->id, "drug_id" => $oxacillin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $grampositive->id, "drug_id" => $penicillin->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $grampositive->id, "drug_id" => $tetracycline->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $grampositive->id, "drug_id" => $trimeth->id));
     DB::table('organism_drugs')->insert(array("organism_id" => $grampositive->id, "drug_id" => $vancomycin->id));
     $this->command->info('Gram positive cocci seeded');
 }
Ejemplo n.º 25
0
 public function historical_stock_take()
 {
     $facility_code = $this->session->userdata('news');
     $data['title'] = "Provide Historical Stock Data";
     $data['content_view'] = "facility/historical_stock_v";
     $data['banner_text'] = "Provide Historical Stock Data";
     $data['quick_link'] = "load_stock";
     $data['link'] = "home";
     $data['drugs'] = Drug::getAll();
     $data['drug_name'] = Drug::get_drug_name();
     $data['drug_categories'] = Drug_Category::getAll();
     $data['historical_data'] = Historical_Stock::load_historical_stock($facility_code);
     $data['quick_link'] = "update_stock_level";
     $this->load->view("template", $data);
 }
Ejemplo n.º 26
0
 /** 
  * @return \yii\db\ActiveQuery 
  */
 public function getDrugs()
 {
     return $this->hasMany(Drug::className(), ['unit_id' => 'unit_id']);
 }
Ejemplo n.º 27
0
 public function newDrug()
 {
     $input = Input::all();
     $drug = new Drug();
     if (Input::has('id')) {
         $drug = Drug::where('id', $input['id'])->first();
     } else {
         $drug->type = $input['type'];
     }
     $drug->name = $input['name'];
     $drug->products = $input['products'];
     $drug->unit = $input['unit'];
     $drug->fixed = 1;
     switch ($drug->type) {
         case '1':
             $drug->morning = $input['morning'];
             $drug->lunch = $input['lunch'];
             $drug->afternoon = $input['afternoon'];
             $drug->night = $input['night'];
             break;
         case '2':
         case '3':
         case '4':
             $drug->special = $input['special'];
             break;
         default:
             break;
     }
     $drug->save();
     return Response::json(array('drug' => $drug));
 }
Ejemplo n.º 28
0
 public function get_leadtime_chart_ajax()
 {
     $district = $this->session->userdata('district1');
     $data['facilities'] = Facilities::getFacilities($district);
     $this->load->view("district/ajax_view/leadtime_v", $data);
     $data['drugs'] = Drug::getAll();
 }