Home / Admin / ACF_KEYSMST_MSTCASECPT – TAB: SAFETY & RISK (v3.0 Modular)
Duplicate Snippet

Embed Snippet on Your Site

ACF_KEYSMST_MSTCASECPT – TAB: SAFETY & RISK (v3.0 Modular)

ismail daugherty PRO
<10
Code Preview
php
<?php
/**
 * ============================================
 * MST CASE - TAB: SAFETY & RISK (v3.0 Modular)
 * ============================================
 * 
 * Purpose: Adds Safety & Risk tab to master field group
 * Parent: group_mst_case_master
 * Source: Form 245 - MST Safety Assessment + ongoing safety monitoring
 * Fields: 20 fields
 * 
 * VERSION: 3.0 - Modular Architecture
 * Priority: 12 (loads after Status & Tracking)
 * 
 * CRITICAL: Safety data for MST compliance and risk management
 * - Current safety status and risk levels
 * - Safety plan information
 * - Crisis contacts and protocols
 * - Historical safety incidents
 * 
 * IMPORTANT: Master field group snippet must be active first!
 * ============================================
 */
if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly
}
add_action('acf/init', 'mst_add_safety_risk_tab', 12);
function mst_add_safety_risk_tab() {
    
    if (!function_exists('acf_add_local_field')) {
        return;
    }
    
    // ========================================
    // TAB: SAFETY & RISK
    // ========================================
    acf_add_local_field(array(
        'key' => 'field_tab_safety_risk',
        'label' => '⚠️ Safety & Risk',
        'name' => '',
        'type' => 'tab',
        'parent' => 'group_mst_case_master',
        'placement' => 'top',
    ));
    
    // ========================================
    // SECTION 1: CURRENT SAFETY STATUS
    // ========================================
    acf_add_local_field(array(
        'key' => 'field_section_current_safety',
        'label' => 'Current Safety Status',
        'name' => '',
        'type' => 'message',
        'parent' => 'group_mst_case_master',
        'message' => '<strong style="color: #d63638;">⚠️ CRITICAL: Current safety assessment and risk levels (updated from Form 245 and Form 301)</strong>',
        'new_lines' => '',
        'esc_html' => 0,
    ));
    
    // Field 1: Current Safety Status
    acf_add_local_field(array(
        'key' => 'field_current_safety_status',
        'label' => 'Current Safety Status',
        'name' => 'current_safety_status',
        'type' => 'select',
        'parent' => 'group_mst_case_master',
        'instructions' => 'Overall safety status - triggers escalation protocols',
        'required' => 1,
        'wrapper' => array('width' => '50'),
        'choices' => array(
            'safe' => '✅ Safe - No Current Concerns',
            'monitor' => '👁️ Monitor - Low Risk Factors Present',
            'high_risk' => '⚠️ High Risk - Active Safety Plan Required',
            'critical' => '🚨 Critical - Immediate Intervention Required',
        ),
        'default_value' => 'safe',
        'allow_null' => 0,
        'ui' => 1,
        'return_format' => 'value',
    ));
    
    // Field 2: Last Safety Assessment Date
    acf_add_local_field(array(
        'key' => 'field_last_safety_assessment_date',
        'label' => 'Last Safety Assessment',
        'name' => 'last_safety_assessment_date',
        'type' => 'date_picker',
        'parent' => 'group_mst_case_master',
        'instructions' => 'Date of most recent Form 245 completion',
        'required' => 0,
        'wrapper' => array('width' => '50'),
        'display_format' => 'm/d/Y',
        'return_format' => 'Y-m-d',
        'first_day' => 0,
    ));
    
    // ========================================
    // SECTION 2: SPECIFIC RISK LEVELS
    // ========================================
    acf_add_local_field(array(
        'key' => 'field_section_risk_levels',
        'label' => 'Specific Risk Assessment',
        'name' => '',
        'type' => 'message',
        'parent' => 'group_mst_case_master',
        'message' => '<strong>Individual risk factors tracked separately</strong>',
        'new_lines' => '',
        'esc_html' => 0,
    ));
    
    // Field 3: Suicide Risk Current
    acf_add_local_field(array(
        'key' => 'field_suicide_risk_current',
        'label' => 'Suicide Risk Level',
        'name' => 'suicide_risk_current',
        'type' => 'select',
        'parent' => 'group_mst_case_master',
        'instructions' => 'Current suicide risk assessment',
        'required' => 0,
        'wrapper' => array('width' => '50'),
        'choices' => array(
            'none' => 'None - No Risk',
            'low' => 'Low - Past History Only',
            'moderate' => 'Moderate - Current Ideation',
            'high' => 'High - Plan Present',
            'imminent' => 'Imminent - Immediate Risk',
        ),
        'default_value' => 'none',
        'allow_null' => 0,
        'ui' => 1,
        'return_format' => 'value',
    ));
    
    // Field 4: Self-Harm Risk
    acf_add_local_field(array(
        'key' => 'field_self_harm_risk',
        'label' => 'Self-Harm Risk',
        'name' => 'self_harm_risk',
        'type' => 'select',
        'parent' => 'group_mst_case_master',
        'instructions' => 'Non-suicidal self-injury risk',
        'required' => 0,
        'wrapper' => array('width' => '50'),
        'choices' => array(
            'none' => 'None',
            'low' => 'Low',
            'moderate' => 'Moderate',
            'high' => 'High',
        ),
        'default_value' => 'none',
        'allow_null' => 0,
        'ui' => 1,
        'return_format' => 'value',
    ));
    
    // Field 5: Violence Risk to Others
    acf_add_local_field(array(
        'key' => 'field_violence_risk_to_others',
        'label' => 'Violence Risk (to others)',
        'name' => 'violence_risk_to_others',
        'type' => 'select',
        'parent' => 'group_mst_case_master',
        'instructions' => 'Risk of harm to others',
        'required' => 0,
        'wrapper' => array('width' => '50'),
        'choices' => array(
            'none' => 'None - No Risk',
            'low' => 'Low - Verbal Threats Only',
            'moderate' => 'Moderate - History of Violence',
            'high' => 'High - Plan Present',
            'imminent' => 'Imminent - Immediate Risk',
        ),
        'default_value' => 'none',
        'allow_null' => 0,
        'ui' => 1,
        'return_format' => 'value',
    ));
    
    // Field 6: Substance Abuse Current
    acf_add_local_field(array(
        'key' => 'field_substance_abuse_current',
        'label' => 'Substance Use Risk',
        'name' => 'substance_abuse_current',
        'type' => 'select',
        'parent' => 'group_mst_case_master',
        'instructions' => 'Current substance use severity',
        'required' => 0,
        'wrapper' => array('width' => '50'),
        'choices' => array(
            'none' => 'None',
            'minimal' => 'Minimal - Experimental',
            'moderate' => 'Moderate - Regular Use',
            'severe' => 'Severe - Daily Use',
            'overdose_risk' => 'Critical - Overdose Risk',
        ),
        'default_value' => 'none',
        'allow_null' => 0,
        'ui' => 1,
        'return_format' => 'value',
    ));
    
    // Field 7: Runaway Risk
    acf_add_local_field(array(
        'key' => 'field_runaway_risk',
        'label' => 'Runaway Risk',
        'name' => 'runaway_risk',
        'type' => 'select',
        'parent' => 'group_mst_case_master',
        'instructions' => 'Risk of youth running away',
        'required' => 0,
        'wrapper' => array('width' => '50'),
        'choices' => array(
            'none' => 'None - No History',
            'low' => 'Low - Past History',
            'moderate' => 'Moderate - Recent Threats',
            'high' => 'High - Imminent Risk',
        ),
        'default_value' => 'none',
        'allow_null' => 0,
        'ui' => 1,
        'return_format' => 'value',
    ));
    
    // Field 8: Sexual Behavior Concerns
    acf_add_local_field(array(
        'key' => 'field_sexual_behavior_concerns',
        'label' => 'Sexual Behavior Concerns',
        'name' => 'sexual_behavior_concerns',
        'type' => 'select',
        'parent' => 'group_mst_case_master',
        'instructions' => 'Risky or problematic sexual behavior',
        'required' => 0,
        'wrapper' => array('width' => '50'),
        'choices' => array(
            'none' => 'None',
            'monitor' => 'Monitor - Age-inappropriate activity',
            'significant' => 'Significant - Safety concerns',
        ),
        'default_value' => 'none',
        'allow_null' => 0,
        'ui' => 1,
        'return_format' => 'value',
    ));
    
    // ========================================
    // SECTION 3: SAFETY PLAN & PROTOCOLS
    // ========================================
    acf_add_local_field(array(
        'key' => 'field_section_safety_plan',
        'label' => 'Safety Plan & Protocols',
        'name' => '',
        'type' => 'message',
        'parent' => 'group_mst_case_master',
        'message' => '<strong>Active safety plan and crisis response protocols</strong>',
        'new_lines' => '',
        'esc_html' => 0,
    ));
    
    // Field 9: Safety Plan Active
    acf_add_local_field(array(
        'key' => 'field_safety_plan_active',
        'label' => 'Safety Plan Status',
        'name' => 'safety_plan_active',
        'type' => 'true_false',
        'parent' => 'group_mst_case_master',
        'instructions' => 'Is there an active safety plan in place?',
        'required' => 0,
        'wrapper' => array('width' => '50'),
        'message' => 'Active safety plan in place',
        'default_value' => 0,
        'ui' => 1,
        'ui_on_text' => 'Yes',
        'ui_off_text' => 'No',
    ));
    
    // Field 10: Safety Plan Last Reviewed
    acf_add_local_field(array(
        'key' => 'field_safety_plan_reviewed_date',
        'label' => 'Safety Plan Last Reviewed',
        'name' => 'safety_plan_reviewed_date',
        'type' => 'date_picker',
        'parent' => 'group_mst_case_master',
        'instructions' => 'Date safety plan was last reviewed with family',
        'required' => 0,
        'wrapper' => array('width' => '50'),
        'display_format' => 'm/d/Y',
        'return_format' => 'Y-m-d',
        'first_day' => 0,
    ));
    
    // Field 11: Current Safety Plan (Summary)
    acf_add_local_field(array(
        'key' => 'field_safety_plan_baseline',
        'label' => 'Current Safety Plan',
        'name' => 'safety_plan_baseline',
        'type' => 'textarea',
        'parent' => 'group_mst_case_master',
        'instructions' => 'Summary of current safety plan and protocols',
        'required' => 0,
        'wrapper' => array('width' => '100'),
        'rows' => 4,
        'maxlength' => '',
        'placeholder' => 'Summarize key safety plan elements, warning signs, coping strategies, and crisis contacts',
    ));
    
    // Field 12: Safety Concerns Current
    acf_add_local_field(array(
        'key' => 'field_safety_concerns_current',
        'label' => 'Current Safety Concerns',
        'name' => 'safety_concerns_current',
        'type' => 'textarea',
        'parent' => 'group_mst_case_master',
        'instructions' => 'Detailed description of current safety concerns',
        'required' => 0,
        'wrapper' => array('width' => '100'),
        'rows' => 3,
        'placeholder' => 'Detail specific safety concerns, triggers, and risk factors',
    ));
    
    // ========================================
    // SECTION 4: CRISIS INFORMATION
    // ========================================
    acf_add_local_field(array(
        'key' => 'field_section_crisis_info',
        'label' => 'Crisis Response Information',
        'name' => '',
        'type' => 'message',
        'parent' => 'group_mst_case_master',
        'message' => '<strong>Emergency contacts and crisis response protocols</strong>',
        'new_lines' => '',
        'esc_html' => 0,
    ));
    
    // Field 13: Crisis Contacts
    acf_add_local_field(array(
        'key' => 'field_crisis_contacts',
        'label' => 'Crisis Contacts',
        'name' => 'crisis_contacts',
        'type' => 'textarea',
        'parent' => 'group_mst_case_master',
        'instructions' => 'Emergency contacts for crisis situations',
        'required' => 0,
        'wrapper' => array('width' => '100'),
        'rows' => 3,
        'placeholder' => 'List emergency contacts with names, relationships, phone numbers, and availability',
    ));
    
    // Field 14: Psychiatric Provider
    acf_add_local_field(array(
        'key' => 'field_psychiatric_provider',
        'label' => 'Psychiatric Provider',
        'name' => 'psychiatric_provider',
        'type' => 'text',
        'parent' => 'group_mst_case_master',
        'instructions' => 'Current psychiatrist or prescriber name',
        'required' => 0,
        'wrapper' => array('width' => '50'),
        'placeholder' => 'Provider name',
    ));
    
    // Field 15: Psychiatric Provider Phone
    acf_add_local_field(array(
        'key' => 'field_psychiatric_provider_phone',
        'label' => 'Psychiatric Provider Phone',
        'name' => 'psychiatric_provider_phone',
        'type' => 'text',
        'parent' => 'group_mst_case_master',
        'instructions' => 'Provider contact phone',
        'required' => 0,
        'wrapper' => array('width' => '50'),
        'placeholder' => 'Phone number',
    ));
    
    // ========================================
    // SECTION 5: MEDICATIONS & COMPLIANCE
    // ========================================
    acf_add_local_field(array(
        'key' => 'field_section_medications',
        'label' => 'Medications & Compliance',
        'name' => '',
        'type' => 'message',
        'parent' => 'group_mst_case_master',
        'message' => '<strong>Current medications and compliance tracking</strong>',
        'new_lines' => '',
        'esc_html' => 0,
    ));
    
    // Field 16: Current Medications
    acf_add_local_field(array(
        'key' => 'field_current_medications',
        'label' => 'Current Medications',
        'name' => 'current_medications',
        'type' => 'textarea',
        'parent' => 'group_mst_case_master',
        'instructions' => 'List all current medications, dosages, and purposes',
        'required' => 0,
        'wrapper' => array('width' => '100'),
        'rows' => 3,
        'placeholder' => 'Medication name | Dosage | Frequency | Purpose',
    ));
    
    // Field 17: Medication Compliance
    acf_add_local_field(array(
        'key' => 'field_medication_compliance',
        'label' => 'Medication Compliance',
        'name' => 'medication_compliance',
        'type' => 'select',
        'parent' => 'group_mst_case_master',
        'instructions' => 'Level of medication adherence',
        'required' => 0,
        'wrapper' => array('width' => '100'),
        'choices' => array(
            'na' => 'N/A - No Medications',
            'poor' => 'Poor - Rarely takes as prescribed',
            'fair' => 'Fair - Sometimes misses doses',
            'good' => 'Good - Usually compliant',
            'excellent' => 'Excellent - Consistently compliant',
        ),
        'default_value' => 'na',
        'allow_null' => 0,
        'ui' => 1,
        'return_format' => 'value',
    ));
    
    // ========================================
    // SECTION 6: SAFETY HISTORY
    // ========================================
    acf_add_local_field(array(
        'key' => 'field_section_safety_history',
        'label' => 'Safety Incident History',
        'name' => '',
        'type' => 'message',
        'parent' => 'group_mst_case_master',
        'message' => '<strong>Historical safety incidents and escalations</strong>',
        'new_lines' => '',
        'esc_html' => 0,
    ));
    
    // Field 18: Psychiatric Hospitalization History
    acf_add_local_field(array(
        'key' => 'field_psychiatric_hospitalization_history',
        'label' => 'Psychiatric Hospitalization History',
        'name' => 'psychiatric_hospitalization_history',
        'type' => 'textarea',
        'parent' => 'group_mst_case_master',
        'instructions' => 'History of psychiatric hospitalizations',
        'required' => 0,
        'wrapper' => array('width' => '100'),
        'rows' => 2,
        'placeholder' => 'Date | Facility | Reason | Duration',
    ));
    
    // Field 19: Safety Escalations Count
    acf_add_local_field(array(
        'key' => 'field_safety_escalations_count',
        'label' => 'Total Safety Escalations',
        'name' => 'safety_escalations_count',
        'type' => 'number',
        'parent' => 'group_mst_case_master',
        'instructions' => 'Number of safety escalations since case opened',
        'required' => 0,
        'wrapper' => array('width' => '50'),
        'default_value' => 0,
        'min' => 0,
        'step' => 1,
        'readonly' => 1,
    ));
    
    // Field 20: Last Safety Incident Date
    acf_add_local_field(array(
        'key' => 'field_last_safety_incident_date',
        'label' => 'Last Safety Incident',
        'name' => 'last_safety_incident_date',
        'type' => 'date_picker',
        'parent' => 'group_mst_case_master',
        'instructions' => 'Date of most recent safety incident',
        'required' => 0,
        'wrapper' => array('width' => '50'),
        'display_format' => 'm/d/Y',
        'return_format' => 'Y-m-d',
        'first_day' => 0,
    ));
}

Comments

Add a Comment