Mercurial > hg > orthanc
comparison OrthancServer/PrepareDatabase.sql @ 262:2354560daf2f
primitives for recycling patients
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 07 Dec 2012 12:56:27 +0100 |
parents | bd009f0b1931 |
children | d384af918264 |
comparison
equal
deleted
inserted
replaced
260:f1fb9d1aa444 | 262:2354560daf2f |
---|---|
53 seriesInstanceUid TEXT, | 53 seriesInstanceUid TEXT, |
54 sopInstanceUid TEXT, | 54 sopInstanceUid TEXT, |
55 date TEXT | 55 date TEXT |
56 ); | 56 ); |
57 | 57 |
58 CREATE TABLE PatientRecyclingOrder( | |
59 seq INTEGER PRIMARY KEY AUTOINCREMENT, | |
60 patientId INTEGER REFERENCES Resources(internalId) ON DELETE CASCADE | |
61 ); | |
62 | |
58 CREATE INDEX ChildrenIndex ON Resources(parentId); | 63 CREATE INDEX ChildrenIndex ON Resources(parentId); |
59 CREATE INDEX PublicIndex ON Resources(publicId); | 64 CREATE INDEX PublicIndex ON Resources(publicId); |
60 CREATE INDEX ResourceTypeIndex ON Resources(resourceType); | 65 CREATE INDEX ResourceTypeIndex ON Resources(resourceType); |
66 CREATE INDEX PatientRecyclingIndex ON PatientRecyclingOrder(patientId); | |
61 | 67 |
62 CREATE INDEX MainDicomTagsIndex1 ON MainDicomTags(id); | 68 CREATE INDEX MainDicomTagsIndex1 ON MainDicomTags(id); |
63 CREATE INDEX MainDicomTagsIndex2 ON MainDicomTags(tagGroup, tagElement); | 69 CREATE INDEX MainDicomTagsIndex2 ON MainDicomTags(tagGroup, tagElement); |
64 CREATE INDEX MainDicomTagsIndexValues ON MainDicomTags(value COLLATE BINARY); | 70 CREATE INDEX MainDicomTagsIndexValues ON MainDicomTags(value COLLATE BINARY); |
65 | 71 |
84 FOR EACH ROW WHEN (SELECT COUNT(*) FROM Resources WHERE parentId = old.parentId) = 0 | 90 FOR EACH ROW WHEN (SELECT COUNT(*) FROM Resources WHERE parentId = old.parentId) = 0 |
85 BEGIN | 91 BEGIN |
86 DELETE FROM Resources WHERE internalId = old.parentId; | 92 DELETE FROM Resources WHERE internalId = old.parentId; |
87 END; | 93 END; |
88 | 94 |
95 CREATE TRIGGER PatientAdded | |
96 AFTER INSERT ON Resources | |
97 FOR EACH ROW WHEN new.resourceType = 1 -- "1" corresponds to "ResourceType_Patient" in C++ | |
98 BEGIN | |
99 INSERT INTO PatientRecyclingOrder VALUES (NULL, new.internalId); | |
100 END; | |
101 | |
102 | |
89 -- Set the version of the database schema | 103 -- Set the version of the database schema |
90 -- The "1" corresponds to the "GlobalProperty_DatabaseSchemaVersion" enumeration | 104 -- The "1" corresponds to the "GlobalProperty_DatabaseSchemaVersion" enumeration |
91 INSERT INTO GlobalProperties VALUES (1, "2"); | 105 INSERT INTO GlobalProperties VALUES (1, "3"); |