<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use App\Models\SelfPaced\Course;
use App\Models\SelfPaced\CourseCategory;
use App\Models\SelfPaced\CourseTopic;
use App\Models\SelfPaced\CourseSubTopic;
use App\Models\SelfPaced\ExamQuestion;
use App\Models\SelfPaced\CourseDownload;
use App\Models\User;

/**
 * HealthPolicyDataGovernanceCourseSeeder
 *
 * Seeds the "Professional Certificate in Health Policy and Data Governance"
 * with 7 topics, 4 subtopics each (28 total), 35 exam questions, and 2 downloads.
 * All fees in South Sudanese Pound (SSP). Fully idempotent via firstOrCreate.
 *
 * Run individually:
 *   php artisan db:seed --class=HealthPolicyDataGovernanceCourseSeeder
 *
 * Requirements: 2.1-2.12, 3.1-3.5, 4.1-4.6, 5.1-5.9, 6.1-6.6, 7.1-7.5, 10.1-10.4
 */
class HealthPolicyDataGovernanceCourseSeeder extends Seeder
{
    private int $createdById  = 1;
    private int $instructorId = 1;

    public function run(): void
    {
        DB::transaction(function () {
            $this->resolveUsers();
            $course = $this->makeCourse();
            $this->seedTopics($course);
            $this->seedQuestions($course);
            $this->seedDownloads($course);
        });

        $this->command->info('HealthPolicyDataGovernanceCourseSeeder: course seeded successfully.');
    }

    private function resolveUsers(): void
    {
        $admin   = User::whereHas('roles', fn ($q) => $q->where('name', 'Super Manager'))->first();
        $trainer = User::whereHas('roles', fn ($q) => $q->where('name', 'Trainers'))->first();
        $this->createdById  = $admin?->id ?? 1;
        $this->instructorId = $trainer?->id ?? $admin?->id ?? 1;
    }

    private function makeCourse(): Course
    {
        $category = CourseCategory::where('slug', 'health')->first();

        return Course::firstOrCreate(
            ['slug' => 'professional-certificate-health-policy-data-governance'],
            [
                'title'                      => 'Professional Certificate in Health Policy and Data Governance',
                'description'                => 'This Professional Certificate equips health professionals and managers in South Sudan with the knowledge and skills to analyse, develop, and implement health policies, and to govern health data effectively. Participants will explore health policy processes, health systems strengthening, data governance frameworks, health information legislation, and accountability mechanisms, with a focus on the South Sudan health context. The course prepares graduates to contribute meaningfully to evidence-based health policy and responsible data stewardship.',
                'objectives'                 => "By the end of this course, participants will be able to:\n- Analyse the health policy process and the factors that influence policy decisions in South Sudan\n- Apply health systems thinking to policy analysis and design\n- Develop and evaluate health policies using evidence-based approaches\n- Implement data governance frameworks in health organisations\n- Interpret legal and regulatory frameworks governing health data in South Sudan\n- Apply accountability and transparency mechanisms in health governance\n- Engage stakeholders effectively in health policy processes\n- Contribute to national health information system governance",
                'prerequisites'              => 'Basic understanding of public health or health service delivery. Experience working in a health management, policy, or research role is recommended. No prior policy or legal training is required.',
                'category_id'                => $category?->id,
                'instructor_id'              => $this->instructorId,
                'fee_amount'                 => 78000.00,
                'currency'                   => 'SSP',
                'duration_hours'             => 38,
                'passing_score'              => 70,
                'exam_attempts_allowed'      => 3,
                'exam_time_limit'            => 90,
                'exam_questions_per_attempt' => 20,
                'status'                     => 'published',
                'created_by'                 => $this->createdById,
                'updated_by'                 => $this->createdById,
            ]
        );
    }

    private function makeTopic(Course $course, string $title, string $description, int $order): CourseTopic
    {
        return CourseTopic::firstOrCreate(
            ['course_id' => $course->id, 'title' => $title],
            ['description' => $description, 'sort_order' => $order, 'is_published' => true]
        );
    }

    private function makeSub(CourseTopic $topic, string $title, string $html, int $order): void
    {
        CourseSubTopic::firstOrCreate(
            ['topic_id' => $topic->id, 'title' => $title],
            ['content' => $html, 'sort_order' => $order, 'is_published' => true]
        );
    }

    private function makeQuestion(Course $course, array $q, int $order): void
    {
        ExamQuestion::firstOrCreate(
            ['course_id' => $course->id, 'question_text' => $q['question']],
            [
                'option_a'               => $q['a'],
                'option_b'               => $q['b'],
                'option_c'               => $q['c'],
                'option_d'               => $q['d'],
                'correct_answer'         => $q['answer'],
                'explanation'            => $q['explanation'],
                'allow_multiple_answers' => false,
                'correct_answers_json'   => null,
                'sort_order'             => $order,
                'is_active'              => true,
            ]
        );
    }

    private function makeDownload(Course $course, string $title, string $fileName, string $mimeType, int $fileSize): void
    {
        $slug = $course->slug;
        CourseDownload::firstOrCreate(
            ['course_id' => $course->id, 'title' => $title],
            [
                'topic_id'  => null,
                'file_path' => "downloads/courses/{$slug}/{$fileName}",
                'file_name' => $fileName,
                'file_size' => $fileSize,
                'mime_type' => $mimeType,
            ]
        );
    }

    private function seedTopics(Course $course): void
    {
        $this->seedTopic1($course);
        $this->seedTopic2($course);
        $this->seedTopic3($course);
        $this->seedTopic4($course);
        $this->seedTopic5($course);
        $this->seedTopic6($course);
        $this->seedTopic7($course);
    }

