Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions client/src/components/TransactionForm.tsx
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -26,7 +19,7 @@ export const TransactionForm: React.FC<TransactionFormProps> = ({ onAdd, sku })
const [guardResult, setGuardResult] = useState<GuardResult | null>(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
Expand Down
16 changes: 16 additions & 0 deletions client/src/mocks/patients.ts
Original file line number Diff line number Diff line change
@@ -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]));