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
- Enter ids, expiryDays, receivedDays. Keep parallel arrays aligned. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- 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 field | Meaning and units | Accepted input |
|---|---|---|
| ids | Ids | Required. Array of text; maximum UTF-16 length 8192; maximum items 256. |
| expiryDays | Expiry Days | Required. Array of safe integer; maximum items 256. |
| receivedDays | Received Days | Required. Array of safe integer; maximum items 256. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| orderedIds | Ordered Ids | Required. Array of text; maximum UTF-16 length 8192; maximum items 256. |
| originalIndices | Original Indices | Required. Array of safe integer; maximum items 256. |
{
"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
Similar or alternative tools
- Medicine Lot Expiry Tie Token
Find the minimum supplied expiry coordinate, retain every matching lot ID in input order, and set tie when more than one record matches.
- Medicine Expiry Period Gap
Parse real Gregorian expiryDate and ordered use-window dates.