Mapping episode of care to patient program

Thanks to @slubwama for sharing with the fhir squad members the resource he developed for their use case.

The fhir resource maps episode of care to patient program. If we agree with the analogy of mapping episode of care to patient program then we can have the resource added to the fhir2 module. On the other hand, if analogy doesn’t work for us then we need to add episode of care object in the core to have the functionality supported by our data model.

Thoughts on this?

cc: @ibacher @janflowers @burke @dkayiwa

2 Likes

While there are parts of programs that aren’t captured by EpisodeOfCare, it’s the proper resource for this. Happy to have this added to the FHIR2 module.

3 Likes

When we created visits (I think it was at our 2nd implementers conference around 2008), we defined “encounter” as a point in time interaction, “visit” as a collection of encounters that happen within a single contiguous event (e.g., outpatient clinic visit, hospitalization), and “episode of care” as a collection of encounters belonging to a specific condition or treatment (likely across visits).

Program was designed to enroll patients into a study or treatment program. Patients can be moved within exclusive states in a program so we could answer questions like “who are all the patients in the HIV treatment program with a status of ‘on treatment’?” Program (whether a treatment program or study protocol) also implies patients could be assigned a program identifier – she is patient 1234 in Dr. Doe’s Diabetes study.

In FHIR, encounter is used both for the OpenMRS’ encounter & visit. I would suspect “episode of care” could, for example, relate all encounters related to a single pregnancy, a course of TB treatment, etc. I would imagine an OpenMRS program could either be linked to an episode of care… or maybe it’s a specific use case for episode of care… but I could easily imagine uses for episode of care for which we wouldn’t want to require a program.

1 Like

@ibacher will be working on this. Just set the ticket. We have some experimental work in UgandaEMR about EpisodeOfCare.

We have also seen a few changes required in a patient program such as PatientProgram Identifier and the need to have encounters map to an episodeOfCare.

We need to work on the last piece to have core map encounters to episodeOfCare.

@burke thanks for bringing out the last piece that is remaining to equate the program to episodeOfCare. I recently held an offline discussion with @dkayiwa about the need to have encounters map to a patient program to enable quick data extracts of patient data within a given program (episodeOfCare).

I believe it is the only piece left to have episodeOfCare directly translate to the openmrs patient Program.

I would suspect we would need something like encounter_patient_program_map to map an encounter to 0-to-n programs.

1 Like

@burke could there be a drawback if we instead use a mandatory relationship(1:n) for mapping an encounter to openmrs programs?

Not all patients are enrolled in programs and not all patient encounters relate to a program.

3 Likes

What @ibacher said… and every change should take us into closer alignment with FHIR, which has a 0…n relationship between encounter and episode of care (for the reasons @ibacher mentioned).

2 Likes

@kdaud do you want to take a stab at a design for this? Making this real will likely require thinking through the dirty details (e.g., auditing info, retiring linkages). I’m imagining this being backed by an encounter_patient_program_map table with attributes like encounter_patient_program_map_id, encounter_id, patient_program_id, created_by, date_created

@ibacher, @slubwama & others, do you think we need to retain a history of linkages? i.e., would these linkages be Retireable or simply be purged when they are removed?

Yes! :grin:

Am coming up with a draft design and will share it to get feedback.

3 Likes

Exactly. as you see attached the fhir mapping for an encounter to an episodeOfCare

Wouldn’t this be voidable data rather than retireable data (i.e., it’s data about a specific patient, not metadata).

I don’t think it’s essential to keep the audit data for the linkages, but it might be nice to be able to treat it as a proper domain object, which suggests we should make it implement the ChangeableOpenmrsData interface…

1 Like

While working on the assignment, I came across two concerns that I need guidance on.

a. Could there be a difference between program and patient_program. And if there is, which of the two should the EpisodeOfCare be mapped on?

b. Am wondering which of the design would be relevant for the start. Am thinking of two designs;

  1. Architectural Design which describes the structure and behavior of how the mapping will look like and stretches out the relationship between various data tables

  2. Entity Relationship Model Design which stretches the relationship between various entities for the mapping.

If none of the above suits the initial work, which design would be appropriate?

/cc @burke @ibacher @slubwama

