<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\RPublication;
use App\Models\RPublicationFile;
use App\Models\RReviewFeedback;
use Illuminate\Support\Facades\DB;

/**
 * Seeder: RResearchDataSeeder
 * 
 * Seeds comprehensive research publications data for SSHIA.
 * Focus on health advocacy, digital health research, and health literacy in South Sudan.
 * 
 * @author SSHIA Development Team
 * @version 1.0.0
 */
class RResearchDataSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $this->command->info('Seeding Research & Innovation Centre data...');

        // Get first user (assumed to be admin/manager) for author
        $authorId = \App\Models\User::first()->id ?? 1;
        $reviewerId = \App\Models\User::whereHas('roles', function($q) {
            $q->whereIn('name', ['Manager', 'Super Manager']);
        })->first()->id ?? $authorId;

        // Create Publications
        $publications = $this->createPublications($authorId);

        // Create Publication Files
        $this->createPublicationFiles($publications);

        // Create Review Feedbacks
        $this->createReviewFeedbacks($publications, $reviewerId);

        $this->command->info('Research & Innovation Centre data seeded successfully!');
        $this->command->info("- Created " . count($publications) . " publications");
    }

    /**
     * Create research publications.
     */
    protected function createPublications(int $authorId): array
    {
        $publications = [];
        $now = now();

        $data = [
            [
                'title' => 'Digital Health Interventions for Maternal Care in Rural South Sudan: A Mixed-Methods Study',
                'abstract' => 'This comprehensive study examines the effectiveness of digital health interventions in improving maternal healthcare outcomes in rural South Sudan. Through a mixed-methods approach combining quantitative surveys and qualitative interviews, we analyzed data from 450 women across three states. Results indicate a 34% improvement in antenatal care attendance and a 28% reduction in maternal complications when digital health tools were utilized. The study highlights the transformative potential of mobile health technologies in resource-limited settings.',
                'methodology' => 'We employed a quasi-experimental design with pre- and post-intervention measurements across three rural health facilities in Jonglei, Unity, and Upper Nile states. Data collection included structured interviews with 450 pregnant women, focus group discussions with community health workers, and analysis of health facility records over an 18-month period from January 2023 to June 2024.',
                'findings' => 'Key findings include: (1) 87% of participants reported improved access to health information via mobile devices; (2) Antenatal care attendance increased from 42% to 76% in intervention areas; (3) Emergency referral times reduced by an average of 2.5 hours; (4) Community health worker efficiency improved by 45%. Barriers identified include limited network coverage, phone ownership disparities, and initial resistance from traditional birth attendants.',
                'references' => '1. WHO (2023). Digital Health Interventions for Health Systems Strengthening. Geneva: World Health Organization. 2. UNICEF (2023). South Sudan Health System Assessment. Juba: UNICEF South Sudan. 3. Bakker et al. (2022). Mobile Health in Humanitarian Settings. The Lancet Digital Health, 4(5), e321-e330.',
                'category' => 'clinical',
                'status' => 'featured',
                'is_featured' => true,
                'submitted_at' => $now->copy()->subMonths(6),
                'approved_at' => $now->copy()->subMonths(5),
                'approved_by' => $authorId,
            ],
            [
                'title' => 'Telemedicine Implementation Framework for Remote Health Facilities in South Sudan',
                'abstract' => 'This paper presents a comprehensive framework for implementing telemedicine services in South Sudan\'s remote health facilities. Drawing from successful implementations in similar contexts across Sub-Saharan Africa, we propose a phased approach that addresses infrastructure requirements, capacity building, and sustainability. The framework emphasizes community engagement and integration with existing health systems for maximum impact on healthcare delivery in underserved regions.',
                'methodology' => 'The research utilized a design-thinking methodology, incorporating stakeholder workshops with 85 participants including health administrators, clinicians, IT specialists, and community representatives. We conducted site assessments at 12 remote health facilities and performed comparative analysis of telemedicine implementations in Kenya, Uganda, and Rwanda.',
                'findings' => 'The proposed framework identifies five critical success factors: (1) reliable solar-powered infrastructure; (2) trained local telemedicine coordinators; (3) simplified diagnostic protocols; (4) multilingual communication support; (5) integration with community health worker networks. Pilot implementation in three facilities showed 89% consultation completion rates and 94% patient satisfaction scores.',
                'references' => '1. Smith et al. (2023). Telemedicine in Resource-Limited Settings. Journal of Global Health, 13(2), 1-12. 2. South Sudan Ministry of Health (2023). National eHealth Strategy 2023-2028. Juba: Government of South Sudan. 3. ITU (2022). Connectivity in Least Developed Countries.',
                'category' => 'tech',
                'status' => 'featured',
                'is_featured' => true,
                'submitted_at' => $now->copy()->subMonths(5),
                'approved_at' => $now->copy()->subMonths(4),
                'approved_by' => $authorId,
            ],
            [
                'title' => 'Community Health Worker Training Programs: Impact on Health Literacy in Juba County',
                'abstract' => 'This study evaluates the effectiveness of structured training programs for Community Health Workers (CHWs) in improving health literacy among populations in Juba County. Through a longitudinal study spanning two years, we assessed knowledge retention, behavioral changes, and health outcomes in communities served by trained CHWs. The findings demonstrate significant improvements in health awareness and preventive health practices.',
                'methodology' => 'A longitudinal cohort study was conducted with 120 CHWs who received standardized training between 2022-2024. We administered pre- and post-training assessments, followed by quarterly knowledge evaluations. Community health outcomes were measured through household surveys covering 2,400 families over the study period.',
                'findings' => 'Trained CHWs demonstrated 78% knowledge retention at 12 months post-training. Communities served by trained CHWs showed: 56% increase in immunization coverage, 43% improvement in maternal health knowledge, 38% increase in early healthcare-seeking behavior, and 29% reduction in preventable disease incidence. The study supports scaling CHW training programs nationally.',
                'references' => '1. Lehmann et al. (2023). Community Health Workers in Humanitarian Settings. BMJ Global Health, 8(1), e009876. 2. WHO (2022). Community Health Worker Programs: Global Evidence Report. 3. South Sudan Health Cluster (2023). CHW Integration Guidelines.',
                'category' => 'social',
                'status' => 'approved',
                'is_featured' => false,
                'submitted_at' => $now->copy()->subMonths(4),
                'approved_at' => $now->copy()->subMonths(3),
                'approved_by' => $authorId,
            ],
            [
                'title' => 'Mobile-Based Disease Surveillance Systems in Humanitarian Settings: Lessons from South Sudan',
                'abstract' => 'This research paper examines the implementation and effectiveness of mobile-based disease surveillance systems in humanitarian settings within South Sudan. Focusing on the Integrated Disease Surveillance and Response (IDSR) system enhancements, we analyze how digital tools have improved outbreak detection, reporting timeliness, and response coordination in displacement camps and conflict-affected areas.',
                'methodology' => 'We conducted a retrospective analysis of surveillance data from 2020-2024 across 45 health facilities in displacement-affected regions. The study included key informant interviews with 30 surveillance officers and analysis of outbreak response times before and after mobile system implementation.',
                'findings' => 'Mobile surveillance systems reduced reporting time from an average of 7 days to 24 hours. Outbreak detection improved by 67%, with measles and cholera outbreaks identified 5 days earlier on average. The system demonstrated 94% data completeness compared to 61% with paper-based systems. Challenges included connectivity issues (23% of reports delayed) and battery limitations in remote areas.',
                'references' => '1. WHO AFRO (2023). IDSR Technical Guidelines, Third Edition. 2. CDC (2023). Mobile Technology for Disease Surveillance. 3. OCHA (2024). Humanitarian Response Plan South Sudan.',
                'category' => 'tech',
                'status' => 'approved',
                'is_featured' => false,
                'submitted_at' => $now->copy()->subMonths(3),
                'approved_at' => $now->copy()->subMonths(2),
                'approved_by' => $authorId,
            ],
            [
                'title' => 'Nutrition Education Through Digital Platforms: Assessing Impact on Child Feeding Practices in Wau',
                'abstract' => 'This study investigates the impact of nutrition education delivered through digital platforms on infant and young child feeding practices in Wau, Western Bahr el Ghazal. The research evaluates whether multimedia content delivered via smartphones and community viewing sessions can effectively change caregiver behaviors and improve child nutrition outcomes in a low-literacy population.',
                'methodology' => 'A cluster-randomized controlled trial was implemented across 24 villages, with 12 receiving the digital nutrition intervention and 12 serving as controls. The intervention included weekly video content on exclusive breastfeeding, complementary feeding, and dietary diversity delivered through community health workers equipped with tablets and solar projectors.',
                'findings' => 'Intervention villages showed: 41% improvement in exclusive breastfeeding rates (from 52% to 73%); 38% increase in minimum dietary diversity for children 6-23 months; 29% reduction in childhood stunting over the 18-month study period. Qualitative findings revealed high acceptability of video content, particularly among younger mothers who shared content via WhatsApp.',
                'references' => '1. UNICEF (2023). Nutrition Programming in South Sudan. 2. Global Nutrition Report (2023). 3. WFP (2024). Digital Nutrition Education Toolkit.',
                'category' => 'clinical',
                'status' => 'approved',
                'is_featured' => false,
                'submitted_at' => $now->copy()->subMonths(3),
                'approved_at' => $now->copy()->subMonths(2),
                'approved_by' => $authorId,
            ],
            [
                'title' => 'Health Information Seeking Behavior Among Urban Youth in South Sudan: Implications for Digital Health Literacy',
                'abstract' => 'This research explores how urban youth in South Sudan seek, evaluate, and use health information in the digital age. With increasing smartphone penetration among young people, understanding their information-seeking patterns is crucial for designing effective health communication strategies. The study identifies key sources, trust factors, and barriers to accessing reliable health information.',
                'methodology' => 'A cross-sectional survey was administered to 800 youth aged 15-24 in Juba, Wau, and Malakal. The survey instrument assessed health information sources, digital literacy levels, trust in various media, and health behaviors. Focus group discussions with 120 participants provided qualitative depth to the quantitative findings.',
                'findings' => 'Social media was the primary health information source for 67% of respondents, with Facebook and WhatsApp being most popular. Only 34% could identify reliable health sources from misinformation. Factors influencing trust included source authority (78%), peer recommendations (65%), and visual presentation (54%). Digital health literacy interventions are urgently needed.',
                'references' => '1. Norman & Skinner (2023). eHealth Literacy Framework. 2. BBC Media Action (2023). Youth and Health Information in East Africa. 3. South Sudan National Bureau of Statistics (2023). Youth Demographics Report.',
                'category' => 'social',
                'status' => 'approved',
                'is_featured' => false,
                'submitted_at' => $now->copy()->subMonths(2),
                'approved_at' => $now->copy()->subMonth(),
                'approved_by' => $authorId,
            ],
            [
                'title' => 'Electronic Medical Records Implementation in Primary Healthcare Facilities: A Feasibility Study for South Sudan',
                'abstract' => 'This feasibility study examines the prerequisites, challenges, and potential benefits of implementing electronic medical records (EMR) systems in primary healthcare facilities across South Sudan. Through comprehensive facility assessments and stakeholder consultations, the study provides evidence-based recommendations for a phased EMR rollout that considers the unique contextual factors of the South Sudanese health system.',
                'methodology' => 'Facility assessments were conducted at 30 primary healthcare centers across all 10 states using the WHO eHealth assessment toolkit. Stakeholder consultations included 45 interviews with health administrators, clinicians, and IT personnel. Cost-benefit analysis was performed using local cost data and projected efficiency gains.',
                'findings' => 'Key feasibility factors identified: reliable electricity (only 23% of facilities), computer availability (31%), basic IT skills among staff (18%). Recommended phased approach: Phase 1 - pilot in 5 facilities with solar power and satellite connectivity; Phase 2 - expand to state hospitals; Phase 3 - nationwide rollout. Projected 5-year ROI of 156% through improved efficiency and reduced medical errors.',
                'references' => '1. WHO (2023). Electronic Health Records Implementation Guide. 2. African Development Bank (2024). Digital Health Infrastructure Assessment. 3. South Sudan Ministry of Health (2023). Health Information System Strategic Plan.',
                'category' => 'tech',
                'status' => 'under_review',
                'is_featured' => false,
                'submitted_at' => $now->copy()->subMonth(),
                'approved_at' => null,
                'approved_by' => null,
            ],
            [
                'title' => 'Gender-Based Violence Response Services: Integrating Digital Tools for Improved Case Management',
                'abstract' => 'This research examines the integration of digital tools in gender-based violence (GBV) response services in South Sudan. The study evaluates a mobile-based case management system implemented by humanitarian organizations, assessing its impact on service quality, case tracking, and survivor outcomes. Findings inform best practices for digital GBV service delivery in humanitarian contexts.',
                'methodology' => 'Mixed-methods evaluation combining analysis of 450 GBV case records, surveys with 30 case workers, and in-depth interviews with 25 survivors who consented to participate. The study compared outcomes before and after digital system implementation at three women\'s centers in Juba, Bentiu, and Yei.',
                'findings' => 'The digital system improved case follow-up rates from 43% to 87%. Average time from incident to service access decreased from 12 days to 4 days. Survivors reported greater confidentiality (92%) and satisfaction with services (88%). Challenges included staff training needs and system downtime in areas with poor connectivity.',
                'references' => '1. UNFPA (2023). GBV Response in Humanitarian Settings. 2. UNHCR (2024). Digital Case Management Guidelines. 3. International Rescue Committee (2023). Technology for GBV Prevention.',
                'category' => 'social',
                'status' => 'approved',
                'is_featured' => false,
                'submitted_at' => $now->copy()->subMonths(2),
                'approved_at' => $now->copy()->subMonth(),
                'approved_by' => $authorId,
            ],
            [
                'title' => 'Malaria Prevention Education Through Community Radio: A Case Study from Northern Bahr el Ghazal',
                'abstract' => 'This case study documents the effectiveness of community radio programs in disseminating malaria prevention education in Northern Bahr el Ghazal State. The research evaluates listener engagement, knowledge acquisition, and behavioral changes related to malaria prevention practices. The study provides insights for scaling radio-based health education across South Sudan.',
                'methodology' => 'Pre- and post-broadcast surveys were conducted with 600 radio listeners across four counties. Program monitoring data included listener call-in volume, quiz participation rates, and message retention scores. Longitudinal data on malaria incidence from health facilities provided outcome measures.',
                'findings' => 'The weekly radio program reached an estimated 180,000 listeners. Survey results showed: 73% of regular listeners could correctly identify malaria symptoms (vs. 41% non-listeners); 68% reported using mosquito nets consistently (vs. 39% baseline); 52% sought treatment within 24 hours of symptom onset (vs. 28% baseline). Facility data indicated 22% reduction in severe malaria cases.',
                'references' => '1. WHO (2023). Malaria Prevention Communication Guidelines. 2. BBC Media Action (2022). Health Communication via Radio. 3. South Sudan Malaria Control Program (2023). Annual Report.',
                'category' => 'clinical',
                'status' => 'approved',
                'is_featured' => false,
                'submitted_at' => $now->copy()->subMonths(4),
                'approved_at' => $now->copy()->subMonths(3),
                'approved_by' => $authorId,
            ],
            [
                'title' => 'Digital Mental Health Interventions for Conflict-Affected Populations in South Sudan',
                'abstract' => 'This pioneering study explores the feasibility and acceptability of digital mental health interventions for conflict-affected populations in South Sudan. The research evaluates a smartphone-based psychological support application adapted for local context, assessing user engagement, symptom reduction, and potential for scale-up in humanitarian settings.',
                'methodology' => 'A pilot randomized controlled trial was conducted with 120 participants (60 intervention, 60 waitlist control) in Juba Protection of Civilians site. The intervention included guided self-help modules for depression, anxiety, and trauma symptoms. Assessments used culturally-validated instruments at baseline, 4 weeks, and 8 weeks.',
                'findings' => 'The intervention group showed significant improvements in depression scores (45% reduction vs. 12% in control) and anxiety symptoms (38% reduction vs. 8% control). User engagement was high, with 78% completing all modules. Participants valued the privacy and accessibility of digital support. Recommendations include integration with community mental health services.',
                'references' => '1. WHO (2023). mhGAP Humanitarian Intervention Guide. 2. Patel et al. (2024). Digital Mental Health in Low-Resource Settings. Lancet Psychiatry, 11(2), 134-145. 3. UNICEF (2023). Mental Health and Psychosocial Support in South Sudan.',
                'category' => 'clinical',
                'status' => 'featured',
                'is_featured' => true,
                'submitted_at' => $now->copy()->subMonths(5),
                'approved_at' => $now->copy()->subMonths(4),
                'approved_by' => $authorId,
            ],
            [
                'title' => 'Health Supply Chain Optimization Using Mobile Technology: Evidence from the Essential Medicines Program',
                'abstract' => 'This research investigates the impact of mobile technology on health supply chain management in South Sudan\'s Essential Medicines Program. The study documents the implementation of a mobile-based inventory management system and evaluates its effectiveness in reducing stockouts, improving order accuracy, and enhancing supply chain visibility across health facilities.',
                'methodology' => 'A before-and-after study design was employed, analyzing supply chain data from 50 health facilities over 24 months (12 months pre-implementation, 12 months post-implementation). Key metrics included stockout rates, order fulfillment time, inventory accuracy, and reporting compliance.',
                'findings' => 'Mobile system implementation resulted in: 67% reduction in essential medicine stockouts; 54% improvement in order accuracy; reporting compliance increased from 45% to 94%; average order fulfillment time reduced from 21 days to 8 days. The system enabled real-time visibility of stock levels at central medical stores, facilitating proactive distribution planning.',
                'references' => '1. USAID (2023). Supply Chain Management in Health Systems. 2. WHO (2024). Essential Medicines and Health Products. 3. John Snow Inc. (2023). Supply Chain Strengthening in South Sudan.',
                'category' => 'tech',
                'status' => 'approved',
                'is_featured' => false,
                'submitted_at' => $now->copy()->subMonths(3),
                'approved_at' => $now->copy()->subMonths(2),
                'approved_by' => $authorId,
            ],
            [
                'title' => 'Traditional Medicine Integration in Primary Healthcare: Perspectives from South Sudanese Communities',
                'abstract' => 'This qualitative study explores community perspectives on integrating traditional medicine practices with conventional healthcare services in South Sudan. Recognizing the continued importance of traditional healers in many communities, the research examines opportunities for complementary approaches that respect cultural practices while ensuring safety and quality of care.',
                'methodology' => 'Qualitative study using focus group discussions (12 FGDs with 120 participants) and key informant interviews (25 traditional healers, 15 healthcare workers, 10 health administrators) across three states. Thematic analysis identified key themes around traditional medicine use, integration preferences, and concerns.',
                'findings' => '78% of community members reported using traditional medicine alongside conventional care. Key integration opportunities identified: referral pathways for traditional healers, shared health education, mutual respect frameworks. Concerns included potential herb-drug interactions, delayed care-seeking for serious conditions, and need for traditional healer training on danger signs. A collaborative model is proposed.',
                'references' => '1. WHO (2023). Traditional Medicine Strategy 2023-2032. 2. African Union (2024). Traditional Medicine in Africa. 3. South Sudan Traditional Health Practitioners Association (2023). Annual Report.',
                'category' => 'social',
                'status' => 'approved',
                'is_featured' => false,
                'submitted_at' => $now->copy()->subMonths(2),
                'approved_at' => $now->copy()->subMonth(),
                'approved_by' => $authorId,
            ],
            [
                'title' => 'COVID-19 Vaccine Hesitancy and Digital Health Communication: Lessons from South Sudan',
                'abstract' => 'This retrospective analysis examines COVID-19 vaccine hesitancy in South Sudan and the role of digital health communication in addressing misinformation. The study documents communication strategies employed, analyzes their effectiveness, and provides recommendations for future pandemic preparedness and vaccine communication in similar contexts.',
                'methodology' => 'Analysis combined COVID-19 vaccination data, social media monitoring, and community surveys (n=1,200) across six states. We reviewed digital communication campaigns and their reach, engagement metrics, and correlation with vaccination uptake. Key informant interviews with 30 health communicators provided implementation insights.',
                'findings' => 'Initial vaccine hesitancy was 64% (March 2022), decreasing to 38% by December 2023. Digital campaigns reached 2.3 million people via social media. Most effective messages featured local religious and community leaders (78% trust). Misinformation correction through WhatsApp fact-checking service was utilized by 45,000 users. Lessons emphasize community leader engagement and pre-bunking strategies.',
                'references' => '1. WHO (2024). COVID-19 Vaccine Communication Lessons. 2. Africa CDC (2023). Vaccine Hesitancy in Africa. 3. Ministry of Health South Sudan (2024). COVID-19 Response Evaluation Report.',
                'category' => 'social',
                'status' => 'approved',
                'is_featured' => false,
                'submitted_at' => $now->copy()->subMonth(),
                'approved_at' => $now->copy()->subWeeks(2),
                'approved_by' => $authorId,
            ],
            [
                'title' => 'Water, Sanitation, and Hygiene (WASH) Programs: Digital Monitoring and Evaluation Framework',
                'abstract' => 'This technical paper presents a digital monitoring and evaluation framework for WASH programs in South Sudan. The framework enables real-time data collection, progress tracking, and outcome measurement for water, sanitation, and hygiene interventions. The paper documents the development process, pilot implementation results, and recommendations for scale-up.',
                'methodology' => 'The framework was developed through iterative design with WASH sector partners, tested in 30 communities across Eastern Equatoria and Central Equatoria states. Data collection tools were designed for offline functionality and synchronized when connectivity was available. Validation included comparison with traditional paper-based methods.',
                'findings' => 'The digital M&E system reduced data collection time by 65% and improved data quality scores from 72% to 94%. Real-time dashboards enabled evidence-based program adjustments. Key features included GPS-tagged facility photos, automated indicator calculations, and integration with national WASH information systems. The system successfully tracked outcomes for 150,000 beneficiaries.',
                'references' => '1. UNICEF/WHO (2023). WASH Monitoring Framework. 2. WASH Cluster South Sudan (2024). M&E Technical Guidelines. 3. WaterAid (2023). Digital WASH Monitoring Toolkit.',
                'category' => 'tech',
                'status' => 'under_review',
                'is_featured' => false,
                'submitted_at' => $now->copy()->subWeeks(3),
                'approved_at' => null,
                'approved_by' => null,
            ],
        ];

        foreach ($data as $item) {
            $publication = RPublication::create(array_merge($item, [
                'user_id' => $authorId,
                'created_at' => $item['submitted_at'] ?? $now,
                'updated_at' => $item['approved_at'] ?? $now,
            ]));
            $publications[] = $publication;
        }

        return $publications;
    }

    /**
     * Create publication files.
     */
    protected function createPublicationFiles(array $publications): void
    {
        foreach ($publications as $index => $publication) {
            // Main PDF file for each publication
            RPublicationFile::create([
                'publication_id' => $publication->id,
                'original_name' => str_replace([':', '/', ' '], '', $publication->title) . '.pdf',
                'stored_name' => 'research_paper_' . ($index + 1) . '.pdf',
                'file_path' => 'publications/research_paper_' . ($index + 1) . '.pdf',
                'file_size' => rand(500000, 2500000),
                'mime_type' => 'application/pdf',
                'file_type' => 'pdf',
                'is_public' => in_array($publication->status, ['approved', 'featured']),
                'version' => 1,
                'description' => 'Main research document',
            ]);

            // Add supplementary files for some publications
            if ($index % 3 == 0) {
                RPublicationFile::create([
                    'publication_id' => $publication->id,
                    'original_name' => 'Supplementary_Data_' . ($index + 1) . '.xlsx',
                    'stored_name' => 'supplementary_' . ($index + 1) . '.xlsx',
                    'file_path' => 'publications/supplementary_' . ($index + 1) . '.xlsx',
                    'file_size' => rand(50000, 200000),
                    'mime_type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
                    'file_type' => 'doc',
                    'is_public' => false,
                    'version' => 1,
                    'description' => 'Supplementary data and analysis files',
                ]);
            }
        }
    }

    /**
     * Create review feedbacks.
     */
    protected function createReviewFeedbacks(array $publications, int $reviewerId): void
    {
        foreach ($publications as $index => $publication) {
            // Only create reviews for approved/featured publications
            if (!in_array($publication->status, ['approved', 'featured'])) {
                continue;
            }

            $decision = 'approve';
            $comments = $this->getReviewComment($index, true);

            RReviewFeedback::create([
                'publication_id' => $publication->id,
                'reviewer_id' => $reviewerId,
                'decision' => $decision,
                'comments' => $comments,
                'criteria_evaluation' => [
                    'originality' => rand(4, 5),
                    'methodology' => rand(4, 5),
                    'clarity' => rand(3, 5),
                    'significance' => rand(4, 5),
                    'references' => rand(3, 5),
                ],
                'reviewed_at' => $publication->approved_at,
            ]);
        }
    }

    /**
     * Get review comment based on index.
     */
    protected function getReviewComment(int $index, bool $approved): string
    {
        $approvedComments = [
            'This research makes a valuable contribution to digital health literature in the South Sudan context. The methodology is sound and the findings have significant practical implications for health programming.',
            'A well-designed study with clear practical applications. The authors have addressed an important gap in the literature. I recommend publication with minor revisions to strengthen the discussion section.',
            'This paper provides important insights into health system challenges in South Sudan. The mixed-methods approach strengthens the validity of findings. Recommended for publication.',
            'An excellent contribution to the field. The research design is appropriate and the analysis is thorough. This work will inform policy and practice in the region.',
            'This study addresses a critical health issue with innovative methodology. The findings are clearly presented and have significant implications for health programming.',
            'A well-written and timely piece of research. The authors demonstrate strong understanding of the local context. The recommendations are practical and evidence-based.',
            'This research provides valuable evidence for health policy development. The methodology is rigorous and appropriate for the research questions.',
            'A comprehensive study that contributes meaningfully to health systems literature. The findings are relevant and well-supported by the data presented.',
            'This paper makes an important contribution to understanding health challenges in South Sudan. I recommend publication and encourage the authors to continue this line of research.',
            'Excellent work on an understudied topic. The research design is sound and the analysis is thorough. The paper will be a valuable resource for practitioners and policymakers.',
        ];

        return $approvedComments[$index % count($approvedComments)];
    }
}
