Skip to content

Commit

Permalink
Fix bugs in relationships and rebuild schema_meta.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonysena committed Sep 27, 2024
1 parent 24b2ac0 commit c1510fc
Show file tree
Hide file tree
Showing 5 changed files with 284 additions and 115 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
branches: [results-data-model, main, master]
pull_request:
branches: [main, master]
release:
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
- name: Execute SchemaSpy
run: |
java -jar extras/rdms/schemaspy-6.2.4.jar -vizjs -dp $HOME -configFile extras/rdms/schemaspy-config.properties -meta extras/rdms/schema_meta.xml -debug -desc "Results data model" -noTablePaging
java -jar extras/rdms/schemaspy-6.2.4.jar -vizjs -dp $HOME -configFile extras/rdms/schemaspy-config.properties -meta extras/rdms/schema_meta.xml -debug -desc "Results data model" -noTablePaging -noimplied
- name: Upload artifact
uses: actions/upload-artifact@v4
Expand Down
13 changes: 9 additions & 4 deletions extras/DocumentResultsDataModel.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ schemaMeta <- xml_new_root("schemaMeta",
"xsi:noNamespaceSchemaLocation" = "http://schemaspy.org/xsd/6/schemameta.xsd")

# Add comments node
xml_add_child(schemaMeta, "comments", "This is where we'll describe the Strategus results data model.")
xml_add_child(
schemaMeta,
"comments",
"The tables in the results data model are grouped using a unique prefix for
each Strategus module. For example, the CharacterizationModule results tables
all start with \"c_\".")

