Files
streamline-emr/docker/_streamline-src/app/Observers/TriageObserver.php
T

160 lines
11 KiB
PHP

<?php
namespace Streamline\Observers;
use Streamline\Models\GenderBasedViolence;
use Streamline\Models\Triage;
use Streamline\Models\HivGenderBaseViolence;
class TriageObserver
{
/**
* Handle the Triage "created" event.
*/
public function created(Triage $triage): void
{
// if (request()->is_hiv_and_gbv_screening_tool_enabled || request()->is_hiv_screening_tool_enabled) {
if (request()->is_hiv_screening_tool_enabled) {
$new_hiv = new HivGenderBaseViolence();
$new_hiv->triage_id = $triage->id;
$new_hiv->patient_id = $triage->patient_id;
$new_hiv->mother_hiv_positive = request()->mother_hiv_positive ?? 0;
$new_hiv->has_been_sick_last_3_months = request()->has_been_sick_last_3_months ?? 0;
$new_hiv->has_recurring_skin_problem = request()->has_recurring_skin_problem ?? 0;
$new_hiv->has_lost_weight_last_3_months = request()->has_lost_weight_last_3_months ?? 0;
$new_hiv->has_had_tb = request()->has_had_tb ?? 0;
$new_hiv->is_growing_well = request()->is_growing_well ?? 0;
$new_hiv->tested_for_hiv_in_past_12_months = request()->tested_for_hiv_in_past_12_months ?? 0;
$new_hiv->had_tb_or_presumptive_tb = request()->had_tb_or_presumptive_tb ?? 0;
$new_hiv->sti_symptoms_present = request()->sti_symptoms_present ?? 0;
$new_hiv->diagnosed_with_hepatitis_b_or_c = request()->diagnosed_with_hepatitis_b_or_c ?? 0;
$new_hiv->experienced_or_caused_sexual_violence = request()->experienced_or_caused_sexual_violence ?? 0;
$new_hiv->reactive_hiv_self_test_result = request()->reactive_hiv_self_test_result ?? 0;
$new_hiv->identified_through_index_client = request()->identified_through_index_client ?? 0;
$new_hiv->exposed_to_hiv_positive_or_unknown_source = request()->exposed_to_hiv_positive_or_unknown_source ?? 0;
$new_hiv->hiv_symptoms_without_recent_test = request()->hiv_symptoms_without_recent_test ?? 0;
$new_hiv->tested_for_hiv_last_3_months = request()->tested_for_hiv_last_3_months ?? 0;
$new_hiv->tested_for_hiv_last_12_months = request()->tested_for_hiv_last_12_months ?? 0;
$new_hiv->unprotected_sex_with_partner_of_unknown_hiv_status = request()->unprotected_sex_with_partner_of_unknown_hiv_status ?? 0;
$new_hiv->unprotected_sex_with_hiv_positive_partner = request()->unprotected_sex_with_hiv_positive_partner ?? 0;
$new_hiv->shared_needles_or_piercing_objects = request()->shared_needles_or_piercing_objects ?? 0;
$new_hiv->experienced_threats_in_past_12_months = request()->experienced_threats_in_past_12_months ?? 0;
$new_hiv->prevented_from_accessing_healthcare_in_past_12_months = request()->prevented_from_accessing_healthcare_in_past_12_months ?? 0;
$new_hiv->experienced_physical_violence_in_past_12_months = request()->experienced_physical_violence_in_past_12_months ?? 0;
$new_hiv->experienced_unwanted_touching_of_private_parts_in_past_12_months = request()->experienced_unwanted_touching_of_private_parts_in_past_12_months ?? 0;
$new_hiv->experienced_forced_sex_in_past_12_months = request()->experienced_forced_sex_in_past_12_months ?? 0;
$new_hiv->experienced_condom_refusal_in_past_12_months = request()->experienced_condom_refusal_in_past_12_months ?? 0;
$new_hiv->save();
}
if (request()->is_gbv_screening_tool_enabled) {
$new_gbv = new GenderBasedViolence();
$new_gbv->triage_id = $triage->id;
$new_gbv->patient_id = $triage->patient_id;
$new_gbv->child_feeling_unsafe = request()->child_feeling_unsafe;
$new_gbv->past_12_threatened_humiliated_caused_afraid_when = request()->past_12_threatened_humiliated_caused_afraid_when;
$new_gbv->past_12_threatened_humiliated_caused_afraid_by_whom = request()->past_12_threatened_humiliated_caused_afraid_by_whom;
$new_gbv->past_12_prevented_coming_clinic_medication_treatment = request()->past_12_prevented_coming_clinic_medication_treatment;
$new_gbv->past_12_any_threatened_or_harmed = request()->past_12_any_threatened_or_harmed;
$new_gbv->past_12_any_touched_private_parts_not_want = request()->past_12_any_touched_private_parts_not_want;
$new_gbv->past_12_any_forced_sex = request()->past_12_any_forced_sex;
$new_gbv->past_12_any_refused_condom_when_wanted = request()->past_12_any_refused_condom_when_wanted;
$new_gbv->created_by = request()->created_by;
$new_gbv->others = request()->others;
$new_gbv->created_by = request()->updated_by;
$new_gbv->save();
}
}
/**
* Handle the Triage "updated" event.
*/
public function updated(Triage $triage): void
{
if (request()->is_hiv_screening_tool_enabled) {
$got_new = HivGenderBaseViolence::where('triage_id', $triage->id)->first();
$got_new->triage_id = $triage->id;
$got_new->patient_id = $triage->patient_id;
$got_new->mother_hiv_positive = request()->mother_hiv_positive ?? $got_new->mother_hiv_positive;
$got_new->has_been_sick_last_3_months = request()->has_been_sick_last_3_months ?? $got_new->has_been_sick_last_3_months;
$got_new->has_recurring_skin_problem = request()->has_recurring_skin_problem ?? $got_new->has_recurring_skin_problem;
$got_new->has_lost_weight_last_3_months = request()->has_lost_weight_last_3_months ?? $got_new->has_lost_weight_last_3_months;
$got_new->has_had_tb = request()->has_had_tb ?? $got_new->has_had_tb;
$got_new->is_growing_well = request()->is_growing_well ?? $got_new->is_growing_well;
$got_new->tested_for_hiv_in_past_12_months = request()->tested_for_hiv_in_past_12_months ?? $got_new->tested_for_hiv_in_past_12_months;
$got_new->had_tb_or_presumptive_tb = request()->had_tb_or_presumptive_tb ?? $got_new->had_tb_or_presumptive_tb;
$got_new->sti_symptoms_present = request()->sti_symptoms_present ?? $got_new->sti_symptoms_present;
$got_new->diagnosed_with_hepatitis_b_or_c = request()->diagnosed_with_hepatitis_b_or_c ?? $got_new->diagnosed_with_hepatitis_b_or_c;
$got_new->experienced_or_caused_sexual_violence = request()->experienced_or_caused_sexual_violence ?? $got_new->experienced_or_caused_sexual_violence;
$got_new->reactive_hiv_self_test_result = request()->reactive_hiv_self_test_result ?? $got_new->reactive_hiv_self_test_result;
$got_new->identified_through_index_client = request()->identified_through_index_client ?? $got_new->identified_through_index_client;
$got_new->exposed_to_hiv_positive_or_unknown_source = request()->exposed_to_hiv_positive_or_unknown_source ?? $got_new->exposed_to_hiv_positive_or_unknown_source;
$got_new->hiv_symptoms_without_recent_test = request()->hiv_symptoms_without_recent_test ?? $got_new->hiv_symptoms_without_recent_test;
$got_new->tested_for_hiv_last_3_months = request()->tested_for_hiv_last_3_months ?? $got_new->tested_for_hiv_last_3_months;
$got_new->tested_for_hiv_last_12_months = request()->tested_for_hiv_last_12_months ?? $got_new->tested_for_hiv_last_12_months;
$got_new->unprotected_sex_with_partner_of_unknown_hiv_status = request()->unprotected_sex_with_partner_of_unknown_hiv_status ?? $got_new->unprotected_sex_with_partner_of_unknown_hiv_status;
$got_new->unprotected_sex_with_hiv_positive_partner = request()->unprotected_sex_with_hiv_positive_partner ?? $got_new->unprotected_sex_with_hiv_positive_partner;
$got_new->shared_needles_or_piercing_objects = request()->shared_needles_or_piercing_objects ?? $got_new->shared_needles_or_piercing_objects;
$got_new->experienced_threats_in_past_12_months = request()->experienced_threats_in_past_12_months ?? $got_new->experienced_threats_in_past_12_months;
$got_new->prevented_from_accessing_healthcare_in_past_12_months = request()->prevented_from_accessing_healthcare_in_past_12_months ?? $got_new->prevented_from_accessing_healthcare_in_past_12_months;
$got_new->experienced_physical_violence_in_past_12_months = request()->experienced_physical_violence_in_past_12_months ?? $got_new->experienced_physical_violence_in_past_12_months;
$got_new->experienced_unwanted_touching_of_private_parts_in_past_12_months = request()->experienced_unwanted_touching_of_private_parts_in_past_12_months ?? $got_new->experienced_unwanted_touching_of_private_parts_in_past_12_months;
$got_new->experienced_forced_sex_in_past_12_months = request()->experienced_forced_sex_in_past_12_months ?? $got_new->experienced_forced_sex_in_past_12_months;
$got_new->experienced_condom_refusal_in_past_12_months = request()->experienced_condom_refusal_in_past_12_months ?? $got_new->experienced_condom_refusal_in_past_12_months;
$got_new->save();
}
if (request()->is_gbv_screening_tool_enabled) {
$got_gbv = GenderBasedViolence::where('triage_id', $triage->id)->first();
$got_gbv->triage_id = $triage->id;
$got_gbv->patient_id = $triage->patient_id;
$got_gbv->child_feeling_unsafe = request()->child_feeling_unsafe ?? $got_gbv->child_feeling_unsafe;
$got_gbv->past_12_threatened_humiliated_caused_afraid_when = request()->past_12_threatened_humiliated_caused_afraid_when ?? $got_gbv->past_12_threatened_humiliated_caused_afraid_when;
$got_gbv->past_12_threatened_humiliated_caused_afraid_by_whom = request()->past_12_threatened_humiliated_caused_afraid_by_whom ?? $got_gbv->past_12_threatened_humiliated_caused_afraid_by_whom;
$got_gbv->past_12_prevented_coming_clinic_medication_treatment = request()->past_12_prevented_coming_clinic_medication_treatment ?? $got_gbv->past_12_prevented_coming_clinic_medication_treatment;
$got_gbv->past_12_any_threatened_or_harmed = request()->past_12_any_threatened_or_harmed ?? $got_gbv->past_12_any_threatened_or_harmed;
$got_gbv->past_12_any_touched_private_parts_not_want = request()->past_12_any_touched_private_parts_not_want ?? $got_gbv->past_12_any_touched_private_parts_not_want;
$got_gbv->past_12_any_forced_sex = request()->past_12_any_forced_sex ?? $got_gbv->past_12_any_forced_sex;
$got_gbv->past_12_any_refused_condom_when_wanted = request()->past_12_any_refused_condom_when_wanted ?? $got_gbv->past_12_any_refused_condom_when_wanted;
$got_gbv->created_by = request()->created_by ?? $got_gbv->created_by;
$got_gbv->others = request()->others ?? $got_gbv->others;
$got_gbv->created_by = request()->updated_by;
$got_gbv->save();
}
}
/**
* Handle the Triage "deleted" event.
*/
public function deleted(Triage $triage): void
{
//
}
/**
* Handle the Triage "restored" event.
*/
public function restored(Triage $triage): void
{
//
}
/**
* Handle the Triage "force deleted" event.
*/
public function forceDeleted(Triage $triage): void
{
//
}
}