DEV Community

Cover image for Modelling Surgical Instrument Sets as Data: A Dilator Set Example
SPG Medisafe
SPG Medisafe

Posted on Originally published at spgmedisafe.com

Modelling Surgical Instrument Sets as Data: A Dilator Set Example

Surgical instruments are often sold as sets, such as a nephrostomy dilator set with ten or more graduated pieces. If you build a catalogue, an inventory tool or a sterile-processing tracker for a hospital, you quickly face a design question: how do you model a set and its parts so that shortages, substitutions and reorders are easy to handle? Here is a small approach.

Separate the set from its members

A set is a template, and the physical tray in a store is an instance of that template. Keeping them apart makes it easy to see what is missing.

from dataclasses import dataclass, field

@dataclass(frozen=True)
class SetItem:
    code: str
    diameter_fr: int
    qty: int = 1

@dataclass
class SetTemplate:
    name: str
    items: list[SetItem] = field(default_factory=list)

template = SetTemplate(
    name="Sequential dilator set",
    items=[SetItem(f"DIL-{d}", d) for d in range(8, 32, 2)],
)
Enter fullscreen mode Exit fullscreen mode

The diameters above are placeholders. Take the real list from the manufacturer's specification sheet.

Compare a tray against its template

from collections import Counter

def missing_items(template: SetTemplate, found_codes: list[str]) -> list[str]:
    needed = Counter({i.code: i.qty for i in template.items})
    have = Counter(found_codes)
    shortfall = needed - have
    return sorted(shortfall.elements())
Enter fullscreen mode Exit fullscreen mode

A scan of the tray after cleaning produces found_codes, and the function returns exactly which sizes must be replaced before the set can be released.

Track reprocessing cycles

Reusable instruments have a stated service life. Store a counter per physical item, not per set, so that one worn piece can be retired without discarding the rest.

CREATE TABLE instrument (
  serial        TEXT PRIMARY KEY,
  code          TEXT NOT NULL,
  cycles_used   INTEGER NOT NULL DEFAULT 0,
  cycles_limit  INTEGER NOT NULL
);
Enter fullscreen mode Exit fullscreen mode

Why it helps buyers

When shortages are visible by size, purchasing can order the single piece that is missing instead of an entire new set. If you want the buyer's view of these products, including types, diameter ranges and supplier checks, read the full guide: nephrostomy dilator set guide.

This is general software advice and not clinical guidance.

Top comments (0)