    // =========================================================================
    // TOPIC 1 — Introduction to Health Policy
    // =========================================================================
    private function seedTopic1(Course $course): void
    {
        $topic = $this->makeTopic($course,
            'Introduction to Health Policy',
            'Foundations of health policy, the policy cycle, and the political economy of health in South Sudan.',
            1
        );

        $this->makeSub($topic, 'What is Health Policy?',
            '<h3>Defining Health Policy</h3><p>Health policy refers to decisions, plans, and actions undertaken to achieve specific health care goals within a society. It encompasses a broad range of activities — from national legislation and strategic plans to facility-level protocols and community health guidelines. Health policy shapes who receives health services, what services are provided, how they are financed, and how health systems are organised and governed.</p><p>In South Sudan, health policy is shaped by a complex interplay of factors including: the legacy of decades of conflict; extreme resource constraints; dependence on international donors; a fragile state with limited institutional capacity; and the diverse health needs of a population spread across a vast and largely inaccessible territory. Understanding this context is essential for anyone seeking to influence health policy in South Sudan.</p><h3>Types of Health Policy</h3><ul><li><strong>Substantive policies:</strong> Define what the health system will do (e.g., free primary health care policy, national immunisation policy).</li><li><strong>Procedural policies:</strong> Define how decisions will be made and implemented (e.g., procurement regulations, human resource management policies).</li><li><strong>Distributive policies:</strong> Allocate resources and services across the population (e.g., health facility construction plans, essential medicines lists).</li><li><strong>Regulatory policies:</strong> Set standards and rules for health sector actors (e.g., health professional licensing, pharmaceutical regulation).</li></ul>',
        1);

        $this->makeSub($topic, 'The Health Policy Cycle',
            '<h3>Stages of the Policy Cycle</h3><p>The policy cycle is a conceptual model that describes the stages through which a policy passes from initial idea to implementation and evaluation. While real-world policy processes are rarely as linear as the model suggests, the cycle provides a useful framework for understanding and influencing policy:</p><ol><li><strong>Agenda setting:</strong> A health problem gains sufficient attention from policymakers to be placed on the policy agenda. Agenda setting is influenced by epidemiological data, media coverage, advocacy by civil society, and political priorities.</li><li><strong>Policy formulation:</strong> Options for addressing the problem are developed and analysed. This stage involves technical analysis, stakeholder consultation, and political negotiation.</li><li><strong>Policy adoption:</strong> A decision is made to adopt a particular policy option. In South Sudan, this typically involves approval by the Ministry of Health and, for major policies, the Council of Ministers.</li><li><strong>Policy implementation:</strong> The adopted policy is put into practice. Implementation requires resources, capacity, coordination, and monitoring.</li><li><strong>Policy evaluation:</strong> The effects of the policy are assessed against its objectives. Evaluation findings feed back into the agenda-setting stage, completing the cycle.</li></ol><h3>Policy Windows</h3><p>Kingdon\'s multiple streams framework identifies three streams — problems, policies, and politics — that must converge to create a "policy window" for change. Health advocates in South Sudan must be alert to policy windows created by events such as disease outbreaks, elections, or new donor funding opportunities.</p>',
        2);

        $this->makeSub($topic, 'Actors and Stakeholders in Health Policy',
            '<h3>Key Health Policy Actors in South Sudan</h3><p>Health policy is shaped by a diverse range of actors with different interests, resources, and levels of influence. Understanding the landscape of health policy actors is essential for effective policy engagement:</p><ul><li><strong>Government:</strong> The Ministry of Health is the primary health policy authority in South Sudan. State Ministries of Health implement national policies at state level. The Ministry of Finance controls health budget allocations.</li><li><strong>International donors:</strong> USAID, the European Union, the UK Foreign Commonwealth and Development Office (FCDO), and other bilateral donors provide a large proportion of health financing in South Sudan and significantly influence health policy priorities.</li><li><strong>UN agencies:</strong> WHO, UNICEF, UNFPA, and WFP play major roles in health service delivery and policy advocacy in South Sudan.</li><li><strong>NGOs:</strong> International and national NGOs implement health programmes and advocate for policy change. Major health NGOs in South Sudan include MSF, IRC, IMC, and Concern Worldwide.</li><li><strong>Civil society:</strong> Professional associations (including SSHIA), community organisations, and patient groups advocate for health policy change.</li><li><strong>Private sector:</strong> Private health facilities, pharmaceutical companies, and medical equipment suppliers have interests in health policy.</li></ul><h3>Stakeholder Analysis</h3><p>Stakeholder analysis maps the interests, influence, and positions of key actors on a specific policy issue. It helps policy advocates identify allies, understand opposition, and develop strategies for building coalitions. Tools include power-interest grids, stakeholder mapping matrices, and net-map analysis.</p>',
        3);

        $this->makeSub($topic, 'Political Economy of Health in South Sudan',
            '<h3>Understanding Political Economy</h3><p>Political economy analysis examines how political and economic factors interact to shape policy outcomes. In health policy, political economy analysis helps explain why technically sound policies are sometimes not adopted or implemented, and why policies that serve narrow interests sometimes prevail over those that would benefit the population.</p><h3>Key Political Economy Factors in South Sudan Health Policy</h3><p>Several political economy factors are particularly important in the South Sudan health context:</p><ul><li><strong>Donor dependence:</strong> South Sudan\'s health system is heavily dependent on international donor funding, which gives donors significant influence over health policy priorities. This can create misalignment between donor priorities and national health needs.</li><li><strong>Fragile governance:</strong> Weak state institutions, limited accountability mechanisms, and the legacy of conflict create an environment where health policy implementation is challenging and corruption risks are high.</li><li><strong>Elite capture:</strong> Health resources and policy benefits may be captured by politically connected elites rather than reaching the most vulnerable populations.</li><li><strong>Ethnic and regional politics:</strong> In South Sudan\'s politically fragmented environment, health resource allocation can be influenced by ethnic and regional political dynamics rather than need.</li><li><strong>Humanitarian-development nexus:</strong> The coexistence of humanitarian health responses and longer-term health system development creates tensions in policy priorities and resource allocation.</li></ul>',
        4);
    }

    // =========================================================================
    // TOPIC 2 — Health Systems Strengthening
    // =========================================================================
    private function seedTopic2(Course $course): void
    {
        $topic = $this->makeTopic($course,
            'Health Systems Strengthening',
            'Understanding health system building blocks and applying health systems thinking to policy and governance in South Sudan.',
            2
        );

        $this->makeSub($topic, 'The WHO Health System Building Blocks',
            '<h3>Six Building Blocks of a Health System</h3><p>The World Health Organization\'s health system framework identifies six building blocks that together constitute a functioning health system:</p><ul><li><strong>Service delivery:</strong> The provision of effective, safe, quality health services to those who need them, when and where needed, with minimum waste of resources.</li><li><strong>Health workforce:</strong> A well-performing health workforce is one that works in ways that are responsive, fair, and efficient to achieve the best health outcomes given available resources and circumstances.</li><li><strong>Health information systems:</strong> Systems that ensure the production, analysis, dissemination, and use of reliable and timely information on health determinants, health system performance, and health status.</li><li><strong>Access to essential medicines:</strong> Equitable access to essential medical products, vaccines, and technologies of assured quality, safety, efficacy, and cost-effectiveness.</li><li><strong>Health financing:</strong> Adequate funds for health are raised in ways that protect people from financial catastrophe and impoverishment associated with having to pay for health services.</li><li><strong>Leadership and governance:</strong> Ensuring strategic policy frameworks exist and are combined with effective oversight, coalition-building, regulation, attention to system design, and accountability.</li></ul><h3>Applying the Building Blocks in South Sudan</h3><p>South Sudan faces significant weaknesses across all six building blocks. Health systems strengthening requires simultaneous attention to all building blocks, as weakness in one area undermines progress in others. For example, training more health workers (workforce) is ineffective if there are no medicines (essential medicines) or if health workers are not paid (financing).</p>',
        1);

        $this->makeSub($topic, 'Universal Health Coverage',
            '<h3>What is Universal Health Coverage?</h3><p>Universal Health Coverage (UHC) means that all people have access to the health services they need — including prevention, promotion, treatment, rehabilitation, and palliative care — without suffering financial hardship. UHC is a key target of the Sustainable Development Goals (SDG 3.8) and a central objective of global health policy.</p><h3>Three Dimensions of UHC</h3><p>UHC is often represented as a cube with three dimensions:</p><ul><li><strong>Population coverage:</strong> Who is covered? The goal is to extend coverage to all people, prioritising the most vulnerable and underserved.</li><li><strong>Service coverage:</strong> Which services are covered? The goal is to expand the range of services covered, prioritising cost-effective interventions.</li><li><strong>Financial protection:</strong> What proportion of costs are covered? The goal is to reduce out-of-pocket payments that cause financial hardship.</li></ul><h3>UHC Progress in South Sudan</h3><p>South Sudan faces enormous challenges in progressing toward UHC. The UHC Service Coverage Index for South Sudan is among the lowest in the world. Key barriers include: extreme poverty limiting ability to pay for health services; geographic inaccessibility of health facilities; severe shortage of health workers; inadequate health financing; and the ongoing impact of conflict on health infrastructure and service delivery. Despite these challenges, the South Sudan National Health Policy and Health Sector Development Plan articulate a commitment to UHC as a long-term goal.</p>',
        2);

        $this->makeSub($topic, 'Health Financing Policy',
            '<h3>Sources of Health Financing in South Sudan</h3><p>Health systems are financed through a combination of sources, each with different implications for equity, efficiency, and sustainability:</p><ul><li><strong>Government budget:</strong> Tax-funded government expenditure on health. In South Sudan, government health spending is extremely low — among the lowest in the world as a percentage of GDP.</li><li><strong>Donor funding:</strong> International development assistance for health. Donor funding accounts for the majority of health expenditure in South Sudan, creating significant dependency and sustainability risks.</li><li><strong>Out-of-pocket payments:</strong> Direct payments by households for health services. High out-of-pocket payments are a major barrier to health access and a cause of financial catastrophe for poor households.</li><li><strong>Health insurance:</strong> Pooled prepayment mechanisms that spread financial risk. Formal health insurance is very limited in South Sudan.</li><li><strong>NGO funding:</strong> Funding from international and national NGOs that deliver health services.</li></ul><h3>Health Financing Policy Objectives</h3><p>Health financing policy aims to achieve three objectives: raising sufficient revenue for health; pooling funds to spread financial risk across the population; and purchasing health services efficiently and equitably. In South Sudan, increasing domestic government health financing, reducing dependence on donors, and protecting households from catastrophic health expenditure are key health financing policy priorities.</p>',
        3);

        $this->makeSub($topic, 'Human Resources for Health Policy',
            '<h3>The Health Workforce Crisis in South Sudan</h3><p>South Sudan has one of the most severe health workforce shortages in the world. The country has fewer than 1 doctor per 100,000 population and fewer than 10 nurses and midwives per 100,000 population — far below the WHO minimum threshold of 44.5 health workers per 10,000 population needed to achieve basic health coverage. This workforce crisis is the result of decades of conflict, limited training capacity, poor remuneration, and significant brain drain.</p><h3>Human Resources for Health Policy Interventions</h3><p>Addressing the health workforce crisis requires a comprehensive policy response across the health worker lifecycle:</p><ul><li><strong>Pre-service training:</strong> Expanding the capacity of health training institutions to produce more health workers, with particular attention to midwives, nurses, and community health workers.</li><li><strong>Recruitment and deployment:</strong> Policies to attract health workers to underserved rural and remote areas, including financial incentives and non-financial motivators.</li><li><strong>Retention:</strong> Competitive salaries, career development opportunities, safe working conditions, and supportive supervision to retain health workers in the public sector.</li><li><strong>Performance management:</strong> Systems to monitor and improve health worker performance, including supervision, continuing professional development, and accountability mechanisms.</li><li><strong>Community health workers:</strong> Expanding and formalising the community health worker cadre as a cost-effective strategy for extending health service reach in South Sudan.</li></ul>',
        4);
    }

