# Incorporating Encounter Diagnoses into openmrs-core

**URL:** <https://talk.openmrs.org/t/incorporating-encounter-diagnoses-into-openmrs-core/9639>\
**Category:** Development\
**Created:** [January 19, 2017, 8:58am UTC](https://talk.openmrs.org/t/incorporating-encounter-diagnoses-into-openmrs-core/9639 "2017-01-19T08:58:43Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![darius](https://talk.openmrs.org/user_avatar/talk.openmrs.org/darius/32/8082_2.png) [@darius](https://talk.openmrs.org/u/darius)\
**Post date:** [January 19, 2017, 8:58am UTC](https://talk.openmrs.org/t/incorporating-encounter-diagnoses-into-openmrs-core/9639/1 "2017-01-19T08:58:43Z")

</div>

PIH first introduce “Diagnoses” in the emrapi module for their Mirebalais project (storing the actual data in an obs group). This has been included in the Reference Application and in Bahmni for years without any real changes being requested to the use case, so I’m pretty confident that we’ve got this right, and it’s time to implement Encounter Diagnoses in openmrs-core.

The general idea would be to add an `encounter_diagnosis` table (and to deprecate what is being done in emrapi).

> <https://issues.openmrs.org/browse/TRUNK-5015>

FYI @burke, @jteich, @mogoodrich, @bharatak

@jthomas, I’d like to discuss on a design call.

---

<div class="post-metadata">

**Author:** ![jthomas](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jthomas/32/21_2.png) [@jthomas](https://talk.openmrs.org/u/jthomas)\
**Post date:** [January 19, 2017, 6:04pm UTC](https://talk.openmrs.org/t/incorporating-encounter-diagnoses-into-openmrs-core/9639/2 "2017-01-19T18:04:57Z")

</div>

@darius @burke @jteich @mogoodrich @bharatak we have an opening on Wednesday, January 25 and Monday, January 30th. I am guessing with this group that the Monday date works best but please correct me if I’m wrong.

---

<div class="post-metadata">

**Author:** ![mogoodrich](https://talk.openmrs.org/user_avatar/talk.openmrs.org/mogoodrich/32/3324_2.png) [@mogoodrich](https://talk.openmrs.org/u/mogoodrich)\
**Post date:** [January 19, 2017, 6:10pm UTC](https://talk.openmrs.org/t/incorporating-encounter-diagnoses-into-openmrs-core/9639/3 "2017-01-19T18:10:25Z")

</div>

I will be travelling the next two weeks so it’s unclear if I could make either of those times, but I don’t need to be there.

I don’t have a problem with it being moved over, however in the spirit of “if-it’s-not-broke-don’t-fix-it”, @darius do you have a compelling reason to prioritize this?

Take care, Mark

---

<div class="post-metadata">

**Author:** ![bharatak](https://talk.openmrs.org/user_avatar/talk.openmrs.org/bharatak/32/1960_2.png) [@bharatak](https://talk.openmrs.org/u/bharatak)\
**Post date:** [January 20, 2017, 2:22am UTC](https://talk.openmrs.org/t/incorporating-encounter-diagnoses-into-openmrs-core/9639/4 "2017-01-20T02:22:50Z")

</div>

I think it is better to move important & useful features to openmrs-core so that it is useful for larger community. emrapi does a lot of things, i think this is a better to make it leaner 🙂

I prefer having the call on Monday if possible.

---

<div class="post-metadata">

**Author:** ![darius](https://talk.openmrs.org/user_avatar/talk.openmrs.org/darius/32/8082_2.png) [@darius](https://talk.openmrs.org/u/darius)\
**Post date:** [January 20, 2017, 5:20am UTC](https://talk.openmrs.org/t/incorporating-encounter-diagnoses-into-openmrs-core/9639/5 "2017-01-20T05:20:16Z")

</div>

> [@mogoodrich](#):
>
> in the spirit of “if-it’s-not-broke-don’t-fix-it”, @darius do you have a compelling reason to prioritize this?

In our 2017 Bahmni roadmap we intend to work on Condition Lists, Care Plans, and also some FHIR work. We’d rather have these things work against openmrs-core code, rather than having yet more new functionality require the emrapi module.

There’s not a specific driver _right now_ but I’m trying to get us ahead of things. 🙂

---

<div class="post-metadata">

**Author:** ![mogoodrich](https://talk.openmrs.org/user_avatar/talk.openmrs.org/mogoodrich/32/3324_2.png) [@mogoodrich](https://talk.openmrs.org/u/mogoodrich)\
**Post date:** [January 20, 2017, 2:13pm UTC](https://talk.openmrs.org/t/incorporating-encounter-diagnoses-into-openmrs-core/9639/6 "2017-01-20T14:13:54Z")

</div>

Seems fair… I’m certainly not opposed to it, just wanted to play devil’s advocate given our limited resources.

Take care, Mark

---

<div class="post-metadata">

**Author:** ![mseaton](https://talk.openmrs.org/user_avatar/talk.openmrs.org/mseaton/32/8088_2.png) [@mseaton](https://talk.openmrs.org/u/mseaton)\
**Post date:** [January 20, 2017, 3:42pm UTC](https://talk.openmrs.org/t/incorporating-encounter-diagnoses-into-openmrs-core/9639/7 "2017-01-20T15:42:53Z")

</div>

Thanks @darius and @bharatak. I have similar concerns to @mogoodrich and would love to be a part of a design call where we can think through some of the implications of this change on the rest of the module and distribution ecosystem, and work to mitigate it. Personally I think this needs to be given equal or greater design consideration and forethought than the actual design of the encounter diagnoses feature.

@mogoodrich and I could probably join the call on Monday the 30th, but the Wednesday call would be more difficult.

Mike

---

<div class="post-metadata">

**Author:** ![jteich](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jteich/32/968_2.png) [@jteich](https://talk.openmrs.org/u/jteich)\
**Post date:** [January 23, 2017, 10:55pm UTC](https://talk.openmrs.org/t/incorporating-encounter-diagnoses-into-openmrs-core/9639/8 "2017-01-23T22:55:18Z")

</div>

Monday Jan. 30 works for me.

---

<div class="post-metadata">

**Author:** ![darius](https://talk.openmrs.org/user_avatar/talk.openmrs.org/darius/32/8082_2.png) [@darius](https://talk.openmrs.org/u/darius)\
**Post date:** [February 3, 2017, 11:56pm UTC](https://talk.openmrs.org/t/incorporating-encounter-diagnoses-into-openmrs-core/9639/9 "2017-02-03T23:56:58Z")

</div>

It looks like we failed to schedule this. @jthomas can we take another shot at scheduling?

Looks like Feb 6 and Feb 8 are both open (though it may be tight to schedule this for Monday on a Friday afternoon).

---

<div class="post-metadata">

**Author:** ![jthomas](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jthomas/32/21_2.png) [@jthomas](https://talk.openmrs.org/u/jthomas)\
**Post date:** [February 6, 2017, 4:16pm UTC](https://talk.openmrs.org/t/incorporating-encounter-diagnoses-into-openmrs-core/9639/10 "2017-02-06T16:16:25Z")

</div>

Looks like this is not being discussed on today’s call so would people prefer Wednesday (2/8) or Monday (2/13)?

@darius @jteich @mogoodrich @bharatak @burke

---

<div class="post-metadata">

**Author:** ![darius](https://talk.openmrs.org/user_avatar/talk.openmrs.org/darius/32/8082_2.png) [@darius](https://talk.openmrs.org/u/darius)\
**Post date:** [February 6, 2017, 6:01pm UTC](https://talk.openmrs.org/t/incorporating-encounter-diagnoses-into-openmrs-core/9639/11 "2017-02-06T18:01:32Z")

</div>

Either is fine for me.

If we are expecting @bharatak I think Wednesday is impossible. (I don’t know if he’s planning to join or not.)

---

<div class="post-metadata">

**Author:** ![jthomas](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jthomas/32/21_2.png) [@jthomas](https://talk.openmrs.org/u/jthomas)\
**Post date:** [February 6, 2017, 7:01pm UTC](https://talk.openmrs.org/t/incorporating-encounter-diagnoses-into-openmrs-core/9639/12 "2017-02-06T19:01:46Z")

</div>

I figured as much but wanted to leave the option out there. @bharatak let me know if you want to make it to this discussion and we will get this on a Monday call.

---

<div class="post-metadata">

**Author:** ![jteich](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jteich/32/968_2.png) [@jteich](https://talk.openmrs.org/u/jteich)\
**Post date:** [February 7, 2017, 2:40am UTC](https://talk.openmrs.org/t/incorporating-encounter-diagnoses-into-openmrs-core/9639/13 "2017-02-07T02:40:10Z")

</div>

Monday 2/13 is good for me.

---

<div class="post-metadata">

**Author:** ![jthomas](https://talk.openmrs.org/user_avatar/talk.openmrs.org/jthomas/32/21_2.png) [@jthomas](https://talk.openmrs.org/u/jthomas)\
**Post date:** [February 7, 2017, 12:07pm UTC](https://talk.openmrs.org/t/incorporating-encounter-diagnoses-into-openmrs-core/9639/14 "2017-02-07T12:07:30Z")

</div>

I am going to put this topic down for Monday. @bharatak and @mogoodrich please let us know if you can not attend.

---

<div class="post-metadata">

**Author:** ![bharatak](https://talk.openmrs.org/user_avatar/talk.openmrs.org/bharatak/32/1960_2.png) [@bharatak](https://talk.openmrs.org/u/bharatak)\
**Post date:** [February 7, 2017, 12:34pm UTC](https://talk.openmrs.org/t/incorporating-encounter-diagnoses-into-openmrs-core/9639/15 "2017-02-07T12:34:20Z")

</div>

Please do it on Monday. I’ll catch up with @darius on what happened.

---

<div class="post-metadata">

**Author:** ![mogoodrich](https://talk.openmrs.org/user_avatar/talk.openmrs.org/mogoodrich/32/3324_2.png) [@mogoodrich](https://talk.openmrs.org/u/mogoodrich)\
**Post date:** [February 8, 2017, 2:58pm UTC](https://talk.openmrs.org/t/incorporating-encounter-diagnoses-into-openmrs-core/9639/16 "2017-02-08T14:58:05Z")

</div>

I will try to make it on Monday… I don’t know if it’s critical that I make it though, as long as there is a design summary to review?

Mark

---

<div class="post-metadata">

**Author:** ![darius](https://talk.openmrs.org/user_avatar/talk.openmrs.org/darius/32/8082_2.png) [@darius](https://talk.openmrs.org/u/darius)\
**Post date:** [February 8, 2017, 3:10pm UTC](https://talk.openmrs.org/t/incorporating-encounter-diagnoses-into-openmrs-core/9639/17 "2017-02-08T15:10:56Z")

</div>

I expect (hope?) there will not be much _design_ discussion.

I think the big question is going to be what steps need to be taken to ensure an easy upgrade path. So it would be great if one of @mogoodrich and @mseaton could be there to represent their concerns on that front.

---

<div class="post-metadata">

**Author:** ![mogoodrich](https://talk.openmrs.org/user_avatar/talk.openmrs.org/mogoodrich/32/3324_2.png) [@mogoodrich](https://talk.openmrs.org/u/mogoodrich)\
**Post date:** [February 8, 2017, 3:44pm UTC](https://talk.openmrs.org/t/incorporating-encounter-diagnoses-into-openmrs-core/9639/18 "2017-02-08T15:44:52Z")

</div>

Yeah, sorry, that’s what I meant… the design behind the migration.

I will do my best to make the call… looks like I should be free.

Take care, Mark

---

<div class="post-metadata">

**Author:** ![burke](https://talk.openmrs.org/user_avatar/talk.openmrs.org/burke/32/17_2.png) [@burke](https://talk.openmrs.org/u/burke)\
**Post date:** [February 13, 2017, 7:28pm UTC](https://talk.openmrs.org/t/incorporating-encounter-diagnoses-into-openmrs-core/9639/19 "2017-02-13T19:28:40Z")

</div>

We had a good design call discussion today (including myself, @jteich, @mogoodrich, @wyclif), discussing how we could incorporate Encounter Diagnoses into core.

We considered both the EMRAPI module and FHIR resources and came up with this plan:

#### 1. Support for encounter diagnoses in core:

- Migrate `CodedOrFreeTextAnswer` to `Condition` (will be used for condition lists and anywhere else we need conditions aka diagnosis/problem/health concern)
- Migrate `Diagnosis` to `EncounterDiagnosis`, which extends `Condition` to add ordinality (PRIMARY vs. SECONDARY)
- Add methods to get primary and secondary diagnoses to `Encounter`

#### 2. Backwards compatibility

- Refactor the EMRAPI module’s diagnoses as a façade using the new encounter diagnoses in core.

#### 3. Going forward

- Create a ticket to migrate data into core’s new `encounter_diagnosis` table
- Update UIs to use new features from core

Here’s a side-by-side comparison:

 ![](https://talk.openmrs.org/uploads/default/original/2X/9/9b59ee8fa1557ce3d6a43d63138a352bce1158f8.jpg)

#### Notes

- `Condition` aligns us with FHIR’s [Condition](https://www.hl7.org/fhir/condition.html) resource
- `CodedOrFreeTextAnswer` is a generic solution to supporting coded or free text that adds another layer of abstraction in the API. We prefer to incorporate this functionality into `Condition`
- Both @jteich and I preferred `EncounterDiagnosis` to simply `Diagnosis` (ambiguous) or `Indication` (FHIR’s term)
- Some renaming:
  - `Order` is replaced with `Ordinality` for PRIMARY vs SECONDARY
  - `Certainty` becomes `VerificationStatus` supporting PROVISIONAL (previously PRESUMED) and CONFIRMED to align with FHIR

- We eliminate the need for `DiagnosisService` once `EncounterDiagnosis` is a property of `Encounter`
- Design call notes [here](https://notes.openmrs.org/2017-02-13-Design-Forum)

I’ve adjusted [TRUNK-5015](https://issues.openmrs.org/browse/TRUNK-5015) accordingly.

---

<div class="post-metadata">

**Author:** ![darius](https://talk.openmrs.org/user_avatar/talk.openmrs.org/darius/32/8082_2.png) [@darius](https://talk.openmrs.org/u/darius)\
**Post date:** [February 14, 2017, 3:15am UTC](https://talk.openmrs.org/t/incorporating-encounter-diagnoses-into-openmrs-core/9639/20 "2017-02-14T03:15:21Z")

</div>

FYI there’s currently an implementation of condition in the emrapi module, which I don’t know of anyone using in production now, and we’re making some tweaks to it for a Bahmni implementation now. Code is at: [https://github.com/openmrs/openmrs-module-emrapi/blob/1.20/condition-list/src/main/java/org/openmrs/Condition.java](https://github.com/openmrs/openmrs-module-emrapi/blob/1.20/condition-list/src/main/java/org/openmrs/Condition.java)

Things that I would expect in the OpenMRS condition model that aren’t in your diagram:

- link to previousCondition (so we can track a history)
- Date onsetDate
- String additionalDetail
- Date endDate
- Concept endReason

I’m not in love with calling the new core class Condition without adding some extra fields (which might not be directly relevant to EncounterDiagnosis)…

[Next page](https://talk.openmrs.org/t/incorporating-encounter-diagnoses-into-openmrs-core/9639.md?page=2)
