Exemple #1
0
 function getGapVisDocPage($docID, $pageID, $paraID = false, $specificPlace = false)
 {
     $output = false;
     $db = $this->startDB();
     $paraTerm = " ";
     if ($paraID != false) {
         $paraTerm = " AND gt.paraID = '{$paraID} ' ";
     }
     $sql = "SELECT gt.id, gt.token, gt.sentID, gt.pws, grefs.uriID, gt.paraID, gt.sectionID\n\t\t\t\t\t FROM gap_tokens AS gt\n\t\t\t\t\t LEFT JOIN gap_gazrefs AS grefs ON (grefs.tokenID = gt.id AND grefs.active = 1)\n\t\t\t\t\t WHERE gt.docID = {$docID} AND gt.pageID = {$pageID}\n\t\t\t\t\t {$paraTerm}\n\t\t\t\t\t ORDER BY gt.id\n\t\t\t\t\t ";
     $result = $db->fetchAll($sql, 2);
     if ($result) {
         $this->sectionID = $result[0]["sectionID"];
         $output = "";
         $firstToken = true;
         $lastParaID = false;
         $prevToken = false;
         $issuesObj = new Issues();
         foreach ($result as $row) {
             $paraID = $row["paraID"];
             $token = $row["token"];
             $tokenID = $row["id"];
             if (strlen($row["uriID"]) > 0) {
                 if (!$specificPlace) {
                     $token = "<span data-token-id=\"" . $tokenID . "\" class=\"place\" data-place-id=\"" . $row["uriID"] . "\" >" . $token . "</span>";
                     /*
                     if($issuesObj->checkTokenIssues($tokenID)){
                     	 $token .= "<sup><a href=\"../report/token-issues/".$tokenID."\" target=\"_blank\"  >[**]</a></sup>";
                     }
                     */
                     if ($issuesObj->checkPlaceIssues($row["uriID"])) {
                         $token .= "<sup><a href=\"../report/place-issues/" . $row["uriID"] . "\" target=\"_blank\" title=\"Problem reported on this place\" >[*]</a></sup>";
                     }
                 } elseif ($specificPlace == $tokenID) {
                     $token = "<span id=\"t-" . $tokenID . "\" class=\"place\">" . $token . "</span>";
                 }
             }
             if ($this->highlightToken == $tokenID) {
                 $token = "<span class=\"highlight\">{$token}</span>";
             }
             if ($lastParaID != $paraID) {
                 $lastParaID = $paraID;
                 if ($prevToken == "." || $prevToken == "!" || $prevToken == "?" || $prevToken == '”') {
                     $output .= "<br/><br/>";
                 }
             }
             if (!$row["pws"] || $firstToken) {
                 $output .= $token;
             } else {
                 $output .= " " . $token;
             }
             $prevToken = $token;
             $firstToken = false;
         }
         $output = $this->GapVisTextDecoding($output);
     }
     return $output;
 }
 /**
  * Copy all messages from source to this object
  * @param Issues $issues
  */
 public function import(Issues $issues)
 {
     foreach ($issues->types() as $type) {
         $source = $issues->messages($type);
         $destination = $this->messages($type);
         foreach ($source as $message) {
             $destination->add($message);
         }
     }
 }
 public function rcopia_sync($practice_id)
 {
     // Update Notification
     $row0 = Practiceinfo::find($practice_id);
     Config::set('app.timezone', $row0->timezone);
     if ($row0->rcopia_update_notification_lastupdate == "") {
         $date0 = date('m/d/Y H:i:s', time());
     } else {
         $date0 = $row0->rcopia_update_notification_lastupdate;
     }
     $xml0 = "<Request><Command>update_notification</Command>";
     $xml0 .= "<LastUpdateDate>" . $date0 . "</LastUpdateDate>";
     $xml0 .= "</Request></RCExtRequest>";
     $result0 = $this->rcopia($xml0, $practice_id);
     $response0 = new SimpleXMLElement($result0);
     if ($response0->Response->Status == "error") {
         $description0 = $response0->Response->Error->Text . "";
         $data0a = array('action' => 'update_notification', 'pid' => '0', 'extensions_name' => 'rcopia', 'description' => $description0, 'practice_id' => $practice_id);
         DB::table('extensions_log')->insert($data0a);
     } else {
         $last_update_date = $response0->Response->LastUpdateDate . "";
         $number = $response0->Response->NotificationList->Number . "";
         if ($number != "0") {
             foreach ($response0->Response->NotificationList->Notification as $notification) {
                 $type = $notification->Type . "";
                 $status = $notification->Status . "";
                 $rcopia_username = $notification->Provider->Username . "";
                 $medication_message = $notification->Sig->Drug->BrandName . "";
                 $form_message = $notification->Sig->Drug->Form . "";
                 $dose_message = $notification->Sig->Drug->Strength . "";
                 $sig_message = $notification->Sig->Dose . "";
                 $sig1_message = $notification->Sig->DoseUnit . "";
                 $route_message = $notification->Sig->Route . "";
                 $frequency_message = $notification->Sig->DoseTiming . "";
                 $instructions_message = $notification->Sig->DoseOther . "";
                 $quantity_message = $notification->Sig->Quantity . "";
                 $quantity_message1 = $notification->Sig->QuantityUnit . "";
                 $refill_message = $notification->Sig->Refills . "";
                 $pharmacy_message = $notification->Pharmacy->Name . "";
                 $medication_message = "Medication: " . $medication_message . ", " . $form_message . ", " . $dose_message;
                 $medication_message .= "\nInstructions: " . $sig_message . " " . $sig1_message . " " . $route_message . ", " . $frequency_message;
                 $medication_message .= "\nOther Instructions: " . $instructions_message;
                 $medication_message .= "\nQuantity: " . $quantity_message . " " . $quantity_message1;
                 $medication_message .= "\nRefills: " . $refill_message;
                 $medication_message .= "\nPharmacy: " . $pharmacy_message;
                 $messages_pid = $notification->Patient->ExternalID . "";
                 $sender = $notification->Sender . "";
                 $title = $notification->Title . "";
                 $text = $notification->Text . "";
                 $full_text = "From: " . $sender . "\nMessage: " . $text;
                 $patient_row = Demographics::where('pid', '=', $messages_pid)->first();
                 $dob_message = date("m/d/Y", strtotime($patient_row->DOB));
                 $patient_name = $patient_row->lastname . ', ' . $patient_row->firstname . ' (DOB: ' . $dob_message . ') (ID: ' . $messages_pid . ')';
                 $provider_row = DB::table('users')->join('providers', 'providers.id', '=', 'users.id')->select('users.lastname', 'users.firstname', 'users.title', 'users.id')->where('providers.rcopia_username', '=', $rcopia_username)->first();
                 if ($provider_row) {
                     $provider_name = $provider_row->firstname . " " . $provider_row->lastname . ", " . $provider_row->title . " (" . $provider_row->id . ")";
                     if ($type == "refill") {
                         $subject = "Refill Request for " . $patient_name;
                         $body = $medication_message;
                     }
                     if ($type == "message") {
                         $subject = $title;
                         $body = $full_text;
                     }
                     $data_message = array('pid' => $messages_pid, 'message_to' => $provider_name, 'message_from' => $provider_row->id, 'subject' => $subject, 'body' => $body, 'patient_name' => $patient_name, 'status' => 'Sent', 'mailbox' => $provider_row->id, 'practice_id' => $practice_id);
                     DB::table('messaging')->insert($data_message);
                     $this->audit('Add');
                 }
             }
         }
         $data_update = array('rcopia_update_notification_lastupdate' => $last_update_date);
         DB::table('practiceinfo')->where('practice_id', '=', $practice_id)->update($data_update);
     }
     // Send Patient
     $query1 = Demographics::where('rcopia_sync', '=', 'n')->get();
     if ($query1) {
         foreach ($query1 as $row1) {
             if ($this->check_practice_id($row1->pid, $practice_id)) {
                 $dob = explode(" ", $row1->DOB);
                 $dob1 = explode("-", $dob[0]);
                 $dob_final = $dob1[1] . "/" . $dob1[2] . "/" . $dob1[0];
                 $xml1 = "<Request><Command>send_patient</Command><Synchronous>y</Synchronous><CheckEligibility>y</CheckEligibility>";
                 $xml1 .= "<PatientList><Patient>";
                 $xml1 .= "<FirstName>" . $row1->firstname . "</FirstName>";
                 $xml1 .= "<LastName>" . $row1->lastname . "</LastName>";
                 $xml1 .= "<MiddleName>" . $row1->middle . "</MiddleName>";
                 $xml1 .= "<DOB>" . $dob_final . "</DOB>";
                 $xml1 .= "<Sex>" . $row1->sex . "</Sex>";
                 $xml1 .= "<ExternalID>" . $row1->pid . "</ExternalID>";
                 $xml1 .= "<HomePhone>" . $row1->phone_home . "</HomePhone>";
                 $xml1 .= "<WorkPhone>" . $row1->phone_work . "</WorkPhone>";
                 $xml1 .= "<Address1>" . $row1->address . "</Address1>";
                 $xml1 .= "<Address2></Address2>";
                 $xml1 .= "<City>" . $row1->city . "</City>";
                 $xml1 .= "<State>" . $row1->state . "</State>";
                 $xml1 .= "<Zip>" . $row1->zip . "</Zip>";
                 $xml1 .= "</Patient></PatientList></Request></RCExtRequest>";
                 $result1 = $this->rcopia($xml1, $practice_id);
                 $response1 = new SimpleXMLElement($result1);
                 $status1 = $response1->Response->PatientList->Patient->Status . "";
                 if ($status1 == "error") {
                     $description1 = $response1->Response->PatientList->Patient->Error->Text . "";
                     $data1a = array('action' => 'send_patient', 'pid' => $row1->pid, 'extensions_name' => 'rcopia', 'description' => $description1, 'practice_id' => $practice_id);
                     DB::table('extensions_log')->insert($data1a);
                 } else {
                     $data1b = array('rcopia_sync' => 'y');
                     DB::table('demographics')->where('pid', '=', $row1->pid)->update($data1b);
                     $this->audit('Update');
                 }
             }
         }
     }
     // Send Allergy
     $query2 = Allergies::where('rcopia_sync', '=', 'n')->where('allergies_date_inactive', '=', '0000-00-00 00:00:00')->get();
     if ($query2) {
         foreach ($query2 as $row2) {
             if ($this->check_practice_id($row2->pid, $practice_id)) {
                 $da = explode(" ", $row2->allergies_date_active);
                 $da1 = explode("-", $da[0]);
                 $da_final = $da1[1] . "/" . $da1[2] . "/" . $da1[0];
                 $xml2 = "<Request><Command>send_allergy</Command><Synchronous>y</Synchronous>";
                 $xml2 .= "<AllergyList><Allergy>";
                 $xml2 .= "<ExternalID>" . $row2->allergies_id . "</ExternalID>";
                 $xml2 .= "<Patient><ExternalID>" . $row2->pid . "</ExternalID></Patient>";
                 $xml2 .= "<Allergen><Name>" . $row2->allergies_med . "</Name>";
                 $xml2 .= "<Drug><NDCID>" . $row2->meds_ndcid . "</NDCID></Drug></Allergen>";
                 $xml2 .= "<Reaction>" . $row2->allergies_reaction . "</Reaction>";
                 $xml2 .= "<OnsetDate>" . $da_final . "</OnsetDate>";
                 $xml2 .= "</Allergy></AllergyList></Request></RCExtRequest>";
                 $result2 = $this->rcopia($xml2, $practice_id);
                 $response2 = new SimpleXMLElement($result2);
                 $status2 = $response2->Response->AllergyList->Allergy->Status . "";
                 if ($status2 == "error") {
                     $description2 = $response2->Response->AllergyList->Allergy->Error->Text . "";
                     $data2a = array('action' => 'send_allergy', 'pid' => $row2->pid, 'extensions_name' => 'rcopia', 'description' => $description2, 'practice_id' => $practice_id);
                     DB::table('extensions_log')->insert($data2a);
                     if ($description2 == "Can find neither name, Rcopia ID, or NDC ID for drug.") {
                         $data2c = array('rcopia_sync' => 'ye');
                         DB::table('allergies')->where('allergies_id', '=', $row2->allergies_id)->update($data2c);
                         $this->audit('Update');
                     }
                 } else {
                     $data2b = array('rcopia_sync' => 'y');
                     DB::table('allergies')->where('allergies_id', '=', $row2->allergies_id)->update($data2b);
                     $this->audit('Update');
                 }
             }
         }
     }
     //Send Medication
     $query3 = Rx_list::where('rcopia_sync', '=', 'n')->where('rxl_date_inactive', '=', '0000-00-00 00:00:00')->where('rxl_date_old', '=', '0000-00-00 00:00:00')->get();
     if ($query3) {
         foreach ($query3 as $row3) {
             if ($this->check_practice_id($row3->pid, $practice_id)) {
                 $dm = explode(" ", $row3->rxl_date_active);
                 $dm1 = explode("-", $dm[0]);
                 $dm_final = $dm1[1] . "/" . $dm1[2] . "/" . $dm1[0];
                 if ($row3->rxl_due_date != '') {
                     $dn = explode(" ", $row3->rxl_due_date);
                     $dn1 = explode("-", $dn[0]);
                     $dn_final = $dn1[1] . "/" . $dn1[2] . "/" . $dn1[0];
                 } else {
                     $dn_final = "";
                 }
                 if ($row3->rxl_ndcid != '') {
                     $ndcid = $row3->rxl_ndcid;
                 } else {
                     $ndcid = '';
                 }
                 $medication_parts1 = explode(", ", $row3->rxl_medication);
                 $generic_name = $medication_parts1[0];
                 if (isset($medication_parts[1])) {
                     $form = $medication_parts1[1];
                 } else {
                     $form = '';
                 }
                 $strength = $row3->rxl_dosage . " " . $row3->rxl_dosage_unit;
                 if ($row3->rxl_sig != '') {
                     if (strpos($row3->rxl_sig, ' ') !== false) {
                         $sig_parts1 = explode(" ", $row3->rxl_sig);
                         $dose = $sig_parts1[0];
                         $dose_unit = $sig_parts1[1];
                     } else {
                         $dose = $row3->rxl_sig;
                         $dose_unit = '';
                     }
                 } else {
                     $dose = '';
                     $dose_unit = '';
                 }
                 if ($row3->rxl_quantity != '') {
                     if (strpos($row3->rxl_quantity, ' ') !== false) {
                         $quantity_parts1 = explode(" ", $row3->rxl_quantity);
                         $quantity = $quantity_parts1[0];
                         $quantity_unit = $quantity_parts1[1];
                     } else {
                         $quantity = $row3->rxl_quantity;
                         $quantity_unit = '';
                     }
                 } else {
                     $quantity = '';
                     $quantity_unit = '';
                 }
                 if ($row3->rxl_daw != '') {
                     $daw = 'n';
                 } else {
                     $daw = 'y';
                 }
                 $xml3 = "<Request><Command>send_medication</Command><Synchronous>y</Synchronous>";
                 $xml3 .= "<MedicationList><Medication>";
                 $xml3 .= "<ExternalID>" . $row3->rxl_id . "</ExternalID>";
                 $xml3 .= "<Patient><ExternalID>" . $row3->pid . "</ExternalID></Patient>";
                 $xml3 .= "<Sig>";
                 $xml3 .= "<Drug><NDCID>" . $ndcid . "</NDCID>";
                 $xml3 .= "<GenericName>" . $generic_name . "</GenericName>";
                 $xml3 .= "<Form>" . $form . "</Form>";
                 $xml3 .= "<Strength>" . $strength . "</Strength></Drug>";
                 $xml3 .= "<Dose>" . $dose . "</Dose>";
                 $xml3 .= "<DoseUnit>" . $dose_unit . "</DoseUnit>";
                 $xml3 .= "<Route>" . $row3->rxl_route . "</Route>";
                 $xml3 .= "<DoseTiming>" . $row3->rxl_frequency . "</DoseTiming>";
                 $xml3 .= "<DoseOther>" . $row3->rxl_instructions . "</DoseOther>";
                 $xml3 .= "<Quantity>" . $quantity . "</Quantity>";
                 $xml3 .= "<QuantityUnit>" . $quantity_unit . "</QuantityUnit>";
                 $xml3 .= "<Refills>" . $row3->rxl_refill . "</Refills>";
                 $xml3 .= "<SubstitutionPermitted>" . $daw . "</SubstitutionPermitted>";
                 $xml3 .= "</Sig>";
                 $xml3 .= "<StartDate>" . $dm_final . "</StartDate>";
                 $xml3 .= "<StopDate>" . $dn_final . "</StopDate>";
                 $xml3 .= "</Medication></MedicationList></Request></RCExtRequest>";
                 $result3 = $this->rcopia($xml3, $practice_id);
                 $response3 = new SimpleXMLElement($result3);
                 $status3 = $response3->Response->MedicationList->Medication->Status . "";
                 if ($status3 == "error") {
                     $description3 = $response3->Response->MedicationList->Medication->Error->Text . "";
                     $data3a = array('action' => 'send_medication', 'pid' => $row3->pid, 'extensions_name' => 'rcopia', 'description' => $description3, 'practice_id' => $practice_id);
                     DB::table('extensions_log')->insert($data3a);
                 } else {
                     $data3b = array('rcopia_sync' => 'y');
                     DB::table('rx_list')->where('rxl_id', '=', $row3->rxl_id)->update($data3b);
                     $this->audit('Update');
                 }
             }
         }
     }
     //Send Problem List
     $query4 = Issues::where('rcopia_sync', '=', 'n')->where('issue_date_inactive', '=', '0000-00-00 00:00:00')->get();
     if ($query4) {
         foreach ($query4 as $row4) {
             if ($this->check_practice_id($row4->pid, $practice_id)) {
                 $di = explode(" [", $row4->issue);
                 $code = str_replace("]", "", $di[1]);
                 $xml4 = "<Request><Command>send_problem</Command><Synchronous>y</Synchronous>";
                 $xml4 .= "<ProblemList><Problem>";
                 $xml4 .= "<ExternalID>" . $row4->issue_id . "</ExternalID>";
                 $xml4 .= "<Patient><ExternalID>" . $row4->pid . "</ExternalID></Patient>";
                 $xml4 .= "<Code>" . $code . "</Code>";
                 $xml4 .= "<Description>" . $di[0] . "</Description>";
                 $xml4 .= "</Problem></ProblemList></Request></RCExtRequest>";
                 $result4 = $this->rcopia($xml4, $practice_id);
                 $response4 = new SimpleXMLElement($result4);
                 $status4 = $response4->Response->ProblemList->Problem->Status . "";
                 if ($status4 == "error") {
                     $description4 = $response4->Response->ProblemList->Problem->Error->Text . "";
                     $data4a = array('action' => 'send_problem', 'pid' => $row4->pid, 'extensions_name' => 'rcopia', 'description' => $description4, 'practice_id' => $practice_id);
                     DB::table('extensions_log')->insert($data4a);
                 } else {
                     $data4b = array('rcopia_sync' => 'y');
                     DB::table('issues')->where('issue_id', '=', $row4->issue_id)->update($data4b);
                     $this->audit('Update');
                 }
             }
         }
     }
     //Delete Allergy
     $query5 = Allergies::where('rcopia_sync', '=', 'nd')->orWhere('rcopia_sync', '=', 'nd1')->get();
     if ($query5) {
         foreach ($query5 as $row5) {
             if ($this->check_practice_id($row5->pid, $practice_id)) {
                 $dda = explode(" ", $row5->allergies_date_active);
                 $daa1 = explode("-", $dda[0]);
                 $dda_final = $dda1[1] . "/" . $dda1[2] . "/" . $dda1[0];
                 $xml5 = "<Request><Command>send_allergy</Command><Synchronous>y</Synchronous>";
                 $xml5 .= "<AllergyList><Allergy><Deleted>y</Deleted>";
                 $xml5 .= "<ExternalID>" . $row5->allergies_id . "</ExternalID>";
                 $xml5 .= "<Patient><ExternalID>" . $row5->pid . "</ExternalID></Patient>";
                 $xml5 .= "<Allergen><Name>" . $row5->allergies_med . "</Name>";
                 $xml5 .= "<Drug><NDCID>" . $row5->meds_ndcid . "</NDCID></Drug></Allergen>";
                 $xml5 .= "<Reaction>" . $row5->allergies_reaction . "</Reaction>";
                 $xml5 .= "<OnsetDate>" . $dda_final . "</OnsetDate>";
                 $xml5 .= "</Allergy></AllergyList></Request></RCExtRequest>";
                 $result5 = $this->rcopia($xml5, $practice_id);
                 $response5 = new SimpleXMLElement($result5);
                 $status5 = $response5->Response->AllergyList->Allergy->Status . "";
                 if ($status5 == "error") {
                     $description5 = $response5->Response->AllergyList->Allergy->Error->Text . "";
                     $data5a = array('action' => 'delete_allergy', 'pid' => $row5->pid, 'extensions_name' => 'rcopia', 'description' => $description5, 'practice_id' => $practice_id);
                     DB::table('extensions_log')->insert($data5a);
                     $data5b = array('rcopia_sync' => 'y');
                     DB::table('allergies')->where('pid', $row5->pid)->update($data5b);
                     $this->audit('Update');
                 } else {
                     $data5b = array('rcopia_sync' => 'y');
                     DB::table('allergies')->where('allergies_id', $row5->allergies_id)->update($data5b);
                     $this->audit('Update');
                 }
             }
         }
     }
     //Delete Medication
     $query6 = Rx_list::where('rcopia_sync', '=', 'nd')->orWhere('rcopia_sync', '=', 'nd1')->get();
     if ($query6) {
         foreach ($query6 as $row6) {
             if ($this->check_practice_id($row6->pid, $practice_id)) {
                 $ddm = explode(" ", $row6->rxl_date_active);
                 $ddm1 = explode("-", $ddm[0]);
                 $ddm_final = $ddm1[1] . "/" . $ddm1[2] . "/" . $ddm1[0];
                 if ($row3->rxl_due_date != '') {
                     $ddn = explode(" ", $row6->rxl_due_date);
                     $ddn1 = explode("-", $ddn[0]);
                     $ddn_final = $ddn1[1] . "/" . $ddn1[2] . "/" . $ddn1[0];
                 } else {
                     $ddn_final = "";
                 }
                 if ($row6->rxl_ndcid != '') {
                     $ndcid1 = $row6->rxl_ndcid;
                     $generic_name1 = '';
                     $form1 = '';
                     $strength1 = '';
                 } else {
                     $ndcid1 = '';
                     $medication_parts2 = explode(", ", $row6->rxl_medication);
                     if (count($medication_parts2) > 1) {
                         $generic_name1 = $medication_parts2[0];
                         $form1 = $medication_parts2[1];
                     } else {
                         $generic_name1 = $medication_parts2[0];
                         $form1 = '';
                     }
                     $strength1 = $row6->rxl_dosage . " " . $row6->rxl_dosage_unit;
                 }
                 $sig_parts2 = explode(" ", $row6->rxl_sig);
                 if (count($sig_parts2) > 1) {
                     $dose = $sig_parts2[0];
                     $doseunit = $sig_parts2[1];
                 } else {
                     $dose = $sig_parts2[0];
                     $doseunit = '';
                 }
                 if ($row6->rxl_quantity != '') {
                     if (strpos($row6->rxl_quantity, ' ') !== false) {
                         $quantity_parts2 = explode(" ", $row6->rxl_quantity);
                         $quantity1 = $quantity_parts2[0];
                         $quantity_unit1 = $quantity_parts2[1];
                     } else {
                         $quantity1 = $row6->rxl_quantity;
                         $quantity_unit1 = '';
                     }
                 } else {
                     $quantity1 = '';
                     $quantity_unit1 = '';
                 }
                 if ($row6->rxl_daw != '') {
                     $daw1 = 'n';
                 } else {
                     $daw1 = 'y';
                 }
                 $xml6 = "<Request><Command>send_medication</Command><Synchronous>y</Synchronous>";
                 $xml6 .= "<MedicationList><Medication><Deleted>y</Deleted>";
                 $xml6 .= "<ExternalID>" . $row6->rxl_id . "</ExternalID>";
                 $xml6 .= "<Patient><ExternalID>" . $row6->pid . "</ExternalID></Patient>";
                 $xml6 .= "<Sig>";
                 $xml6 .= "<Drug><NDCID>" . $ndcid1 . "</NDCID>";
                 $xml6 .= "<GenericName>" . $generic_name1 . "</GenericName>";
                 $xml6 .= "<Form>" . $form1 . "</Form>";
                 $xml6 .= "<Strength>" . $strength1 . "</Strength></Drug>";
                 $xml6 .= "<Dose>" . $dose . "</Dose>";
                 $xml6 .= "<DoseUnit>" . $doseunit . "</DoseUnit>";
                 $xml6 .= "<Route>" . $row6->rxl_route . "</Route>";
                 $xml6 .= "<DoseTiming>" . $row6->rxl_frequency . "</DoseTiming>";
                 $xml6 .= "<DoseOther>" . $row6->rxl_instructions . "</DoseOther>";
                 $xml6 .= "<Quantity>" . $quantity1 . "</Quantity>";
                 $xml6 .= "<QuantityUnit>" . $quantity_unit1 . "</QuantityUnit>";
                 $xml6 .= "<Refills>" . $row6->rxl_refill . "</Refills>";
                 $xml6 .= "<SubstitutionPermitted>" . $daw1 . "</SubstitutionPermitted>";
                 $xml6 .= "</Sig>";
                 $xml6 .= "<StartDate>" . $ddm_final . "</StartDate>";
                 $xml6 .= "<StopDate>" . $ddn_final . "</StopDate>";
                 $xml6 .= "</Medication></MedicationList></Request></RCExtRequest>";
                 $result6 = $this->rcopia($xml6, $practice_id);
                 $response6 = new SimpleXMLElement($result6);
                 $status6 = $response6->Response->MedicationList->Medication->Status . "";
                 if ($status6 == "error") {
                     $description6 = $response3->Response->MedicationList->Medication->Error->Text . "";
                     $data6a = array('action' => 'delete_medication', 'pid' => $row6->pid, 'extensions_name' => 'rcopia', 'description' => $description6, 'practice_id' => $practice_id);
                     DB::table('extensions_log')->insert($data6a);
                     $data6b = array('rcopia_sync' => 'y');
                     DB::table('rx_list')->where('pid', '=', $row6->pid)->update($data6b);
                     $this->audit('Update');
                 } else {
                     $data6b = array('rcopia_sync' => 'y');
                     DB::table('rx_list')->where('rxl_id', '=', $row6->rxl_id)->update($data6b);
                     $this->audit('Update');
                 }
             }
         }
     }
     //Delete Problem List
     $query7 = Issues::where('rcopia_sync', '=', 'nd')->orWhere('rcopia_sync', '=', 'nd1')->get();
     if ($query7) {
         foreach ($query7 as $row7) {
             if ($this->check_practice_id($row7->pid, $practice_id)) {
                 $ddi = explode(" [", $row7->issue);
                 $code1 = str_replace("]", "", $ddi[1]);
                 $xml7 = "<Request><Command>send_problem</Command><Synchronous>y</Synchronous>";
                 $xml7 .= "<ProblemList><Problem><Deleted>y</Deleted>";
                 $xml7 .= "<ExternalID>" . $row7->issue_id . "</ExternalID>";
                 $xml7 .= "<Patient><ExternalID>" . $row7->pid . "</ExternalID></Patient>";
                 $xml7 .= "<Code>" . $code1 . "</Code>";
                 $xml7 .= "<Description>" . $ddi[0] . "</Description>";
                 $xml7 .= "</Problem></ProblemList></Request></RCExtRequest>";
                 $result7 = $this->rcopia($xml7, $practice_id);
                 $response7 = new SimpleXMLElement($result7);
                 $status7 = $response7->Response->ProblemList->Problem->Status . "";
                 if ($status7 == "error") {
                     $description7 = $response7->Response->ProblemList->Problem->Error->Text . "";
                     $data7a = array('action' => 'delete_problem', 'pid' => $row7->pid, 'extensions_name' => 'rcopia', 'description' => $description7, 'practice_id' => $practice_id);
                     DB::table('extensions_log')->insert($data7a);
                     $data7b = array('rcopia_sync' => 'y');
                     DB::table('issues')->where('pid', '=', $row7->pid)->update($data7b);
                     $this->audit('Update');
                 } else {
                     $data7b = array('rcopia_sync' => 'y');
                     DB::table('issues')->where('issue_id', '=', $row7->issue_id)->update($data7b);
                     $this->audit('Update');
                 }
             }
         }
     }
 }
 public function postCopyIssues()
 {
     $query = Issues::where('pid', '=', Session::get('pid'))->where('issue_date_inactive', '=', '0000-00-00 00:00:00')->get();
     if ($query) {
         $result = '';
         foreach ($query as $row) {
             $result .= $row->issue . ', ' . date('Y-m-d', $this->human_to_unix($row->issue_date_active)) . ';';
         }
         echo $result;
     } else {
         echo 'No';
     }
 }