    // =========================================================================
    // TOPIC 3 — Evidence-Based Health Policy
    // =========================================================================
    private function seedTopic3(Course $course): void
    {
        $topic = $this->makeTopic($course,
            'Evidence-Based Health Policy',
            'Using research evidence to inform health policy decisions, and understanding the barriers to evidence use in South Sudan.',
            3
        );

        $this->makeSub($topic, 'Evidence-Based Policy Making',
            '<h3>What is Evidence-Based Policy?</h3><p>Evidence-based policy making is the process of using the best available evidence to inform policy decisions. It draws on research findings, programme evaluations, health data, and expert knowledge to identify effective interventions and guide resource allocation. Evidence-based policy is contrasted with policy driven by ideology, political expediency, or anecdote.</p><p>In health policy, evidence-based approaches have been formalised through mechanisms such as: systematic reviews and meta-analyses synthesising evidence on intervention effectiveness; health technology assessments evaluating the cost-effectiveness of health interventions; and clinical practice guidelines translating evidence into recommendations for clinical practice.</p><h3>Types of Evidence in Health Policy</h3><p>Health policy decisions draw on multiple types of evidence:</p><ul><li><strong>Epidemiological evidence:</strong> Data on disease burden, risk factors, and health trends.</li><li><strong>Effectiveness evidence:</strong> Research on what interventions work to improve health outcomes.</li><li><strong>Economic evidence:</strong> Cost-effectiveness analyses comparing the value of different interventions.</li><li><strong>Implementation evidence:</strong> Research on how interventions can be successfully implemented in specific contexts.</li><li><strong>Equity evidence:</strong> Data on health inequities and the differential impact of interventions on different population groups.</li><li><strong>Community evidence:</strong> Knowledge and preferences of communities and patients.</li></ul>',
        1);

        $this->makeSub($topic, 'Health Technology Assessment',
            '<h3>What is Health Technology Assessment?</h3><p>Health Technology Assessment (HTA) is a multidisciplinary process that uses explicit methods to determine the value of a health technology at different points in its lifecycle. The purpose of HTA is to inform policy decisions about the adoption, coverage, pricing, and appropriate use of health technologies — including medicines, medical devices, diagnostics, and health programmes.</p><h3>Key Components of HTA</h3><ul><li><strong>Clinical effectiveness:</strong> Does the technology work? What is the evidence from clinical trials and systematic reviews?</li><li><strong>Safety:</strong> What are the risks and adverse effects of the technology?</li><li><strong>Cost-effectiveness:</strong> Is the technology worth the cost compared to alternatives? Expressed as cost per quality-adjusted life year (QALY) or cost per DALY averted.</li><li><strong>Budget impact:</strong> What is the total cost to the health system of adopting the technology?</li><li><strong>Equity:</strong> Does the technology benefit all population groups equally?</li><li><strong>Organisational and social implications:</strong> What changes to health system organisation and social norms does the technology require?</li></ul><h3>HTA in Low-Resource Settings</h3><p>Formal HTA processes are resource-intensive and require significant technical capacity. In South Sudan and similar low-resource settings, simplified HTA approaches and the use of evidence from other countries (with appropriate contextualisation) are more feasible. The WHO-CHOICE (Choosing Interventions that are Cost-Effective) database provides cost-effectiveness data for a range of health interventions in different world regions.</p>',
        2);

        $this->makeSub($topic, 'Barriers to Evidence Use in Policy',
            '<h3>Why Evidence is Not Always Used</h3><p>Despite the availability of research evidence, health policy decisions are often not evidence-based. Understanding the barriers to evidence use is essential for health advocates seeking to promote evidence-informed policy in South Sudan:</p><ul><li><strong>Limited research capacity:</strong> South Sudan has very limited capacity to produce locally relevant health research, and policymakers may not be aware of or have access to international research evidence.</li><li><strong>Research-policy gap:</strong> Researchers and policymakers often operate in different worlds with different incentives, timelines, and communication styles. Research findings are rarely packaged in formats accessible to policymakers.</li><li><strong>Political factors:</strong> Policy decisions are influenced by political interests, ideological commitments, and the preferences of powerful stakeholders, which may override evidence.</li><li><strong>Urgency:</strong> Policymakers often need to make decisions quickly, without time to review evidence systematically.</li><li><strong>Uncertainty:</strong> Evidence is often uncertain, contested, or context-specific, making it difficult to apply directly to policy decisions.</li><li><strong>Capacity constraints:</strong> Limited analytical capacity in government ministries constrains the ability to interpret and apply research evidence.</li></ul><h3>Strategies to Promote Evidence Use</h3><p>Strategies to bridge the research-policy gap include: producing policy-relevant research; engaging policymakers as partners in research design; producing policy briefs and other accessible knowledge products; building relationships between researchers and policymakers; and strengthening analytical capacity in government.</p>',
        3);

        $this->makeSub($topic, 'Policy Analysis Frameworks',
            '<h3>The Policy Triangle Framework</h3><p>The policy triangle framework, developed by Walt and Gilson, provides a tool for analysing health policies by examining four interacting elements:</p><ul><li><strong>Content:</strong> What does the policy say? What are its goals, strategies, and implementation mechanisms?</li><li><strong>Context:</strong> What situational factors influence the policy? Political, economic, social, and historical factors that shape the policy environment.</li><li><strong>Process:</strong> How was the policy developed and implemented? Who was involved, and how were decisions made?</li><li><strong>Actors:</strong> Who are the key stakeholders? What are their interests, power, and positions on the policy?</li></ul><h3>Other Policy Analysis Tools</h3><p>Additional tools for health policy analysis include:</p><ul><li><strong>SWOT analysis:</strong> Assesses the Strengths, Weaknesses, Opportunities, and Threats related to a policy or health system.</li><li><strong>PESTLE analysis:</strong> Examines Political, Economic, Social, Technological, Legal, and Environmental factors affecting health policy.</li><li><strong>Problem tree analysis:</strong> Maps the causes and effects of a health problem to inform policy design.</li><li><strong>Cost-benefit analysis:</strong> Compares the monetary costs and benefits of a policy option.</li></ul><p>Applying these frameworks to South Sudan health policy analysis requires contextual knowledge and sensitivity to the unique political economy of the country. No single framework captures all relevant dimensions, and analysts typically draw on multiple tools.</p>',
        4);
    }

