Skip to content

Instantly share code, notes, and snippets.

View iaditya's full-sized avatar
🐢
Learning

Aditya Pansari iaditya

🐢
Learning
View GitHub Profile
<script>
$(".cd-select").select2({
placeholder: 'Click and type',
allowClear: true,
ajax: {
url: function (params) {
return '/citiesDistricts/searchDistricts.json?q=' + params.term;
},
dataType: 'json',
success: function (response) {
if (response) {
var eventData = response.events;
var arr = [], i;
for (i in eventData) arr.push([i, eventData[i]].join('$$'));
var reverseData = arr.reverse();
var append_text = "";
public function bmiGraphApi($patient_id) {
if(!empty($patient_id)) {
$query = $this->Encounters->find()
->join(['Patients']);
$time = $query->func()->date_format([
'Encounters.visitdate' => 'identifier',
"'%m-%d-%y'" => 'literal'
]);
$data = $query->select([ 'visitdate' => $time, 'bmi' => 'Patients.bmi'])
//using on patientDashboard - from today
public function nextAppointment($patient_id) {
$start = Time::now()->toDateString(); // today
$event = $this->Events->findByPatientId($patient_id)
->contain(['Facilities', 'Providers' => ['Users']])
->where(['Events.start >= :now'])
->bind(':now', $start, 'time')->first();
$this->set(compact('event'));
// this function is using on calendar slot -appointment - aditya
public function lastVisitDate($patient_id, $facility_id) {
$last_visit_date = " ";
$Prescriptions = TableRegistry::get('prescriptions');
$prescription = $Prescriptions->find()
->where(['patient_id' => $patient_id])
->andWhere(['facility_id' => $facility_id]);
if($prescription->last()) {
//debug("pres-hh");
$last_visit_date = $prescription->last()->created;
$_data = [
'users' => [],
'recipientLists' => [],
'template' => 'default',
'vars' => [],
'tracking_id' => $this->getTrackingId()
];
foreach ($data['vars'] as $key => $value) {
if (($key != 'new_email') && ($key != 'hyperlink')) {
$data['vars'][$key] = substr($value, 0, 18);
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']]);
// 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]]])
;
// 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 {
@iaditya
iaditya / EventsCtrl
Created April 28, 2017 07:16
EventsController/ patientfeed() function
$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,