patient_program is more appropriate than program per se. Program probably correlates to some kind of CarePlan or similar resource.

Honestly, I’d use whatever makes the most sense to you and helps the most. Don’t worry too much about diagramming things. Most of the FHIR2 mappings were worked on using tables like those here that just list attributes in both data models. Don’t need to overcomplicate things too much.

1 Like

@kdaud A program is a type of a patient_program if I may put it that way.

Look at this bundle with an episode of care and how the encounters can reference episodeOfCare. It might help with the design.

{
  "resourceType": "Bundle",
  "type": "transaction",
  "entry": [
    {
      "resource": {
        "identifier": [
          {
            "extension": [
              {
                "valueReference": {
                  "reference": "Location/86863db4-6101-4ecf-9a86-5e716d6504e4",
                  "display": "ART Clinic",
                  "type": "Location"
                },
                "url": "http://fhir.openmrs.org/ext/patient/identifier#location"
              }
            ],
            "use": "official",
            "id": "6d71a17a-55d6-4858-b5ed-a85d081365a7",
            "type": {
              "coding": [
                {
                  "system": "UgandaEMR",
                  "code": "05a29f94-c0ed-11e2-94be-8c13b969e334"
                }
              ],
              "text": "OpenMRS ID"
            },
            "value": "10V6E3"
          },
          {
            "use": "usual",
            "id": "270d8f89-cc2d-41ca-bc94-e91951ff3801",
            "type": {
              "coding": [
                {
                  "system": "UgandaEMR",
                  "code": "f0c16a6d-dc5f-4118-a803-616d0075d282"
                }
              ],
              "text": "National ID No."
            },
            "value": "XXXXXXXXXXXXXX"
          },
          {
            "use": "usual",
            "id": "2540b291-1a4b-4651-b049-9d31120a7a03",
            "type": {
              "coding": [
                {
                  "system": "UgandaEMR",
                  "code": "8110f2d2-1f98-4c38-aef3-11b19bb0a589"
                }
              ],
              "text": "TB No."
            },
            "value": "68574633"
          }
        ],
        "address": [
          {
            "country": "Uganda",
            "extension": [
              {
                "extension": [
                  {
                    "valueString": "MAKINDYE DIVISION",
                    "url": "http://fhir.openmrs.org/ext/address#subcounty"
                  },
                  {
                    "valueString": "Muyenga",
                    "url": "http://fhir.openmrs.org/ext/address#parish"
                  },
                  {
                    "valueString": "Bukasa",
                    "url": "http://fhir.openmrs.org/ext/address#village"
                  }
                ],
                "url": "http://fhir.openmrs.org/ext/address"
              }
            ],
            "use": "home",
            "id": "520f8ea6-a5bf-412d-b486-915c49227297",
            "state": "KCCA"
          }
        ],
        "gender": "male",
        "active": true,
        "birthDate": "1977-01-01",
        "contained": [
          {
            "agent": [
              {
                "role": [
                  {
                    "coding": [
                      {
                        "system": "http://terminology.hl7.org/CodeSystemv3-ParticipationType",
                        "code": "AUT",
                        "display": "author"
                      }
                    ]
                  }
                ],
                "type": {
                  "coding": [
                    {
                      "system": "http://terminology.hl7.org/CodeSystemprovenance-participant-type",
                      "code": "author",
                      "display": "Author"
                    }
                  ]
                },
                "who": {
                  "reference": "Practitioner/1c3db49d-440a-11e6-a65c-00e04c680037",
                  "display": "Emerson Kaseem",
                  "type": "Practitioner"
                }
              }
            ],
            "activity": {
              "coding": [
                {
                  "system": "http://terminology.hl7.org/CodeSystemv3-DataOperation",
                  "code": "CREATE",
                  "display": "create"
                }
              ]
            },
            "id": "1e83abcb-df8b-4b0d-b797-5cca9ba1ed82",
            "recorded": "2022-06-07T13:03:22.000+03:00",
            "resourceType": "Provenance"
          },
          {
            "agent": [
              {
                "role": [
                  {
                    "coding": [
                      {
                        "system": "http://terminology.hl7.org/CodeSystemv3-ParticipationType",
                        "code": "AUT",
                        "display": "author"
                      }
                    ]
                  }
                ],
                "type": {
                  "coding": [
                    {
                      "system": "http://terminology.hl7.org/CodeSystemprovenance-participant-type",
                      "code": "author",
                      "display": "Author"
                    }
                  ]
                },
                "who": {
                  "reference": "Practitioner/1c3db49d-440a-11e6-a65c-00e04c680037",
                  "display": "Emerson Kaseem",
                  "type": "Practitioner"
                }
              }
            ],
            "activity": {
              "coding": [
                {
                  "system": "http://terminology.hl7.org/CodeSystemv3-DataOperation",
                  "code": "UPDATE",
                  "display": "revise"
                }
              ]
            },
            "id": "f1527d6a-da35-4822-aede-5e78e37d2a53",
            "recorded": "2022-06-07T14:58:49.000+03:00",
            "resourceType": "Provenance"
          }
        ],
        "deceasedBoolean": false,
        "managingOrganization": {
          "reference": "Organization/XXXXXX",
          "identifier": {
            "system": "https://hmis.health.go.ug/",
            "use": "official",
            "value": "XXXXXX"
          },
          "display": "Demo Health Center",
          "type": "Organization"
        },
        "meta": {
          "lastUpdated": "2022-06-07T14:58:49.000+03:00"
        },
        "name": [
          {
            "given": [
              "Tom"
            ],
            "id": "94e0c75b-7b6f-4dac-990c-bc106271439a",
            "family": "James"
          }
        ],
        "telecom": [
          {
            "id": "f295c1c0-68d0-4d28-9bcb-8fddffbf1db1",
            "value": "0776000000"
          }
        ],
        "id": "c350f310-fd89-44de-ad75-bb7827ca1d5b",
        "resourceType": "Patient"
      },
      "request": {
        "method": "PUT",
        "url": "Patient/c350f310-fd89-44de-ad75-bb7827ca1d5b"
      }
    },
    {
      "resource": {
        "resourceType": "EpisodeOfCare",
        "id": "ee2539ed-2e10-4ba5-a089-8d540b328112",
        "identifier": [
          {
            "use": "usual",
            "system": "https://ugandaemr/",
            "value": "68574633",
            "type": {
              "coding": [
                {
                  "system": "UgandaEMR",
                  "code": "8110f2d2-1f98-4c38-aef3-11b19bb0a589"
                }
              ],
              "text": "TB No."
            }
          }
        ],
        "status": "active",
        "type": [
          {
            "coding": [
              {
                "code": "160541AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
                "display": "Tuberculosis treatment program"
              }
            ]
          }
        ],
        "patient": {
          "reference": "Patient/c350f310-fd89-44de-ad75-bb7827ca1d5b",
          "type": "Patient",
          "display": "Tom James (OpenMRS ID: 10V6E3)"
        },
        "managingOrganization": {
          "reference": "Organization/XXXXX",
          "type": "Organization",
          "identifier": {
            "use": "official",
            "system": "https://hmis.health.go.ug/",
            "value": "XXXXX"
          },
          "display": "Demo Health Center"
        },
        "period": {
          "start": "2022-04-01T00:00:00+03:00"
        }
      },
      "request": {
        "method": "POST"
      }
    },
    {
      "resource": {
        "partOf": {
          "reference": "Encounter/e50e4c31-08a6-407b-b3cc-417bc92885fe",
          "type": "Encounter"
        },
        "period": {
          "start": "2022-04-01T00:00:00+03:00"
        },
        "subject": {
          "reference": "Patient/c350f310-fd89-44de-ad75-bb7827ca1d5b",
          "display": "Tom James (OpenMRS ID: 10V6E3)",
          "type": "Patient"
        },
        "type": [
          {
            "coding": [
              {
                "system": "http://fhir.openmrs.org/code-system/encounter-type",
                "code": "455bad1f-5e97-4ee9-9558-ff1df8808732",
                "display": "TB Encounter (Followup)"
              }
            ]
          }
        ],
        "participant": [
          {
            "individual": {
              "reference": "Practitioner/2455a599-a800-11e6-9919-80c16ef29100",
              "identifier": {
                "value": "2455"
              },
              "display": "Emerson Kaseem (Identifier: 2455)",
              "type": "Practitioner"
            }
          }
        ],
        "contained": [
          {
            "agent": [
              {
                "role": [
                  {
                    "coding": [
                      {
                        "system": "http://terminology.hl7.org/CodeSystemv3-ParticipationType",
                        "code": "AUT",
                        "display": "author"
                      }
                    ]
                  }
                ],
                "type": {
                  "coding": [
                    {
                      "system": "http://terminology.hl7.org/CodeSystemprovenance-participant-type",
                      "code": "author",
                      "display": "Author"
                    }
                  ]
                },
                "who": {
                  "reference": "Practitioner/1c3db49d-440a-11e6-a65c-00e04c680037",
                  "display": "Emerson Kaseem",
                  "type": "Practitioner"
                }
              }
            ],
            "activity": {
              "coding": [
                {
                  "system": "http://terminology.hl7.org/CodeSystemv3-DataOperation",
                  "code": "CREATE",
                  "display": "create"
                }
              ]
            },
            "id": "7dd0288f-5c50-48eb-84c8-a917fb804f1e",
            "recorded": "2022-06-07T13:24:22.000+03:00",
            "resourceType": "Provenance"
          }
        ],
        "meta": {
          "tag": [
            {
              "system": "http://fhir.openmrs.org/ext/encounter-tag",
              "code": "encounter",
              "display": "Encounter"
            }
          ]
        },
        "serviceProvider": {
          "reference": "Organization/XXXXX",
          "identifier": {
            "system": "https://hmis.health.go.ug/",
            "use": "official",
            "value": "XXXXX"
          },
          "display": "Demo Health Center",
          "type": "Organization"
        },
        "location": [
          {
            "location": {
              "reference": "Location/8ab22b55-9a17-4121-bf08-6134a9a2439f",
              "display": "TB Clinic",
              "type": "Location"
            }
          }
        ],
        "id": "41ff8811-23ed-43f9-b302-f90485d915e4",
        "episodeOfCare": {
          "reference": "EpisodeOfCare/ee2539ed-2e10-4ba5-a089-8d540b328112"
        },
        "class": {
          "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
          "code": "AMB"
        },
        "resourceType": "Encounter",
        "status": "unknown"
      },
      "request": {
        "method": "POST"
      }
    },
    {
      "resource": {
        "partOf": {
          "reference": "Encounter/e50e4c31-08a6-407b-b3cc-417bc92885fe",
          "type": "Encounter"
        },
        "contained": [
          {
            "agent": [
              {
                "role": [
                  {
                    "coding": [
                      {
                        "system": "http://terminology.hl7.org/CodeSystemv3-ParticipationType",
                        "code": "AUT",
                        "display": "author"
                      }
                    ]
                  }
                ],
                "type": {
                  "coding": [
                    {
                      "system": "http://terminology.hl7.org/CodeSystemprovenance-participant-type",
                      "code": "author",
                      "display": "Author"
                    }
                  ]
                },
                "who": {
                  "reference": "Practitioner/1c3db49d-440a-11e6-a65c-00e04c680037",
                  "display": "Emerson Kaseem",
                  "type": "Practitioner"
                }
              }
            ],
            "activity": {
              "coding": [
                {
                  "system": "http://terminology.hl7.org/CodeSystemv3-DataOperation",
                  "code": "CREATE",
                  "display": "create"
                }
              ]
            },
            "id": "3ceb5dc3-efca-40b3-b116-f8c0d002a91a",
            "recorded": "2022-06-07T13:13:25.000+03:00",
            "resourceType": "Provenance"
          }
        ],
        "period": {
          "start": "2022-04-01T00:00:00+03:00"
        },
        "meta": {
          "tag": [
            {
              "system": "http://fhir.openmrs.org/ext/encounter-tag",
              "code": "encounter",
              "display": "Encounter"
            }
          ]
        },
        "subject": {
          "reference": "Patient/c350f310-fd89-44de-ad75-bb7827ca1d5b",
          "display": "Tom James (OpenMRS ID: 10V6E3)",
          "type": "Patient"
        },
        "serviceProvider": {
          "reference": "Organization/XXXXX",
          "identifier": {
            "system": "https://hmis.health.go.ug/",
            "use": "official",
            "value": "XXXXX"
          },
          "display": "Demo Health Center",
          "type": "Organization"
        },
        "id": "7067e0f7-3309-41b4-8e89-fb3e77a7e537",
        "episodeOfCare": {
          "reference": "EpisodeOfCare/ee2539ed-2e10-4ba5-a089-8d540b328112"
        },
        "type": [
          {
            "coding": [
              {
                "system": "http://fhir.openmrs.org/code-system/encounter-type",
                "code": "334bf97e-28e2-4a27-8727-a5ce31c7cd66",
                "display": "TB Summary (Enrollment)"
              }
            ]
          }
        ],
        "class": {
          "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
          "code": "AMB"
        },
        "resourceType": "Encounter",
        "status": "unknown"
      },
      "request": {
        "method": "POST"
      }
    },
    {
      "request": {
        "method": "POST"
      },
      "resource": {
        "contained": [
          {
            "agent": [
              {
                "role": [
                  {
                    "coding": [
                      {
                        "system": "http://terminology.hl7.org/CodeSystemv3-ParticipationType",
                        "code": "AUT",
                        "display": "author"
                      }
                    ]
                  }
                ],
                "type": {
                  "coding": [
                    {
                      "system": "http://terminology.hl7.org/CodeSystemprovenance-participant-type",
                      "code": "author",
                      "display": "Author"
                    }
                  ]
                },
                "who": {
                  "reference": "Practitioner/1c3db49d-440a-11e6-a65c-00e04c680037",
                  "display": "Emerson Kaseem",
                  "type": "Practitioner"
                }
              }
            ],
            "activity": {
              "coding": [
                {
                  "system": "http://terminology.hl7.org/CodeSystemv3-DataOperation",
                  "code": "CREATE",
                  "display": "create"
                }
              ]
            },
            "id": "cb6dd69c-3e41-4010-a592-f133879fe1c5",
            "recorded": "2022-06-07T13:13:25.000+03:00",
            "resourceType": "Provenance"
          }
        ],
        "code": {
          "coding": [
            {
              "code": "d2f31713-aada-4d0d-9340-014b2371bdd8",
              "display": "Examination Date"
            },
            {
              "system": "UgandaEMR",
              "code": "164431",
              "display": "Examination Date"
            }
          ]
        },
        "effectiveDateTime": "2022-04-01T00:00:00+03:00",
        "subject": {
          "reference": "Patient/c350f310-fd89-44de-ad75-bb7827ca1d5b",
          "display": "Tom James (OpenMRS ID: 10V6E3)",
          "type": "Patient"
        },
        "valueDateTime": "2022-04-01T00:00:00+03:00",
        "id": "0d68a870-1d7c-4eac-a919-c9c7c0f90672",
        "encounter": {
          "reference": "Encounter/7067e0f7-3309-41b4-8e89-fb3e77a7e537",
          "type": "Encounter"
        },
        "category": [
          {
            "coding": [
              {
                "system": "http://terminology.hl7.org/CodeSystem/observation-category",
                "code": "exam",
                "display": "Exam"
              }
            ]
          }
        ],
        "issued": "2022-06-07T13:13:25.000+03:00",
        "resourceType": "Observation",
        "status": "final"
      }
    }
  ]
}

Note this is a demo patient. not real names.

2 Likes

Actually, in OpenMRS program defines treatment program or study program (e.g., “HIV treatment program” or “TB treatment program”). A program may have one or more associated workflows (a set of mutually exclusive states used to track the status of a patient who has been enrolled in the program).

patient_program links a patient to a program – i.e., representing a specific patient’s enrollment into the program (in some program, patient’s might be enrolled more than once). The current status(es) of a patient within any program’s workflow(s) are tracked as patient_state.

1 Like

@kdaud, are you still blocked?

program defines an overall treatment program or study protocol and, as such, is not patient-specific. Patient’s are enrolled into a program through patient_program and its possible for a patient to be enrolled more than once – i.e., patient_program represents one “episode” of a patient entering a program. So, patient_program is most analogous to FHIR’s EpisodeOfCare and is that to which you should map.

Personally, for these types of efforts where we are trying to agree on how various resources relate, I find UML or ER diagrams that show the “data model” the easiest place to start. But whatever works for you is fine with me. :slight_smile:

1 Like