Device and equipment extraction¶
device_extraction.py finds medical devices and durable medical equipment (DME) in dashboard_data.json, both from structured codes (HCPCS Level II, CPT and SNOMED CT) and from free text in notes and documents. Equipment is a large part of care in ALS and other progressive neurologic diseases: speech-generating devices, non-invasive ventilation, cough assist, hospital beds, power wheelchairs, feeding tubes, and the occupational, physical and speech therapy evaluations that lead to them.
Each output row says where it came from, a code or a text match, so the two can be counted separately. Text matches are candidates for review, with the same context cues as note extraction.
Module source (device_extraction.py) Device dashboard demo
Coverage¶
Categories, codes and text patterns in the shipped tables
| Category | Structured codes | Text patterns |
|---|---|---|
| AAC and speech-generating devices | HCPCS E1902, E2500 to E2512; SNOMED CT 17988007, 462866006, 702779005 | AAC, speech-generating device, Tobii Dynavox, Dynavox, PRC (Prentke Romich), TouchChat, Proloquo2Go and Proloquo4Text, eye-gaze input, communication board |
| AAC evaluations and therapy | CPT 92605 to 92609, 97755 | |
| Wheelchair, type not stated | wheelchair, transport chair, tilt-in-space, recline | |
| Manual wheelchair | HCPCS K0001 to K0009, E1037, E1038, E1130, E1140, E1170; SNOMED CT 466089005 | manual wheelchair |
| Power wheelchair and controls | HCPCS E1230, K0813, K0814, K0822, K0848, K0856, K0861, K0890; SNOMED CT 466088002 | power or motorized wheelchair, sip-and-puff control, head-array control |
| Wheelchair management and training | CPT 97542 | |
| Standers | HCPCS E0637, E0638, E0642 | stander, standing frame, sit-to-stand |
| Walkers, canes and crutches | HCPCS E0100 to E0148; SNOMED CT 40847000, 116167008, 37148003 | walker or rollator, quad cane, crutches |
| Lifts and transfer aids | HCPCS E0635, E0639, E0641 | Hoyer, mechanical or ceiling lift; transfer board, belt, sling or pole; gait belt |
| Bathing and toileting safety | HCPCS E0163, E0240, E0241, E0244, E0247 | shower chair or tub transfer bench, bedside commode, raised toilet seat, grab bar |
| Hospital beds and pressure mattresses | HCPCS E0181, E0260, E0261, E0277, E0297 | hospital bed, pressure-reducing or alternating-pressure mattress |
| Respiratory equipment | HCPCS E0464 to E0466, E0470 to E0472, E0481 to E0483, E0500, E0600, E1390 to E1392; SNOMED CT 243140006, 243144000, 301401004, 466762001, 706180003 | BiPAP or bi-level, CPAP, non-invasive ventilation, home or portable ventilator, cough assist, high-frequency chest wall oscillation vest, suction machine, oxygen concentrator, ventilator brand names (Trilogy, Astral, Vivo, VOCSN, Luisa) |
| Feeding tubes and enteral pumps | HCPCS B4034 to B4036, B9002 | PEG, gastrostomy, jejunostomy or NG feeding tube; enteral feeding pump |
| Orthotic and prosthetic management | CPT 97760, 97761, 97763 | |
| Equipment referrals and evaluations | DME order or referral; OT, PT or SLP evaluation for equipment; wheelchair fitting or seating clinic; AAC evaluation or trial; home safety evaluation |
The code ranges list only the codes in DEVICE_CODES; codes inside a range that are not listed there are not matched.
The tables are DEVICE_CODES and DEVICE_PATTERNS at the top of the module. Brand-name patterns sit beside the generic ones because notes often name a device by brand ("uses a Trilogy overnight", "trial of Tobii Dynavox").
Codes and text¶
HCPCS Level II codes are equipment and supply billing codes, CPT codes are clinician services and evaluations, and SNOMED CT codes are clinical terms. Every coding on a record is checked, and code system names are normalized so "CPT" and "CPT-4" count as one system.
Records pulled from a health system's EHR often do not include orders filled by outside DME suppliers, so many devices appear only in notes. Count coded and text evidence separately, and read an absence of equipment codes as an absence of codes, not of equipment.
The SNOMED CT concept IDs are seed values. Before using them, check each against the current SNOMED CT release for active status and preferred term, and decide whether you want device concepts, procedure concepts or both.
Outputs¶
Both files are restricted: they hold participant IDs, dates and text. run_all.py writes them to restricted/. Cells that begin with =, +, - or @ are prefixed with an apostrophe so a spreadsheet does not read them as formulas.
device_codes.csv, one row per coded record that matches DEVICE_CODES:
| Column | Contents |
|---|---|
patient_id |
Participant identifier |
source_kind |
Bundle table the record came from (procedures, medications, care_plans, encounters, problems, observations, diagnostic_reports) |
code_system, code |
The matching coding |
recorded_display_name |
Display name in the record |
label |
Label from DEVICE_CODES |
category |
Equipment category |
effective_date, status |
From the record |
device_extractions.csv, one row per text match, with the same columns as note_extractions.csv: patient_id, source_kind, source_id, document_date, pattern, category, value, context_hint, snippet, char_offset, description, review_status.
Both files use the same patient_id as patient_master.csv and note_extractions.csv, so equipment can be lined up with diagnoses, ALSFRS-R scores and milestone dates.
Running it¶
run_all.py runs device extraction and the device dashboard. To run it on its own:
import device_extraction
device_extraction.main(bundle_path='dashboard_data.json', out_root='restricted/')
Before using the results¶
- The patterns are seed patterns. Check them against a sample of notes from each contributing health system and add the phrasing and brand names you find.
- Text matches include plans, trials and refusals ("discussed BiPAP", "declined PEG"). Read the context cue and the snippet.
- The module covers equipment that affects function and independence; it does not track supplies such as catheters, dressings or batteries.