Skip to content

Main content

Medicine Expiry First Out Tie Rule Tool

Sort supplied lots by expiry, receipt and stable input order.

Loading tool…

Description

Sort by expiry day, then received day, then original index, returning ordered IDs and originalIndices.

Pharmacy inventory distinguishes physical stock, reservations, holds, lots, package units, and expiry records. A stock calculation describes supplied records and cannot establish that a medicine is suitable or authorized for use.

Sort by expiry day, then received day, then original index, returning ordered IDs and originalIndices.

When to use this tool

Use Medicine Expiry First Out Tie Rule when you need one explicit pharmacy stock-accounting component.

How to use the tool and how it works

  1. Enter ids, expiryDays, receivedDays. Keep parallel arrays aligned. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read orderedIds, originalIndices. Use the output convention below.

Require aligned IDs, expiryDays, and receivedDays with unique IDs. Sort by expiry day, then received day, then original index, returning ordered IDs and originalIndices.1

Input fieldMeaning and unitsAccepted input
idsIdsRequired. Array of text; maximum UTF-16 length 8192; maximum items 256.
expiryDaysExpiry DaysRequired. Array of safe integer; maximum items 256.
receivedDaysReceived DaysRequired. Array of safe integer; maximum items 256.
Output fieldInterpretationReturned shape
orderedIdsOrdered IdsRequired. Array of text; maximum UTF-16 length 8192; maximum items 256.
originalIndicesOriginal IndicesRequired. Array of safe integer; maximum items 256.
json
{
  "input": {
    "ids": [
      "A",
      "B",
      "C"
    ],
    "expiryDays": [
      100,
      90,
      100
    ],
    "receivedDays": [
      10,
      20,
      5
    ]
  },
  "output": {
    "orderedIds": [
      "B",
      "C",
      "A"
    ],
    "originalIndices": [
      1,
      2,
      0
    ]
  }
}

Limitations and assumptions

  • Numeric day coordinates and eligibility must already be valid; deterministic first-expiry ordering does not establish actual stock availability or authorize dispensing.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.

Alternative or Complementary methods

Reconcile verified inventory and product records within the pharmacy's controlled workflow before purchasing, releasing, or dispensing stock.

References

  1. Calculation and input contract: hospital-pharmacy/medicine-expiry-first-out-tie-rule — tool.io

Similar or alternative tools