const { useState, useEffect, useRef } = React; const API_BASE = '/api/v1/medical-store/'; // Detect store slug from URL (e.g. /MedicalStore/storeA or /app/medical-store/storeB) function getInitialStoreSlug() { if (window.INITIAL_STORE_SLUG) { return window.INITIAL_STORE_SLUG; } const path = window.location.pathname; const match = path.match(/(?:MedicalStore|app\/medical-store)\/([a-zA-Z0-9_\-]+)/i); return match ? match[1] : null; } // ========================================================================= // ROOT ERROR BOUNDARY // ========================================================================= class ErrorBoundary extends React.Component { constructor(props) { super(props); this.state = { hasError: false, error: null }; } static getDerivedStateFromError(error) { return { hasError: true, error }; } componentDidCatch(error, errorInfo) { console.error("Medical Store UI Error:", error, errorInfo); } render() { if (this.state.hasError) { return (
{this.state.error?.message || 'An unexpected error occurred while rendering the counter desk.'}
Synchronizing pharmacy counters, terminal licenses & ABDM...
Could not locate any active pharmacy store counter for /{storeSlugFromUrl || 'default'}.
Please verify store configuration in HMS Admin.
This computer terminal is accessing the counter for the first time. Please enter the Security Key or 6-digit OTP provided by HMS Admin.
{selectedPatient.uhid}
Gender/Age: {selectedPatient.gender}, {selectedPatient.age}
{(selectedPatient.abha_id || selectedPatient.abha_address) && (
ABDM Linked: {selectedPatient.abha_id || ''} {selectedPatient.abha_address ? `(${selectedPatient.abha_address})` : ''}
)}
{selectedPatient.has_active_ipd && (
{selectedPatient.active_ipd.bed_info?.ward_name || 'Ward'} / {selectedPatient.active_ipd.bed_info?.bed_no || 'Bed'} (Dr. {selectedPatient.active_ipd.doctor_name})
)}
{selectedPatient.has_active_opd && !selectedPatient.has_active_ipd && (
OPD Dr. {selectedPatient.active_opd.doctor_name}
)}
| # | Medicine Name | Batch / Exp | Qty | MRP (₹) | Disc (% / ₹) | GST% | Total (₹) | |
|---|---|---|---|---|---|---|---|---|
| Scan barcode or search medicine to add items to bill. | ||||||||
| {idx + 1} |
{it.item_name}
{it.generic_name} • HSN: {it.hsn_code}
|
{it.batch_no}
Exp: {it.expiry_display}
|
updateCartItem(idx, 'qty', e.target.value)} /> | ₹{it.unit_mrp} |
updateCartItem(idx, 'discount_val', e.target.value)}
/>
{lineDisc > 0 && (
{it.discount_type === 'pct'
? `-₹${lineDisc.toFixed(2)}`
: `${(lineGross > 0 ? ((lineDisc / lineGross) * 100).toFixed(1) : 0)}% off`}
)}
|
{it.gst_rate}% | ₹{lineNet} | |
| Item | Batch | Qty | Total |
|---|---|---|---|
| {it.item_name} | {it.batch_no} | {it.qty} | ₹{it.total_amount} |
| # | Medicine Name | HSN | Batch | Exp | Qty | MRP (₹) | Amount (₹) |
|---|---|---|---|---|---|---|---|
| {i + 1} |
{it.item_name}
{it.snomed_ct_code && SNOMED: {it.snomed_ct_code} }
|
{it.hsn_code} | {it.batch_no} | {it.expiry_date.substring(0,7)} | {it.qty} | ₹{it.unit_mrp} | ₹{it.total_amount} |
{lastInvoice.sale.uhid || 'Walk-in'}| # | Medicine & Formulation | HSN | Batch No | Exp Date | Qty | MRP (₹) | Taxable (₹) | CGST (₹) | SGST (₹) | Total (₹) |
|---|---|---|---|---|---|---|---|---|---|---|
| {i + 1} |
{it.item_name}
{it.snomed_ct_code && (
SNOMED-CT:
)}
{it.snomed_ct_code} ({it.snomed_display || ''})
|
{it.hsn_code} | {it.batch_no} | {it.expiry_date} | {it.qty} | ₹{it.unit_mrp} | ₹{it.taxable_value} | ₹{it.cgst_amount} | ₹{it.sgst_amount} | ₹{it.total_amount} |
| HSN Code | GST Rate | Taxable Value (₹) | CGST (₹) | SGST (₹) | Total Tax (₹) |
|---|---|---|---|---|---|
| {h.hsn_code} | {h.gst_rate}% | ₹{h.taxable_value.toFixed(2)} | ₹{h.cgst_amount.toFixed(2)} | ₹{h.sgst_amount.toFixed(2)} | ₹{h.total_tax.toFixed(2)} |
{fhirBundleData.care_context_ref}
{JSON.stringify(fhirBundleData.bundle, null, 2)}
| # | Item & Generic Molecule | Category | Batch No | Expiry | Current Qty | PTR (₹) | MRP (₹) | Cost Value (₹) | Status |
|---|---|---|---|---|---|---|---|---|---|
| Loading inventory... | |||||||||
| No stock records found. | |||||||||
| {idx + 1} |
{s.item_name}
{s.generic_name} • HSN: {s.hsn_code}
|
{s.category} | {s.batch_no} | {s.expiry_display} | {s.current_qty} | ₹{s.ptr} | ₹{s.mrp} | ₹{s.cost_valuation} | {s.is_expired ? ( EXPIRED ) : s.is_near_expiry ? ( Near Expiry ) : ( Good Stock )} |
| Medicine Name | Batch No | Expiry | Packs | Free | Units/Pack | PTR (₹) | MRP (₹) | GST% | |
|---|---|---|---|---|---|---|---|---|---|
| updateRow(i, 'item_name', e.target.value)} /> | updateRow(i, 'batch_no', e.target.value)} /> | updateRow(i, 'expiry_date', e.target.value)} /> | updateRow(i, 'qty_packs', e.target.value)} /> | updateRow(i, 'free_qty_packs', e.target.value)} /> | updateRow(i, 'units_per_pack', e.target.value)} /> | updateRow(i, 'ptr', e.target.value)} /> | updateRow(i, 'mrp', e.target.value)} /> |
Upload your stock export from Marg Pharmacy Software or Microsoft Excel to seamlessly import medicines, batch numbers, MRP, PTR, HSN codes, and opening stock into {store.store_name}.
Ensure file is exported in CSV format from Marg ERP.
| # | Supplier Name | DL Form 20B / 21B | GSTIN | Phone / Contact | Credit Terms |
|---|---|---|---|---|---|
| {i + 1} | {s.supplier_name} | {s.dl_no_20b || 'N/A'} / {s.dl_no_21b || 'N/A'} | {s.gstin} |
{s.phone} ({s.contact_person}) | {s.credit_days} Days |
Building counters can requisition medicines from the Main Hospital Central Store. Once dispatched and physically verified, stock transfers automatically.
| Invoice No | Time | Patient (UHID) | Doctor | Mode | CGST (₹) | SGST (₹) | Net Amount |
|---|---|---|---|---|---|---|---|
| {t.invoice_no} | {t.sale_date.split(' ')[1]} | {t.patient_name} {t.uhid ? `(${t.uhid})` : ''} | {t.doctor_name} | {t.payment_mode} | ₹{t.cgst_amount} | ₹{t.sgst_amount} | ₹{t.net_amount} |
| HSN Code | GST Slab | Taxable Value (₹) | CGST (₹) | SGST (₹) | IGST (₹) | Total Invoice Value (₹) |
|---|---|---|---|---|---|---|
{g.hsn_code} |
{g.gst_rate}% | ₹{Number(g.taxable_val).toFixed(2)} | ₹{Number(g.cgst_val).toFixed(2)} | ₹{Number(g.sgst_val).toFixed(2)} | ₹{Number(g.igst_val).toFixed(2)} | ₹{Number(g.total_val).toFixed(2)} |
| Date | Bill No | Patient Name & Address | Prescribing Doctor & Reg No | Medicine Name | Batch No | Qty Supplied |
|---|---|---|---|---|---|---|
| No Schedule H1 medicines dispensed in this period. | ||||||
| {h.sale_date.split(' ')[0]} | {h.invoice_no} | {h.patient_name} {h.patient_address ? `(${h.patient_address})` : ''} | {h.doctor_name} {h.doctor_reg_no ? `(Reg: ${h.doctor_reg_no})` : ''} | {h.item_name} | {h.batch_no} |
{h.qty} |