-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample_queries.sql
More file actions
74 lines (52 loc) · 3.36 KB
/
example_queries.sql
File metadata and controls
74 lines (52 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
.schema
SELECT * FROM "protocols";
SELECT * FROM "equipment";
SELECT * FROM "medications";
SELECT * FROM "current_protocols" WHERE "condition_name" = 'heart attack'
AND "organisation_id" = (
SELECT "id" FROM "organisations" WHERE "name" = 'Emergency medical service test'
);
SELECT * FROM "current_equipment" WHERE "condition_name" = 'major trauma'
AND "organisation_id" = (
SELECT "id" FROM "organisations" WHERE "name" = 'Emergency medical service test'
);
SELECT * FROM "current_medications" WHERE "condition_name" = 'heart attack'
AND "organisation_id" = (
SELECT "id" FROM "organisations" WHERE "name" = 'Emergency medical service test'
);
SELECT * FROM "current_medications" WHERE "condition_name" = 'heart attack'
AND "organisation_id" = (
SELECT "id" FROM "organisations" WHERE "name" = 'Fire resque organisationt'
);
INSERT INTO "conditions" ("name", "type", "description")
VALUES ('anaphylaxis', 'surgical', 'Anaphylactic reaction is a strong allergic reaction. It is a life threatening condition that requires immediate care');
INSERT INTO "medications" ("name", "active_ingredient", "packaging_in_use")
VALUES ('epinephrine', 'epinephrini hydrochloridum', '1 mg / 1 ml');
INSERT INTO "dosages" ("condition_id", "organisation_id", "medication_id", "dosage", "description", "cave", "paediatric")
VALUES ((SELECT "id" FROM "conditions" WHERE "name" = 'anaphylaxis'), (SELECT "id" FROM "organisations" WHERE "name" = 'Emergency medical service test'),
(SELECT "id" FROM "medications" WHERE "name" = 'epinephrine'), '0.5 mg intra muscular for an adult', 'Rapidly constricts blood vessels, relaxes airway muscles, and reduces swelling to counteract the life-threatening symptoms of anaphylaxis.',
'increased heart rate (tachycardia), palpitations, anxiety, tremors, headache, dizziness, nausea, sweating, and, in rare cases, arrhythmias, high blood pressure, or chest pain',
0
);
UPDATE "conditions" SET "type" = 'internal' WHERE "name" = 'anaphylaxis';
SELECT * FROM "current_medications" WHERE "condition_name" = 'anaphylaxis'
AND "organisation_id" = (
SELECT "id" FROM "organisations" WHERE "name" = 'Emergency medical service test'
);
SELECT * FROM "logs";
DELETE FROM "conditions" WHERE "name" = 'anaphylaxis';
DELETE FROM "medications" WHERE "name" = 'epinephrine';
DELETE FROM "dosages" WHERE "medication_id" = (
SELECT "id" FROM "medications" WHERE "name" = 'epinephrine'
) AND "organisation_id" = (
SELECT "id" FROM "organisations" WHERE "name" = 'Emergency medical service test'
) AND "condition_id" = (
SELECT "id" FROM "conditions" WHERE "name" = 'anaphylaxis'
);
INSERT INTO "dosages" ("condition_id", "organisation_id", "medication_id", "dosage", "description", "cave", "paediatric")
VALUES ((SELECT "id" FROM "conditions" WHERE "name" = 'anaphylaxis'), (SELECT "id" FROM "organisations" WHERE "name" = 'Emergency medical service test'),
(SELECT "id" FROM "medications" WHERE "name" = 'epinephrine'), '0.5 mg intra muscular for an adult', 'Rapidly constricts blood vessels, relaxes airway muscles, and reduces swelling to counteract the life-threatening symptoms of anaphylaxis.',
'increased heart rate (tachycardia), palpitations, anxiety, tremors, headache, dizziness, nausea, sweating, and, in rare cases, arrhythmias, high blood pressure, or chest pain',
0
);
SELECT * FROM "logs";