This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function editCaregivers($id = null) | |
{ | |
if ($this->request->session()->read('Auth.User.role') == "Patient") { | |
$patient_user_id = $this->request->session()->read('Auth.User.id'); | |
$patient = $this->Patients->findByUserId($patient_user_id) | |
->contain(['Users', 'Facilities', 'PatientAddresses', 'Languages'])->first(); | |
} else { | |
$patient = $this->Patients->get($id, [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$today = Time::now()->toDateString(); | |
$patient_scale_entities = $this->Patients->PatientScales->findByPatientId($patient->id) | |
->where(['PatientScales.completed' => 0]) | |
->andWhere(['Date(PatientScales.validity_date) >=' => $today]); | |
if($patient_scale_entities->count() > 0) { | |
foreach ($patient_scale_entities as $patient_scale_entity) { | |
$patient_scale_entity->caregiver_patient_id = $new_caregiver_id1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function lastVisitDate($patient_id, $facility_id) { | |
$start = Time::now()->toDateString(); // today | |
$events = $this->Events->find() | |
->where(['patient_id' => $patient_id]) | |
->andWhere(['facility_id' => $facility_id]) | |
->andWhere(['Events.start < :now']) // returns the past appointments (not check today) | |
->bind(':now', $start, 'time'); | |
if($events->count() > 1) { | |
$event_date = $events->limit(2)->orderDesc('id')->first()->start; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function lastVisitDate($patient_id, $facility_id) { | |
$start = Time::now()->toDateString(); // today | |
$events = TableRegistry::get('events'); | |
$events_data = $events->find() | |
->where(['patient_id' => $patient_id]) | |
->andWhere(['facility_id' => $facility_id]) | |
->andWhere(['events.start < :now']) // returns the past appointments (not check today) | |
->bind(':now', $start, 'time'); | |
if($events_data->count() > 1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function lastVisitDate($patient_id, $facility_id) { | |
$start = Time::now()->toDateString(); // today | |
$events = TableRegistry::get('events'); | |
$events_data = $events->find() | |
->where(['patient_id' => $patient_id]) | |
->andWhere(['facility_id' => $facility_id]) | |
->andWhere(['events.start < :now']) // returns the past appointments (not check today) | |
->bind(':now', $start, 'time'); | |
if($events_data->count() > 1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function lastVisitDate($patient_id, $facility_id) { | |
$start = Time::now()->toDateString(); // today | |
$events = $this->Events->find() | |
->where(['patient_id' => $patient_id]) | |
->andWhere(['facility_id' => $facility_id]) | |
->andWhere(['Events.start < :now']) // returns the past appointments (not check today) | |
->bind(':now', $start, 'time'); | |
if($events->count() > 1) { | |
$event_date = $events->limit(2)->orderDesc('id')->first()->start; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$patient_uuid = !$event->patient->external_patient_id ? $event->patient->patient_uuid : $event->patient->external_patient_id; | |
// aditya changes - | |
$last_visit_date = $this->lastVisitDate($event->patient->id, $event->facility->id); | |
// For last_vist date , please check for null then appply below date function, whereever you call | |
$last_visit_date = ($last_visit_date != null) ? (new Date($last_visit_date))->timeAgoInWords() : null; | |
$age = !($event->patient->age == "Not Defined") ? (" | ". $event->patient->age . " years old ") : ""; | |
/* | |
* 'title' => $patient . " | " . $event->patient->sex . $age . $last_visit_date, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// primary caregiver | |
if($patient->dirty('primary_contact_email') || $patient->dirty('primary_contact_phone1')) { | |
if ($new_caregiver_id1) { | |
// Found Existing user | |
// send notification | |
// create mapper Entity | |
if($caregiver1) { | |
$caregiver1->caregiver_patient_id = $new_caregiver_id1; | |
$this->Patients->Caregivers->save($caregiver1); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// using for EventCalendar/provider_cal.ctp | |
public function getSlotsForProvider($provider_id=null) { | |
Log::debug("getSlotsForProvider".$provider_id); | |
$providerSlots = $this->ProviderSlots->find("all") | |
->where(['provider_id' => $provider_id]) | |
// ->where(['OR' => [['alldays' => 1], ['day' => 0]]]) | |
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function lastVisitDate($patient_id, $facility_id) { | |
$Events = TableRegistry::get('events'); | |
$start = Time::now()->toDateString(); // today | |
$events = $Events->find() | |
->where(['patient_id' => $patient_id]) | |
->andWhere(['facility_id' => $facility_id]) | |
->andWhere(['events.start < :now']) // returns the past appointments (not includes today) | |
->bind(':now', $start, 'time') | |
->contain(['Encounters' => ['Prescriptions']]); | |