Skip to content

Flag five v5.3 fields as foreign keys so their constraints are generated - #825

Open
chenyangsu wants to merge 1 commit into
OHDSI:mainfrom
chenyangsu:fix/v5.3-missing-foreign-keys
Open

chenyangsu wants to merge 1 commit into
OHDSI:mainfrom
chenyangsu:fix/v5.3-missing-foreign-keys

Conversation

@chenyangsu

Copy link
Copy Markdown

In inst/csv/OMOP_CDMv5.3_Field_Level.csv, five rows name an fkTableName/fkFieldName but have isForeignKey = No, so createForeignKeys() skips them and the shipped v5.3 constraints scripts have no constraint for them:

Field References
procedure_occurrence.provider_id PROVIDER.PROVIDER_ID
procedure_occurrence.visit_occurrence_id VISIT_OCCURRENCE.VISIT_OCCURRENCE_ID
procedure_occurrence.visit_detail_id VISIT_DETAIL.VISIT_DETAIL_ID
procedure_occurrence.procedure_source_concept_id CONCEPT.CONCEPT_ID
condition_era.person_id PERSON.PERSON_ID

The same fields are foreign keys in the other v5.3 event tables (condition_occurrence, drug_exposure, drug_era, dose_era) and in v5.4 and v5.5. These are the only v5.3 rows that have an FK target but isForeignKey = No, apart from drug_exposure.days_supply, whose misalignment #820 fixes.

Change

  • Set isForeignKey to Yes on the five rows.
  • Regenerated inst/ddl/5.3/*/OMOPCDM_*_5.3_constraints.sql with buildRelease() (SqlRender 1.19.7). Rebuilding from the unchanged CSV first reproduced the committed constraints files byte for byte, so the diff in each of the 16 files is only the five new ALTER TABLE lines.
  • Updated the Foreign Key column on the v5.3 spec page (docs/cdm53.html, docs/search.json). I kept only the content changes from the render because my local Quarto is 1.10.20, not 1.10.18.

Check
I ran the v5.3 PostgreSQL ddl, primary keys and constraints scripts in PGlite. All statements succeed, and the foreign-key count goes from 157 to 162.

If v5.3 spec fixes should go to a particular release branch, I can retarget.

In OMOP_CDMv5.3_Field_Level.csv these rows named a target table and field
but had isForeignKey = No, so createForeignKeys() skipped them:

- procedure_occurrence.provider_id -> PROVIDER.PROVIDER_ID
- procedure_occurrence.visit_occurrence_id -> VISIT_OCCURRENCE.VISIT_OCCURRENCE_ID
- procedure_occurrence.visit_detail_id -> VISIT_DETAIL.VISIT_DETAIL_ID
- procedure_occurrence.procedure_source_concept_id -> CONCEPT.CONCEPT_ID
- condition_era.person_id -> PERSON.PERSON_ID

The same fields are foreign keys in the other v5.3 event tables
(condition_occurrence, drug_exposure, drug_era, dose_era) and in v5.4 and v5.5.

Regenerated the v5.3 constraints scripts for all dialects with buildRelease()
(SqlRender 1.19.7); the only change in each is the five new ALTER TABLE lines.
Updated the Foreign Key column on the v5.3 specification page to match.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant