diff --git a/client/src/components/TransactionForm.tsx b/client/src/components/TransactionForm.tsx index 2451bdf..c5c879a 100644 --- a/client/src/components/TransactionForm.tsx +++ b/client/src/components/TransactionForm.tsx @@ -1,13 +1,6 @@ import React, { useState } from 'react'; import { checkDispensingEligibility, type LocalSettings, type GuardResult } from '../utils/dispensingGuard'; -import { type PatientDocType } from '../db/schema'; - -// Mock Patient Data (Since we don't have a patient picker UI yet) -const MOCK_PATIENTS: (PatientDocType & { last_sync_date: string })[] = [ - { id: 'P1', name: 'Juan Dela Cruz', municipality: 'Tabuk', last_sync_date: new Date().toISOString() }, - { id: 'P2', name: 'Maria Clara', municipality: 'Lubuagan', last_sync_date: new Date().toISOString() }, // Visitor - { id: 'P3', name: 'Jose Rizal', municipality: 'Tabuk', last_sync_date: '2023-01-01T00:00:00Z' } // Stale -]; +import { MOCK_PATIENTS, PATIENTS_MAP } from '../mocks/patients'; const LOCAL_SETTINGS: LocalSettings = { municipality: 'Tabuk', @@ -26,7 +19,7 @@ export const TransactionForm: React.FC = ({ onAdd, sku }) const [guardResult, setGuardResult] = useState(null); const handleDispense = () => { - const patient = MOCK_PATIENTS.find(p => p.id === selectedPatientId); + const patient = PATIENTS_MAP.get(selectedPatientId); if (!patient) return; // Run Protocol-20k Check diff --git a/client/src/mocks/patients.ts b/client/src/mocks/patients.ts new file mode 100644 index 0000000..bbfafd4 --- /dev/null +++ b/client/src/mocks/patients.ts @@ -0,0 +1,16 @@ +import { type PatientDocType } from '../db/schema'; + +/** + * Mock Patient Data + * Anonymized to comply with PII guidelines. + */ +export const MOCK_PATIENTS: (PatientDocType & { last_sync_date: string })[] = [ + { id: 'P1', name: 'Patient A', municipality: 'Tabuk', last_sync_date: new Date().toISOString() }, + { id: 'P2', name: 'Patient B', municipality: 'Lubuagan', last_sync_date: new Date().toISOString() }, // Visitor + { id: 'P3', name: 'Patient C', municipality: 'Tabuk', last_sync_date: '2023-01-01T00:00:00Z' } // Stale +]; + +/** + * PATIENTS_MAP for O(1) lookups by ID. + */ +export const PATIENTS_MAP = new Map(MOCK_PATIENTS.map(p => [p.id, p]));