255 lines
9.8 KiB
PHP
255 lines
9.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\PatientPocSpirometry;
|
|
use App\Models\PocSpirometry;
|
|
use App\Models\FeedbackPocSpirometry;
|
|
use Illuminate\Http\Request;
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
use App\Exports\InvoicesExport;
|
|
use Svg\Tag\Rect;
|
|
|
|
class PatientPocSpirometryController extends Controller
|
|
{
|
|
public function __construct()
|
|
{
|
|
}
|
|
|
|
public function listpatient(Request $request)
|
|
{
|
|
$user_info = $request->session()->get('user_info');
|
|
if ($user_info == '') {
|
|
return redirect()->route('poclogin');
|
|
}
|
|
|
|
$data = PocSpirometry::find($user_info->id)->patient;
|
|
return view('pocspirometry.listpatient', compact('data', 'user_info'));
|
|
}
|
|
|
|
public function pocpatientlist(Request $request)
|
|
{
|
|
$data = PatientPocSpirometry::get();
|
|
$title = 'POC Spirometry Patient';
|
|
|
|
$buttons = [
|
|
'actions' => ['title' => 'Actions', 'buttons' => ['edit', 'delete']],
|
|
];
|
|
|
|
return view('pocspirometry.listallpatient', compact('data', 'title', 'buttons'));
|
|
}
|
|
|
|
public function poclistfeedback(Request $request)
|
|
{
|
|
$data = FeedbackPocSpirometry::with('pocspirometry')->get();
|
|
// echo "<pre>";
|
|
// print_r($data);
|
|
// exit;
|
|
|
|
$title = 'Feedback';
|
|
|
|
return view('pocspirometry.listallfeedback', compact('data', 'title'));
|
|
}
|
|
|
|
public function exportallfeedback(Request $request)
|
|
{
|
|
$data = FeedbackPocSpirometry::with('pocspirometry')->get();
|
|
|
|
$fields = ['Name of doctor', 'Mobile Number', 'Spirometer improved confidence in diagnosing', 'Easy and readily accessibility is an advantage', 'Immediate diagnosis is an advantage', 'Saves patients time efforts and money as compared to test at a d', 'Better acceptance of diagnosis by the patients', 'Better acceptance of inhalers and better adherence to therapy', 'Better health outcome for the patient', 'Reduces chance of losing the patients to a specialist', 'Time consuming', 'I am better off not using a spirometer ', 'Maintenance of equipment is a challenge', 'Arranging supply of mouthpieces is a challenge', 'The advantages of having a point of care spirometer outweigh the', 'Any other thoughts'];
|
|
$exceldata = [];
|
|
$exceldata[] = $fields;
|
|
foreach ($data as $row) {
|
|
$item = [
|
|
$row->pocspirometry->name_of_doctor,
|
|
$row->pocspirometry->mobile_number,
|
|
$row->spirometer_improved_confidence_in_diagnosing,
|
|
$row->easy_and_readily_accessibility_is_an_advantage,
|
|
$row->immediate_diagnosis_is_an_advantage,
|
|
$row->saves_patients_time_efforts_and_money_as_compared_to_test_at_a_d,
|
|
$row->better_acceptance_of_diagnosis_by_the_patients,
|
|
$row->better_acceptance_of_inhalers_and_better_adherence_to_therapy,
|
|
$row->better_health_outcome_for_the_patient,
|
|
$row->reduces_chance_of_losing_the_patients_to_a_specialist,
|
|
$row->time_consuming,
|
|
$row->i_am_better_off_not_using_a_spirometer_,
|
|
$row->maintenance_of_equipment_is_a_challenge,
|
|
$row->arranging_supply_of_mouthpieces_is_a_challenge,
|
|
$row->the_advantages_of_having_a_point_of_care_spirometer_outweigh_the,
|
|
$row->any_other_thoughts,
|
|
];
|
|
$exceldata[] = $item;
|
|
}
|
|
|
|
|
|
return Excel::download(new InvoicesExport($exceldata), 'feedback.xlsx');
|
|
}
|
|
|
|
function exportallpatient(Request $request)
|
|
{
|
|
$data = PatientPocSpirometry::get();
|
|
// return print_r($data);
|
|
$fields = ['patient_no', 'age', 'gender', 'presenting_with_respiratory_symptoms', 'past_or_current_ho_smoking', 'past_or_current_ho_exposure_to_indoor_or_ambient_air_pollution', 'past_or_current_ho_atopy', 'family_ho_atopy', 'clinical_diagnosis', 'whether_spirometry_advised', 'if_yes_diagnosis_after_spirometry'];
|
|
$exceldata = [];
|
|
$exceldata[] = $fields;
|
|
foreach ($data as $row) {
|
|
$item = [
|
|
$row->patient_no,
|
|
$row->age,
|
|
$row->gender,
|
|
$row->presenting_with_respiratory_symptoms,
|
|
$row->past_or_current_ho_smoking,
|
|
$row->past_or_current_ho_exposure_to_indoor_or_ambient_air_pollution,
|
|
$row->past_or_current_ho_atopy,
|
|
$row->family_ho_atopy,
|
|
$row->clinical_diagnosis,
|
|
$row->whether_spirometry_advised,
|
|
$row->if_yes_diagnosis_after_spirometry
|
|
];
|
|
$exceldata[] = $item;
|
|
}
|
|
|
|
|
|
return Excel::download(new InvoicesExport($exceldata), 'patient_report.xlsx');
|
|
}
|
|
|
|
function exportalldoctor(Request $request)
|
|
{
|
|
$data = PocSpirometry::get();
|
|
// return print_r($data);
|
|
$fields = ['Name Of Doctor', 'Mobile Number', 'Password', 'City Town', 'Qualification', 'Specialization', 'Type Of Practice', 'Years Of Practice', 'No Of Patients Seen In Opd', 'Respiratory Symptoms Percentage', 'Diagnosis Basis', 'Spirometry Done From Where', 'What Prevented You To Buy Spirometer'];
|
|
$exceldata = [];
|
|
$exceldata[] = $fields;
|
|
foreach ($data as $row) {
|
|
$item = [
|
|
$row->name_of_doctor,
|
|
$row->mobile_number,
|
|
$row->password,
|
|
$row->city_town,
|
|
$row->qualification,
|
|
$row->specialization,
|
|
$row->type_of_practice,
|
|
$row->years_of_practice,
|
|
$row->no_of_patients_seen_in_opd,
|
|
$row->respiratory_symptoms_percentage,
|
|
$row->diagnosis_basis,
|
|
$row->spirometry_done_from_where,
|
|
$row->what_prevented_you_to_buy_spirometer
|
|
];
|
|
$exceldata[] = $item;
|
|
}
|
|
|
|
|
|
return Excel::download(new InvoicesExport($exceldata), 'patient_report.xlsx');
|
|
}
|
|
|
|
public function pocdoctorslist(Request $request)
|
|
{
|
|
$data = PocSpirometry::get();
|
|
$title = 'POC Spirometry Doctor';
|
|
return view('pocspirometry.listalldoctors', compact('data', 'title'));
|
|
}
|
|
|
|
public function exportpocpatient(Request $request)
|
|
{
|
|
$user_info = $request->session()->get('user_info');
|
|
if ($user_info == '') {
|
|
return redirect()->route('poclogin');
|
|
}
|
|
|
|
$data = PocSpirometry::find($user_info->id)->patient;
|
|
|
|
$fields = ['patient_no', 'age', 'gender', 'presenting_with_respiratory_symptoms', 'past_or_current_ho_smoking', 'past_or_current_ho_exposure_to_indoor_or_ambient_air_pollution', 'past_or_current_ho_atopy', 'family_ho_atopy', 'clinical_diagnosis', 'whether_spirometry_advised', 'if_yes_diagnosis_after_spirometry'];
|
|
$exceldata = [];
|
|
$exceldata[] = $fields;
|
|
foreach ($data as $row) {
|
|
$item = [
|
|
$row->patient_no,
|
|
$row->age,
|
|
$row->gender,
|
|
$row->presenting_with_respiratory_symptoms,
|
|
$row->past_or_current_ho_smoking,
|
|
$row->past_or_current_ho_exposure_to_indoor_or_ambient_air_pollution,
|
|
$row->past_or_current_ho_atopy,
|
|
$row->family_ho_atopy,
|
|
$row->clinical_diagnosis,
|
|
$row->whether_spirometry_advised,
|
|
$row->if_yes_diagnosis_after_spirometry
|
|
];
|
|
$exceldata[] = $item;
|
|
}
|
|
|
|
|
|
return Excel::download(new InvoicesExport($exceldata), 'patients.xlsx');
|
|
}
|
|
|
|
public function addpatient(Request $request)
|
|
{
|
|
$user_info = $request->session()->get('user_info');
|
|
if ($user_info == '') {
|
|
return redirect()->route('poclogin');
|
|
}
|
|
return view('pocspirometry.addpatient');
|
|
}
|
|
|
|
public function submitpatient(Request $request)
|
|
{
|
|
$fields = $request->only([
|
|
'edit_record_id',
|
|
'patient_no',
|
|
'age',
|
|
'gender',
|
|
'presenting_with_respiratory_symptoms',
|
|
'past_or_current_ho_smoking',
|
|
'past_or_current_ho_exposure_to_indoor_or_ambient_air_pollution',
|
|
'past_or_current_ho_atopy',
|
|
'family_ho_atopy',
|
|
'clinical_diagnosis',
|
|
'whether_spirometry_advised',
|
|
'if_yes_diagnosis_after_spirometry',
|
|
]);
|
|
|
|
$data = $request->session()->get('user_info');
|
|
$fields['user_id'] = $data->id;
|
|
unset($fields['edit_record_id']);
|
|
|
|
if ($request->edit_record_id != '') {
|
|
|
|
$res = PatientPocSpirometry::where('id', $request->edit_record_id)->update($fields);
|
|
if ($res) {
|
|
return redirect()->route('pocpatient')->with('success', 'Patient Edited Sucessfully');
|
|
} else {
|
|
return redirect()->route('pocpatient')->with('error', 'Internal Server Error');
|
|
}
|
|
} else {
|
|
|
|
PatientPocSpirometry::create($fields);
|
|
return redirect()->route('pocpatient')->with('success', 'Patient Added Sucessfully');
|
|
}
|
|
}
|
|
|
|
public function editpatient(Request $request, $id)
|
|
{
|
|
$data = PatientPocSpirometry::find($id);
|
|
return view('pocspirometry.addpatient', compact('data'));
|
|
}
|
|
|
|
public function feedback(Request $request)
|
|
{
|
|
$user_info = $request->session()->get('user_info');
|
|
if ($user_info == '') {
|
|
return redirect()->route('poclogin');
|
|
}
|
|
return view('pocspirometry.feedback');
|
|
}
|
|
|
|
public function submitpocfeedback(Request $request)
|
|
{
|
|
$fields = $request->except('_token');
|
|
$data = $request->session()->get('user_info');
|
|
$fields['user_id'] = $data->id;
|
|
|
|
FeedbackPocSpirometry::create($fields);
|
|
return redirect()->route('pocpatient')->with('success', 'Feedback submitted Sucessfully');
|
|
}
|
|
}
|