    // =========================================================================
    // TOPIC 4 — Data Governance Frameworks
    // =========================================================================
    private function seedTopic4(Course $course): void
    {
        $topic = $this->makeTopic($course,
            'Data Governance Frameworks',
            'Principles, frameworks, and structures for governing health data in organisations and national health systems.',
            4
        );

        $this->makeSub($topic, 'Introduction to Data Governance',
            '<h3>What is Data Governance?</h3><p>Data governance is the overall management of the availability, usability, integrity, and security of data used in an organisation or system. It encompasses the policies, processes, standards, and roles that ensure data is managed as a valuable organisational asset. In health systems, data governance is critical because health data is both highly sensitive (requiring strong privacy protections) and highly valuable (enabling evidence-based decision-making).</p><h3>Why Data Governance Matters in Health</h3><p>Effective data governance in health systems delivers multiple benefits:</p><ul><li><strong>Data quality:</strong> Governance frameworks establish standards and accountability for data quality, ensuring that health data is accurate, complete, and timely.</li><li><strong>Privacy protection:</strong> Governance policies protect patient confidentiality and comply with data protection legislation.</li><li><strong>Data security:</strong> Governance frameworks establish controls to protect health data from unauthorised access, modification, or loss.</li><li><strong>Data sharing:</strong> Governance frameworks enable appropriate data sharing between health system actors while protecting privacy.</li><li><strong>Accountability:</strong> Governance structures establish clear accountability for data management decisions.</li><li><strong>Trust:</strong> Effective governance builds public trust in health data systems, encouraging health-seeking behaviour and participation in health surveys and research.</li></ul><p>In South Sudan, data governance is an emerging priority as the country invests in digital health infrastructure. Building robust data governance frameworks from the outset is essential to avoid the data quality, privacy, and security problems that have plagued health information systems in other countries.</p>',
        1);

        $this->makeSub($topic, 'Data Governance Structures and Roles',
            '<h3>Key Data Governance Roles</h3><p>Effective data governance requires clearly defined roles and responsibilities. Key roles in a health data governance structure include:</p><ul><li><strong>Data owner:</strong> The organisational unit or individual responsible for a specific dataset. The data owner has authority over decisions about data access, use, and retention.</li><li><strong>Data steward:</strong> Responsible for day-to-day management of data quality, metadata, and compliance with governance policies. Data stewards are the operational face of data governance.</li><li><strong>Data custodian:</strong> Responsible for the technical management of data storage, security, and backup. Typically an IT function.</li><li><strong>Data governance committee:</strong> A cross-functional body that sets data governance policy, resolves disputes, and oversees compliance. In a national health information system, this might include representatives from the Ministry of Health, health facilities, research institutions, and civil society.</li><li><strong>Chief Data Officer (CDO) or Health Informatics Director:</strong> Senior leadership role responsible for the overall data governance strategy.</li></ul><h3>Data Governance Frameworks</h3><p>Several internationally recognised data governance frameworks provide guidance for health organisations. The DAMA (Data Management Association) Data Management Body of Knowledge (DMBOK) is a comprehensive framework covering all aspects of data management. The COBIT framework provides governance guidance for IT and data assets. In the health sector, the HL7 FHIR (Fast Healthcare Interoperability Resources) standard provides a framework for health data exchange and governance.</p>',
        2);

        $this->makeSub($topic, 'Data Quality Management in Health Systems',
            '<h3>Dimensions of Health Data Quality</h3><p>Data quality in health systems has multiple dimensions that must be actively managed:</p><ul><li><strong>Accuracy:</strong> Data correctly represents the real-world health events it describes.</li><li><strong>Completeness:</strong> All required data elements are recorded for all relevant patients and facilities.</li><li><strong>Consistency:</strong> Data is consistent across different systems, time periods, and reporting levels.</li><li><strong>Timeliness:</strong> Data is available when needed for decision-making.</li><li><strong>Validity:</strong> Data values fall within expected ranges and conform to defined formats.</li><li><strong>Uniqueness:</strong> Each patient, facility, or event is recorded only once (no duplicates).</li></ul><h3>Data Quality Improvement Cycle</h3><p>Improving health data quality requires a systematic cycle of assessment, root cause analysis, intervention, and monitoring:</p><ol><li><strong>Assess:</strong> Conduct a data quality assessment to identify specific quality problems and their magnitude.</li><li><strong>Analyse:</strong> Identify the root causes of data quality problems (e.g., unclear definitions, inadequate training, poor system design).</li><li><strong>Intervene:</strong> Implement targeted interventions to address root causes (e.g., training, system improvements, supervision).</li><li><strong>Monitor:</strong> Track data quality indicators over time to assess the impact of interventions.</li></ol><p>In South Sudan, the DHIS2 Data Quality Tool provides automated checks for completeness, timeliness, and consistency of routine health data, supporting systematic data quality monitoring at national and subnational levels.</p>',
        3);

        $this->makeSub($topic, 'Data Sharing and Interoperability',
            '<h3>The Importance of Health Data Interoperability</h3><p>Health data interoperability — the ability of different health information systems to exchange and use data — is essential for a functioning health system. Without interoperability, patient data is fragmented across multiple systems, leading to duplication, errors, and inability to track patients across the continuum of care. In South Sudan, where multiple parallel health information systems have been implemented by different donors and NGOs, interoperability is a major challenge.</p><h3>Standards for Health Data Exchange</h3><p>Several international standards support health data interoperability:</p><ul><li><strong>HL7 FHIR:</strong> A modern standard for exchanging health care information electronically. Increasingly adopted as the global standard for health data exchange.</li><li><strong>OpenHIE architecture:</strong> A framework for building interoperable national health information systems using open standards and open-source software.</li><li><strong>ICD-10/ICD-11:</strong> International Classification of Diseases — standard coding systems for diagnoses and health conditions.</li><li><strong>SNOMED CT:</strong> A comprehensive clinical terminology system enabling consistent coding of clinical concepts.</li></ul><h3>Data Sharing Governance</h3><p>Data sharing must be governed by clear policies that balance the benefits of data sharing (improved care coordination, research, public health surveillance) with the obligation to protect patient privacy. Data sharing agreements, data use agreements, and de-identification protocols are key governance tools. In South Sudan, developing national data sharing policies and standards is a priority for the Ministry of Health and its digital health partners.</p>',
        4);
    }

