Encounters <> Program Attribution in O3
Summary:
A program is a thread of care, not a one-time enrollment record. Some run for life (HIV, hypertension, diabetes, mental health); others are time-bounded and repeatable (a pregnancy/PMTCT episode, a TB treatment course). In every case, the patient returns for care under that program.
Desired capability: for whatever program a patient is enrolled in, the encounters delivered under it should be linkable back to that program — so the patient's program-specific care can be reassembled and continued.
Currently, no follow-up encounter is linked to its program. At return-to-care, a clinician sees only an undifferentiated pile of all encounters. "Which program was this encounter for?" is unanswerable in the stack. Root cause is structural: the data model has no encounter/visit → program reference.
Picture showing what this project is about (e.g. a key mockup, drawing; anything visual)
1. Problem
Enrolling a patient in a program is only the front door. What matters is the care that follows: the patient comes back to the facility under that program — a hypertensive patient for blood-pressure reviews and refills, an HIV patient for viral loads and ART, a pregnant patient for antenatal visits across one pregnancy. The purpose of program support is to link those encounters to the program, so that when the patient returns, their program-specific history can be reassembled and continued as one coherent thread — regardless of whether the program lasts a lifetime or a single episode.
O3 doesn't do this. Enrollment is stored as a free-floating marker — payload {program, patient, dateEnrolled, dateCompleted, location, states}, no encounter or visit field (programs.resource.tsx:53) — and the encounters that follow are never tied back to it. The chart can show that a patient is enrolled and that encounters happened, but not which encounters belong to which program.
The structural cause — Nothing stamps an encounter with the program it served. Core OpenMRS has no reference from an encounter or visit to a program; PatientProgram carries only patient, program, dates, location, and states. Attribution therefore has to be reconstructed downstream in ETL/reporting by deriving from encounter type, form, and enrollment date window.
Determination should happen at the point of care, not after. A patient enrolled in two concurrent programs — HIV and TB, or hypertension and diabetes — with a generic "Clinical consultation" encounter is ambiguous to any after-the-fact rule; date-window inference then breaks further on re-enrollment and retrospective entry. The moment the system actually knows the answer is at check-in — and today it throws that knowledge away. Capturing the program when the visit starts is the only point at which ambiguity never enters the record.
2. User Stories
As a clinician, when a patient returns for follow-up, I want the encounters, labs, and medications for the program they're enrolled in gathered under that program, so I can continue care with the full journey in front of me.
As a clinician, I want each follow-up encounter I create in a program visit linked to that program, so the care thread stays coherent visit after visit.
As an M&E/reporting officer, I want encounters attributed to a program in the record, so program indicators (e.g., hypertension control rates, viral suppression, ANC coverage) come from data, not reconstruction.
As a program manager, I want a patient's follow-up encounters tied to the enrollment that governed them, so a program's care reads as one timeline instead of scattered across the chart.
As a data manager, I want a patient who completes and re-enrols (e.g., a new pregnancy) to keep each episode's encounters tied to that episode, so history isn't collapsed.
As a clinician, when a patient is in two programs at once, I want each encounter attributed correctly, so neither program's record is polluted.
3. Market Analysis
No implementer has a first-class encounter → program link in the platform: PIH reconstructs it downstream (data-warehouse date window), TaifaCare/KenyaEMR binds it at the point of care via a Care Panel + form metadata (enrollment confirmed; follow-up unproven), and UgandaEMR builds an implied relationship on encounter type and wants it structured. Everyone works around a link the platform should own.
Implementer | How implementers tie encounters to a program |
|---|---|
PIH |
|
Palladium |
Care Panel Encounter Type Form <> Encounter Type Form <> Encounter Type |
UgandaEMR | No backend link — attribution is an implied / assumed relationship built on encounter type. Confirmed; explicitly wants it "finally fully structured to relate directly" — a direct endorsement of the platform fix. |
4. Technical Considerations & Dependencies
Gap analysis → proposed direction:
# | Gap | Impact on the care | Proposed direction |
|---|---|---|---|
1 | Enrolled in a program ↔ clinical visits — enrollment is a one-time record; the visits that follow carry no reference back to the program. The two sides never touch | When the patient returns, there's no thread to pull — program-specific care can't be reassembled | Stamp the visit with the program at check-in: visit attribute short-term, FHIR |
2 | Are there programs using visit type? — the visit-start form recommends visit types by enrollment but discards the program on submit. No core program↔visit-type metadata | The one moment the system knows which program the visit is for, it throws it away | Persist the selected program on the visit (cheapest); move the program→visit-type mapping into core metadata instead of ETL |
3 | What encounters need relationships — every follow-up encounter in a longitudinal program needs a tie to that program; none has one and the model offers no field | Encounters can't be differentiated by the program that produced them | Once visits are stamped, every encounter under a program-linked visit inherits the program; program-specific forms reinforce the attribution |
4 | Determination of which program? — a shared/generic encounter type can't tell you which program it served (a patient in HIV and TB, or hypertension and diabetes, with a "Clinical consultation" encounter is ambiguous). | Inferred-later determination is lossy; ambiguity enters the record and breaks on re-enrollment and retrospective entry | The check-in stamp is the determination moment — the program is declared when the visit starts, so ambiguity never enters the record. UgandaEMR names this exact "implied/assumed relationship" problem and asks for it to be structured directly. |
Options
First/second option capture the program at the point of care (determination unambiguous); third/fourth infer it later (lossy).
FHIR
EpisodeOfCare— Preferred (durable)Enrollment episode = an episode; every encounter in the period references it
Strongest — built to group encounters over a program period; re-enrollment = new episode. FHIR-module support unverified
Program reference on the visit (visit attribute) — Candidate (short-term)
Stamp the visit; encounters inherit it
Good, simpler; visit-level only, no first-class episode. Platform change
Encounter/visit-type → program config map — Interim bridge
Core metadata mapping, replacing ETL
Weak — breaks on shared encounter types across concurrent programs
Date-window correlation — Fallback only
Attribute encounters inside the enrollment window
Weakest — ambiguous on overlap / re-enrollment / RDE; reconstructs rather than records
5. Sketches