Import Bahmni Obs Data without setting VisitEndDate

(Posting on behalf of a community member, to ensure this gets documented for future)

Hello! I am trying to import observation data and I want the visit to remain open. However, when I import data using the CSV importer it is closing the visit and assigning it an end date. By default if I exclude the non-mandatory ‘Visit End Date’ field, the import assigns the visit a ‘date_stopped’ that is one second after the ‘date_started’/csv field ‘Visit Start Date’ (picture attached) . If I import a blank ‘Visit End Date’ the import still assigns it a ‘date_stopped’, as pictured, and when I import with an ‘NA’ it throws an error for date formatting. Is there a way to ensure the visit remains open for data I’m importing via the csv importer?

image

I spent some time looking at the Bahmni import CSV code. I assume you are using the Encounter import, that allows you to specify Obs/Encounter/Visit in CSV for patients as documented in Wiki here: https://bahmni.atlassian.net/wiki/spaces/BAH/pages/13697066/Migrate+Patient+and+Encounter+Data#MigratePatientandEncounterData-2.Encounters

The import code triggered by the UI, in the backend seems to come here:

From there, while searching for an existing visit in DB for this patient, it tries to associate the Obs/Encounter to that visit. If an existing Visit is not found, it seems to create a new one. See this: bahmni-core/VisitIdentificationHelper.java at e1db1777a0abda728b54f1746c3dad489c248b93 · Bahmni/bahmni-core · GitHub

Here, it sets the END Date to midnight-1sec (end of visit start date), as the visitEnd Date.

I think this is what you also show in your screenshot. The Visit End Date is set to END of the day when the visit is started.

In summary, I think since it isn’t finding an existing Visit in the system to associate this data with, it is creating a new visit for that same date/time you mentioned in VisitStartDate column, and marking Visit as closed as midnight same day (11:59pm). I don’t think it will let you currently leave Visit as open in this scenario.

The integration tests for this functionality are here (although there isn’t any test for validating what happens when VisitEndDate is null and existing Visit doesn’t exisit): bahmni-core/EncounterPersisterIT.java at 60cd85ca9881ac0623327a300979f2ca3413e7d2 · Bahmni/bahmni-core · GitHub

cc: @sivareddy @binduak @angshuonline – Cc’ing others who may know this code better than me.

1 Like

@gsluthra if we set encounter date to current date, then visit end date set to null. bahmni-core/VisitIdentificationHelper.java at master · Bahmni/bahmni-core · GitHub

Thanks @sivareddy – so if encounter date is today, then it is assumed that visit is still open (since visit end date is in future… which is tonight at 11:59), which therefore the system doesn’t not automatically set. right?

yes @gsluthra .

1 Like