OHDSI Home | Forums | Wiki | Github

Logic to create own visit_occurrence_ids

Hello Everyone,

We have visit data from the hospital which has visit_type, person_id, admit_time, discharge_time and visit_ids.

However the issue is visit_ids (visit_occurrence_ids) are repeating and aren’t unique. Meaning I can see that in our data

a) Multiple person sharing the same visit_ids
b) One person with same visit_ids occurring multiple times

Am I right to understand that

scenario a) indicates issue with data? I feel this is an issue with data but still wanted to check with you folks in forum on whether you have dealt with such issues here and how did you resolve them while transforming them to OMOP CDM?.

scenario b) is possible that the patient visited different counters in the hospital where they made use of same visit_id as reference? Can you shed some light on this? Have you encountered this scenario at your end? If yes, I can drop these source visit_ids and create custom visit_ids based on your logic

Is there any one here who devised their own logic to create visit_occurrence_ids based on time or any other approach?

But still in visit_occurrence table, we know that visit_occurrence_ids cannot repeat (as it is a primary key). So, in this case, will my scenario b) also becomes a data issue?

Any suggestions or help please?

It would be interesting if you provided the source data system, Epic, Cerner …
Multiple person sharing the same visit_ids
Obviously visit_id is not a primary key in your source, so I would look at visit_id/person instead. You might also have to add date and location to get something closer to a unique identifier. Do not just depend on the source visit_id by itself for transforming into OMOP Visit Occurrence.
One person with same visit_ids occurring multiple times
Yes, you must create custom visit_ids otherwise the OMOP visit_id will not be unique. You can create a unique visit occurrence id using a sequence or identity column depending on database. I caution against creating visit_occurrence_id base on time, because you may start to rely on the visit_occurrence_id having some inherent meaning when it should just be a unique identifier. The visit occurrence table has a start date, end date and if desired a preceding visit, more than enough attributes so that there is no reason to give the visit occurrence id some special meaning.

A way to figure out the best approach pick a few people and get all their information from your data and see if you can understand their story. What does the data tell you about their interaction with the health care system. Then if possible find someone familiar with the source data to see if your interpretation matches their understanding. After understanding what the source data is telling you, you it will be easier to figure out how to transform the information into OMOP so that OMOP tells the same story.

1 Like

@DTorok - Source system is local EHR system and not EPIC or Cerner.

@DTorok - I was thinking. I know the below isn’t the best approach.

Would it be okay to just key in a sequence number for visit_occurrence_id (under my visit table) and use NULL in preceding_visit_occurrence_id and other tables (where we have visit_occurrence_ids).

In this way, the OMOP constraints from visit table is also met because visit_ids are unique and other tables will not use this dummy visit_ids (because they are NULL) while joining/merging tables.

If we wish to fetch corresponding lab/conditions/drugs for a specific visit, we can make use of the visit_start_date and visit_end_date.

Meaning any measurements/conditions/drugs within this specific visit_start_date and visit_end_date can be seen as corresponding to that visit. Am I right?

Will this result in any problems that I am not able to foresee? Hence seeking your views on this approach?

You can do what you say and you probably will not get any errors. But you will be circumventing the intent of the OMOP data model. You will create visits with no events attached to them. I do not understand why if you can:

  1. Create visits with a sequence number
  2. Find visits from lab/conditions/drugs by person/visit date

That you cannot populate the visit ids in your lab/conditions/drug tables. But if you do not intend to participate in any network studies and if whatever you do meets your internal needs then you can do what you want. But just because you are able to avoid OMOP constraint errors, it will not mean that you have an OMOP complaint CDM.

t