# Surrogate & Donor Connect (SDC) — Complete Implementation Checklist
*Conforming Strictly to [beefplan.md](file:///c:/xampp/htdocs/mdo/SDC/beefplan.md) and User Requirements*

---

## 1. System Architecture & Foundation
- [x] **Core PHP 8.x + MySQLi Only** (Strictly No PDO).
- [x] **Standardized REST JSON API Helper** (`config/db.php`):
  - [x] `api_response($status, $message, $data, $httpCode)`
  - [x] `get_json_input()`
  - [x] `require_auth($requiredRole)`
  - [x] `log_audit($userId, $role, $action, $targetType, $targetId, $details)`
- [x] **16 Relational MySQL Tables** (`sdc` database):
  - [x] `users` (id, role, full_name, email, phone, password_hash, auth_token, is_active)
  - [x] `parent_profiles` (user_id, marital_status, spouse_name, occupation, address, state, kyc_status, kyc_id_type, kyc_id_number)
  - [x] `candidates` (user_id, ref_no, category, status [12 stages], is_available, obstetric history, guarantor details, biological traits, photo URLs, screening status)
  - [x] `agency_profiles` (user_id, org_name, reg_number, state, address, authorized_rep, verification_level, services_offered)
  - [x] `packages` (code, audience, duration_days, price, request_quota)
  - [x] `subscriptions` (customer_user_id, package_id, quota_total, quota_used, status, dates)
  - [x] `sourcing_requests` (ref_no, customer_user_id, category, status, preferred traits & notes)
  - [x] `shortlists` (request_id, candidate_id, customer_interest, candidate_consent, disclosure_approved)
  - [x] `invoices` (invoice_no, user_id, amount, status, due_date, paid_at)
  - [x] `payments` (invoice_id, user_id, amount, utr_reference, payment_proof_file, status, verified_by)
  - [x] `introductions` (sourcing_request_id, candidate_id, customer_user_id, status, handover details)
  - [x] `audit_logs` (user_id, role, action, target_type, target_id, details, ip_address)
  - [x] `agency_contacts` (parent_user_id, agency_id, message, status)
  - [x] `support_tickets` & `ticket_replies`
  - [x] `system_settings` (GTBank details, pricing config, terms)

---

## 2. 12 Candidate Workflow Stages Checklist (beefplan.md Section 7)
- [x] **Stage 1: Newly Registered** (`newly_registered`) — Candidate submits self-registration, initial obstetric/biological history.
- [x] **Stage 2: Information Incomplete** (`information_incomplete`) — Missing guarantor, identification, or demographic data.
- [x] **Stage 3: Under Review** (`under_review`) — SDC compliance & clinical team screening.
- [x] **Stage 4: Awaiting Documents** (`awaiting_documents`) — Awaiting government ID, proof of address, or prior birth proofs.
- [x] **Stage 5: Awaiting Relevant Screening** (`awaiting_screening`) — Awaiting infectious disease panel, hormone profile, or psychological evaluation.
- [x] **Stage 6: Approved for Consideration** (`approved_for_consideration`) — Background checks cleared, eligible for matching.
- [x] **Stage 7: Available for Referral** (`available_for_referral`) — Active in pool, ready for customer matching.
- [x] **Stage 8: Temporarily Unavailable** (`temporarily_unavailable`) — Candidate pauses availability or in active cycle.
- [x] **Stage 9: Introduction Pending** (`introduction_pending`) — Customer requested match, informed candidate consent being obtained.
- [x] **Stage 10: Referred / Handover in Progress** (`referred_handover`) — Consent accepted, clinical handover documents in progress.
- [x] **Stage 11: Withdrawn** (`withdrawn`) — Candidate voluntary withdrawal.
- [x] **Stage 12: Not Eligible** (`not_eligible`) — Clinical exclusion (no prior births, smoking, BMI limit).

---

## 3. Role 1: Intended Parent Flow & APIs
- [x] **Registration & SDC Package Selection** (`beefplan.md` Section 5 & 8):
  - [x] Marital status: Married Couple / Single Parent / In Relationship
  - [x] Spouse name & Occupation
  - [x] Restricted Address (hidden from candidates)
  - [x] KYC NIN / Passport details
  - [x] Service Package: One Surrogate (₦500), One Donor (₦150k), Both (₦150.5k)
  - [x] Auto creates user + sourcing request + invoice and redirects to checkout.
- [x] **GTBank Manual UTR Payment Submission**:
  - [x] Displays GTBank Account `0123456789`, Surrogate & Donor Connect Ltd.
  - [x] UTR reference number submission form (`/api/v1/parent/billing/pay_utr.php`).
- [x] **Parent APIs**:
  - [x] `POST /api/v1/parent/auth/register.php`
  - [x] `POST /api/v1/parent/auth/login.php`
  - [x] `GET /api/v1/parent/auth/me.php`
  - [x] `POST /api/v1/parent/profile/update.php`
  - [x] `GET /api/v1/parent/requests/list.php`
  - [x] `POST /api/v1/parent/requests/create.php`
  - [x] `GET /api/v1/parent/candidates/explore.php`
  - [x] `POST /api/v1/parent/candidates/request_intro.php`
  - [x] `GET /api/v1/parent/billing/invoices.php`
  - [x] `POST /api/v1/parent/billing/pay_utr.php`
  - [x] `GET /api/v1/parent/directory/list.php`
  - [x] `POST /api/v1/parent/directory/contact.php`

---

## 4. Role 2: Surrogate Candidate Flow & APIs
- [x] **Candidate Intake & Obstetric Details** (`beefplan.md` Section 4 & 7):
  - [x] Age 21–38 confirmation
  - [x] Prior births: min 1 live birth required, CS count, miscarriages
  - [x] Guarantor name, phone, relationship, residential address
  - [x] Data processing & summary disclosure consents
  - [x] Auto assigns `SDC-SUR-XXXX` at Stage 1 `newly_registered`.
- [x] **Live Availability Toggle**:
  - [x] One-click switch: `Available for Referral` $\leftrightarrow$ `Temporarily Unavailable`.
- [x] **Surrogate APIs**:
  - [x] `POST /api/v1/surrogate/auth/register.php`
  - [x] `POST /api/v1/surrogate/auth/login.php`
  - [x] `GET /api/v1/surrogate/profile/me.php`
  - [x] `POST /api/v1/surrogate/profile/update.php`
  - [x] `POST /api/v1/surrogate/profile/toggle_availability.php`
  - [x] `GET /api/v1/surrogate/status/pathway.php`
  - [x] `GET /api/v1/surrogate/consent/list.php`
  - [x] `POST /api/v1/surrogate/consent/respond.php`
  - [x] `POST /api/v1/surrogate/documents/upload.php`

---

## 5. Role 3: Donor Candidate Flow & APIs
- [x] **Biological Traits & Screening** (`beefplan.md` Section 4 & 7):
  - [x] Egg donor vs Sperm donor category
  - [x] Genotype (AA, AS), Blood group
  - [x] Height, Weight, Complexion, Eye colour, Hair colour
  - [x] Education, Occupation, Special talents
  - [x] Auto assigns `SDC-EGG-XXXX` / `SDC-SPM-XXXX` at Stage 1 `newly_registered`.
- [x] **Donor APIs**:
  - [x] `POST /api/v1/donor/auth/register.php`
  - [x] `POST /api/v1/donor/auth/login.php`
  - [x] `GET /api/v1/donor/profile/me.php`
  - [x] `POST /api/v1/donor/profile/update.php`
  - [x] `POST /api/v1/donor/profile/toggle_availability.php`
  - [x] `GET /api/v1/donor/status/pathway.php`
  - [x] `POST /api/v1/donor/documents/upload.php`
  - [x] `GET /api/v1/donor/consent/list.php`
  - [x] `POST /api/v1/donor/consent/respond.php`

---

## 6. Role 4: Agency & Clinic Flow & APIs
- [x] **Corporate Subscription & Quota Tracking** (`beefplan.md` Section 6 & 8):
  - [x] CAC / RC Registration Number & Authorized Representative
  - [x] Subscription Tier: Monthly (₦150k / 3 quota), 3 Months (₦350k / 8 quota), 6 Months (₦650k / 18 quota), 12 Months (₦1.2M / 40 quota)
  - [x] Auto-generated subscription invoice with GTBank details
  - [x] Quota deduction on candidate sourcing requests.
- [x] **Agency APIs**:
  - [x] `POST /api/v1/agency/auth/register.php`
  - [x] `POST /api/v1/agency/auth/login.php`
  - [x] `GET /api/v1/agency/profile/me.php`
  - [x] `POST /api/v1/agency/profile/update.php`
  - [x] `GET /api/v1/agency/subscription/status.php`
  - [x] `POST /api/v1/agency/subscription/order.php`
  - [x] `POST /api/v1/agency/billing/pay_utr.php`
  - [x] `GET /api/v1/agency/requests/list.php`
  - [x] `POST /api/v1/agency/requests/create.php`
  - [x] `GET /api/v1/agency/candidates/browse.php`
  - [x] `POST /api/v1/agency/candidates/express_interest.php`
  - [x] `POST /api/v1/agency/directory/update_profile.php`

---

## 7. Admin Backoffice Panel (`/admin/`)
- [x] **Theme**: Modern White BG + Sky Green / Mint Green (`#e0f2f1`, `#348a27`, `#00796b`).
- [x] **Responsive Layout**: Sidebar toggle, accordion submenus, horizontal scroll tables.
- [x] **Dedicated Management Modules**:
  - [x] `dashboard.php`: Real-time KPI queries (Candidates, Requests, Invoices, Subscriptions, Verified Revenue).
  - [x] `candidates.php`: Full review modal (Obstetric history, Guarantor info, Uploaded files badges/links, 12-stage status advance, Screening clearance, Photo clearance, Anonymous summary editor).
  - [x] `billing.php`: Manual Bank Payments (UTR Approver: Approve / Reject UTR), Manual Invoice Creator, Void Invoice.
  - [x] `packages.php`: Manage Pricing & Quota entitlements.
  - [x] `customers.php`: Intended Parents & Agency accounts directory.
  - [x] `requests.php`: Sourcing Requests assignment & shortlist disclosures.
  - [x] `directory.php`: IVF Clinics directory accreditation & publishing.
  - [x] `handover.php`: Referral Handover completion checklist & closure.

---

## 8. All Panels Unified Tester (`sdc_unified_tester.html`)
- [x] Identical to user-provided RedORA Healthcare reference:
  - [x] Top Environment Bar (Active Tokens: Admin, Parent, Surrogate, Donor, Agency, Active Invoice, Active Request, Active Candidate).
  - [x] Role Filter Tabs (All 85 APIs, Admin Operations, Intended Parent, Surrogate Portal, Donor Portal, Agency Portal, 10-Step Sequential Flow).
  - [x] Live Search by Name, URL, Method.
  - [x] Pre-filled JSON Request bodies with Format / Reset buttons.
  - [x] Send API Request with live HTTP status, execution time, and formatted JSON viewer.
  - [x] 1-Click "Run Full Auto Flow" end-to-end runner.

---

## 9. Official Postman Collection v2.1.0 (`sdc_postman_collection.json`)
- [x] **Full Standard Schema**: Conforming to Postman Collection v2.1.0 (`https://schema.getpostman.com/json/collection/v2.1.0/collection.json`).
- [x] **6 Main Role Folders**:
  1. `01. Admin Operations & Governance`
  2. `02. Intended Parent Flow`
  3. `03. Surrogate Mother Candidate Flow`
  4. `04. Egg & Sperm Donor Candidate Flow`
  5. `05. Surrogacy Agency & Clinic Flow`
  6. `06. Public SDC Discovery & Catalog`
- [x] **28 Functional Flow Subfolders**:
  - Structured strictly flow-wise (e.g. `01. Authentication`, `02. Identity & KYC`, `03. Sourcing Requests`, `04. GTBank Manual UTR Billing`, `05. Candidate Exploration`, `06. 12-Stage Pipeline Tracking`, `07. Mutual Handover & Consent`, etc.).
- [x] **Postman Collection (Customer & Public Mobile App Flows)**:
  - **Live API Domain**: `https://mydaddyonline.cloud/api/v1` (with local staging `http://localhost/mdo/SDC/api/v1`)
  - **61 Total Customer API Endpoints** (Admin operations strictly excluded from Mobile App and reserved for Desktop Backoffice).
  - 5 Structured Main Flow Folders:
    1. `01. Intended Parent Flow` (18 APIs)
    2. `02. Surrogate Mother Candidate Flow` (13 APIs)
    3. `03. Egg & Sperm Donor Candidate Flow` (11 APIs)
    4. `04. Surrogacy Agency & Clinic Flow` (16 APIs)
    5. `05. Public SDC Discovery & Catalog` (3 APIs)
  - `base_url` configured to `https://mydaddyonline.cloud`.
- [x] **Direct Downloads Available At**:
  - File: `c:\xampp\htdocs\mdo\SDC\sdc_postman_collection.json` (~131 KB)
  - Master Hub button on `http://localhost/mdo/SDC/index.php`
  - Top header button on `http://localhost/mdo/SDC/sdc_unified_tester.html`

---

### 10. Mobile App Master Implementation Prompt (`APP_MASTER_PROMPT.md`)
- [x] **Live API Domain Configured**:
  - Production Base URL: `https://mydaddyonline.cloud/api/v1`
  - Local Staging URL: `http://localhost/mdo/SDC/api/v1`
- [x] **Strict Constraint: NO Admin Role in Mobile App**:
  - Mobile app exclusively serves the 4 customer roles: Intended Parents, Surrogate Mother, Egg/Sperm Donor, and Surrogacy Agency/Clinic.
  - Admin login and screens are 100% excluded from the mobile app architecture.
- [x] **Screenshots UI Reverse-Engineering**:
  - **Screen 1 (Onboarding Carousel)**: Full-bleed hero lifestyle family photography + white curved bottom sheet (`32px` radius) + elongated emerald green active pill + 2 inactive grey dots + `Skip` and `Next` buttons.
  - **Screen 2 (Role Selector)**: Top centered SDC Logo + `"Surrogate & Donor Connect"` + `"Select Your Role"` + 2x2 grid (Intending Parents, Surrogate, Donor, Agency) with green icons + `"Already have an account? Login"` link.
  - **Screen 3 (Unified Login)**: SDC Logo + `"Welcome Back"` + 4-way Segmented Role Switcher (`[Parents]` `[Surrogate]` `[Donor]` `[Agency]`) in soft grey pill track + input fields with left icons + password eye toggle + full-width green pill `"Login"` button.
  - **Screen 4 (Dynamic Registration)**: Back button `<` + Role Switcher tabs + `"1. ACCOUNT & SIGN-IN"` + `"2. PERSONAL INFORMATION"` (2-column DOB & Nationality) + `"3. ROLE-SPECIFIC REQUIREMENTS"` (`beefplan.md` clinical and corporate fields).
- [x] **4 Independent Role Bottom Navigation Bars**:
  - **Parents**: Home, Browse/Match, My Requests, Invoices & UTR, Profile & KYC.
  - **Surrogate**: Home, My Availability (toggle), 12-Stage Pipeline (visual stepper), Guarantor & Vetting, Profile.
  - **Donor**: Home, Catalog & Traits, Availability, Compensation & Invoices, Settings & Privacy.
  - **Agency**: Dashboard (Sourcing Quota progress), Candidates Roster, Sourcing Requests, Subscriptions & Invoices, Agency Profile & Badge.
- [x] **In-App Live API Debug Tray / Network Inspector**:
  - Bottom toggle button `[🛠️ Debug API Inspector]` on all screens.
  - Slide-up drawer displaying active role APIs, full URLs (`https://mydaddyonline.cloud/api/v1/...`), HTTP status code badge (200, 401, etc.), latency in ms, and formatted JSON viewer with 1-click copy.
- [x] **Developer Copy-Paste Prompt**:
  - Ready-to-use master prompt at [`APP_MASTER_PROMPT.md`](file:///c:/xampp/htdocs/mdo/SDC/APP_MASTER_PROMPT.md) for Claude, GPT, Cursor, Windsurf, Flutter, or React Native dev agents.


