mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-11 18:51:31 +00:00
updated streamline-setup v2
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Reports\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
||||
+1771
File diff suppressed because it is too large
Load Diff
+161
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Reports\Http\Controllers;
|
||||
|
||||
use Barryvdh\Snappy\Facades\SnappyPdf;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Streamline\Models\HospitalInformation;
|
||||
use Streamline\Models\PatientEpisode;
|
||||
use Streamline\Models\Investigation;
|
||||
|
||||
class HmisController002 extends Controller {
|
||||
|
||||
public function page_1(Request $request) {
|
||||
$search_text = "";
|
||||
|
||||
switch ($request->search_date_by){
|
||||
case 'yesterday':
|
||||
$end_date = Carbon::yesterday()->endOfDay()->format('Y-m-d H:i:s');
|
||||
$start_date = Carbon::yesterday()->startOfDay()->format('Y-m-d H:i:s');
|
||||
$search_text .= "Yesterday ";
|
||||
break;
|
||||
case 'custom_date':
|
||||
$end_date = Carbon::parse($request->start_date)->endOfDay()->format('Y-m-d H:i:s');
|
||||
$start_date = Carbon::parse($request->start_date)->startOfDay()->format('Y-m-d H:i:s');
|
||||
$search_text .= "From: " . streamline_date($start_date) . " ";
|
||||
break;
|
||||
case 'custom_date_range':
|
||||
$end_date = Carbon::parse($request->end_date)->endOfDay()->format('Y-m-d H:i:s');
|
||||
$start_date = Carbon::parse($request->start_date)->startOfDay()->format('Y-m-d H:i:s');
|
||||
$search_text .= "From: " . streamline_date($start_date) . " to " . streamline_date($end_date) . " ";
|
||||
break;
|
||||
case 'today':
|
||||
default:
|
||||
$end_date = Carbon::today()->endOfDay()->format('Y-m-d H:i:s');
|
||||
$start_date = Carbon::today()->startOfDay()->format('Y-m-d H:i:s');
|
||||
$search_text .= "Today ";
|
||||
break;
|
||||
}
|
||||
|
||||
$episodes = PatientEpisode::leftJoin('triage', 'patient_episodes.triage_id', '=', 'triage.id')
|
||||
->leftJoin('patients', 'patient_episodes.patient_id', '=', 'patients.id')
|
||||
->leftJoin('consultations as c', 'patient_episodes.id', '=', 'c.episode_id')
|
||||
->leftJoin('districts', 'patients.district_id', '=', 'districts.id')
|
||||
->leftJoin('subcounties', 'patients.subcounty_id', '=', 'subcounties.id')
|
||||
->leftJoin('parishes', 'patients.parish_id', '=', 'parishes.id')
|
||||
->leftJoin('villages', 'patients.village_id', '=', 'villages.id')
|
||||
->leftJoin('family_relations', 'patients.next_of_kin_relationship', '=', 'family_relations.id')
|
||||
->select('patient_episodes.id as id', 'first_name', 'last_name', 'date_of_birth', 'gender', 'citizenship', 'next_of_kin', 'national_id', 'phone', 'rbs', 'phone_of_next_of_kin', 'next_of_kin_relationship', 'family_relations.name as relation', 'observations', 'new_attendance', 'villages.name as village', 'parishes.name as parish', 'subcounties.name as subcounty', 'districts.name as district', 'patient_episodes.created_at', 'patient_episodes.consultation_id','patient_episodes.triage_id')
|
||||
->whereBetween('patient_episodes.created_at', [$start_date, $end_date])->orderBy('id', 'asc')
|
||||
->get();
|
||||
|
||||
$hospital_info = HospitalInformation::find(1);
|
||||
|
||||
return view('reports::hmis_reports.002.page-1', compact('search_text', 'episodes', 'start_date','hospital_info','end_date'));
|
||||
}
|
||||
|
||||
public function page_1_print($start_date, $end_date) {
|
||||
$episodes = PatientEpisode::leftJoin('triage', 'patient_episodes.triage_id', '=', 'triage.id')
|
||||
->leftJoin('patients', 'patient_episodes.patient_id', '=', 'patients.id')
|
||||
->leftJoin('consultations as c', 'patient_episodes.id', '=', 'c.episode_id')
|
||||
->leftJoin('districts', 'patients.district_id', '=', 'districts.id')
|
||||
->leftJoin('subcounties', 'patients.subcounty_id', '=', 'subcounties.id')
|
||||
->leftJoin('parishes', 'patients.parish_id', '=', 'parishes.id')
|
||||
->leftJoin('villages', 'patients.village_id', '=', 'villages.id')
|
||||
->leftJoin('family_relations', 'patients.next_of_kin_relationship', '=', 'family_relations.id')
|
||||
->select('patient_episodes.id as id', 'first_name', 'last_name', 'date_of_birth', 'gender', 'citizenship', 'next_of_kin', 'national_id', 'phone', 'rbs', 'phone_of_next_of_kin', 'next_of_kin_relationship', 'family_relations.name as relation', 'observations', 'new_attendance', 'villages.name as village', 'parishes.name as parish', 'subcounties.name as subcounty', 'districts.name as district', 'patient_episodes.created_at', 'patient_episodes.consultation_id','patient_episodes.triage_id')
|
||||
->whereBetween('patient_episodes.created_at', [$start_date, $end_date])->orderBy('id', 'asc')
|
||||
->get();
|
||||
|
||||
$search_text = "From: " . streamline_date($start_date) . " to " . streamline_date($end_date);
|
||||
$hospital_info = HospitalInformation::find(1);
|
||||
$data = [
|
||||
'search_text' => $search_text,
|
||||
'episodes' => $episodes,
|
||||
'hospital_info' => $hospital_info,
|
||||
'start_date' => $start_date,
|
||||
'end_date' => $end_date
|
||||
];
|
||||
|
||||
$pdf = SnappyPDF::loadView('reports::hmis_reports/002/page-1-print', $data)
|
||||
->setOrientation('landscape')
|
||||
->setPaper('a3')
|
||||
->setOption('margin-bottom', 10)
|
||||
->setOption('footer-left', 'Stre@mline')
|
||||
->setOption('footer-right', '[page] of [toPage]');
|
||||
|
||||
return $pdf->inline('HMIS OPD 002 - Outpatient Register' . date(" d-m-y h:ia") . '.pdf');
|
||||
}
|
||||
|
||||
public function page_2(Request $request) {
|
||||
$search_text = !empty($request->search_text)? $request->search_text :"";
|
||||
if(!empty($request->page_1_start_date)){
|
||||
$end_date = $request->end_date;
|
||||
$start_date = $request->page_1_start_date;
|
||||
} else
|
||||
switch ($request->search_date_by){
|
||||
case 'yesterday':
|
||||
$end_date = Carbon::yesterday()->endOfDay()->format('Y-m-d H:i:s');
|
||||
$start_date = Carbon::yesterday()->startOfDay()->format('Y-m-d H:i:s');
|
||||
$search_text .= "Yesterday ";
|
||||
break;
|
||||
case 'custom_date':
|
||||
$end_date = Carbon::parse($request->start_date)->endOfDay()->format('Y-m-d H:i:s');
|
||||
$start_date = Carbon::parse($request->start_date)->startOfDay()->format('Y-m-d H:i:s');
|
||||
$search_text .= "From: " . streamline_date($start_date) . " ";
|
||||
break;
|
||||
case 'custom_date_range':
|
||||
$end_date = Carbon::parse($request->end_date)->endOfDay()->format('Y-m-d H:i:s');
|
||||
$start_date = Carbon::parse($request->start_date)->startOfDay()->format('Y-m-d H:i:s');
|
||||
$search_text .= "From: " . streamline_date($start_date) . " to " . streamline_date($end_date) . " ";
|
||||
break;
|
||||
case 'today':
|
||||
default:
|
||||
$end_date = Carbon::today()->endOfDay()->format('Y-m-d H:i:s');
|
||||
$start_date = Carbon::today()->startOfDay()->format('Y-m-d H:i:s');
|
||||
$search_text .= "Today ";
|
||||
break;
|
||||
}
|
||||
|
||||
$episodes = PatientEpisode::leftJoin('triage', 'patient_episodes.triage_id', '=', 'triage.id')
|
||||
->leftJoin('patients', 'patient_episodes.patient_id', '=', 'patients.id')
|
||||
->leftJoin('consultations as c', 'patient_episodes.id', '=', 'c.episode_id')
|
||||
->leftJoin('treatments as t', 'patient_episodes.id', '=', 't.episode_id')
|
||||
->leftJoin('investigation_results as or', 'or.episode_id','patient_episodes.id')
|
||||
->leftJoin('eye_clinic_main_exam as e', 'patient_episodes.id', '=', 'e.episode_id')
|
||||
->select('patient_episodes.id as id', 'first_name', 'last_name', 'date_of_birth', 'gender', 'next_of_kin', 'national_id','patients.id as patient_id', 'attendance', 'phone', 'phone_of_next_of_kin', 'new_attendance', 're_attendance','primary_diagnosis','other_diagnoses','rdt',DB::raw('GROUP_CONCAT(drugs) as drugs'),DB::raw('GROUP_CONCAT(frequencies) as frequencies'),DB::raw('GROUP_CONCAT(durations) as durations'),DB::raw('GROUP_CONCAT(doses) as doses'),'tb_status_assessment',
|
||||
'next_of_kin_relationship', 'right_eye_diagnosis', 'triage.symptoms', 'c.symptoms as symps', 'patient_episodes.clinic_id', 'left_eye_diagnosis', DB::raw('GROUP_CONCAT(or.investigation_id) as investigation_ids'), 'observations', 'new_attendance', 'patient_episodes.created_at', 'patient_episodes.consultation_id','patient_episodes.triage_id', 'number', 'c.referred_to')
|
||||
->whereBetween('patient_episodes.created_at', [$start_date, $end_date])->orderBy('id', 'asc')->groupBy('id')
|
||||
->get();
|
||||
|
||||
$hospital_info = HospitalInformation::find(1);
|
||||
$fever_symptom_ids = DB::table('symptoms')->where('name', 'LIKE', "%fever%")->orderBy('name')->pluck('id')->toArray();
|
||||
$tb_clinic_ids = DB::table('clinics')->where('name', 'LIKE', "%tb%")->orWhere('name', 'LIKE', "%tuber%")->pluck('id')->toArray();
|
||||
$investigations = Investigation::whereIn('hmis_002_slug', [2,3])->pluck('id')->toArray();
|
||||
return view('reports::hmis_reports.002.page-2', compact('search_text', 'episodes', 'start_date', 'end_date', 'hospital_info', 'fever_symptom_ids','tb_clinic_ids','investigations'));
|
||||
}
|
||||
|
||||
public function page_2_print(Request $request) {
|
||||
$data = [
|
||||
'search_text' => $request->search_text,
|
||||
'episodes'=> unserialize($request->episodes),
|
||||
'start_date' => $request->start_date,
|
||||
'end_date' => $request->end_date,
|
||||
'hospital_info' => unserialize($request->hospital_info),
|
||||
'fever_symptom_ids'=> unserialize($request->fever_symptom_ids),
|
||||
'tb_clinic_ids'=> unserialize($request->tb_clinic_ids),
|
||||
'investigations'=> unserialize($request->investigations)
|
||||
];
|
||||
|
||||
$pdf = SnappyPDF::loadView('reports::hmis_reports/002/page-2-print', $data)
|
||||
->setOrientation('landscape')
|
||||
->setPaper('a3')
|
||||
->setOption('margin-bottom', 10)
|
||||
->setOption('footer-left', 'Stre@mline')
|
||||
->setOption('footer-right', '[page] of [toPage]');
|
||||
|
||||
return $pdf->inline('HMIS OPD 002 - Outpatient Register' . date(" d-m-y h:ia") . '.pdf');
|
||||
}
|
||||
}
|
||||
+762
@@ -0,0 +1,762 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Reports\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Carbon\Carbon;
|
||||
use DateTime;
|
||||
use Barryvdh\Snappy\Facades\SnappyPdf;
|
||||
use Streamline\Models\HospitalInformation;
|
||||
use Streamline\Models\HmisCategory;
|
||||
use Streamline\Models\HmisCategoryOptions;
|
||||
use Streamline\Models\Diagnosis;
|
||||
use Streamline\Models\Consultation;
|
||||
use Streamline\Models\Investigation;
|
||||
use Streamline\Models\Treatment;
|
||||
use Streamline\Models\OrderedInvestigation;
|
||||
|
||||
class HmisController105 extends Controller {
|
||||
|
||||
/**
|
||||
* OPD Attendances, Referrals and Diagnosis Totals HMIS
|
||||
*/
|
||||
public function hmis_105(Request $request) {
|
||||
|
||||
$hospital_information = HospitalInformation::find(1);
|
||||
|
||||
if(isset($request->date_from)) {
|
||||
$attendance_from = Carbon::createFromFormat('d-m-Y', $request->date_from)->format('Y-m-d');
|
||||
// Add one day to make the report accurate
|
||||
$attendance_to = Carbon::createFromFormat('d-m-Y', $request->date_to)->addDays(1)->format('Y-m-d');
|
||||
|
||||
$dateRange = $request->date_from . '/' . $request->date_to;
|
||||
} else {
|
||||
$attendance_from = Carbon::today()->subDays(6)->format('Y-m-d');
|
||||
$attendance_to = Carbon::today()->addDays(1)->format('Y-m-d');
|
||||
|
||||
$dateRange = Carbon::today()->subDays(6)->format('d-m-Y') . '/' . Carbon::today()->addDays(1)->format('d-m-Y');
|
||||
}
|
||||
|
||||
$patient_ids_male_0_28_days_new_attendance = [];
|
||||
$patient_ids_male_0_28_days_re_attendance = [];
|
||||
$patient_ids_female_0_28_days_new_attendance = [];
|
||||
$patient_ids_female_0_28_days_re_attendance = [];
|
||||
|
||||
$patient_ids_male_29days_4yrs_new_attendance = [];
|
||||
$patient_ids_male_29days_4yrs_re_attendance = [];
|
||||
$patient_ids_female_29days_4yrs_new_attendance = [];
|
||||
$patient_ids_female_29days_4yrs_re_attendance = [];
|
||||
|
||||
$patient_ids_male_5_9yrs_new_attendance = [];
|
||||
$patient_ids_male_5_9yrs_re_attendance = [];
|
||||
$patient_ids_female_5_9yrs_new_attendance = [];
|
||||
$patient_ids_female_5_9yrs_re_attendance = [];
|
||||
|
||||
$patient_ids_male_10_19yrs_new_attendance = [];
|
||||
$patient_ids_male_10_19yrs_re_attendance = [];
|
||||
$patient_ids_female_10_19yrs_new_attendance = [];
|
||||
$patient_ids_female_10_19yrs_re_attendance = [];
|
||||
|
||||
$patient_ids_male_20yrs_new_attendance = [];
|
||||
$patient_ids_male_20yrs_re_attendance = [];
|
||||
$patient_ids_female_20yrs_new_attendance = [];
|
||||
$patient_ids_female_20yrs_re_attendance = [];
|
||||
|
||||
|
||||
/*$triageRecords = DB::table('triage')->whereIn('new_attendance', [0, 1])->whereIn('re_attendance', [0, 1])
|
||||
->whereBetween('created_at', [$attendance_from, $attendance_to])
|
||||
->select('patient_id', 'new_attendance', 're_attendance')->get();*/
|
||||
$triageRecords = DB::table('triage')->whereBetween('created_at', [$attendance_from, $attendance_to])
|
||||
->where(function($q) {
|
||||
$q->whereIn('new_attendance', [0, 1])
|
||||
->orWhereIn('re_attendance', [0, 1]);
|
||||
})->select('patient_id', 'new_attendance', 're_attendance')->get();
|
||||
|
||||
|
||||
foreach ($triageRecords as $triage):
|
||||
// Get patient and their age
|
||||
$patient = DB::table('patients')->where('id', $triage->patient_id)->select('id', 'date_of_birth', 'gender', 'created_at')->first();
|
||||
|
||||
if ($patient && in_array($patient->gender, [1, 2])): // Check if patient has valid gender
|
||||
$dateOfBirth = Carbon::parse($patient->date_of_birth);
|
||||
//$dateCreated = Carbon::parse($patient->created_at);
|
||||
$currentDateTimeStamp = Carbon::now();
|
||||
|
||||
$diffInDays = $dateOfBirth->diffInDays($currentDateTimeStamp);
|
||||
|
||||
|
||||
switch ($diffInDays):
|
||||
case ($diffInDays >= 0 && $diffInDays <= 29): // 0 - 28 days olds
|
||||
if ($patient->gender == 1): // Males
|
||||
|
||||
if (!empty($triage->new_attendance)):
|
||||
$patient_ids_male_0_28_days_new_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
if (!empty($triage->re_attendance)):
|
||||
$patient_ids_male_0_28_days_re_attendance[] = $patient->id;
|
||||
endif;
|
||||
elseif ($patient->gender == 2): // Females
|
||||
|
||||
if (!empty($triage->new_attendance)):
|
||||
$patient_ids_female_0_28_days_new_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
if (!empty($triage->re_attendance)):
|
||||
$patient_ids_female_0_28_days_re_attendance[] = $patient->id;
|
||||
endif;
|
||||
endif;
|
||||
break;
|
||||
case ($diffInDays >= 28 && $diffInDays <= 1825): // 29 Days - 4 Years
|
||||
if ($patient->gender == 1): // Males
|
||||
|
||||
if (!empty($triage->new_attendance)):
|
||||
$patient_ids_male_29days_4yrs_new_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
if (!empty($triage->re_attendance)):
|
||||
$patient_ids_male_29days_4yrs_re_attendance[] = $patient->id;
|
||||
endif;
|
||||
elseif ($patient->gender == 2): // Females
|
||||
|
||||
if (!empty($triage->new_attendance)):
|
||||
$patient_ids_female_29days_4yrs_new_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
if (!empty($triage->re_attendance)):
|
||||
$patient_ids_female_29days_4yrs_re_attendance[] = $patient->id;
|
||||
endif;
|
||||
endif;
|
||||
break;
|
||||
case ($diffInDays >= 1826 && $diffInDays <= 3650): // 5 - 9 Years
|
||||
if ($patient->gender == 1): // Males
|
||||
|
||||
if (!empty($triage->new_attendance)):
|
||||
$patient_ids_male_5_9yrs_new_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
if (!empty($triage->re_attendance)):
|
||||
$patient_ids_male_5_9yrs_re_attendance[] = $patient->id;
|
||||
endif;
|
||||
elseif ($patient->gender == 2): // Females
|
||||
|
||||
if (!empty($triage->new_attendance)):
|
||||
$patient_ids_female_5_9yrs_new_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
if (!empty($triage->re_attendance)):
|
||||
$patient_ids_female_5_9yrs_re_attendance[] = $patient->id;
|
||||
endif;
|
||||
endif;
|
||||
break;
|
||||
case ($diffInDays >= 3651 && $diffInDays <= 7300): // 10 - 19 Years
|
||||
if ($patient->gender == 1): // Males
|
||||
|
||||
if (!empty($triage->new_attendance)):
|
||||
$patient_ids_male_10_19yrs_new_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
if (!empty($triage->re_attendance)):
|
||||
$patient_ids_male_10_19yrs_re_attendance[] = $patient->id;
|
||||
endif;
|
||||
elseif ($patient->gender == 2): // Females
|
||||
|
||||
if (!empty($triage->new_attendance)):
|
||||
$patient_ids_female_10_19yrs_new_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
if (!empty($triage->re_attendance)):
|
||||
$patient_ids_female_10_19yrs_re_attendance[] = $patient->id;
|
||||
endif;
|
||||
endif;
|
||||
break;
|
||||
case ($diffInDays >= 7301): // 20 Years & Above
|
||||
if ($patient->gender == 1): // Males
|
||||
|
||||
if (!empty($triage->new_attendance)):
|
||||
$patient_ids_male_20yrs_new_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
if (!empty($triage->re_attendance)):
|
||||
$patient_ids_male_20yrs_re_attendance[] = $patient->id;
|
||||
endif;
|
||||
elseif ($patient->gender == 2): // Females
|
||||
|
||||
if (!empty($triage->new_attendance)):
|
||||
$patient_ids_female_20yrs_new_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
if (!empty($triage->re_attendance)):
|
||||
$patient_ids_female_20yrs_re_attendance[] = $patient->id;
|
||||
endif;
|
||||
endif;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
endswitch;
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
$printing = false;
|
||||
|
||||
|
||||
return view('reports::hmis_reports.105.index', compact('hospital_information', 'attendance_from', 'attendance_to',
|
||||
'patient_ids_male_0_28_days_new_attendance', 'patient_ids_male_0_28_days_re_attendance',
|
||||
'patient_ids_female_0_28_days_new_attendance', 'patient_ids_female_0_28_days_re_attendance',
|
||||
'patient_ids_male_29days_4yrs_new_attendance', 'patient_ids_male_29days_4yrs_re_attendance',
|
||||
'patient_ids_female_29days_4yrs_new_attendance', 'patient_ids_female_29days_4yrs_re_attendance',
|
||||
'patient_ids_male_5_9yrs_new_attendance', 'patient_ids_male_5_9yrs_re_attendance',
|
||||
'patient_ids_female_5_9yrs_new_attendance', 'patient_ids_female_5_9yrs_re_attendance',
|
||||
'patient_ids_male_10_19yrs_new_attendance', 'patient_ids_male_10_19yrs_re_attendance',
|
||||
'patient_ids_female_10_19yrs_new_attendance', 'patient_ids_female_10_19yrs_re_attendance',
|
||||
'patient_ids_male_20yrs_new_attendance', 'patient_ids_male_20yrs_re_attendance', 'dateRange',
|
||||
'patient_ids_female_20yrs_new_attendance', 'patient_ids_female_20yrs_re_attendance', 'printing'));
|
||||
}
|
||||
|
||||
public function print_hmis_105(Request $request) {
|
||||
|
||||
$hospital_information = HospitalInformation::find(1);
|
||||
//dd($request->all());
|
||||
|
||||
if(request()->segment(4)) {
|
||||
$attendance_from = request()->segment(4);
|
||||
// Add one day to make the report accurate
|
||||
$attendance_to = request()->segment(5);
|
||||
|
||||
$dateRange = $request->date_from . '/' . $request->date_to;
|
||||
} else {
|
||||
$attendance_from = Carbon::today()->subDays(6)->format('Y-m-d');
|
||||
$attendance_to = Carbon::today()->addDays(1)->format('Y-m-d');
|
||||
|
||||
$dateRange = Carbon::today()->subDays(6)->format('d-m-Y') . '/' . Carbon::today()->addDays(1)->format('d-m-Y');
|
||||
}
|
||||
|
||||
$patient_ids_male_0_28_days_new_attendance = [];
|
||||
$patient_ids_male_0_28_days_re_attendance = [];
|
||||
$patient_ids_female_0_28_days_new_attendance = [];
|
||||
$patient_ids_female_0_28_days_re_attendance = [];
|
||||
|
||||
$patient_ids_male_29days_4yrs_new_attendance = [];
|
||||
$patient_ids_male_29days_4yrs_re_attendance = [];
|
||||
$patient_ids_female_29days_4yrs_new_attendance = [];
|
||||
$patient_ids_female_29days_4yrs_re_attendance = [];
|
||||
|
||||
$patient_ids_male_5_9yrs_new_attendance = [];
|
||||
$patient_ids_male_5_9yrs_re_attendance = [];
|
||||
$patient_ids_female_5_9yrs_new_attendance = [];
|
||||
$patient_ids_female_5_9yrs_re_attendance = [];
|
||||
|
||||
$patient_ids_male_10_19yrs_new_attendance = [];
|
||||
$patient_ids_male_10_19yrs_re_attendance = [];
|
||||
$patient_ids_female_10_19yrs_new_attendance = [];
|
||||
$patient_ids_female_10_19yrs_re_attendance = [];
|
||||
|
||||
$patient_ids_male_20yrs_new_attendance = [];
|
||||
$patient_ids_male_20yrs_re_attendance = [];
|
||||
$patient_ids_female_20yrs_new_attendance = [];
|
||||
$patient_ids_female_20yrs_re_attendance = [];
|
||||
|
||||
if (!empty($attendance_from) && !empty($attendance_to)) {
|
||||
|
||||
$triageRecords = DB::table('triage')->whereIn('new_attendance', [0, 1])->whereIn('re_attendance', [0, 1])
|
||||
->whereBetween('created_at', [$attendance_from, $attendance_to])
|
||||
->select('patient_id', 'new_attendance', 're_attendance')->get();
|
||||
|
||||
foreach ($triageRecords as $triage):
|
||||
// Get patient and their age
|
||||
$patient = DB::table('patients')->where('id', $triage->patient_id)->select('id', 'date_of_birth', 'gender', 'created_at')->first();
|
||||
|
||||
if ($patient && in_array($patient->gender, [1, 2])): // Check if patient has valid gender
|
||||
$dateOfBirth = Carbon::parse($patient->date_of_birth);
|
||||
$dateCreated = Carbon::parse($patient->created_at);
|
||||
|
||||
$diffInDays = $dateOfBirth->diffInDays($dateCreated);
|
||||
|
||||
|
||||
switch ($diffInDays):
|
||||
case ($diffInDays >= 0 && $diffInDays <= 29): // 0 - 28 days olds
|
||||
if ($patient->gender == 1): // Males
|
||||
|
||||
if ($triage->new_attendance):
|
||||
$patient_ids_male_0_28_days_new_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
if ($triage->re_attendance):
|
||||
$patient_ids_male_0_28_days_re_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
elseif ($patient->gender == 2): // Females
|
||||
|
||||
if ($triage->new_attendance):
|
||||
$patient_ids_female_0_28_days_new_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
if ($triage->re_attendance):
|
||||
$patient_ids_female_0_28_days_re_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
endif;
|
||||
break;
|
||||
case ($diffInDays >= 28 && $diffInDays <= 1825): // 29 Days - 4 Years
|
||||
if ($patient->gender == 1): // Males
|
||||
|
||||
if ($triage->new_attendance):
|
||||
$patient_ids_male_29days_4yrs_new_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
if ($triage->re_attendance):
|
||||
$patient_ids_male_29days_4yrs_re_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
elseif ($patient->gender == 2): // Females
|
||||
|
||||
if ($triage->new_attendance):
|
||||
$patient_ids_female_29days_4yrs_new_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
if ($triage->re_attendance):
|
||||
$patient_ids_female_29days_4yrs_re_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
endif;
|
||||
break;
|
||||
case ($diffInDays >= 1826 && $diffInDays <= 3650): // 5 - 9 Years
|
||||
if ($patient->gender == 1): // Males
|
||||
|
||||
if ($triage->new_attendance):
|
||||
$patient_ids_male_5_9yrs_new_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
if ($triage->re_attendance):
|
||||
$patient_ids_male_5_9yrs_re_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
elseif ($patient->gender == 2): // Females
|
||||
|
||||
if ($triage->new_attendance):
|
||||
$patient_ids_female_5_9yrs_new_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
if ($triage->re_attendance):
|
||||
$patient_ids_female_5_9yrs_re_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
endif;
|
||||
break;
|
||||
case ($diffInDays >= 3651 && $diffInDays <= 7300): // 10 - 19 Years
|
||||
if ($patient->gender == 1): // Males
|
||||
|
||||
if ($triage->new_attendance):
|
||||
$patient_ids_male_10_19yrs_new_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
if ($triage->re_attendance):
|
||||
$patient_ids_male_10_19yrs_re_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
elseif ($patient->gender == 2): // Females
|
||||
|
||||
if ($triage->new_attendance):
|
||||
$patient_ids_female_10_19yrs_new_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
if ($triage->re_attendance):
|
||||
$patient_ids_female_10_19yrs_re_attendance[] = $patient->id;
|
||||
endif;
|
||||
endif;
|
||||
break;
|
||||
case ($diffInDays >= 7301): // 20 Years & Above
|
||||
if ($patient->gender == 1): // Males
|
||||
|
||||
if ($triage->new_attendance):
|
||||
$patient_ids_male_20yrs_new_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
if ($triage->re_attendance):
|
||||
$patient_ids_male_20yrs_re_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
elseif ($patient->gender == 2): // Females
|
||||
|
||||
if ($triage->new_attendance):
|
||||
$patient_ids_female_20yrs_new_attendance[] = $patient->id;
|
||||
endif;
|
||||
|
||||
if ($triage->re_attendance):
|
||||
$patient_ids_female_20yrs_re_attendance[] = $patient->id;
|
||||
endif;
|
||||
endif;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
endswitch;
|
||||
|
||||
endif;
|
||||
endforeach;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'hospital_information' => $hospital_information,
|
||||
'attendance_from' => $attendance_from,
|
||||
'attendance_to' => $attendance_to,
|
||||
'patient_ids_male_0_28_days_new_attendance' => $patient_ids_male_0_28_days_new_attendance,
|
||||
'patient_ids_male_0_28_days_re_attendance' => $patient_ids_male_0_28_days_re_attendance,
|
||||
'patient_ids_female_0_28_days_new_attendance' => $patient_ids_female_0_28_days_new_attendance,
|
||||
'patient_ids_female_0_28_days_re_attendance' => $patient_ids_female_0_28_days_re_attendance,
|
||||
'patient_ids_male_29days_4yrs_new_attendance' => $patient_ids_male_29days_4yrs_new_attendance,
|
||||
'patient_ids_male_29days_4yrs_re_attendance' => $patient_ids_male_29days_4yrs_re_attendance,
|
||||
'patient_ids_female_29days_4yrs_new_attendance' => $patient_ids_female_29days_4yrs_new_attendance,
|
||||
'patient_ids_female_29days_4yrs_re_attendance' => $patient_ids_female_29days_4yrs_re_attendance,
|
||||
'patient_ids_male_5_9yrs_new_attendance' => $patient_ids_male_5_9yrs_new_attendance,
|
||||
'patient_ids_male_5_9yrs_re_attendance' => $patient_ids_male_5_9yrs_re_attendance,
|
||||
'patient_ids_female_5_9yrs_new_attendance' => $patient_ids_female_5_9yrs_new_attendance,
|
||||
'patient_ids_female_5_9yrs_re_attendance' => $patient_ids_female_5_9yrs_re_attendance,
|
||||
'patient_ids_male_10_19yrs_new_attendance' => $patient_ids_male_10_19yrs_new_attendance,
|
||||
'patient_ids_male_10_19yrs_re_attendance' => $patient_ids_male_10_19yrs_re_attendance,
|
||||
'patient_ids_female_10_19yrs_new_attendance' => $patient_ids_female_10_19yrs_new_attendance,
|
||||
'patient_ids_female_10_19yrs_re_attendance' => $patient_ids_female_10_19yrs_re_attendance,
|
||||
'patient_ids_male_20yrs_new_attendance' => $patient_ids_male_20yrs_new_attendance,
|
||||
'patient_ids_male_20yrs_re_attendance' => $patient_ids_male_20yrs_re_attendance,
|
||||
'patient_ids_female_20yrs_new_attendance' => $patient_ids_female_20yrs_new_attendance,
|
||||
'patient_ids_female_20yrs_re_attendance' => $patient_ids_female_20yrs_re_attendance,
|
||||
'printing' => false
|
||||
];
|
||||
|
||||
$pdf = SnappyPDF::loadView('reports::hmis_reports/105/print', $data)
|
||||
->setOrientation('landscape')
|
||||
->setPaper('a4')
|
||||
->setOption('margin-bottom', 10)
|
||||
->setOption('footer-left', 'Stre@mline')
|
||||
->setOption('footer-right', '[page] of [toPage]');
|
||||
|
||||
|
||||
return $pdf->inline('HMIS 105 Report' . date(" d-m-y h:ia") . '.pdf');
|
||||
}
|
||||
|
||||
public function opd_attendance_drill(Request $request) {
|
||||
|
||||
$patientIDs = unserialize($request->patients);
|
||||
|
||||
$patients = DB::table('patients')->whereIn('id', $patientIDs)->orderBy('last_name')->paginate(25);
|
||||
$categories = DB::table('patient_categories')->pluck('name', 'id');
|
||||
|
||||
return view('reports::hmis_reports.105.opd-attendance-details', compact('patients', 'categories'));
|
||||
}
|
||||
|
||||
public function opd_referral_drill(Request $request) {
|
||||
$patientIDs = decrypt($request->patients);
|
||||
|
||||
$patients = DB::table('patients')->whereIn('id', $patientIDs)->orderBy('last_name')->paginate(25);
|
||||
$categories = DB::table('patient_categories')->pluck('name', 'id');
|
||||
|
||||
return view('reports::hmis_reports.105.opd-referral-details', compact('patients', 'categories'));
|
||||
}
|
||||
|
||||
public function opd_diagnosis_drill(Request $request) {
|
||||
|
||||
$patientIDs = decrypt($request->patients);
|
||||
|
||||
$patients = DB::table('patients')->whereIn('id', $patientIDs)->orderBy('last_name')->paginate(25);
|
||||
$categories = DB::table('patient_categories')->pluck('name', 'id');
|
||||
|
||||
return view('reports::hmis_reports.105.opd-diagnosis-details', compact('patients', 'categories'));
|
||||
}
|
||||
|
||||
/* form for displaying risky behaviour report */
|
||||
|
||||
public function risky_behaviours(Request $request) {
|
||||
|
||||
$hospital_information = HospitalInformation::find(1);
|
||||
|
||||
if (isset($request->date_from) && isset($request->date_to)) {
|
||||
|
||||
$attendance_from = Carbon::createFromFormat('d/m/Y', $request->date_from)->toDateString();
|
||||
$attendance_to = Carbon::createFromFormat('d/m/Y', $request->date_to)->toDateString();
|
||||
|
||||
$search_button = $request->filterBtn;
|
||||
} else {
|
||||
$attendance_from = \Carbon\Carbon::today()->subDays(30)->format('Y-m-d');
|
||||
$attendance_to = date("Y-m-d");
|
||||
}
|
||||
|
||||
$alcohol_male_5to9 = [];
|
||||
$alcohol_male_10to19 = [];
|
||||
$alcohol_male_20plus = [];
|
||||
|
||||
$tobacco_male_5to9 = [];
|
||||
$tobacco_male_10to19 = [];
|
||||
$tobacco_male_20plus = [];
|
||||
|
||||
$alcohol_female_5to9 = [];
|
||||
$alcohol_female_10to19 = [];
|
||||
$alcohol_female_20plus = [];
|
||||
|
||||
$tobacco_female_5to9 = [];
|
||||
$tobacco_female_10to19 = [];
|
||||
$tobacco_female_20plus = [];
|
||||
|
||||
// $query_behavior = "SELECT t.patient_id as patient_id, t.id as triage_id, t.observations as observations, t.created_at as create_date,"
|
||||
// . "d.date_of_birth as dob, d.gender as gender FROM triage t, patients d "
|
||||
// . "WHERE (t.created_at BETWEEN '{$attendance_from}' AND '{$attendance_to}')"
|
||||
// . " AND (patient_id = d.id) AND ((t.observations LIKE '%Alcohol use=High%') "
|
||||
// . "OR (t.observations LIKE '%Alcohol use=Moderate%') "
|
||||
// . "OR (t.observations LIKE '%Alcohol use=Low%') "
|
||||
// . "OR (t.observations LIKE '%Tobacco use=High%') "
|
||||
// . "OR (t.observations LIKE '%Tobacco use=Moderate%') "
|
||||
// . "OR (t.observations LIKE '%Tobacco use=Low%')) ORDER BY patient_id DESC";
|
||||
|
||||
// $triage_results1 = DB::select($query_behavior);
|
||||
$triage_results = DB::table('triage')
|
||||
->leftJoin('patients', 'triage.patient_id', '=', 'patients.id')
|
||||
->select('patient_id', 'date_of_birth as dob','gender','patient_id','observations','triage.id as triage_id','triage.created_at as create_date')
|
||||
->whereBetween('triage.created_at', [$attendance_from, $attendance_to])
|
||||
->orWhere([ ['observations', 'LIKE', '%Alcohol use=High%'],
|
||||
['observations', 'LIKE', '%Alcohol use=Moderate%'],
|
||||
['observations', 'LIKE', '%Alcohol use=Low%'],
|
||||
['observations', 'LIKE', '%Tobacco use=High%'],
|
||||
['observations', 'LIKE', '%Tobacco use=Moderate%'],
|
||||
['observations', 'LIKE', '%Tobacco use=Low%']
|
||||
])
|
||||
->orderBy('patient_id', 'desc')
|
||||
->get();
|
||||
if (count($triage_results) > 0) {
|
||||
foreach ($triage_results as $triage_result) {
|
||||
|
||||
$dob = new Carbon($triage_result->dob);
|
||||
$age = $dob->diffInYears($triage_result->create_date);
|
||||
|
||||
$age = intval($age);
|
||||
$sex = $triage_result->gender;
|
||||
$observation_explode = explode(",", $triage_result->observations);
|
||||
|
||||
if ($age > 5 && $age < 10) {
|
||||
if ($sex == 1 && (in_array('Alcohol use=High', $observation_explode) || in_array('Alcohol use=Moderate', $observation_explode) || in_array('Alcohol use=Low', $observation_explode))) {
|
||||
array_push($alcohol_male_5to9, $triage_result->patient_id);
|
||||
}
|
||||
if ($sex == 1 && (in_array('Tobacco use=High', $observation_explode) || in_array('Tobacco use=Moderate', $observation_explode) || in_array('Tobacco use=Low', $observation_explode))) {
|
||||
array_push($tobacco_male_5to9, $triage_result->patient_id);
|
||||
}
|
||||
if ($sex == 2 && (in_array('Alcohol use=High', $observation_explode) || in_array('Alcohol use=Moderate', $observation_explode) || in_array('Alcohol use=Low', $observation_explode))) {
|
||||
array_push($alcohol_female_5to9, $triage_result->patient_id);
|
||||
}
|
||||
if ($sex == 2 && (in_array('Tobacco use=High', $observation_explode) || in_array('Tobacco use=Moderate', $observation_explode) || in_array('Tobacco use=Low', $observation_explode))) {
|
||||
array_push($tobacco_female_5to9, $triage_result->patient_id);
|
||||
}
|
||||
} elseif ($age > 10 && $age < 20) {
|
||||
if ($sex == 1 && (in_array('Alcohol use=High', $observation_explode) || in_array('Alcohol use=Moderate', $observation_explode) || in_array('Alcohol use=Low', $observation_explode))) {
|
||||
array_push($alcohol_male_10to19, $triage_result->patient_id);
|
||||
}
|
||||
if ($sex == 1 && (in_array('Tobacco use=High', $observation_explode) || in_array('Tobacco use=Moderate', $observation_explode) || in_array('Tobacco use=Low', $observation_explode))) {
|
||||
array_push($tobacco_male_10to19, $triage_result->patient_id);
|
||||
}
|
||||
if ($sex == 2 && (in_array('Alcohol use=High', $observation_explode) || in_array('Alcohol use=Moderate', $observation_explode) || in_array('Alcohol use=Low', $observation_explode))) {
|
||||
array_push($alcohol_female_10to19, $triage_result->patient_id);
|
||||
}
|
||||
if ($sex == 2 && (in_array('Tobacco use=High', $observation_explode) || in_array('Tobacco use=Moderate', $observation_explode) || in_array('Tobacco use=Low', $observation_explode))) {
|
||||
array_push($tobacco_female_10to19, $triage_result->patient_id);
|
||||
}
|
||||
} elseif ($age > 20) {
|
||||
if ($sex == 1 && (in_array('Alcohol use=High', $observation_explode) || in_array('Alcohol use=Moderate', $observation_explode) || in_array('Alcohol use=Low', $observation_explode))) {
|
||||
array_push($alcohol_male_20plus, $triage_result->patient_id);
|
||||
}
|
||||
if ($sex == 1 && (in_array('Tobacco use=High', $observation_explode) || in_array('Tobacco use=Moderate', $observation_explode) || in_array('Tobacco use=Low', $observation_explode))) {
|
||||
array_push($tobacco_male_20plus, $triage_result->patient_id);
|
||||
}
|
||||
if ($sex == 2 && (in_array('Alcohol use=High', $observation_explode) || in_array('Alcohol use=Moderate', $observation_explode) || in_array('Alcohol use=Low', $observation_explode))) {
|
||||
array_push($alcohol_female_20plus, $triage_result->patient_id);
|
||||
}
|
||||
if ($sex == 2 && (in_array('Tobacco use=High', $observation_explode) || in_array('Tobacco use=Moderate', $observation_explode) || in_array('Tobacco use=Low', $observation_explode))) {
|
||||
array_push($tobacco_female_20plus, $triage_result->patient_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return view('reports::hmis_reports.105.risky-behaviours', compact('hospital_information', 'attendance_from', 'attendance_to',
|
||||
'triage_results', 'alcohol_male_10to19', 'alcohol_male_5to9', 'alcohol_male_20plus',
|
||||
'tobacco_male_10to19', 'tobacco_male_5to9', 'tobacco_male_20plus', 'alcohol_female_10to19',
|
||||
'alcohol_female_5to9', 'alcohol_female_20plus', 'tobacco_female_10to19',
|
||||
'tobacco_female_5to9', 'tobacco_female_20plus'));
|
||||
}
|
||||
|
||||
public function risky_behaviour_drill(Request $request) {
|
||||
$behaviour = $request->behaviour;
|
||||
$gender = $request->sex;
|
||||
$age = $request->age;
|
||||
$patient_id_array = unserialize($request->patient_ids);
|
||||
$patients_results = DB::table('patients')->whereIn('id', $patient_id_array)->get();
|
||||
return view('reports::hmis_reports.105.risky-behaviours-drill', compact('behaviour', 'gender', 'age', 'patients_results'));
|
||||
}
|
||||
|
||||
public function monthly_outpatient_diagnoses(Request $request) {
|
||||
request()->validate([
|
||||
'date_from' => 'nullable|date|required_with:date_to',
|
||||
'date_to' => 'bail|nullable|required_with:date_from|date|after:date_from',
|
||||
]);
|
||||
$start = !empty($request->date_from)? date('Y-m-d', strtotime($request->date_from)) : Carbon::now()->subMonth()->startOfMonth()->format('Y-m-d');
|
||||
$end = !empty($request->date_to)? date('Y-m-d', strtotime($request->date_to)) : date("Y-m-t", strtotime($start));
|
||||
$page = 'Outpatient Diagnoses';$printing = false;
|
||||
$citizenship = isset($request->type)? $request->type :1;
|
||||
$dates = $primary_diagnosis = $other_diagnoses = $table_options = $dependent_options = $diagnoses_data = [];
|
||||
if(empty($request->date_from)){
|
||||
$dates['last_month'] = date('F', strtotime($start));
|
||||
$dates['last_year'] = date('Y', strtotime($start));
|
||||
$dates['days'] = date('t', strtotime($start));
|
||||
$dates['citizenship'] = $citizenship;
|
||||
$dateRange = $start . '/' . $end;
|
||||
$attendance_from = $start;
|
||||
$attendance_to = $end;
|
||||
}else {
|
||||
$dates['start'] = date('d-M-Y', strtotime($start));
|
||||
$dates['end'] = date('d-M-Y', strtotime($end));
|
||||
$dates['days'] = intval((new DateTime($start))->diff(new DateTime($end))->format("%a"));
|
||||
$dates['citizenship'] = $citizenship;
|
||||
$attendance_from = $start;
|
||||
$attendance_to = $end;
|
||||
$dateRange = $attendance_from . '/' . $attendance_to;
|
||||
}
|
||||
$parent_categories = array_unique(HmisCategoryOptions::where('parent_option', '<>','')->pluck('parent_option')->toArray());
|
||||
$episodes = Consultation::leftJoin('patients as p', 'consultations.patient_id','p.id')
|
||||
->leftJoin('triage as tr', 'consultations.episode_id','tr.episode_id')
|
||||
->select('consultations.id','consultations.patient_id', 'consultations.episode_id', 'gender', 'date_of_birth as dob', 'primary_diagnosis', 'other_diagnoses', 'rdt')
|
||||
->whereBetween('consultations.created_at', [Carbon::parse($start)->startOfDay()->toDateTimeString(), Carbon::parse($end)->endOfDay()->toDateTimeString()])->where('citizenship', $citizenship)->get();
|
||||
$primary_diagnosis = $ordered_investigations = $prescribed_treatments = $ordered_investigation_results = $others =$other_diagnoses = $patientIds = [];
|
||||
foreach ($episodes as $episode) {
|
||||
$primary_diagnosis[] = $episode->primary_diagnosis;
|
||||
$others = (!empty($episode->other_diagnoses))? unserialize($episode->other_diagnoses):[];
|
||||
if(!empty($others)) foreach($others as $other) if(!empty($other)) $other_diagnoses[] = $other;
|
||||
$patients[] = ['id'=> $episode->id,'patient_id'=> $episode->patient_id, 'episode_id'=>$episode->episode_id, 'gender'=> $episode->gender, 'age'=> $episode->dob, 'primary_diagnosis'=> $episode->primary_diagnosis, 'other_diagnoses'=> $others, 'rdt' => $episode->rdt ];
|
||||
}
|
||||
$malaria_diagnoses = Diagnosis::where('outpatient_hmis_category',10096)->whereIn('outpatient_dependent_option', [400, 401, 399, 402])->get(['id','name', 'outpatient_hmis_category_option','outpatient_hmis_category','outpatient_dependent_option'])->first();
|
||||
$all_diagnoses = array_unique(array_merge($primary_diagnosis,$other_diagnoses));
|
||||
$diag = Diagnosis::whereNotNull(['outpatient_hmis_category','outpatient_hmis_category_option'])->whereIn('id', $all_diagnoses)->get(['id','name', 'outpatient_hmis_category_option','outpatient_hmis_category','outpatient_dependent_option']);
|
||||
foreach($diag as $dia) {
|
||||
$diagnosis = $dia->id;$other = $primary = $other = [];
|
||||
if(!empty($patients)) {
|
||||
$primary = array_filter($patients, function ($item) use ($diagnosis) {
|
||||
return $item['primary_diagnosis'] == $diagnosis;
|
||||
});
|
||||
foreach ($patients as $patient) if(in_array($diagnosis, $patient['other_diagnoses'] )) $other[] =$patient;
|
||||
}
|
||||
$diagnoses_data[]=['id'=>$diagnosis,'name'=>$dia->name, 'hmis_category'=>$dia->outpatient_hmis_category, 'hmis_category_option'=>$dia->outpatient_hmis_category_option, 'dependent_option'=>$dia->outpatient_dependent_option, 'primary'=>$primary, 'other'=>$other];
|
||||
}
|
||||
|
||||
$diagnosis_categories = HmisCategory::where('section_number', '1')->select('id','number', 'title')->get()->toArray();
|
||||
foreach($diagnosis_categories as $diagnosis_category) {
|
||||
$options=[];
|
||||
$category_options = HmisCategoryOptions::where('hmis_category_id', $diagnosis_category['id'])->select('id','number', 'name')->get()->toArray();
|
||||
foreach($category_options as $category_option) {
|
||||
$dependent_options = [];
|
||||
if(in_array($category_option['id'], $parent_categories)) $dependent_options = HmisCategoryOptions::where('parent_option', $category_option['id'])->select('id','number', 'name')->get()->toArray();
|
||||
$options[]=['id'=>$category_option['id'], 'name'=>$category_option['name'], 'number'=>$category_option['number'], 'dependent_options'=>$dependent_options];
|
||||
}
|
||||
$table_options[] = ['category_id'=>$diagnosis_category['id'],'category_name'=>$diagnosis_category['title'],'category_number'=>$diagnosis_category['number'],'category_options'=>$options, 'dependent_options'=>$dependent_options];
|
||||
}
|
||||
$hospital_information = HospitalInformation::find(1);
|
||||
$malaria_investigations =Investigation::whereIn('hmis_002_slug', [2,3])->pluck('id')->toArray();
|
||||
$malaria_ids = '';
|
||||
foreach($malaria_investigations as $key => $malaria_investigation) {
|
||||
if(count($malaria_investigations) == 1) $malaria_ids .= 'FIND_IN_SET('.$malaria_investigation.',r.investigation_id)';
|
||||
else {
|
||||
if($key == 0) $malaria_ids .= '(FIND_IN_SET('.$malaria_investigation.',r.investigation_id)';
|
||||
else $malaria_ids .= ' OR FIND_IN_SET('.$malaria_investigation.',r.investigation_id)';
|
||||
if($key == array_key_last($malaria_investigations)) $malaria_ids .=')';
|
||||
}
|
||||
}
|
||||
if(!empty($malaria_ids)){
|
||||
$results = OrderedInvestigation::leftJoin('patients as p', 'patient_id','p.id')->leftJoin('investigation_results as r', 'order_id','ordered_investigations.id')
|
||||
->leftJoin('consultations as c', 'c.episode_id','ordered_investigations.episode_id')->where([['ordered_investigations.inpatient',0], ['citizenship', $citizenship]])
|
||||
->whereRaw($malaria_ids)
|
||||
->whereBetween('ordered_investigations.created_at', [Carbon::parse($start)->startOfDay()->toDateTimeString(), Carbon::parse($end)->endOfDay()->toDateTimeString()])
|
||||
->get(['ordered_investigations.id','p.id as patient_id', 'r.investigation_id','r.episode_id','gender','date_of_birth as age','value', 'r.id as result_id', 'primary_diagnosis', 'other_diagnoses', 'per_investigation']);
|
||||
foreach($results as $result) {
|
||||
$other_diagnoses = unserialize($result->other_diagnoses);
|
||||
$ordered_investigations[] = ['id'=> $result->id,'patient_id'=> $result->patient_id, 'episode_id'=>$result->episode_id, 'gender'=> $result->gender, 'age'=> $result->age, "primary_diagnosis" =>$result->primary_diagnosis?? 'N/A', "other_diagnoses" => (!empty($other_diagnoses))? $other_diagnoses:[]];
|
||||
$ids = explode(',', $result->investigation_id);
|
||||
$values = explode(',', $result->value);
|
||||
$authenticated = explode(',', $result->per_investigation);
|
||||
foreach($malaria_investigations as $malaria_investigation){
|
||||
$id = array_search($malaria_investigation, $ids);
|
||||
if($id !== false) {
|
||||
$inv_result = strtolower($values[$id]);
|
||||
$result_authenticated = $authenticated[$id];
|
||||
if((str_contains($inv_result, 'pos') || $inv_result =='+'|| $inv_result =='++'|| $inv_result =='+++') && !in_array($result->patient_id, $patientIds) && !empty($result_authenticated)) {
|
||||
$ordered_investigation_results[] = ['id'=> $result->result_id,'patient_id'=> $result->patient_id, 'result'=>$inv_result ,'episode_id'=>$result->episode_id, 'gender'=> $result->gender, 'age'=> $result->age, "primary_diagnosis" => $result->primary_diagnosis?? 'N/A', "other_diagnoses" => (!empty($other_diagnoses))? $other_diagnoses:[]];
|
||||
$patientIds[] = $result->patient_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$anti_malarials = DB::table('drugs')->leftJoin('drug_categories as d', 'category_id','d.id')->where('d.anti_malarial', 1)->pluck('drugs.id')->toArray();
|
||||
$patientIds = [];
|
||||
$anti_malarial_ids = '';
|
||||
foreach($anti_malarials as $key => $anti_malarial) {
|
||||
if(count($anti_malarials) == 1) $anti_malarial_ids .= 'FIND_IN_SET('.$anti_malarial.',drugs)';
|
||||
else {
|
||||
if($key == 0) $anti_malarial_ids .= '(FIND_IN_SET('.$anti_malarial.',drugs)';
|
||||
else $anti_malarial_ids .= ' OR FIND_IN_SET('.$anti_malarial.',drugs)';
|
||||
if($key == array_key_last($anti_malarials)) $anti_malarial_ids .=')';
|
||||
}
|
||||
}
|
||||
if(!empty($anti_malarial_ids)){
|
||||
$treatments = Treatment::leftJoin('patients as p', 'patient_id','p.id') ->leftJoin('consultations as c', 'c.episode_id','treatments.episode_id')
|
||||
->where([['citizenship', $citizenship]])->whereBetween('treatments.created_at', [Carbon::parse($start)->startOfDay()->toDateTimeString(), Carbon::parse($end)->endOfDay()->toDateTimeString()])
|
||||
->whereRaw($anti_malarial_ids)
|
||||
->groupBy('patient_id')
|
||||
->get(['treatments.id','p.id as patient_id', DB::raw('GROUP_CONCAT(drugs) as drugs'),'c.episode_id','gender','date_of_birth as age', 'primary_diagnosis', 'other_diagnoses']);
|
||||
foreach ($treatments as $treatment) {
|
||||
$other_diagnoses = unserialize($treatment->other_diagnoses);
|
||||
if(!in_array($treatment->patient_id, $patientIds)) {
|
||||
$prescribed_treatments[] = ['id'=> $treatment->id,'patient_id'=> $treatment->patient_id, 'episode_id'=>$treatment->episode_id, 'gender'=> $treatment->gender, 'age'=> $treatment->age, "primary_diagnosis" => $treatment->primary_diagnosis, "other_diagnoses" => !empty($other_diagnoses)? $other_diagnoses:[], 'drugs'=> $treatment->drugs];
|
||||
$patientIds[] = $treatment->patient_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
return view('reports::hmis_reports.105.index', compact('hospital_information','dates','diagnoses_data','table_options','page', 'dateRange', 'attendance_from', 'attendance_to', 'printing', 'ordered_investigation_results', 'ordered_investigations', 'prescribed_treatments', 'malaria_diagnoses'));
|
||||
}
|
||||
|
||||
public function print_hmis_105_information(Request $request){
|
||||
$diagnoses_data =!empty($request->diagnoses_data)? unserialize($request->diagnoses_data):[];
|
||||
$table_options = !empty($request->table_options)? unserialize($request->table_options):[];
|
||||
$ordered_investigation_results = !empty($request->ordered_investigation_results)? unserialize($request->ordered_investigation_results):[];
|
||||
$ordered_investigations = !empty($request->ordered_investigations)? unserialize($request->ordered_investigations):[];
|
||||
$prescribed_treatments = !empty($request->prescribed_treatments)? unserialize($request->prescribed_treatments):[];
|
||||
$dates = !empty($request->dates)? unserialize($request->dates):[];
|
||||
$page = $request->page;
|
||||
$pdf = SnappyPDF::loadView('reports::hmis_reports.105.print_hmis_105_information', compact('dates','page','table_options','diagnoses_data','ordered_investigations', 'ordered_investigation_results', 'prescribed_treatments'))
|
||||
->setOrientation('portrait')
|
||||
->setOption('margin-bottom', 7)
|
||||
->setOption('margin-top', 5)
|
||||
->setOption('footer-html', '<i>'. config('app.name') .' - Printed On ' . date('Y-m-d') . ' By ' . auth()->user()->first_name . " " . auth()->user()->last_name . '</i>');
|
||||
return $pdf->inline(__('hmis_reports.hmis_108_report_census') . date(" d-m-y h:ia") . '.pdf');
|
||||
|
||||
}
|
||||
|
||||
public function hmis_data(){
|
||||
try{
|
||||
DB::transaction(function() {
|
||||
$options = HmisCategoryOptions::leftJoin('hmis_categories AS a','a.id', 'hmis_category_options.hmis_category_id')
|
||||
->select('a.id as outpatient_hmis_category','hmis_category_options.id','parent_option', 'hmis_category_options.number as number')
|
||||
->where([['a.type', 0], ['a.section_number',1]])->orWhereNotNull('parent_option')
|
||||
->get();
|
||||
foreach ($options as $option) {
|
||||
if(!empty($option->parent_option)) {
|
||||
$outpatient_hmis_category = HmisCategoryOptions::find($option->parent_option);
|
||||
Diagnosis::where('hmis_no_outpatient',$option->number)->update(['outpatient_hmis_category'=>$outpatient_hmis_category->hmis_category_id, 'outpatient_hmis_category_option'=>$option->parent_option, 'outpatient_dependent_option'=>$option->id]);
|
||||
}
|
||||
else Diagnosis::where('hmis_no_outpatient',$option->number)->update(['outpatient_hmis_category'=>$option->outpatient_hmis_category, 'outpatient_hmis_category_option'=>$option->id]);
|
||||
}
|
||||
});
|
||||
|
||||
}catch(\Exception $e){
|
||||
flash('HMIS Outpatient Data has NOT been reconciled. Contact system admin. '.$e->getMessage())->error();
|
||||
return redirect()->back()->withInput();
|
||||
}
|
||||
|
||||
flash("HMIS Outpatient Data has been reconciled.")->success();
|
||||
return redirect("/list/hmis-reports");
|
||||
}
|
||||
|
||||
}
|
||||
+209
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Reports\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Streamline\Models\Consultation;
|
||||
use Streamline\Models\Diagnosis;
|
||||
use Streamline\Models\Drug;
|
||||
use Streamline\Models\PatientAppointment;
|
||||
use Streamline\Models\Treatment;
|
||||
|
||||
class MentalHealthReportsController extends Controller {
|
||||
|
||||
public function diagnosed_patients(Request $request){
|
||||
if (isset($request->start_date)){
|
||||
$start_date = Carbon::parse($request->start_date)->startOfDay()->toDateTimeString();
|
||||
$end_date = Carbon::parse($request->end_date)->endOfDay()->toDateTimeString();
|
||||
} else {
|
||||
$start_date = Carbon::now()->startOfDay()->toDateTimeString();
|
||||
$end_date = Carbon::now()->endOfDay()->toDateTimeString();
|
||||
}
|
||||
|
||||
// get all diagnoses with hmis category mental health
|
||||
$diagnoses = Diagnosis::where('hmis_category', 8)->get()->toArray();
|
||||
|
||||
$reports = [];
|
||||
|
||||
foreach ($diagnoses as $diagnosis){
|
||||
$patient_ids =[];
|
||||
$consultation = Consultation::where('primary_diagnosis', $diagnosis['id'])->whereBetween('created_at', [$start_date, $end_date])->get();
|
||||
if(!empty($consultation)) foreach ($consultation as $key => $value) $patient_ids[] = $value->patient_id;
|
||||
|
||||
$reports[] = ['name'=>$diagnosis['name'], 'count'=>count($consultation), 'patient_ids'=>$patient_ids];
|
||||
|
||||
}
|
||||
return view('reports::mental_health_reports.diagnosed_patients', compact('start_date', 'end_date', 'reports'));
|
||||
}
|
||||
|
||||
public function persons_taking_psychotropic_drugs(Request $request){
|
||||
|
||||
// get array of accepted drugs
|
||||
$drugs = Drug::whereIn('category_id', [13,27,32,37,46,53])->pluck('id', 'id')->toArray();
|
||||
$drugs = array_fill_keys(array_keys($drugs), 0);
|
||||
$drug_patient_id = [];
|
||||
if (isset($request->start_date)){
|
||||
$start_date = Carbon::parse($request->start_date)->startOfDay()->toDateTimeString();
|
||||
$end_date = Carbon::parse($request->end_date)->endOfDay()->toDateTimeString();
|
||||
} else {
|
||||
$start_date = Carbon::now()->startOfDay()->toDateTimeString();
|
||||
$end_date = Carbon::now()->endOfDay()->toDateTimeString();
|
||||
}
|
||||
|
||||
// get all diagnoses with hmis category mental health
|
||||
$diagnoses = Diagnosis::where('hmis_category', 8)->get()->toArray();
|
||||
|
||||
foreach ($diagnoses as $diagnosis){
|
||||
$consultations = Consultation::where('primary_diagnosis', $diagnosis['id'])->whereBetween('created_at', [$start_date, $end_date])->get();
|
||||
|
||||
foreach ($consultations as $consultation){
|
||||
$patient_id = $consultation->patient_id;
|
||||
$episode_id = $consultation->episode_id;
|
||||
|
||||
// select treatments
|
||||
$treatments = Treatment::where('patient_id', $patient_id)->where('episode_id', $episode_id)->get();
|
||||
|
||||
foreach ($treatments as $treatment){
|
||||
$ordered_drugs_array = explode(",", $treatment->drugs);
|
||||
|
||||
// i'm tired of foreach's
|
||||
foreach ($ordered_drugs_array as $record){
|
||||
if (key_exists($record, $drugs)){
|
||||
$drugs[$record]++;
|
||||
$drug_patient_id[$record]['patient_ids'][]= $patient_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return view('reports::mental_health_reports.persons_taking_psychotropic_drugs', compact('drugs', 'start_date','drug_patient_id', 'end_date'));
|
||||
}
|
||||
|
||||
public function diagnosed_persons_who_received_treatment(Request $request){
|
||||
if (isset($request->start_date)){
|
||||
$start_date = Carbon::parse($request->start_date)->startOfDay()->toDateTimeString();
|
||||
$end_date = Carbon::parse($request->end_date)->endOfDay()->toDateTimeString();
|
||||
} else {
|
||||
$start_date = Carbon::now()->startOfDay()->toDateTimeString();
|
||||
$end_date = Carbon::now()->endOfDay()->toDateTimeString();
|
||||
}
|
||||
|
||||
// get all diagnoses with hmis category mental health
|
||||
$diagnoses = Diagnosis::where('hmis_category', 8)->get()->toArray();
|
||||
|
||||
$reports = [];
|
||||
$reports_counter = 0;
|
||||
|
||||
foreach ($diagnoses as $diagnosis){
|
||||
$consultations = Consultation::where('primary_diagnosis', $diagnosis['id'])->whereBetween('created_at', [$start_date, $end_date])->get();
|
||||
$reports[$reports_counter]['name'] = $diagnosis['name'];
|
||||
$reports[$reports_counter]['number_of_patients'] = count($consultations);
|
||||
$patient_ids = $treated_patient_ids =[];
|
||||
|
||||
$patients_who_received_treatment = 0;
|
||||
|
||||
foreach ($consultations as $consultation){
|
||||
// select treatments
|
||||
$treatments = Treatment::where('patient_id', $consultation->patient_id)->where('episode_id', $consultation->episode_id)->get();
|
||||
|
||||
if (count($treatments) > 0){
|
||||
// patient received treatment
|
||||
$patients_who_received_treatment++;
|
||||
foreach($treatments as $treatment) $treated_patient_ids[] = $treatment->patient_id;
|
||||
}
|
||||
$patient_ids[]= $consultation->patient_id;
|
||||
}
|
||||
|
||||
$reports[$reports_counter]['number_of_patients_with_treatment'] = $patients_who_received_treatment;
|
||||
$reports[$reports_counter]['patient_ids'] = $patient_ids;
|
||||
$reports[$reports_counter]['treated_patient_ids'] = $treated_patient_ids;
|
||||
|
||||
$reports_counter++;
|
||||
}
|
||||
return view('reports::mental_health_reports.diagnosed_persons_who_received_treatment', compact('reports', 'start_date', 'end_date'));
|
||||
}
|
||||
|
||||
public function patients_lost_to_follow_up(Request $request) {
|
||||
if (isset($request->start_date)){
|
||||
$start_date = Carbon::createFromFormat('d/m/Y', $request->start_date)->toDateString();
|
||||
$end_date = Carbon::createFromFormat('d/m/Y', $request->end_date)->toDateString();
|
||||
} else {
|
||||
$start_date = Carbon::now()->startOfDay()->toDateTimeString();
|
||||
$end_date = Carbon::now()->endOfDay()->toDateTimeString();
|
||||
}
|
||||
|
||||
// get all diagnoses with hmis category mental health
|
||||
$diagnoses = Diagnosis::where('hmis_category', 8)->pluck('id')->toArray();
|
||||
|
||||
$follow_ups = $number_of_patients_lost_ids = $total_follow_ups_ids = [];
|
||||
$number_of_patients_lost = 0;
|
||||
$total_follow_ups = 0;
|
||||
|
||||
$lost_follow_ups = PatientAppointment::whereBetween('appointment_date', [$start_date, $end_date])->get();
|
||||
|
||||
foreach ($lost_follow_ups as $record) {
|
||||
$consultation = Consultation::where('episode_id', $record->episode_id)->first();
|
||||
|
||||
if ($consultation && in_array($consultation->primary_diagnosis, $diagnoses)){
|
||||
|
||||
if ($record->appointment_fulfilled == 0){
|
||||
$follow_ups[$number_of_patients_lost]['patient_id']= $number_of_patients_lost_ids[] = $record->patient_id;
|
||||
$follow_ups[$number_of_patients_lost]['created_at'] = $record->created_at;
|
||||
$follow_ups[$number_of_patients_lost]['appointment_date'] = $record->appointment_date;
|
||||
$number_of_patients_lost++;
|
||||
}
|
||||
$total_follow_ups++;
|
||||
$total_follow_ups_ids[]= $record->patient_id;
|
||||
}
|
||||
}
|
||||
|
||||
$number_of_patients_followed_up = $total_follow_ups - $number_of_patients_lost;
|
||||
$number_of_patients_followed_up_ids = array_diff($total_follow_ups_ids, $number_of_patients_lost_ids);
|
||||
$drop_out_rate = $total_follow_ups > 0 ? ($number_of_patients_lost / $total_follow_ups) * 100 : 0;
|
||||
|
||||
return view('reports::mental_health_reports.patients_lost_to_follow_up', compact('follow_ups', 'start_date', 'end_date', 'total_follow_ups', 'number_of_patients_followed_up', 'number_of_patients_lost', 'drop_out_rate','number_of_patients_followed_up_ids','number_of_patients_lost_ids', 'total_follow_ups_ids'));
|
||||
}
|
||||
|
||||
public function days_drugs_out_of_stock(Request $request) {
|
||||
|
||||
$drugs = DB::table('drugs')->where('available', 1)->whereNull('deleted_at')
|
||||
->whereIn('category_id', [13,27,32,37,46,53])
|
||||
->pluck('id')->toArray();
|
||||
|
||||
if (isset($request->start_date)) {
|
||||
$start_date = Carbon::createFromFormat('d/m/Y', $request->start_date);
|
||||
$end_date = Carbon::createFromFormat('d/m/Y', $request->end_date);
|
||||
} else {
|
||||
$start_date = Carbon::now();
|
||||
$end_date = Carbon::now();
|
||||
}
|
||||
|
||||
$selected_drugs = [];
|
||||
|
||||
$stock_watcher_records = DB::table('stock_watcher')
|
||||
->where('item_type', 1)
|
||||
->whereIn('item_id', $drugs)
|
||||
->get();
|
||||
|
||||
foreach ($stock_watcher_records as $record) {
|
||||
$start_date_search = clone $start_date; // or you can use $start_date->copy()
|
||||
$end_date_search = clone $end_date;
|
||||
|
||||
$details_arr = json_decode($record->details, true);
|
||||
|
||||
// keep incrementing the start date till it reaches the next day after the end date and stop
|
||||
while (!$start_date_search->isAfter($end_date_search)) {
|
||||
if (isset($details_arr[$start_date_search->toDateString()]) && $details_arr[$start_date_search->toDateString()]["pharmacy_stock"] < 1 && $details_arr[$start_date_search->toDateString()]["store_stock"] < 1) {
|
||||
$selected_drugs[$record->item_id] = 1 + ($selected_drugs[$record->item_id] ?? 0);
|
||||
}
|
||||
|
||||
$start_date_search->addDay();
|
||||
}
|
||||
}
|
||||
|
||||
return view('reports::mental_health_reports.days_drugs_out_of_stock', compact('selected_drugs', 'start_date', 'end_date'));
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Reports\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Streamline\Models\MaternityDeliveryRecord;
|
||||
use Carbon\Carbon;
|
||||
use Streamline\Models\HospitalInformation;
|
||||
use Streamline\Models\District;
|
||||
use Streamline\Models\Parish;
|
||||
use Streamline\Models\Subcounty;
|
||||
use Streamline\Models\Patient;
|
||||
use Streamline\Models\Occupation;
|
||||
use Streamline\Models\County;
|
||||
use Streamline\Models\Village;
|
||||
|
||||
class NiraReportController extends Controller {
|
||||
|
||||
public function __construct() {
|
||||
$this->middleware('auth');
|
||||
$this->middleware('permission:nira-birth-report', ['only' => ['birth_report']]);
|
||||
}
|
||||
|
||||
public function birth_report() {
|
||||
$episode_id = session()->get('episode_id');
|
||||
|
||||
// Getting details from the maternity delivery records table
|
||||
$deliveryRecord = MaternityDeliveryRecord::select('patient_id', 'foetal_number', 'date_of_birth', 'delivery_time', 'gender', 'weight')
|
||||
->where('episode_id', $episode_id)->first();
|
||||
|
||||
$hospitalInfo = HospitalInformation::select('name', 'district', 'parish', 'sub_county', 'country', 'sub_district')->where('id', 1)->first();
|
||||
$hospitalDistrict = District::find($hospitalInfo->district)->name;
|
||||
$hospitalSubcounty = Subcounty::find($hospitalInfo->sub_county)->name;
|
||||
$hospitalParish = Parish::find($hospitalInfo->parish)->name;
|
||||
$hospitalLocation = $hospitalParish . ',' . $hospitalSubcounty;
|
||||
$hospitalDistrict = $hospitalDistrict . ',' . $hospitalInfo->country;
|
||||
|
||||
$date_of_birth = is_null($deliveryRecord) ? [] : explode(',', $deliveryRecord->date_of_birth);
|
||||
$delivery_time = is_null($deliveryRecord) ? [] : explode(',', $deliveryRecord->delivery_time);
|
||||
|
||||
$babyOne = [
|
||||
'dob' => is_null($deliveryRecord) ? 'NA' : $date_of_birth[0],
|
||||
'delivery_time' => is_null($deliveryRecord) ? 'NA' : Carbon::parse($delivery_time[0])->format('g:i A'),
|
||||
'hospitalLocation' => is_null($deliveryRecord) ? 'NA' : $hospitalLocation,
|
||||
'hospitalDistrict' => is_null($deliveryRecord) ? 'NA' : $hospitalDistrict,
|
||||
'hospitalName' => is_null($deliveryRecord) ? 'NA' : $hospitalInfo->name,
|
||||
'gender' => is_null($deliveryRecord) ? 'NA' : $deliveryRecord->gender[0],
|
||||
'weight' => is_null($deliveryRecord) ? 'NA' : $deliveryRecord->weight[0],
|
||||
];
|
||||
|
||||
$motherDetail = is_null($deliveryRecord) ? '' :
|
||||
Patient::select('first_name', 'last_name', 'occupation_id', 'national_id', 'district_id', 'county_id', 'subcounty_id', 'parish_id', 'village_id')
|
||||
->where('id', $deliveryRecord->patient_id)->first();
|
||||
$mother = [
|
||||
'last_name' => is_null($deliveryRecord) ? 'NA' : $motherDetail->last_name,
|
||||
'first_name' => is_null($deliveryRecord) ? 'NA' : $motherDetail->first_name,
|
||||
'NIN' => is_null($deliveryRecord) ? 'NA' : $motherDetail->national_id,
|
||||
'occupation' => is_null($deliveryRecord) ? 'NA' : Occupation::find($motherDetail->occupation_id)->name,
|
||||
'district' => is_null($deliveryRecord) ? 'NA' : District::find($motherDetail->district_id)->name,
|
||||
'county' => is_null($deliveryRecord) ? 'NA' : County::find($motherDetail->county_id)->name,
|
||||
'subcounty' => is_null($deliveryRecord) ? 'NA' : Subcounty::find($motherDetail->subcounty_id)->name,
|
||||
'parish' => is_null($deliveryRecord) ? 'NA' : Parish::find($motherDetail->parish_id)->name,
|
||||
'village' => is_null($deliveryRecord) ? 'NA' : Village::find($motherDetail->village_id)->name
|
||||
];
|
||||
|
||||
if (is_null($deliveryRecord)):
|
||||
flash("The MATERNITY DELIVERY RECORD has not been saved on Stre@mline.")->error();
|
||||
endif;
|
||||
|
||||
return view('reports::reports.nira.birth', compact('babyOne', 'mother'));
|
||||
}
|
||||
|
||||
public function death_report() {
|
||||
$episode_id = session()->get('episode_id');
|
||||
return view('reports::reports.nira.death');
|
||||
}
|
||||
|
||||
}
|
||||
+2233
File diff suppressed because it is too large
Load Diff
+2904
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user