    // =========================================================================
    // TOPIC 5 — Health Data Privacy and Legal Frameworks
    // =========================================================================
    private function seedTopic5(Course $course): void
    {
        $topic = $this->makeTopic($course,
            'Health Data Privacy and Legal Frameworks',
            'Legal and regulatory frameworks governing health data privacy and protection in South Sudan and internationally.',
            5
        );

        $this->makeSub($topic, 'Principles of Health Data Privacy',
            '<h3>Why Health Data Privacy Matters</h3><p>Health data is among the most sensitive categories of personal data. Unauthorised disclosure of health information can cause serious harm to individuals, including discrimination in employment and insurance, stigma associated with certain conditions (HIV, mental illness, tuberculosis), damage to personal relationships, and psychological distress. Health professionals have both an ethical and a legal obligation to protect the privacy of patient health information.</p><h3>Core Data Privacy Principles</h3><p>International data protection frameworks, including the EU General Data Protection Regulation (GDPR) and the African Union Convention on Cyber Security and Personal Data Protection, are built on a set of core principles:</p><ul><li><strong>Lawfulness, fairness, and transparency:</strong> Data must be processed lawfully, fairly, and in a transparent manner.</li><li><strong>Purpose limitation:</strong> Data must be collected for specified, explicit, and legitimate purposes and not processed in ways incompatible with those purposes.</li><li><strong>Data minimisation:</strong> Only data that is necessary for the specified purpose should be collected.</li><li><strong>Accuracy:</strong> Data must be accurate and kept up to date.</li><li><strong>Storage limitation:</strong> Data should not be kept longer than necessary for the specified purpose.</li><li><strong>Integrity and confidentiality:</strong> Data must be processed in a manner that ensures appropriate security, including protection against unauthorised access, loss, or destruction.</li><li><strong>Accountability:</strong> The data controller is responsible for and must demonstrate compliance with these principles.</li></ul>',
        1);

        $this->makeSub($topic, 'Legal Framework for Health Data in South Sudan',
            '<h3>Existing Legal Framework</h3><p>South Sudan\'s legal framework for health data privacy is still developing. Key relevant legislation and policies include:</p><ul><li><strong>The Transitional Constitution of South Sudan (2011):</strong> Provides for the right to privacy as a fundamental right, which extends to health information.</li><li><strong>The Public Health Act:</strong> Governs public health activities including disease notification, which involves mandatory disclosure of certain health information to public health authorities.</li><li><strong>The National Health Policy:</strong> Articulates principles of confidentiality and patient rights in health service delivery.</li><li><strong>The ICT Policy:</strong> Addresses data protection in the digital environment, though comprehensive data protection legislation is not yet in place.</li></ul><h3>Gaps in the Legal Framework</h3><p>South Sudan does not yet have comprehensive data protection legislation equivalent to the GDPR or similar frameworks in other African countries (e.g., Kenya\'s Data Protection Act 2019, Uganda\'s Data Protection and Privacy Act 2019). This creates significant gaps in the legal protection of health data. Health organisations operating in South Sudan must therefore rely on international standards, professional codes of conduct, and organisational policies to govern health data privacy in the absence of comprehensive national legislation.</p><h3>Implications for Health Professionals</h3><p>In the absence of comprehensive data protection legislation, health professionals in South Sudan must apply the principles of international data protection frameworks and professional ethics to their handling of health data. This includes obtaining informed consent for data collection, implementing appropriate security measures, limiting access to health data on a need-to-know basis, and reporting data breaches promptly.</p>',
        2);

        $this->makeSub($topic, 'Data Security in Health Systems',
            '<h3>Health Data Security Threats</h3><p>Health data faces a range of security threats that must be addressed through technical and organisational controls:</p><ul><li><strong>Unauthorised access:</strong> Individuals accessing health data without authorisation, either through hacking, theft of credentials, or exploitation of system vulnerabilities.</li><li><strong>Data breaches:</strong> Accidental or deliberate disclosure of health data to unauthorised parties.</li><li><strong>Ransomware:</strong> Malicious software that encrypts health data and demands payment for decryption. Ransomware attacks on health systems have increased globally.</li><li><strong>Insider threats:</strong> Health workers or IT staff misusing their access to health data.</li><li><strong>Physical security:</strong> Theft or loss of devices containing health data.</li></ul><h3>Security Controls for Health Data</h3><p>A layered approach to health data security combines technical, administrative, and physical controls:</p><ul><li><strong>Technical controls:</strong> Encryption of data at rest and in transit; strong authentication (passwords, multi-factor authentication); access controls limiting data access to authorised users; audit logs recording all data access; regular security patching and updates.</li><li><strong>Administrative controls:</strong> Data security policies; staff training on data security; background checks for staff with access to sensitive data; incident response procedures.</li><li><strong>Physical controls:</strong> Secure storage of devices and paper records; visitor access controls; screen privacy filters in clinical areas.</li></ul>',
        3);

        $this->makeSub($topic, 'Patient Rights and Data Subject Rights',
            '<h3>Data Subject Rights in Health</h3><p>Individuals whose health data is collected and processed have specific rights that health organisations must respect. These rights are recognised in international data protection frameworks and professional ethics codes:</p><ul><li><strong>Right to access:</strong> Patients have the right to access their own health records and to receive a copy of their data.</li><li><strong>Right to rectification:</strong> Patients have the right to have inaccurate health data corrected.</li><li><strong>Right to erasure:</strong> In some circumstances, patients have the right to have their health data deleted (though this right may be limited by legal obligations to retain health records).</li><li><strong>Right to restrict processing:</strong> Patients may have the right to restrict how their data is used in certain circumstances.</li><li><strong>Right to data portability:</strong> Patients have the right to receive their health data in a portable format and to transfer it to another provider.</li><li><strong>Right to object:</strong> Patients may have the right to object to certain uses of their health data, including use for research or marketing.</li></ul><h3>Implementing Data Subject Rights in South Sudan</h3><p>Implementing data subject rights in South Sudan\'s health system requires: clear policies on patient access to health records; trained staff who can respond to patient requests; systems for recording and tracking requests; and escalation procedures for complex cases. Building a culture of respect for patient data rights is a long-term process that requires leadership commitment and sustained investment in staff training and system development.</p>',
        4);
    }

    // =========================================================================
    // TOPIC 6 — Health Governance and Accountability
    // =========================================================================
    private function seedTopic6(Course $course): void
    {
        $topic = $this->makeTopic($course,
            'Health Governance and Accountability',
            'Principles and mechanisms of health governance, accountability, and transparency in the South Sudan health system.',
            6
        );

        $this->makeSub($topic, 'Principles of Good Health Governance',
            '<h3>What is Health Governance?</h3><p>Health governance refers to the actions and means adopted by a society to organise itself in the promotion and protection of the health of its population. It encompasses the rules, norms, and institutions that shape how health decisions are made, who makes them, and how decision-makers are held accountable. Good health governance is a prerequisite for an effective, equitable, and sustainable health system.</p><h3>Principles of Good Governance</h3><p>The United Nations Development Programme (UNDP) identifies eight principles of good governance that apply to health systems:</p><ul><li><strong>Participation:</strong> All stakeholders, including communities and civil society, have a voice in health decisions.</li><li><strong>Rule of law:</strong> Health governance is conducted within a framework of laws and regulations that are fairly enforced.</li><li><strong>Transparency:</strong> Health decisions and their rationale are open to public scrutiny.</li><li><strong>Responsiveness:</strong> Health institutions respond to the needs and concerns of stakeholders in a timely manner.</li><li><strong>Consensus orientation:</strong> Health governance mediates differing interests to reach broad consensus on what is in the best interest of the population.</li><li><strong>Equity and inclusiveness:</strong> All members of society have opportunities to improve or maintain their health.</li><li><strong>Effectiveness and efficiency:</strong> Health institutions produce results that meet the needs of society while making the best use of resources.</li><li><strong>Accountability:</strong> Health decision-makers are answerable to the public and to institutional stakeholders for their decisions and actions.</li></ul>',
        1);

        $this->makeSub($topic, 'Accountability Mechanisms in Health',
            '<h3>Types of Accountability in Health Systems</h3><p>Accountability in health systems operates through multiple mechanisms:</p><ul><li><strong>Political accountability:</strong> Health ministers and senior officials are accountable to elected representatives (parliament) and ultimately to citizens through elections.</li><li><strong>Administrative accountability:</strong> Health managers are accountable to their superiors through hierarchical reporting and performance management systems.</li><li><strong>Professional accountability:</strong> Health professionals are accountable to their professional bodies (e.g., medical councils, nursing boards) for adherence to professional standards.</li><li><strong>Social accountability:</strong> Health providers are accountable to communities and patients through mechanisms such as community health committees, patient feedback systems, and civil society monitoring.</li><li><strong>Financial accountability:</strong> Health organisations are accountable for the proper use of public funds through audit, financial reporting, and anti-corruption mechanisms.</li></ul><h3>Social Accountability Tools</h3><p>Social accountability tools empower communities to monitor and demand accountability from health providers. Tools used in South Sudan and similar contexts include: community scorecards (communities assess health service quality against agreed standards); citizen report cards (surveys measuring community satisfaction with health services); community health committees (formal structures for community participation in health facility governance); and participatory budgeting (communities participate in decisions about health resource allocation).</p>',
        2);

        $this->makeSub($topic, 'Anti-Corruption in Health Systems',
            '<h3>Corruption in Health Systems</h3><p>Corruption — the abuse of entrusted power for private gain — is a major challenge in health systems globally, and particularly in fragile states like South Sudan. Corruption in health systems takes many forms:</p><ul><li><strong>Procurement corruption:</strong> Kickbacks and fraud in the procurement of medicines, equipment, and health services.</li><li><strong>Absenteeism:</strong> Health workers receiving salaries for positions they do not fill or work they do not perform.</li><li><strong>Informal payments:</strong> Health workers demanding unofficial payments from patients for services that should be free.</li><li><strong>Theft of medicines and supplies:</strong> Diversion of medicines and medical supplies from public health facilities to private markets.</li><li><strong>Falsification of data:</strong> Manipulation of health data to meet targets or access funding.</li></ul><h3>Anti-Corruption Strategies</h3><p>Effective anti-corruption strategies in health systems combine prevention, detection, and enforcement:</p><ul><li><strong>Prevention:</strong> Transparent procurement processes; competitive salaries; clear codes of conduct; conflict of interest policies; internal controls.</li><li><strong>Detection:</strong> Internal and external audit; whistleblower mechanisms; community monitoring; data analytics to identify anomalies.</li><li><strong>Enforcement:</strong> Investigation and prosecution of corruption; disciplinary action; recovery of stolen assets.</li></ul>',
        3);

        $this->makeSub($topic, 'Decentralisation and Health Governance in South Sudan',
            '<h3>Decentralisation in South Sudan\'s Health System</h3><p>South Sudan\'s health system is organised across three levels: national (Ministry of Health), state (State Ministries of Health), and county (County Health Departments). The 2011 Transitional Constitution established a decentralised governance structure, with significant responsibilities devolved to state and county levels. In practice, however, decentralisation has been constrained by: limited financial transfers to subnational levels; weak institutional capacity at state and county levels; ongoing conflict disrupting governance structures; and the dominance of donor-funded parallel systems that bypass government structures.</p><h3>Implications for Health Policy and Governance</h3><p>Effective decentralisation of health governance requires: adequate financial transfers to subnational levels; capacity building for state and county health managers; clear delineation of roles and responsibilities between levels; accountability mechanisms linking subnational performance to national standards; and community participation in local health governance. Strengthening decentralised health governance is a long-term process that requires sustained political commitment and investment in institutional capacity at all levels of the health system.</p>',
        4);
    }

