Create Sale
Learn how to create and process a new sale transaction.
This guide walks through the complete process of creating a sale in MediFlux, from initiating the transaction to finalizing payment. Whether you're processing a simple over-the-counter purchase or a complex prescription order with insurance billing, the workflow follows the same fundamental steps.
Creating a Sale via the Dashboard
The MediFlux POS interface is accessible from the main dashboard. Click New Sale or press F2 to start a new transaction.
Add Items to the Sale
Add products to the sale by scanning their barcode, searching by name, or entering the product code directly. Each item appears in the transaction list with its price, quantity, and applicable tax.
const sale = await fetch("https://api.mediflux.io/v1/sales", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer your-api-key",
},
body: JSON.stringify({
location_id: "loc_xyz789",
cashier_id: "usr_jane_doe",
items: [
{
product_id: "prod_amoxicillin_500",
quantity: 1,
prescription_id: "rx_20240115_001",
},
{
product_id: "prod_bandages_medium",
quantity: 2,
},
{
product_id: "prod_vitamin_d3_1000",
quantity: 1,
},
],
}),
});
const saleData = await sale.json();
console.log("Sale created:", saleData.id);
// Output: Sale created: sale_2024_00456MediFlux automatically checks inventory availability when items are added. If an item is out of stock or below the reserved quantity threshold, you'll receive an immediate warning.
Verify Prescriptions
For prescription medications, MediFlux prompts the pharmacist to verify the prescription before the sale can proceed. The verification step captures the prescription number, prescriber information, and the pharmacist's digital signature.
await fetch(`https://api.mediflux.io/v1/sales/${saleData.id}/verify`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer pharmacist-api-key",
},
body: JSON.stringify({
item_id: "item_001",
prescription: {
rx_number: "RX-2024-78901",
prescriber: "Dr. Sarah Mitchell",
prescriber_npi: "1234567890",
date_written: "2024-01-10",
refills_authorized: 3,
refills_used: 0,
},
pharmacist_id: "usr_pharmacist_01",
verification_method: "digital_signature",
}),
});Sales containing unverified prescription items cannot be finalized. A licensed pharmacist must complete the verification step before payment can be processed.
Apply Discounts and Insurance
Apply any applicable discounts, loyalty program benefits, or insurance coverage. MediFlux supports stacking multiple discount types and will automatically calculate the correct amount.
await fetch(`https://api.mediflux.io/v1/sales/${saleData.id}/adjustments`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer your-api-key",
},
body: JSON.stringify({
adjustments: [
{
type: "insurance",
provider: "BlueCross BlueShield",
policy_number: "BCB-9876543",
coverage_amount: 45.0,
copay: 10.0,
},
{
type: "loyalty_discount",
program: "HealthFirst Rewards",
points_redeemed: 500,
discount_amount: 5.0,
},
],
}),
});Process Payment
Finalize the sale by processing payment. MediFlux supports single and split payment methods.
const payment = await fetch(
`https://api.mediflux.io/v1/sales/${saleData.id}/pay`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer your-api-key",
},
body: JSON.stringify({
payments: [
{
method: "credit_card",
amount: 22.5,
reference: "txn_stripe_abc123",
},
],
}),
}
);
const result = await payment.json();
console.log("Sale completed:", result.status);
// Output: Sale completed: completedOnce payment is processed, MediFlux automatically updates inventory quantities, posts the revenue and COGS entries to your accounting ledger, and generates a receipt.
Sale Response Object
A completed sale returns a comprehensive response object:
{
"id": "sale_2024_00456",
"status": "completed",
"location_id": "loc_xyz789",
"cashier_id": "usr_jane_doe",
"items": [
{
"product_id": "prod_amoxicillin_500",
"name": "Amoxicillin 500mg Capsules",
"quantity": 1,
"unit_price": 55.00,
"prescription_verified": true
},
{
"product_id": "prod_bandages_medium",
"name": "Sterile Bandages (Medium)",
"quantity": 2,
"unit_price": 4.99
},
{
"product_id": "prod_vitamin_d3_1000",
"name": "Vitamin D3 1000 IU",
"quantity": 1,
"unit_price": 12.50
}
],
"subtotal": 77.48,
"tax": 1.40,
"insurance_coverage": 45.00,
"loyalty_discount": 5.00,
"total": 28.88,
"payments": [
{
"method": "credit_card",
"amount": 28.88
}
],
"created_at": "2024-01-15T14:30:00Z",
"receipt_url": "https://api.mediflux.io/v1/receipts/rcpt_2024_00456"
}Keyboard Shortcuts
The MediFlux POS interface supports keyboard shortcuts for faster transaction processing:
Once payment is processed, MediFlux automatically updates inventory quantities, posts the revenue and COGS entries to your accounting ledger, and generates a receipt.