Skip to content

[FEATURE] Link Scanned Barcodes and Medicine IDs to Counterfeit Incident Reports #1202

Description

@dipexplorer

Which part of SahiDawa needs improvement?

Backend API (apps/api/src/routes/reports.ts) & Frontend wizard (apps/web/components/reports/ReportWizard.tsx)

Description

There is a functional disconnect between scanning a suspicious medicine and filing a counterfeit report:

  1. When a user reports a batch using POST /api/verify/batch/report, it associates the report with scanned_barcode and medicine_id (by resolving the batch number), but doesn't take images, descriptions, state details, etc.
  2. When a user reports an incident via the Report Wizard (POST /api/reports), they can add description, pharmacy details, and images, but POST /api/reports schema and logic completely ignores scanned_barcode and medicine_id.

If a user gets a suspicious result in the medicine scanner and clicks "Report", the system cannot link the scanned barcode or database medicine entry to the final incident report.

Detailed Implementation Guidance

1. Backend Route (apps/api/src/routes/reports.ts)

  • Locate createReportSchema in reports.ts. Extend it with two new optional fields:
    • scannedBarcode: z.string().optional()
    • medicineId: z.string().uuid().optional()
  • Update the SQL payload inside supabase.from("counterfeit_reports").insert({...}) to parse and store scanned_barcode and medicine_id columns:
    scanned_barcode: data.scannedBarcode ?? null,
    medicine_id: data.medicineId ?? null,

2. Frontend Wizard (apps/web/components/reports/ReportWizard.tsx)

  • Check if the URL contains query parameters barcode or medicineId when the user enters the reporting workflow from a scan details screen.
  • Store these properties in the wizard component's state.
  • Include scannedBarcode and medicineId in the JSON request payload when sending the report data to the POST /api/reports endpoint on submission.

GSSoC 2026

  • I am a GSSoC 2026 participant and would like to solve this issue.

To get assigned, please reply with your planned approach. Keep it clean and avoid spamming.


⚠️ Contributor Instructions (Please Read Carefully)

  • Do NOT spam "/assign" or "Please assign me".
  • To claim this task, you MUST reply with a brief proposed implementation plan/approach. What files will you touch? How will you solve it?
  • Once your approach is reviewed and approved by a maintainer, you will be officially assigned.
  • Any PR opened without prior assignment and approach approval will be closed.

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
🎉 Merged

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions