Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-5398

False Obs being unvoided along with Encounter when unvoiding Encounter

    Details

    • Type: Bug
    • Status: Needs Assessment
    • Priority: TBD
    • Resolution: Unresolved
    • Affects Version/s: Platform 2.1.3
    • Fix Version/s: None
    • Component/s: Data Model
    • Complexity:
      Low

      Description

      When voiding an Encounter object, all top level Obs and Orders are also voided with same reason; when unvoiding a voided Encounter, all the Obs and Orders which were voided along with Encounter are also supposed to be unvoided. The problem is this:

      Suppose there's an encounter X with Observations A, B and C.

      • C was voided with reason "Duplicate".
      • Later, it was found that Encounter X was also a duplicate, thus it was voided with reason "Duplicate".
      • The data operator later came to know that Encounter X was a false positive, so he unvoids it.
      • Now, Obs A and B should be unvoided but C should remain voided (because it was a valid void)

      What's happening is that – I found out while digging in – the unvoidEncounter method in EncounterServiceImpl checks for "Reason" alone, and does not take the Date voided into account.

      We could do something like:

      /* Line 416 to 420 */
      for (Obs o : encounter.getObsAtTopLevel(true)) {
      if (voidReason.equals(o.getVoidReason())) {
      os.unvoidObs(o);
      }
      }
      
      /* Replace with */
      for (Obs o : encounter.getObsAtTopLevel(true)) {
      boolean reasonFlag = voidReason.equals(o.getVoidReason());
      boolean dateFlag = DateUtil.truncateToSeconds(encounter.getDateVoided()).equals(DateUtil.truncateToSeconds(o.getDateVoided()));
      if (reasonFlag && dateFlag) {
      os.unvoidObs(o);
      }
      }
      

      This approach should match with more precision exactly which Observations to unvoid.

      I only observed unvoiding encounters, this fix may require thorough review of other entities.

        Gliffy Diagrams

          Attachments

            Attachments-Category-Modification

              Activity

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  owais.hussain Owais Hussain
                  Watchers:
                  Owais Hussain
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:

                    Time Tracking

                    Estimated:
                    Original Estimate - 1 day
                    1d
                    Remaining:
                    Remaining Estimate - 1 day
                    1d
                    Logged:
                    Time Spent - Not Specified
                    Not Specified