Exemple #5
0
        echo -1;
        return;
        // 必须项为空
    }
    // 解json,查看格式是否正确
    $origin = json_decode($origin, true);
    $target = json_decode($target, true);
    if (!$origin || !$target) {
        echo -2;
        return;
    }
    // 重新encode成json字符串,用来存储
    $origin = json_encode($origin);
    $target = json_encode($target);
    $id = md5($origin . $target);
    $issue = new Issues();
    $issue->id = $id;
    $issue->ip = $ip;
    $issue->origin = $origin;
    $issue->target = $target;
    $issue->console = $console;
    $issue->solved = 0;
    $issue->time = time();
    if ($issue->create() === false) {
        echo -3 . '|' . $id;
        return;
        // 报单已存在
    }
    echo $id;
});
/**
 public function getHistory($id)
 {
     $myissues = Issues::find_by_sql("SELECT * FROM issues WHERE issue_mem_id=" . $id);
     return $myissues;
 }
 protected function page_ccr($pid)
 {
     $data['patientInfo'] = Demographics::find($pid);
     $data['dob'] = date('m/d/Y', $this->human_to_unix($data['patientInfo']->DOB));
     $data['insuranceInfo'] = '';
     $query_in = Insurance::where('pid', '=', $pid)->where('insurance_plan_active', '=', 'Yes')->get();
     if ($query_in) {
         foreach ($query_in as $row_in) {
             $data['insuranceInfo'] .= $row_in->insurance_plan_name . '; ID: ' . $row_in->insurance_id_num . '; Group: ' . $row_in->insurance_group . '; ' . $row_in->insurance_insu_lastname . ', ' . $row_in->insurance_insu_firstname . '<br><br>';
         }
     }
     $body = 'Active Issues:<br />';
     $query = Issues::where('pid', '=', $pid)->where('issue_date_inactive', '=', '0000-00-00 00:00:00')->get();
     if ($query) {
         $body .= '<ul>';
         foreach ($query as $row) {
             $body .= '<li>' . $row->issue . '</li>';
         }
         $body .= '</ul>';
     } else {
         $body .= 'None.';
     }
     $body .= '<hr />Active Medications:<br />';
     $query1 = Rx_list::where('pid', '=', $pid)->where('rxl_date_inactive', '=', '0000-00-00 00:00:00')->where('rxl_date_old', '=', '0000-00-00 00:00:00')->get();
     if ($query1) {
         $body .= '<ul>';
         foreach ($query1 as $row1) {
             if ($row1->rxl_sig == '') {
                 $body .= '<li>' . $row1->rxl_medication . ' ' . $row1->rxl_dosage . ' ' . $row1->rxl_dosage_unit . ', ' . $row1->rxl_instructions . ' for ' . $row1->rxl_reason . '</li>';
             } else {
                 $body .= '<li>' . $row1->rxl_medication . ' ' . $row1->rxl_dosage . ' ' . $row1->rxl_dosage_unit . ', ' . $row1->rxl_sig . ' ' . $row1->rxl_route . ' ' . $row1->rxl_frequency . ' for ' . $row1->rxl_reason . '</li>';
             }
         }
         $body .= '</ul>';
     } else {
         $body .= 'None.';
     }
     $body .= '<hr />Immunizations:<br />';
     $query2 = Immunizations::where('pid', '=', $pid)->orderBy('imm_immunization', 'asc')->orderBy('imm_sequence', 'asc')->get();
     if ($query2) {
         $body .= '<ul>';
         foreach ($query2 as $row2) {
             $sequence = '';
             if ($row2->imm_sequence == '1') {
                 $sequence = ', first,';
             }
             if ($row2->imm_sequence == '2') {
                 $sequence = ', second,';
             }
             if ($row2->imm_sequence == '3') {
                 $sequence = ', third,';
             }
             if ($row2->imm_sequence == '4') {
                 $sequence = ', fourth,';
             }
             if ($row2->imm_sequence == '5') {
                 $sequence = ', fifth,';
             }
             $body .= '<li>' . $row2->imm_immunization . $sequence . ' given on ' . date('F jS, Y', $this->human_to_unix($row2->imm_date)) . '</li>';
         }
         $body .= '</ul>';
     } else {
         $body .= 'None.';
     }
     $body .= '<hr />Allergies:<br />';
     $query3 = Allergies::where('pid', '=', $pid)->where('allergies_date_inactive', '=', '0000-00-00 00:00:00')->get();
     if ($query3) {
         $body .= '<ul>';
         foreach ($query3 as $row3) {
             $body .= '<li>' . $row3->allergies_med . ' - ' . $row3->allergies_reaction . '</li>';
         }
         $body .= '</ul>';
     } else {
         $body .= 'No known allergies.';
     }
     $body .= '<br />Printed by ' . Session::get('displayname') . '.';
     $data['letter'] = $body;
     return View::make('pdf.ccr_page', $data);
 }
Exemple #8
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Issues::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public function postIssuesList($mobile = false)
 {
     $query = Issues::where('pid', '=', Session::get('pid'))->where('issue_date_inactive', '=', '0000-00-00 00:00:00')->get();
     $result = '';
     if ($query) {
         if ($mobile == false) {
             $result .= '<ul>';
             foreach ($query as $row) {
                 $result .= '<li>' . $row->issue . '</li>';
             }
             $result .= '</ul>';
         } else {
             $list_array = [];
             $form = [];
             $i = 1;
             $columns = Schema::getColumnListing('issues');
             $row_index = $columns[0];
             $list_array[] = ['label' => 'Add Issue', 'pid' => Session::get('pid'), 'href' => action('MobileController@editpage', array('issues', $row_index, ''))];
             foreach ($query as $row) {
                 $list_array[] = ['label' => $row->issue, 'pid' => Session::get('pid'), 'href' => action('MobileController@editpage', array('issues', $row_index, $row->{$row_index}))];
             }
             $result .= $this->mobile_result_build($list_array, 'mobile_issues_list');
         }
     } else {
         $result .= ' None.';
     }
     echo $result;
 }
Exemple #10
0
 public function updateIssueAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     if ($this->acceptEdits) {
         $postParams = $this->_request->getPost();
         Zend_Loader::loadClass("Issues");
         $issuesObj = new Issues();
         $success = false;
         if ($postParams) {
             if (isset($postParams["tokenID"]) && isset($postParams["issueID"]) && isset($postParams["newNote"])) {
                 $issuesObj->updateIssueByID($postParams["issueID"], $postParams["newNote"]);
                 $location = "../../report/token-issues/" . $postParams["tokenID"];
                 header("Location: " . $location);
             } else {
                 header("HTTP/1.0 403 Forbidden");
                 echo "Need to POST to tokenID and issueID";
             }
         } else {
             $message = array("success" => false, "message" => "Please POST issues to this URI.");
             header('Content-Type: application/json; charset=utf8');
             header("HTTP/1.0 405 Method Not Allowed");
             header("Allow: POST");
             $output = Zend_Json::encode($message);
             echo $output;
         }
     } else {
         header("HTTP/1.0 403 Forbidden");
         echo $this->editMessage;
     }
 }