OHDSI/ETL-Synthea

Query RN generation within Final_visit_ids.sql

lizzieLepoo opened this issue · 1 comments

I am really new to all things Synthea / OMOP / CDM - so am trying to work my way through the tutorials and documentation for loading SYNTHEA 1k data into OMOP tables. I've hit a problem with VISIT_OCCURRENCES. I think, to get from ENCOUNTERS (Synthea) to VISIT_OCCURRENCES (CDM) I should follow the logic from these four scripts:-

  1. AllVisitTable.sql
  2. AAVITable.sql
  3. final_visit_ids.sql
  4. insert_visit_occurrence.sql

I kept getting different results - and at present I think that seems to be coming from the generation of RN for the RN=1 criteria in the Final_Visit_IDs.sql.
The RN is only ordered by PRIORITY, but I am finding there are, for example, multiple rows for a given encounter_id where both sides of the join have 'inpatient' type and therefore result in a PRIORITY of 1.
The RN calculation then assigns a random row - from those - as RN = 1.
This affects the eventual outcome by resulting quite dramatically.

NB - I am running my version of the logic in SQL Server, could that be (part of) the issue - or is there something fundamental I am missing? Thank you

@lizzieLepoo The order you describe is the correct order being implemented during table creation using the package. Are you still experiencing this issue? If so, can you provide examples?