    // =========================================================================
    // TOPIC 7 — Health Information System Governance
    // =========================================================================
    private function seedTopic7(Course $course): void
    {
        $topic = $this->makeTopic($course,
            'Health Information System Governance',
            'Governing national health information systems, DHIS2 governance in South Sudan, and building a culture of data use.',
            7
        );

        $this->makeSub($topic, 'National Health Information System Governance',
            '<h3>Components of HIS Governance</h3><p>Governing a national health information system (HIS) requires attention to multiple dimensions:</p><ul><li><strong>Policy and legal framework:</strong> National policies and legislation governing health data collection, management, sharing, and privacy.</li><li><strong>Institutional arrangements:</strong> Clear roles and responsibilities for HIS governance across government ministries, health facilities, and other stakeholders.</li><li><strong>Standards and interoperability:</strong> National standards for health data definitions, coding systems, and data exchange protocols.</li><li><strong>Data quality assurance:</strong> Systems and processes for monitoring and improving the quality of health data.</li><li><strong>Human capacity:</strong> Trained health informatics professionals and data managers at all levels of the health system.</li><li><strong>Technology infrastructure:</strong> Reliable hardware, software, connectivity, and power supply to support HIS operations.</li><li><strong>Financing:</strong> Sustainable funding for HIS operations, maintenance, and development.</li></ul><h3>The National eHealth Strategy</h3><p>A national eHealth strategy provides the overarching framework for HIS governance. It articulates the vision for digital health, sets priorities for investment, defines governance structures, and establishes accountability mechanisms. South Sudan\'s Ministry of Health, with support from WHO and other partners, has been developing a national eHealth strategy to guide digital health investments and governance.</p>',
        1);

        $this->makeSub($topic, 'DHIS2 Governance in South Sudan',
            '<h3>DHIS2 as the National HIS Platform</h3><p>DHIS2 (District Health Information Software 2) is the primary platform for routine health data collection and reporting in South Sudan. Governing DHIS2 effectively requires attention to:</p><ul><li><strong>System administration:</strong> Who has authority to make changes to the DHIS2 configuration (data elements, indicators, organisation units, user accounts)?</li><li><strong>Data ownership:</strong> Who owns the data in DHIS2? What are the rules for data access and sharing?</li><li><strong>User management:</strong> How are user accounts created, managed, and deactivated? What data can different user roles access?</li><li><strong>Data validation:</strong> What validation rules are in place to ensure data quality? Who is responsible for investigating and resolving validation alerts?</li><li><strong>System updates:</strong> How are DHIS2 software updates managed? Who approves changes to the system configuration?</li><li><strong>Backup and disaster recovery:</strong> How is DHIS2 data backed up? What is the plan for restoring the system in the event of a failure?</li></ul><h3>DHIS2 Governance Challenges in South Sudan</h3><p>Common DHIS2 governance challenges in South Sudan include: limited technical capacity for system administration; high staff turnover disrupting institutional knowledge; multiple stakeholders (government, donors, NGOs) with different interests in system configuration; and limited use of DHIS2 data for decision-making at subnational levels. Addressing these challenges requires investment in human capacity, clear governance policies, and sustained leadership commitment to data-driven health management.</p>',
        2);

        $this->makeSub($topic, 'Building a Culture of Data Use',
            '<h3>From Data Collection to Data Use</h3><p>A persistent challenge in health information systems globally — and particularly in South Sudan — is the gap between data collection and data use. Health facilities and programmes collect large amounts of data, but this data is often not used to inform decisions at the facility, district, or national level. Building a culture of data use requires addressing both technical and behavioural barriers.</p><h3>Strategies for Promoting Data Use</h3><p>Evidence-based strategies for promoting data use in health systems include:</p><ul><li><strong>Data review meetings:</strong> Regular meetings at facility, district, and national levels where health data is reviewed, discussed, and used to make decisions. Data review meetings create accountability for data quality and demonstrate the value of data for management.</li><li><strong>Data visualisation:</strong> Presenting data in accessible visual formats (charts, maps, dashboards) makes it easier for managers and clinicians to interpret and act on data.</li><li><strong>Feedback loops:</strong> Providing facilities with feedback on their performance relative to targets and peers motivates data quality improvement and performance improvement.</li><li><strong>Capacity building:</strong> Training health managers in data analysis and interpretation skills.</li><li><strong>Leadership modelling:</strong> Senior health leaders who visibly use data in their decision-making send a powerful signal about the importance of data.</li><li><strong>Incentives:</strong> Linking resource allocation or recognition to data quality and data use performance.</li></ul>',
        3);

        $this->makeSub($topic, 'Digital Health Policy Development',
            '<h3>Components of a Digital Health Policy</h3><p>A comprehensive national digital health policy addresses the following components:</p><ul><li><strong>Vision and objectives:</strong> The desired future state of digital health and the specific objectives the policy aims to achieve.</li><li><strong>Governance:</strong> Institutional arrangements for digital health governance, including roles, responsibilities, and coordination mechanisms.</li><li><strong>Infrastructure:</strong> Standards and investments for digital health infrastructure, including connectivity, power, hardware, and software.</li><li><strong>Human resources:</strong> Strategies for building the health informatics workforce and digital literacy of health workers.</li><li><strong>Data standards and interoperability:</strong> National standards for health data definitions, coding, and exchange.</li><li><strong>Privacy and security:</strong> Legal and regulatory framework for health data privacy and security.</li><li><strong>Financing:</strong> Strategies for sustainable financing of digital health investments.</li><li><strong>Monitoring and evaluation:</strong> Indicators and mechanisms for monitoring digital health policy implementation and impact.</li></ul><h3>Digital Health Policy in South Sudan</h3><p>South Sudan is at an early stage of digital health policy development. Key priorities include: developing comprehensive data protection legislation; establishing a national health data standards framework; strengthening DHIS2 governance; expanding connectivity to health facilities; and building health informatics capacity. Engaging with the Ministry of Health\'s digital health policy processes is an important opportunity for health professionals to contribute to shaping the digital health future of South Sudan.</p>',
        4);
    }

