<?php

namespace Database\Seeders;

use App\Models\PrescriptionItemList;
use Illuminate\Database\Seeder;

class PrescriptionItemListSeeder extends Seeder
{
    public function run(): void
    {
        // Quantity Items
        $quantityItems = [
            '5ml Teaspoon', '10ml', '15ml', '20ml',
            ...array_map(fn($i) => $i . ' ' . ($i == 1 ? 'Tablet' : 'Tablets'), range(1, 40)),
            'Apply', 'Chew', 'Dab', 'Dissolve', 'Drip', 'Drop', 'Flush', 'Gargle',
            'Infuse', 'Inhale', 'Inject', 'Insert', 'Instil', 'Massage',
            'Place between gum and cheek', 'Place under the tongue', 'Rinse', 'Rub',
            'Soak', 'Spray', 'Spread', 'Sprinkle', 'Swallow', 'Swish and spit'
        ];

        foreach ($quantityItems as $index => $item) {
            PrescriptionItemList::create([
                'type' => 'quantity',
                'name' => $item,
                'sort_order' => $index,
                'is_active' => true,
            ]);
        }

        // Frequency Items
        $frequencyItems = [
            'Once a day', 'Immediately', 'At night', 'At bedtime',
            'Twice a day', 'Three times a day', 'Four times a day',
            'Every four hours', 'Every six hours', 'Every eight hours',
            'Every twelve hours', 'Every twenty-four hours',
            'Once a week', 'Every week', 'Once a month',
            'instill 1 drop', 'instill 2 drops', 'instill 3 drops',
            'instill 5 drops', 'instill 10 drops'
        ];

        foreach ($frequencyItems as $index => $item) {
            PrescriptionItemList::create([
                'type' => 'frequency',
                'name' => $item,
                'sort_order' => $index,
                'is_active' => true,
            ]);
        }

        // Instruction Items
        $instructionItems = [
            'When required', 'Finish the Course', 'Only if necessary',
            'Before meals', 'After meals', 'With food', 'On alternate days',
            'At night only', 'As directed by your healthcare provider',
            'Up to the maximum prescribed dose',
            'Gradually increase or decrease the dose as instructed'
        ];

        foreach ($instructionItems as $index => $item) {
            PrescriptionItemList::create([
                'type' => 'instruction',
                'name' => $item,
                'sort_order' => $index,
                'is_active' => true,
            ]);
        }

        // Duration Items
        $durationItems = [];
        for ($i = 1; $i <= 7; $i++) {
            $durationItems[] = $i . ' ' . ($i == 1 ? 'Day' : 'Days') . ' Treatment';
        }
        for ($i = 1; $i <= 5; $i++) {
            $durationItems[] = $i . ' ' . ($i == 1 ? 'Week' : 'Weeks') . ' Treatment';
        }
        for ($i = 1; $i <= 6; $i++) {
            $durationItems[] = $i . ' ' . ($i == 1 ? 'Month' : 'Months') . ' Treatment';
        }
        $durationItems[] = '12 Months Treatment';

        foreach ($durationItems as $index => $item) {
            PrescriptionItemList::create([
                'type' => 'duration',
                'name' => $item,
                'sort_order' => $index,
                'is_active' => true,
            ]);
        }
    }
}
