-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Data model supports multiple providers and default provider (#8271)
* model supports multiple providers and default provider * grant metabase access to facility providers table * Rework liquibase changes to be backwards compatible * minimize diff * accidental delete * remove test change * switch to just using getorderingprovider method * nvm * don't fail tests using invalid null provider facilities
- Loading branch information
Showing
2 changed files
with
114 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5626,7 +5626,6 @@ databaseChangeLog: | |
references: role | ||
- sql: | | ||
GRANT SELECT ON ${database.defaultSchemaName}.api_user_role TO ${noPhiUsername}; | ||
- changeSet: | ||
id: add-timer-started-at-to-test_order-table | ||
author: [email protected] | ||
|
@@ -5643,7 +5642,6 @@ databaseChangeLog: | |
- dropColumn: | ||
tableName: test_order | ||
columnName: timer_started_at | ||
|
||
- changeSet: | ||
id: add-hepatitis-c-to-supported_disease-table | ||
author: [email protected] | ||
|
@@ -5662,7 +5660,6 @@ databaseChangeLog: | |
rollback: | ||
- sql: | ||
sql: DELETE FROM ${database.defaultSchemaName}.supported_disease WHERE name = 'Hepatitis-C'; | ||
|
||
- changeSet: | ||
id: update-hepatitis-c-naming-in-supported-disease-table | ||
author: [email protected] | ||
|
@@ -5681,7 +5678,6 @@ databaseChangeLog: | |
UPDATE ${database.defaultSchemaName}.supported_disease | ||
SET name = 'Hepatitis-C' | ||
WHERE name = 'Hepatitis C' AND loinc = 'LP14400-3' | ||
- changeSet: | ||
id: add-gonorrhea-to-supported_disease-table | ||
author: [email protected] | ||
|
@@ -5700,7 +5696,6 @@ databaseChangeLog: | |
rollback: | ||
- sql: | ||
sql: DELETE FROM ${database.defaultSchemaName}.supported_disease WHERE name = 'Gonorrhea'; | ||
|
||
- changeSet: | ||
id: add-chlamydia-to-supported_disease-table | ||
author: [email protected] | ||
|
@@ -5718,4 +5713,94 @@ databaseChangeLog: | |
(gen_random_uuid(), 'Chlamydia', 'LP14298-1') | ||
rollback: | ||
- sql: | ||
sql: DELETE FROM ${database.defaultSchemaName}.supported_disease WHERE name = 'Chlamydia'; | ||
sql: DELETE FROM ${database.defaultSchemaName}.supported_disease WHERE name = 'Chlamydia'; | ||
- changeSet: | ||
id: create-facility_providers-table | ||
author: [email protected] | ||
changes: | ||
- tagDatabase: | ||
tag: add-facility-providers-table | ||
- createTable: | ||
tableName: facility_providers | ||
remarks: Join table for mapping multiple providers to a facility. | ||
columns: | ||
- column: | ||
name: facility_id | ||
type: uuid | ||
constraints: | ||
nullable: false | ||
foreignKeyName: fk__facility_providers__facility | ||
references: facility | ||
- column: | ||
name: provider_id | ||
type: uuid | ||
constraints: | ||
nullable: false | ||
foreignKeyName: fk__facility_providers__provider | ||
references: provider | ||
- changeSet: | ||
id: grant-facility_providers-access-to-metabase-user | ||
author: [email protected] | ||
changes: | ||
- sql: | ||
sql: | | ||
GRANT SELECT ON ${database.defaultSchemaName}.facility_providers TO ${noPhiUsername}; | ||
rollback: | ||
- sql: | ||
sql: | | ||
REVOKE SELECT ON TABLE ${database.defaultSchemaName}.facility_providers FROM ${noPhiUsername}; | ||
- changeSet: | ||
id: add-default-provider | ||
author: [email protected] | ||
changes: | ||
- tagDatabase: | ||
tag: add-default-provider-col | ||
- addColumn: | ||
tableName: facility | ||
columns: | ||
- column: | ||
name: default_ordering_provider_id | ||
remarks: The default ordering provider for tests at this facility. | ||
type: uuid | ||
constraints: | ||
foreignKeyName: fk__facility__default_ordering_provider | ||
references: provider(internal_id) | ||
- changeSet: | ||
id: populate-facility-providers-table | ||
author: [email protected] | ||
changes: | ||
- tagDatabase: | ||
tag: populate-facility-providers-table | ||
- sql: | ||
sql: | | ||
INSERT INTO ${database.defaultSchemaName}.facility_providers ( | ||
facility_id, | ||
provider_id | ||
) | ||
SELECT | ||
internal_id, | ||
ordering_provider_id | ||
FROM ${database.defaultSchemaName}.facility; | ||
rollback: | ||
- sql: | ||
sql: | | ||
TRUNCATE TABLE ${database.defaultSchemaName}.facility_providers; | ||
- changeSet: | ||
id: populate-default-provider-column | ||
author: [email protected] | ||
changes: | ||
- tagDatabase: | ||
tag: populate-default-provider-column | ||
- sql: | ||
sql: | | ||
UPDATE ${database.defaultSchemaName}.facility | ||
SET | ||
default_ordering_provider_id = facility.ordering_provider_id | ||
WHERE facility.default_ordering_provider_id is NULL; | ||
rollback: | ||
- sql: | ||
sql: | | ||
UPDATE ${database.defaultSchemaName}.facility | ||
SET | ||
default_ordering_provider_id = NULL | ||
WHERE facility.default_ordering_provider_id is NOT NULL; |