    // =========================================================================
    // EXAM QUESTIONS
    // =========================================================================
    private function seedQuestions(Course $course): void
    {
        $questions = [
            ['question' => 'Which stage of the health policy cycle involves placing a health problem on the agenda for government action?', 'a' => 'Policy formulation', 'b' => 'Agenda setting', 'c' => 'Policy adoption', 'd' => 'Policy evaluation', 'answer' => 'B', 'explanation' => 'Agenda setting is the stage where a health problem gains sufficient attention from policymakers to be placed on the policy agenda for action.'],
            ['question' => 'The WHO health system framework identifies how many building blocks?', 'a' => 'Four', 'b' => 'Five', 'c' => 'Six', 'd' => 'Eight', 'answer' => 'C', 'explanation' => 'The WHO health system framework identifies six building blocks: service delivery, health workforce, health information systems, access to essential medicines, health financing, and leadership and governance.'],
            ['question' => 'Universal Health Coverage (UHC) is defined as:', 'a' => 'Free health care for all citizens funded by the government', 'b' => 'Access to needed health services without financial hardship', 'c' => 'Health insurance coverage for the entire population', 'd' => 'Equal distribution of health facilities across all regions', 'answer' => 'B', 'explanation' => 'UHC means all people have access to the health services they need without suffering financial hardship — it is not limited to free or government-funded care.'],
            ['question' => 'Which framework analyses health policy by examining content, context, process, and actors?', 'a' => 'PESTLE analysis', 'b' => 'SWOT analysis', 'c' => 'The policy triangle framework', 'd' => 'The logical framework approach', 'answer' => 'C', 'explanation' => 'The policy triangle framework, developed by Walt and Gilson, analyses health policies through four interacting elements: content, context, process, and actors.'],
            ['question' => 'What is the primary purpose of data governance in health systems?', 'a' => 'To collect more health data from facilities', 'b' => 'To manage the availability, usability, integrity, and security of health data', 'c' => 'To train health workers in data entry', 'd' => 'To publish health statistics annually', 'answer' => 'B', 'explanation' => 'Data governance is the overall management of the availability, usability, integrity, and security of data — ensuring it is managed as a valuable organisational asset.'],
            ['question' => 'The principle of data minimisation in data protection means:', 'a' => 'Data should be stored for the minimum possible time', 'b' => 'Only data necessary for the specified purpose should be collected', 'c' => 'The minimum number of staff should have access to data', 'd' => 'Data should be collected from the minimum number of facilities', 'answer' => 'B', 'explanation' => 'Data minimisation means collecting only the data that is necessary for the specified, legitimate purpose — avoiding collection of unnecessary personal data.'],
            ['question' => 'Which type of accountability holds health providers accountable to communities through mechanisms like community scorecards?', 'a' => 'Political accountability', 'b' => 'Administrative accountability', 'c' => 'Professional accountability', 'd' => 'Social accountability', 'answer' => 'D', 'explanation' => 'Social accountability empowers communities to monitor and demand accountability from health providers through tools such as community scorecards, citizen report cards, and community health committees.'],
            ['question' => 'What does HTA stand for in health policy?', 'a' => 'Health Training Assessment', 'b' => 'Health Technology Assessment', 'c' => 'Health Transfer Agreement', 'd' => 'Health Transparency Audit', 'answer' => 'B', 'explanation' => 'HTA stands for Health Technology Assessment — a multidisciplinary process that determines the value of a health technology to inform policy decisions about adoption and coverage.'],
            ['question' => 'Which international standard is increasingly adopted as the global standard for health data exchange?', 'a' => 'ICD-10', 'b' => 'SNOMED CT', 'c' => 'HL7 FHIR', 'd' => 'DHIS2', 'answer' => 'C', 'explanation' => 'HL7 FHIR (Fast Healthcare Interoperability Resources) is a modern standard for exchanging health care information electronically, increasingly adopted as the global standard for health data exchange.'],
            ['question' => 'Kingdon\'s multiple streams framework identifies which three streams that must converge for policy change?', 'a' => 'Evidence, funding, and political will', 'b' => 'Problems, policies, and politics', 'c' => 'Agenda, formulation, and implementation', 'd' => 'Research, advocacy, and legislation', 'answer' => 'B', 'explanation' => 'Kingdon\'s multiple streams framework identifies three streams — problems, policies, and politics — that must converge to create a policy window for change.'],
            ['question' => 'Which form of corruption involves health workers demanding unofficial payments from patients for services that should be free?', 'a' => 'Procurement corruption', 'b' => 'Data falsification', 'c' => 'Informal payments', 'd' => 'Absenteeism', 'answer' => 'C', 'explanation' => 'Informal payments are unofficial payments demanded by health workers from patients for services that should be provided free of charge — a common form of corruption in health systems.'],
            ['question' => 'The right of patients to access their own health records is known as:', 'a' => 'Right to rectification', 'b' => 'Right to erasure', 'c' => 'Right to access', 'd' => 'Right to portability', 'answer' => 'C', 'explanation' => 'The right to access allows patients to access their own health records and receive a copy of their personal health data held by health organisations.'],
            ['question' => 'What is the UHC Service Coverage Index used to measure?', 'a' => 'The percentage of the population with health insurance', 'b' => 'Progress toward universal health coverage across a range of health service indicators', 'c' => 'The number of health facilities per 10,000 population', 'd' => 'Government health expenditure as a percentage of GDP', 'answer' => 'B', 'explanation' => 'The UHC Service Coverage Index measures progress toward UHC by tracking coverage of a range of essential health services across the population.'],
            ['question' => 'Which DHIS2 governance question relates to who has authority to make changes to the system configuration?', 'a' => 'Data ownership', 'b' => 'System administration', 'c' => 'Data validation', 'd' => 'Backup and recovery', 'answer' => 'B', 'explanation' => 'System administration governance defines who has authority to make changes to the DHIS2 configuration, including data elements, indicators, organisation units, and user accounts.'],
            ['question' => 'The DAMA DMBOK framework provides guidance on:', 'a' => 'Clinical practice guidelines', 'b' => 'Health technology assessment', 'c' => 'Data management and governance', 'd' => 'Health financing policy', 'answer' => 'C', 'explanation' => 'The DAMA Data Management Body of Knowledge (DMBOK) is a comprehensive framework covering all aspects of data management and governance.'],
            ['question' => 'Which strategy for promoting data use involves regular meetings where health data is reviewed and used to make decisions?', 'a' => 'Data visualisation', 'b' => 'Data review meetings', 'c' => 'Capacity building', 'd' => 'Feedback loops', 'answer' => 'B', 'explanation' => 'Data review meetings create accountability for data quality and demonstrate the value of data for management by regularly reviewing and acting on health data at facility, district, and national levels.'],
            ['question' => 'What is the primary source of health financing in South Sudan?', 'a' => 'Government tax revenue', 'b' => 'Health insurance premiums', 'c' => 'International donor funding', 'd' => 'Out-of-pocket payments', 'answer' => 'C', 'explanation' => 'International donor funding accounts for the majority of health expenditure in South Sudan, as government health spending is extremely low.'],
            ['question' => 'The principle of purpose limitation in data protection means:', 'a' => 'Data must be accurate and up to date', 'b' => 'Data must be collected for specified, explicit, and legitimate purposes only', 'c' => 'Data must be deleted after a specified period', 'd' => 'Data must be stored securely', 'answer' => 'B', 'explanation' => 'Purpose limitation means data must be collected for specified, explicit, and legitimate purposes and not processed in ways incompatible with those purposes.'],
            ['question' => 'Which tool maps the interests, influence, and positions of key actors on a specific health policy issue?', 'a' => 'SWOT analysis', 'b' => 'Problem tree analysis', 'c' => 'Stakeholder analysis', 'd' => 'Cost-benefit analysis', 'answer' => 'C', 'explanation' => 'Stakeholder analysis maps the interests, influence, and positions of key actors on a specific policy issue, helping advocates identify allies and develop engagement strategies.'],
            ['question' => 'What does the WHO minimum threshold of 44.5 health workers per 10,000 population represent?', 'a' => 'The number needed to achieve specialist care', 'b' => 'The number needed to achieve basic health coverage', 'c' => 'The global average health worker density', 'd' => 'The target for high-income countries', 'answer' => 'B', 'explanation' => 'The WHO minimum threshold of 44.5 health workers (doctors, nurses, and midwives) per 10,000 population is the level needed to achieve basic health coverage.'],
            ['question' => 'Which accountability mechanism involves parliament holding health ministers accountable for health system performance?', 'a' => 'Social accountability', 'b' => 'Professional accountability', 'c' => 'Financial accountability', 'd' => 'Political accountability', 'answer' => 'D', 'explanation' => 'Political accountability holds health ministers and senior officials accountable to elected representatives (parliament) and ultimately to citizens through elections.'],
            ['question' => 'The OpenHIE architecture is designed to support:', 'a' => 'Clinical trial management', 'b' => 'Interoperable national health information systems', 'c' => 'Health worker training', 'd' => 'Pharmaceutical procurement', 'answer' => 'B', 'explanation' => 'OpenHIE (Open Health Information Exchange) is a community-driven framework for building interoperable national health information systems using open standards and open-source software.'],
            ['question' => 'Which dimension of UHC relates to reducing out-of-pocket payments that cause financial hardship?', 'a' => 'Population coverage', 'b' => 'Service coverage', 'c' => 'Financial protection', 'd' => 'Geographic coverage', 'answer' => 'C', 'explanation' => 'Financial protection is the UHC dimension that aims to reduce out-of-pocket payments so that people do not suffer financial hardship when accessing health services.'],
            ['question' => 'What is the role of a data steward in health data governance?', 'a' => 'Setting overall data governance policy', 'b' => 'Technical management of data storage and backup', 'c' => 'Day-to-day management of data quality, metadata, and compliance', 'd' => 'Authorising data sharing agreements', 'answer' => 'C', 'explanation' => 'Data stewards are responsible for day-to-day management of data quality, metadata, and compliance with governance policies — the operational face of data governance.'],
            ['question' => 'Which type of evidence in health policy examines the differential impact of interventions on different population groups?', 'a' => 'Effectiveness evidence', 'b' => 'Economic evidence', 'c' => 'Equity evidence', 'd' => 'Implementation evidence', 'answer' => 'C', 'explanation' => 'Equity evidence examines health inequities and the differential impact of interventions on different population groups, informing policies that address health disparities.'],
            ['question' => 'The COBIT framework provides governance guidance for:', 'a' => 'Clinical practice', 'b' => 'IT and data assets', 'c' => 'Health financing', 'd' => 'Human resources management', 'answer' => 'B', 'explanation' => 'COBIT (Control Objectives for Information and Related Technologies) provides governance and management guidance for IT and data assets in organisations.'],
            ['question' => 'Which anti-corruption strategy involves communities monitoring health service delivery and reporting problems?', 'a' => 'Internal audit', 'b' => 'Competitive procurement', 'c' => 'Community monitoring', 'd' => 'Staff background checks', 'answer' => 'C', 'explanation' => 'Community monitoring is a detection strategy where communities observe health service delivery and report problems, providing an external check on health provider behaviour.'],
            ['question' => 'What is the primary challenge of decentralisation in South Sudan\'s health system?', 'a' => 'Too many health facilities at state level', 'b' => 'Limited financial transfers and weak institutional capacity at subnational levels', 'c' => 'Excessive community participation in health governance', 'd' => 'Over-reliance on domestic government funding', 'answer' => 'B', 'explanation' => 'Decentralisation in South Sudan is constrained by limited financial transfers to subnational levels and weak institutional capacity at state and county levels.'],
            ['question' => 'Which data quality dimension asks whether all required data elements are recorded for all relevant patients?', 'a' => 'Accuracy', 'b' => 'Timeliness', 'c' => 'Completeness', 'd' => 'Consistency', 'answer' => 'C', 'explanation' => 'Completeness asks whether all required data elements are recorded for all relevant patients and facilities — a fundamental dimension of health data quality.'],
            ['question' => 'A national eHealth strategy primarily serves to:', 'a' => 'Procure digital health equipment', 'b' => 'Provide the overarching framework for HIS governance and digital health investment', 'c' => 'Train health workers in computer skills', 'd' => 'Regulate private health technology companies', 'answer' => 'B', 'explanation' => 'A national eHealth strategy provides the overarching framework for HIS governance, articulating the vision for digital health, setting investment priorities, and establishing accountability mechanisms.'],
            ['question' => 'Which principle of good governance ensures health decisions and their rationale are open to public scrutiny?', 'a' => 'Participation', 'b' => 'Rule of law', 'c' => 'Transparency', 'd' => 'Accountability', 'answer' => 'C', 'explanation' => 'Transparency is the governance principle that ensures health decisions and their rationale are open to public scrutiny, enabling citizens and civil society to hold decision-makers accountable.'],
            ['question' => 'What is the WHO-CHOICE database used for in health policy?', 'a' => 'Tracking disease outbreaks globally', 'b' => 'Providing cost-effectiveness data for health interventions in different world regions', 'c' => 'Managing health worker registrations', 'd' => 'Storing national health survey data', 'answer' => 'B', 'explanation' => 'WHO-CHOICE (Choosing Interventions that are Cost-Effective) provides cost-effectiveness data for a range of health interventions in different world regions, supporting evidence-based priority setting.'],
            ['question' => 'Ransomware is a health data security threat that involves:', 'a' => 'Unauthorised access to patient records by staff', 'b' => 'Malicious software that encrypts data and demands payment for decryption', 'c' => 'Physical theft of devices containing health data', 'd' => 'Accidental deletion of health records', 'answer' => 'B', 'explanation' => 'Ransomware is malicious software that encrypts health data and demands payment (ransom) for the decryption key, disrupting health system operations.'],
            ['question' => 'Which health financing mechanism best protects households from catastrophic health expenditure?', 'a' => 'Out-of-pocket payments', 'b' => 'User fees at point of service', 'c' => 'Prepayment and risk pooling through insurance or taxation', 'd' => 'Donor-funded free services', 'answer' => 'C', 'explanation' => 'Prepayment and risk pooling — through health insurance or tax-funded systems — spread financial risk across the population, protecting households from catastrophic health expenditure.'],
        ];

        foreach ($questions as $i => $q) {
            $this->makeQuestion($course, $q, $i + 1);
        }
    }

    // =========================================================================
    // DOWNLOADS
    // =========================================================================
    private function seedDownloads(Course $course): void
    {
        $this->makeDownload(
            $course,
            'Health Policy and Data Governance Reference Guide',
            'health-policy-data-governance-reference-guide.pdf',
            'application/pdf',
            2359296
        );

        $this->makeDownload(
            $course,
            'South Sudan Health System Overview and Policy Frameworks',
            'south-sudan-health-system-policy-frameworks.pdf',
            'application/pdf',
            1048576
        );
    }
}