# Create tables node
tables <- xml_add_child(schemaMeta, "tables")
Expand All @@ -127,7 +132,7 @@ resultsTableRelationships <-CohortGenerator::readCsv(
for (i in seq_along(uniqueTableNames)) {
# Add table node with attributes
currentTableName <- uniqueTableNames[i]
print(currentTableName)
#print(currentTableName)
# Get the table description, if it exists
currentTableDescriptionInfo <- tableDescriptions %>%
filter(.data$tableName == currentTableName)
Expand All @@ -144,14 +149,14 @@ for (i in seq_along(uniqueTableNames)) {
for (j in 1:nrow(columnsForCurrentTable)) {
curColumnName <- columnsForCurrentTable$columnName[j]
description <- columnsForCurrentTable$description[j]
print(paste0(" -- ", curColumnName))
#print(paste0(" -- ", curColumnName))
# Add column node with attributes
columnNode <- xml_add_child(table, "column", name = curColumnName, comments = description)
# Determine if this table + column has a FK relationship to any other tables
curColumnFk <- resultsTableRelationships %>%
filter(.data$tableName == currentTableName & .data$columnName == curColumnName)
if (nrow(curColumnFk) > 0) {
print(paste0("-- FK FOUND FOR: ", currentTableName, ".", curColumnName))
#print(paste0("-- FK FOUND FOR: ", currentTableName, ".", curColumnName))
for (k in 1:nrow(curColumnFk)) {
fkTable <- curColumnFk$fkTableName[k]
fkColumn <- curColumnFk$fkColumnName[k]
Expand Down
76 changes: 38 additions & 38 deletions extras/rdms/results_table_relationships.csv
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,35 @@ c_covariates_continuous,covariate_id,c_covariate_ref,covariate_id
c_covariates_continuous,database_id,c_settings,database_id
c_covariates_continuous,database_id,database_meta_data,database_id
database_meta_data,database_id,c_cohort_details,database_id
c_DECHALLENGE_RECHALLENGE,target_cohort_definition_id,cg_cohort_definition,cohort_definition_id
c_DECHALLENGE_RECHALLENGE,outcome_cohort_definition_id,cg_cohort_definition,cohort_definition_id
c_DECHALLENGE_RECHALLENGE,database_id,database_meta_data,database_id
ci_incidence_SUMMARY,outcome_id,ci_outcome_def,outcome_id
ci_incidence_SUMMARY,ref_id,ci_outcome_def,ref_id
ci_incidence_SUMMARY,ref_id,ci_tar_def,ref_id
ci_incidence_SUMMARY,tar_id,ci_tar_def,ref_id
ci_incidence_SUMMARY,subgroup_id,ci_subgroup_def,subgroup_id
ci_incidence_SUMMARY,ref_id,ci_subgroup_def,ref_id
ci_incidence_SUMMARY,age_group_id,ci_age_group_def,age_group_id
ci_incidence_SUMMARY,ref_id,ci_age_group_def,ref_id
ci_incidence_SUMMARY,database_id,database_meta_data,database_id
ci_incidence_SUMMARY,target_cohort_definition_id,cg_cohort_definition,cohort_definition_id
ci_incidence_SUMMARY,outcome_cohort_definition_id,cg_cohort_definition,cohort_definition_id
c_TIME_TO_EVENT,database_id,database_meta_data,database_id
c_dechallenge_rechallenge,target_cohort_definition_id,cg_cohort_definition,cohort_definition_id
c_dechallenge_rechallenge,outcome_cohort_definition_id,cg_cohort_definition,cohort_definition_id
c_dechallenge_rechallenge,database_id,database_meta_data,database_id
ci_incidence_summary,outcome_id,ci_outcome_def,outcome_id
ci_incidence_summary,ref_id,ci_outcome_def,ref_id
ci_incidence_summary,ref_id,ci_tar_def,ref_id
ci_incidence_summary,tar_id,ci_tar_def,ref_id
ci_incidence_summary,subgroup_id,ci_subgroup_def,subgroup_id
ci_incidence_summary,ref_id,ci_subgroup_def,ref_id
ci_incidence_summary,age_group_id,ci_age_group_def,age_group_id
ci_incidence_summary,ref_id,ci_age_group_def,ref_id
ci_incidence_summary,database_id,database_meta_data,database_id
ci_incidence_summary,target_cohort_definition_id,cg_cohort_definition,cohort_definition_id
ci_incidence_summary,outcome_cohort_definition_id,cg_cohort_definition,cohort_definition_id
c_time_to_event,database_id,database_meta_data,database_id
cd_temporal_covariate_ref,analysis_id,cd_temporal_analysis_ref,analysis_id
cd_temporal_covariate_ref,covariate_id,cd_temporal_covariate_value,covariate_id
cd_temporal_covariate_ref,time_id,cd_temporal_time_ref,time_id
cd_included_source_concept,concept_id,cd_concept,concept_id
cd_incidence_rate,database_id,cd_cohort_count,database_id
cd_incidence_rate,cohort_id,cd_cohort_count,cohort_id
cd_index_event_breakdown,concept_id,cd_concept,concept_id
cd_orphan_concept,cohort_id,cd_concept_set,cohort_id
cd_orphan_concept,concept_set_id,cd_concept_set,concept_set_id
cd_orphan_concept,cohort_id,cd_concept_sets,cohort_id
cd_orphan_concept,concept_set_id,cd_concept_sets,concept_set_id
cd_orphan_concept,concept_id,cd_concept,concept_id
cd_cohort_count,database_id,database_meta_data,database_id
cd_visit_context,concept_id,cd_concept,concept_id
cg_cohort_count,database_id,database_meta_data,database_id
cg_cohort_count,cohort_id,cg_cohort_definition,cohort_id
cg_cohort_count,cohort_id,cg_cohort_definition,cohort_definition_id
cg_cohort_generation,database_id,database_meta_data,database_id
cg_cohort_summary_stats,database_id,database_meta_data,database_id
cg_cohort_summary_stats,cohort_definition_id,cg_cohort_definition,cohort_definition_id
Expand All @@ -68,11 +68,11 @@ cm_covariate_balance,database_id,cm_covariate,database_id
cm_covariate,covariate_id,cm_propensity_model,covariate_id
cm_analysis,analysis_id,cm_result,analysis_id
cm_analysis,database_id,database_meta_data,database_id
cm_analysis,analysis_id,cm_diagnostic_summary,analysis_id
cm_analysis,target_id,cm_diagnostic_summary,target_id
cm_analysis,comparator_id,cm_diagnostic_summary,comparator_id
cm_analysis,outcome_id,cm_diagnostic_summary,outcome_id
cm_analysis,database_id,cm_diagnostic_summary,database_id
cm_analysis,analysis_id,cm_diagnostics_summary,analysis_id
cm_analysis,target_id,cm_diagnostics_summary,target_id
cm_analysis,comparator_id,cm_diagnostics_summary,comparator_id
cm_analysis,outcome_id,cm_diagnostics_summary,outcome_id
cm_analysis,database_id,cm_diagnostics_summary,database_id
cm_analysis,target_id,cg_cohort_definition,cohort_definition_id
cm_analysis,outcome_id,cg_cohort_definition,cohort_definition_id
cm_analysis,comparator_id,cg_cohort_definition,cohort_definition_id
Expand Down Expand Up @@ -100,12 +100,12 @@ sccs_result,exposures_outcome_set_id,sccs_covariate,exposures_outcome_set_id
sccs_result,database_id,sccs_covariate,database_id
sccs_result,covariate_id,sccs_covariate,covariate_id
sccs_result,database_id,database_meta_data,database_id
sccs_result,exposures_outcome_set_id,sccs_diagnostics_sumary,exposures_outcome_set_id
sccs_result,database_id,sccs_diagnostics_sumary,database_id
sccs_result,analysis_id,sccs_diagnostics_sumary,analysis_id
sccs_result,covariate_id,sccs_diagnostics_sumary,covariate_id
sccs_result,exposures_outcome_set_id,sccs_diagnostics_summary,exposures_outcome_set_id
sccs_result,database_id,sccs_diagnostics_summary,database_id
sccs_result,analysis_id,sccs_diagnostics_summary,analysis_id
sccs_result,covariate_id,sccs_diagnostics_summary,covariate_id
sccs_result,analysis_id,sccs_covariate,analysis_id
sccs_result,exposures_outcome_set_id,sccs_exposure_outcome_set,exposures_outcome_set_id
sccs_result,exposures_outcome_set_id,sccs_exposures_outcome_set,exposures_outcome_set_id
sccs_result,analysis_id,sccs_analysis,analysis_id
sccs_result,outcome_id,cg_cohort_definition,cohort_definition_id
sccs_exposures_outcome_set,nesting_cohort_id,cg_cohort_definition,cohort_definition_id
Expand All @@ -114,15 +114,15 @@ sccs_exposures_outcome_set,exposures_outcome_set_id,sccs_exposure,exposures_outc
sccs_exposures_outcome_set,era_id,sccs_exposure,era_id
sccs_exposures_outcome_set,era_id,cg_cohort_definition,era_id
sccs_result,exposures_outcome_set_id,sccs_exposures_outcome_set,exposures_outcome_set_id
sccs_covariate_result,exposures_outcome_set_id,sccs_exposure_outcome_set,exposures_outcome_set_id
sccs_time_trend,exposures_outcome_set_id,sccs_exposure_outcome_set,exposures_outcome_set_id
sccs_diagnostics_summary,exposures_outcome_set_id,sccs_exposure_outcome_set,exposures_outcome_set_id
sccs_time_to_event,exposures_outcome_set_id,sccs_exposure_outcome_set,exposures_outcome_set_id
sccs_attrition,exposures_outcome_set_id,sccs_exposure_outcome_set,exposures_outcome_set_id
sccs_event_dep_observation,exposures_outcome_set_id,sccs_exposure_outcome_set,exposures_outcome_set_id
sccs_age_spanning,exposures_outcome_set_id,sccs_exposure_outcome_set,exposures_outcome_set_id
sccs_calendar_time_spanning,exposures_outcome_set_id,sccs_exposure_outcome_set,exposures_outcome_set_id
sccs_spline,exposures_outcome_set_id,sccs_exposure_outcome_set,exposures_outcome_set_id
sccs_covariate_result,exposures_outcome_set_id,sccs_exposures_outcome_set,exposures_outcome_set_id
sccs_time_trend,exposures_outcome_set_id,sccs_exposures_outcome_set,exposures_outcome_set_id
sccs_diagnostics_summary,exposures_outcome_set_id,sccs_exposures_outcome_set,exposures_outcome_set_id
sccs_time_to_event,exposures_outcome_set_id,sccs_exposures_outcome_set,exposures_outcome_set_id
sccs_attrition,exposures_outcome_set_id,sccs_exposures_outcome_set,exposures_outcome_set_id
sccs_event_dep_observation,exposures_outcome_set_id,sccs_exposures_outcome_set,exposures_outcome_set_id
sccs_age_spanning,exposures_outcome_set_id,sccs_exposures_outcome_set,exposures_outcome_set_id
sccs_calendar_time_spanning,exposures_outcome_set_id,sccs_exposures_outcome_set,exposures_outcome_set_id
sccs_spline,exposures_outcome_set_id,sccs_exposures_outcome_set,exposures_outcome_set_id
sccs_diagnostics_summary,analysis_id,sccs_covariate,analysis_id
plp_model_designs,target_id,cg_cohort_definition,cohort_definition_id
plp_model_designs,outcome_id,cg_cohort_definition,cohort_definition_id
Expand All @@ -137,4 +137,4 @@ plp_performances,development_database_id,database_meta_data,database_id
plp_performances,validation_database_id,database_meta_data,database_id
plp_performances,database_id,database_meta_data,database_id
plp_cohorts,cohort_definition_id,cg_cohort_definition,cohort_definition_id
c_cohort_details,target_id,cg_cohort_definition,cohort_id
c_cohort_details,target_id,cg_cohort_definition,cohort_definition_id
2 changes: 1 addition & 1 deletion extras/rdms/run-local.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"E:\Program Files\Amazon Corretto\jdk17.0.12_7\bin\java.exe" -jar schemaspy-6.2.4.jar -vizjs -dp E:\jdbcDrivers -configFile schemaspy-config.properties -meta schema_meta.xml -desc "Results data model" -noTablePaging
"E:\Program Files\Amazon Corretto\jdk17.0.12_7\bin\java.exe" -jar schemaspy-6.2.4.jar -vizjs -dp E:\jdbcDrivers -configFile schemaspy-config.properties -meta schema_meta.xml -desc "Results data model" -noTablePaging -noimplied
Loading

0 comments on commit c1510fc

Please sign in to comment.