# Quick Start: Patient Import for Remote Monitoring

## TL;DR - What Happened

✅ **23 patients imported successfully** from `app/Console/for-import.csv`

- User accounts created (IDs 1778-1800)
- Insurance records created
- All patients ready for remote monitoring workflow

## How to Use the Import Command

### 1. Preview Before Importing (Recommended)

```bash
php artisan patients:import-remote-monitoring app/Console/for-import.csv --dry-run
```

### 2. Import Patients & Insurance

```bash
php artisan patients:import-remote-monitoring app/Console/for-import.csv
```

### 3. Import with Patient Intake Records

```bash
php artisan patients:import-remote-monitoring app/Console/for-import.csv --staff-id=2 --create-intake
```

## What Gets Created

| Item | Count | Details |
|------|-------|---------|
| Patient Accounts | 23 | Role: patient, Status: active |
| Insurance Records | 23 | Provider, policy, plan type |
| Patient Intakes | 0 | Optional (use `--create-intake`) |

## CSV File Format

Required columns:
- `name` - Patient name (required)
- `Email Address` - Email (optional)
- `phone` - Phone number (optional)
- `DOB` - Date of birth MM/DD/YY (optional)
- `address` - Address (optional)
- `conditions` - Medical conditions (optional)
- `insurance company` - Insurance provider (optional)
- `Policy Number` - Policy number (optional)
- `Group Number` - Group number (optional)
- `Plan Type HMO PPO HMO-POS` - Plan type (optional)

## Recognized Conditions

The system automatically detects:
- **Hypertension**: "high blood pressure", "hypertension"
- **Diabetes**: "diabetes"
- **Heart Failure**: "heart", "cardiac"
- **Chronic Pain**: "chronic pain", "pain"
- **Arthritis**: "arthritis"
- **COPD/Asthma**: "copd", "asthma"

## Service Path Auto-Detection

Based on conditions, the system determines:
- **CCM**: 2+ conditions
- **RPM**: Hypertension, Diabetes, or Heart Failure
- **RTM**: Chronic Pain, Arthritis, COPD, or Asthma

## Verify Import Success

```bash
php artisan tinker

# Count patients
>>> User::where('id', '>=', 1778)->count()

# View a patient
>>> User::find(1778)->load('insurances')

# Check insurance
>>> Insurance::where('user_id', '>=', 1778)->count()
```

## Next Steps

### Option 1: Create Intake Records
```bash
# Find staff member ID first
php artisan tinker
>>> User::where('role', 'staff')->first()

# Then create intakes
php artisan patients:import-remote-monitoring app/Console/for-import.csv --staff-id=2 --create-intake
```

### Option 2: Manual Intake via Web
1. Log in as staff
2. Go to patient profile
3. Click "Remote Monitoring"
4. Complete intake form

### Option 3: Skip to Doctor Orders
Doctors can create orders directly for patients with insurance info.

## Common Commands

```bash
# Find staff member ID
php artisan tinker
>>> User::where('role', 'staff')->get(['id', 'name'])

# Find doctor ID
>>> User::where('role', 'doctor')->get(['id', 'name'])

# Check patient intake
>>> PatientIntake::where('patient_id', 1778)->first()

# Check doctor orders
>>> DoctorOrder::where('patient_id', 1778)->first()
```

## Troubleshooting

| Issue | Solution |
|-------|----------|
| File not found | Check path is relative to project root |
| Unknown column 'role' | Run `php artisan migrate` |
| Duplicate email | Command updates existing records |
| Missing staff ID | Use `--staff-id=X` with valid staff ID |

## Documentation

- **Full Guide**: `docs/PATIENT_IMPORT_GUIDE.md`
- **Import Results**: `docs/IMPORT_SUMMARY.md`
- **Next Steps**: `docs/NEXT_STEPS_AFTER_IMPORT.md`
- **Workflow**: `docs/REMOTE_MONITORING_WORKFLOW.md`

## Current Status

✅ **Completed**:
- 23 patients imported
- Insurance records created
- Patients ready for workflow

⏳ **Next**:
- Create patient intakes (optional)
- Doctors create orders
- Staff verify insurance
- Doctors approve
- Patients begin monitoring

---

**Need help?** See the full documentation in the `docs/` directory.

