This repository has been archived by the owner on Jan 28, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(readme): add sql deployment section
- Loading branch information
Frazer Smith
committed
Jan 8, 2021
1 parent
54e45aa
commit b3af0c0
Showing
3 changed files
with
93 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
SET ANSI_NULLS ON | ||
GO | ||
|
||
SET QUOTED_IDENTIFIER ON | ||
GO | ||
|
||
CREATE SCHEMA lookup; | ||
GO | ||
|
||
CREATE SCHEMA patient; | ||
GO | ||
|
||
CREATE SCHEMA receipt; | ||
GO | ||
|
||
CREATE TABLE lookup.preferenceType | ||
( | ||
preferenceTypeId INT IDENTITY(1,1) NOT NULL, | ||
preferenceType VARCHAR(MAX) NOT NULL, | ||
CONSTRAINT PK_PreferenceTypeId PRIMARY KEY (preferenceTypeId) | ||
); | ||
GO | ||
|
||
CREATE TABLE lookup.preferenceValue | ||
( | ||
preferenceValueId INT IDENTITY(1,1) NOT NULL, | ||
preferenceValue VARCHAR(255) NOT NULL, | ||
CONSTRAINT PK_PreferenceValueId PRIMARY KEY (preferenceValueId) | ||
); | ||
GO | ||
|
||
CREATE TABLE patient.preferences | ||
( | ||
patientId VARCHAR(255) NOT NULL, | ||
preferenceTypeId INT NOT NULL, | ||
preferenceValueId INT NULL, | ||
preferencePriority INT NULL, | ||
created DATETIME NOT NULL, | ||
lastUpdated DATETIME, | ||
CONSTRAINT CK_PatientPreference PRIMARY KEY (patientId, preferenceTypeId), | ||
CONSTRAINT FK_PreferenceType FOREIGN KEY (preferenceTypeId) REFERENCES lookup.preferenceType(preferenceTypeId), | ||
CONSTRAINT FK_PreferenceValue FOREIGN KEY (preferenceValueId) REFERENCES lookup.preferenceValue(preferenceValueid) | ||
); | ||
GO | ||
|
||
|
||
CREATE TABLE receipt.documents | ||
( | ||
patientId VARCHAR(255) NOT NULL, | ||
[guid] CHAR(36) NOT NULL, | ||
ts DATETIME NOT NULL, | ||
CONSTRAINT CK_DocumentReceipt PRIMARY KEY (patientId, [guid]) | ||
); | ||
GO |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
SET ANSI_NULLS ON | ||
GO | ||
|
||
SET QUOTED_IDENTIFIER ON | ||
GO | ||
|
||
INSERT INTO lookup.preferenceType | ||
(preferenceType) | ||
VALUES | ||
('SMS'), | ||
('Email'), | ||
('Phone'), | ||
('Letters'); | ||
GO | ||
|
||
INSERT INTO lookup.preferenceValue | ||
(preferenceValue) | ||
VALUES | ||
('yes'), | ||
('no'); | ||
GO | ||
|
||
INSERT INTO patient.preferences | ||
(patientId, preferenceTypeId, preferenceValueId, preferencePriority, created) | ||
VALUES | ||
(1, 1, 1, 0, CURRENT_TIMESTAMP), | ||
(1, 2, 2, 1, CURRENT_TIMESTAMP), | ||
(1, 3, 1, 2, CURRENT_TIMESTAMP), | ||
(1, 4, 2, 3, CURRENT_TIMESTAMP), | ||
(2, 1, 1, 0, CURRENT_TIMESTAMP), | ||
(2, 2, 2, 1, CURRENT_TIMESTAMP); | ||
GO |