-
Notifications
You must be signed in to change notification settings - Fork 1
/
mlab-dod.sql
1264 lines (1180 loc) · 48.8 KB
/
mlab-dod.sql
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Navicat Premium Data Transfer
Source Server : OFFICE POSTGRES 82
Source Server Type : PostgreSQL
Source Server Version : 120008
Source Host : 197.232.82.136:5432
Source Catalog : mlab-dod-old
Source Schema : public
Target Server Type : PostgreSQL
Target Server Version : 120008
File Encoding : 65001
Date: 08/09/2021 11:27:38
*/
-- ----------------------------
-- Sequence structure for api_users_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."api_users_id_seq";
CREATE SEQUENCE "public"."api_users_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 32767
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for clients_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."clients_id_seq";
CREATE SEQUENCE "public"."clients_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 10
CACHE 1;
-- ----------------------------
-- Sequence structure for health_facilities_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."health_facilities_id_seq";
CREATE SEQUENCE "public"."health_facilities_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 11398
CACHE 1;
-- ----------------------------
-- Sequence structure for hts_results_hts_result_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."hts_results_hts_result_id_seq";
CREATE SEQUENCE "public"."hts_results_hts_result_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 2147483647
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for hts_results_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."hts_results_id_seq";
CREATE SEQUENCE "public"."hts_results_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 25
CACHE 1;
-- ----------------------------
-- Sequence structure for il_facilities_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."il_facilities_id_seq";
CREATE SEQUENCE "public"."il_facilities_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 33
CACHE 1;
-- ----------------------------
-- Sequence structure for inbox2_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."inbox2_id_seq";
CREATE SEQUENCE "public"."inbox2_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 91542
CACHE 1;
-- ----------------------------
-- Sequence structure for inbox_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."inbox_id_seq";
CREATE SEQUENCE "public"."inbox_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 33
CACHE 1;
-- ----------------------------
-- Sequence structure for oauth_clients_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."oauth_clients_id_seq";
CREATE SEQUENCE "public"."oauth_clients_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 2147483647
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for oauth_personal_access_clients_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."oauth_personal_access_clients_id_seq";
CREATE SEQUENCE "public"."oauth_personal_access_clients_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 2147483647
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for partner_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."partner_id_seq";
CREATE SEQUENCE "public"."partner_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 52
CACHE 1;
-- ----------------------------
-- Sequence structure for results_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."results_id_seq";
CREATE SEQUENCE "public"."results_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1949746
CACHE 1;
-- ----------------------------
-- Sequence structure for send_log_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."send_log_id_seq";
CREATE SEQUENCE "public"."send_log_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for sms_gateway_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."sms_gateway_id_seq";
CREATE SEQUENCE "public"."sms_gateway_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for srl_eid_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."srl_eid_id_seq";
CREATE SEQUENCE "public"."srl_eid_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 2147483647
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for srl_hts_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."srl_hts_id_seq";
CREATE SEQUENCE "public"."srl_hts_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 2147483647
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for srl_viral_loads_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."srl_viral_loads_id_seq";
CREATE SEQUENCE "public"."srl_viral_loads_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 2147483647
START 1
CACHE 1;
-- ----------------------------
-- Sequence structure for tbresult_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."tbresult_id_seq";
CREATE SEQUENCE "public"."tbresult_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 11
CACHE 1;
-- ----------------------------
-- Sequence structure for users_id_seq
-- ----------------------------
DROP SEQUENCE IF EXISTS "public"."users_id_seq";
CREATE SEQUENCE "public"."users_id_seq"
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 767
CACHE 1;
-- ----------------------------
-- Table structure for api_users
-- ----------------------------
DROP TABLE IF EXISTS "public"."api_users";
CREATE TABLE "public"."api_users" (
"created_at" timestamp(0) NOT NULL DEFAULT now(),
"updated_at" timestamp(0) NOT NULL DEFAULT now(),
"id" int2 NOT NULL DEFAULT nextval('api_users_id_seq'::regclass),
"name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"email" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"password" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"status" varchar(255) COLLATE "pg_catalog"."default" DEFAULT NULL::character varying,
"user_level" int2 NOT NULL DEFAULT 1
)
;
-- ----------------------------
-- Table structure for clients
-- ----------------------------
DROP TABLE IF EXISTS "public"."clients";
CREATE TABLE "public"."clients" (
"id" int4 NOT NULL DEFAULT nextval('clients_id_seq'::regclass),
"f_name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"l_name" varchar(255) COLLATE "pg_catalog"."default",
"kdod_number" varchar(32) COLLATE "pg_catalog"."default",
"phone" varchar(255) COLLATE "pg_catalog"."default",
"facility_id" int4,
"notification" int4,
"created_at" timestamp(6) NOT NULL DEFAULT now(),
"updated_at" timestamp(6) NOT NULL DEFAULT now(),
"status" text COLLATE "pg_catalog"."default" NOT NULL DEFAULT 'Active'::text
)
;
-- ----------------------------
-- Table structure for county
-- ----------------------------
DROP TABLE IF EXISTS "public"."county";
CREATE TABLE "public"."county" (
"id" int4 NOT NULL,
"name" varchar(255) COLLATE "pg_catalog"."default",
"status" varchar(255) COLLATE "pg_catalog"."default",
"time_stamp" timestamp(6) NOT NULL
)
;
-- ----------------------------
-- Table structure for health_facilities
-- ----------------------------
DROP TABLE IF EXISTS "public"."health_facilities";
CREATE TABLE "public"."health_facilities" (
"id" int4 NOT NULL DEFAULT nextval('health_facilities_id_seq'::regclass),
"code" int4 NOT NULL,
"name" text COLLATE "pg_catalog"."default",
"keph_level" varchar(255) COLLATE "pg_catalog"."default",
"facility_type" varchar(255) COLLATE "pg_catalog"."default",
"Sub_County_ID" int4,
"unit_id" int4,
"mobile" varchar(100) COLLATE "pg_catalog"."default",
"modified" timestamp(6),
"lat" varchar(255) COLLATE "pg_catalog"."default",
"lng" varchar(255) COLLATE "pg_catalog"."default",
"active" varchar(5) COLLATE "pg_catalog"."default" NOT NULL,
"active_last_month" varchar(5) COLLATE "pg_catalog"."default" NOT NULL,
"created_at" timestamp(6) NOT NULL DEFAULT now(),
"updated_at" timestamp(6) NOT NULL DEFAULT now()
)
;
-- ----------------------------
-- Table structure for health_facilities_old
-- ----------------------------
DROP TABLE IF EXISTS "public"."health_facilities_old";
CREATE TABLE "public"."health_facilities_old" (
"id" int4 NOT NULL DEFAULT nextval('health_facilities_id_seq'::regclass),
"code" int4 NOT NULL,
"name" text COLLATE "pg_catalog"."default",
"keph_level" varchar(255) COLLATE "pg_catalog"."default",
"facility_type" varchar(255) COLLATE "pg_catalog"."default",
"Sub_County_ID" int4,
"partner_id" int4,
"mobile" varchar(100) COLLATE "pg_catalog"."default",
"modified" timestamp(6),
"lat" varchar(255) COLLATE "pg_catalog"."default",
"lng" varchar(255) COLLATE "pg_catalog"."default",
"active" varchar(5) COLLATE "pg_catalog"."default" NOT NULL,
"active_last_month" varchar(5) COLLATE "pg_catalog"."default" NOT NULL,
"created_at" timestamp(6) NOT NULL DEFAULT now(),
"updated_at" timestamp(6) NOT NULL DEFAULT now()
)
;
-- ----------------------------
-- Table structure for hts_results
-- ----------------------------
DROP TABLE IF EXISTS "public"."hts_results";
CREATE TABLE "public"."hts_results" (
"nhrl_lab_id" varchar(100) COLLATE "pg_catalog"."default" NOT NULL,
"kdod_number" varchar(100) COLLATE "pg_catalog"."default" NOT NULL,
"age" varchar(100) COLLATE "pg_catalog"."default" NOT NULL,
"gender" varchar(10) COLLATE "pg_catalog"."default" NOT NULL,
"test" varchar(100) COLLATE "pg_catalog"."default" NOT NULL,
"result_value" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"status" varchar(255) COLLATE "pg_catalog"."default",
"component" varchar(255) COLLATE "pg_catalog"."default",
"mfl_code" int4 NOT NULL,
"submit_date" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
"date_released" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
"created_at" timestamp(6) NOT NULL DEFAULT now(),
"updated_at" timestamp(6) NOT NULL DEFAULT now(),
"processed" int4 NOT NULL DEFAULT 0,
"sample_id" varchar(20) COLLATE "pg_catalog"."default" NOT NULL,
"date_sent" timestamp(6),
"date_delivered" timestamp(6),
"date_read" timestamp(6),
"hts_result_id" int4 NOT NULL DEFAULT nextval('hts_results_hts_result_id_seq'::regclass)
)
;
-- ----------------------------
-- Table structure for il_facilities
-- ----------------------------
DROP TABLE IF EXISTS "public"."il_facilities";
CREATE TABLE "public"."il_facilities" (
"id" int4 NOT NULL DEFAULT nextval('il_facilities_id_seq'::regclass),
"mfl_code" int4 NOT NULL,
"phone_no" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"created_at" timestamp(6) NOT NULL DEFAULT now(),
"updated_at" timestamp(6) NOT NULL DEFAULT now(),
"internet" varchar(5) COLLATE "pg_catalog"."default" NOT NULL DEFAULT 'No'::character varying
)
;
-- ----------------------------
-- Table structure for inbox
-- ----------------------------
DROP TABLE IF EXISTS "public"."inbox";
CREATE TABLE "public"."inbox" (
"id" int4 NOT NULL DEFAULT nextval('inbox2_id_seq'::regclass),
"shortCode" varchar(255) COLLATE "pg_catalog"."default",
"MSISDN" varchar(255) COLLATE "pg_catalog"."default",
"message" text COLLATE "pg_catalog"."default",
"msgDateCreated" varchar(255) COLLATE "pg_catalog"."default",
"createdOn" varchar(255) COLLATE "pg_catalog"."default",
"message_id" varchar(255) COLLATE "pg_catalog"."default",
"processed" int4 DEFAULT 0,
"LinkId" varchar(255) COLLATE "pg_catalog"."default",
"created_at" timestamp(6) NOT NULL DEFAULT now(),
"updated_at" timestamp(6)
)
;
-- ----------------------------
-- Table structure for new_facilities
-- ----------------------------
DROP TABLE IF EXISTS "public"."new_facilities";
CREATE TABLE "public"."new_facilities" (
"Code" varchar(255) COLLATE "pg_catalog"."default",
"Name" varchar(255) COLLATE "pg_catalog"."default",
"Officialname" varchar(255) COLLATE "pg_catalog"."default",
"Registration_number" varchar(255) COLLATE "pg_catalog"."default",
"Keph level" varchar(255) COLLATE "pg_catalog"."default",
"Facility type" varchar(255) COLLATE "pg_catalog"."default",
"Facility_type_category" varchar(255) COLLATE "pg_catalog"."default",
"Owner" varchar(255) COLLATE "pg_catalog"."default",
"Owner type" varchar(255) COLLATE "pg_catalog"."default",
"Regulatory body" varchar(255) COLLATE "pg_catalog"."default",
"Beds" varchar(255) COLLATE "pg_catalog"."default",
"Cots" varchar(255) COLLATE "pg_catalog"."default",
"County" varchar(255) COLLATE "pg_catalog"."default",
"Constituency" varchar(255) COLLATE "pg_catalog"."default",
"Sub county" varchar(255) COLLATE "pg_catalog"."default",
"Ward" varchar(255) COLLATE "pg_catalog"."default",
"Operation status" varchar(255) COLLATE "pg_catalog"."default",
"Open_whole_day" varchar(255) COLLATE "pg_catalog"."default",
"Open_public_holidays" varchar(255) COLLATE "pg_catalog"."default",
"Open_weekends" varchar(255) COLLATE "pg_catalog"."default",
"Open_late_night" varchar(255) COLLATE "pg_catalog"."default",
"Service_names" varchar(255) COLLATE "pg_catalog"."default",
"Approved" varchar(255) COLLATE "pg_catalog"."default",
"Public visible" varchar(255) COLLATE "pg_catalog"."default",
"Closed" varchar(255) COLLATE "pg_catalog"."default"
)
;
-- ----------------------------
-- Table structure for oauth_access_tokens
-- ----------------------------
DROP TABLE IF EXISTS "public"."oauth_access_tokens";
CREATE TABLE "public"."oauth_access_tokens" (
"id" varchar(100) COLLATE "pg_catalog"."default" NOT NULL,
"user_id" int4,
"client_id" int4 NOT NULL,
"name" varchar(255) COLLATE "pg_catalog"."default",
"scopes" text COLLATE "pg_catalog"."default",
"revoked" bool NOT NULL,
"created_at" timestamp(0),
"updated_at" timestamp(0),
"expires_at" timestamp(0)
)
;
-- ----------------------------
-- Table structure for oauth_auth_codes
-- ----------------------------
DROP TABLE IF EXISTS "public"."oauth_auth_codes";
CREATE TABLE "public"."oauth_auth_codes" (
"id" varchar(100) COLLATE "pg_catalog"."default" NOT NULL,
"user_id" int4 NOT NULL,
"client_id" int4 NOT NULL,
"scopes" text COLLATE "pg_catalog"."default",
"revoked" bool NOT NULL,
"expires_at" timestamp(0)
)
;
-- ----------------------------
-- Table structure for oauth_clients
-- ----------------------------
DROP TABLE IF EXISTS "public"."oauth_clients";
CREATE TABLE "public"."oauth_clients" (
"user_id" int4,
"name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"secret" varchar(100) COLLATE "pg_catalog"."default" NOT NULL,
"redirect" text COLLATE "pg_catalog"."default" NOT NULL,
"personal_access_client" bool NOT NULL,
"password_client" bool NOT NULL,
"revoked" bool NOT NULL,
"created_at" timestamp(0),
"updated_at" timestamp(0),
"id" int4 NOT NULL DEFAULT nextval('oauth_clients_id_seq'::regclass)
)
;
-- ----------------------------
-- Table structure for oauth_personal_access_clients
-- ----------------------------
DROP TABLE IF EXISTS "public"."oauth_personal_access_clients";
CREATE TABLE "public"."oauth_personal_access_clients" (
"client_id" int4 NOT NULL,
"created_at" timestamp(0),
"updated_at" timestamp(0),
"id" int4 NOT NULL DEFAULT nextval('oauth_personal_access_clients_id_seq'::regclass)
)
;
-- ----------------------------
-- Table structure for oauth_refresh_tokens
-- ----------------------------
DROP TABLE IF EXISTS "public"."oauth_refresh_tokens";
CREATE TABLE "public"."oauth_refresh_tokens" (
"id" varchar(100) COLLATE "pg_catalog"."default" NOT NULL,
"access_token_id" varchar(100) COLLATE "pg_catalog"."default" NOT NULL,
"revoked" bool NOT NULL,
"expires_at" timestamp(0)
)
;
-- ----------------------------
-- Table structure for oldfacility
-- ----------------------------
DROP TABLE IF EXISTS "public"."oldfacility";
CREATE TABLE "public"."oldfacility" (
"id" int4,
"code" int4,
"name" varchar(255) COLLATE "pg_catalog"."default",
"reg_number" varchar(255) COLLATE "pg_catalog"."default",
"keph_level" varchar(255) COLLATE "pg_catalog"."default",
"facility_type" varchar(255) COLLATE "pg_catalog"."default",
"owner" varchar(255) COLLATE "pg_catalog"."default",
"regulatory_body" varchar(255) COLLATE "pg_catalog"."default",
"beds" varchar(255) COLLATE "pg_catalog"."default",
"cots" varchar(255) COLLATE "pg_catalog"."default",
"county_id" varchar(255) COLLATE "pg_catalog"."default",
"consituency_id" varchar(255) COLLATE "pg_catalog"."default",
"Sub_County_ID" int4,
"Ward_id" varchar(255) COLLATE "pg_catalog"."default",
"operational_status" varchar(255) COLLATE "pg_catalog"."default",
"Open_whole_day" varchar(255) COLLATE "pg_catalog"."default",
"Open_public_holidays" varchar(255) COLLATE "pg_catalog"."default",
"Open_weekends" varchar(255) COLLATE "pg_catalog"."default",
"Open_late_night" varchar(255) COLLATE "pg_catalog"."default",
"Service_names" varchar(255) COLLATE "pg_catalog"."default",
"Approved" varchar(255) COLLATE "pg_catalog"."default",
"Public_visible" varchar(255) COLLATE "pg_catalog"."default",
"Closed" varchar(255) COLLATE "pg_catalog"."default",
"assigned" varchar(255) COLLATE "pg_catalog"."default",
"created_by" varchar(255) COLLATE "pg_catalog"."default",
"updated_by" varchar(255) COLLATE "pg_catalog"."default",
"lat" varchar(255) COLLATE "pg_catalog"."default",
"lng" varchar(255) COLLATE "pg_catalog"."default",
"created_at" varchar(255) COLLATE "pg_catalog"."default",
"updated_at" varchar(255) COLLATE "pg_catalog"."default",
"ushauri_id" varchar(255) COLLATE "pg_catalog"."default",
"db_source" varchar(255) COLLATE "pg_catalog"."default"
)
;
-- ----------------------------
-- Table structure for results
-- ----------------------------
DROP TABLE IF EXISTS "public"."results";
CREATE TABLE "public"."results" (
"id" int4 NOT NULL DEFAULT nextval('results_id_seq'::regclass),
"source" varchar(5) COLLATE "pg_catalog"."default",
"result_id" varchar(100) COLLATE "pg_catalog"."default",
"result_type" varchar(10) COLLATE "pg_catalog"."default",
"request_id" varchar(50) COLLATE "pg_catalog"."default",
"kdod_number" varchar(100) COLLATE "pg_catalog"."default",
"age" varchar(10) COLLATE "pg_catalog"."default",
"gender" varchar(10) COLLATE "pg_catalog"."default",
"result_content" varchar(100) COLLATE "pg_catalog"."default",
"units" varchar(50) COLLATE "pg_catalog"."default",
"data_key" int4,
"mfl_code" int4,
"lab_id" int4,
"cst" varchar(10) COLLATE "pg_catalog"."default",
"cj" varchar(10) COLLATE "pg_catalog"."default",
"csr" varchar(10) COLLATE "pg_catalog"."default",
"date_collected" varchar(50) COLLATE "pg_catalog"."default",
"lab_order_date" varchar(50) COLLATE "pg_catalog"."default",
"sys_code" int4 DEFAULT 1,
"date_sent" timestamp(6),
"date_delivered" timestamp(6),
"date_read" timestamp(6),
"processed" int4 DEFAULT 0,
"il_send" int4 DEFAULT 0,
"created_at" timestamp(6) NOT NULL DEFAULT now(),
"updated_at" timestamp(6) NOT NULL DEFAULT now(),
"lab_name" varchar(255) COLLATE "pg_catalog"."default",
"client_notified" bool NOT NULL DEFAULT false
)
;
-- ----------------------------
-- Table structure for send_log
-- ----------------------------
DROP TABLE IF EXISTS "public"."send_log";
CREATE TABLE "public"."send_log" (
"send_log_id" int4 NOT NULL DEFAULT nextval('send_log_id_seq'::regclass),
"number" varchar(25) COLLATE "pg_catalog"."default" NOT NULL,
"message" text COLLATE "pg_catalog"."default" NOT NULL,
"status" varchar(25) COLLATE "pg_catalog"."default" NOT NULL,
"statusCode" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"messageId" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"cost" varchar(100) COLLATE "pg_catalog"."default" NOT NULL,
"updated_at" timestamp(6),
"created_at" timestamp(6)
)
;
-- ----------------------------
-- Table structure for service
-- ----------------------------
DROP TABLE IF EXISTS "public"."service";
CREATE TABLE "public"."service" (
"id" int4 NOT NULL DEFAULT nextval('partner_id_seq'::regclass),
"name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"status" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"created_at" timestamp(6) NOT NULL DEFAULT now(),
"updated_at" timestamp(6) NOT NULL DEFAULT now()
)
;
-- ----------------------------
-- Table structure for sms_gateway
-- ----------------------------
DROP TABLE IF EXISTS "public"."sms_gateway";
CREATE TABLE "public"."sms_gateway" (
"id" int4 NOT NULL DEFAULT nextval('sms_gateway_id_seq'::regclass),
"user_id" int4 NOT NULL,
"phone_no" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
"message" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"delivery_status" varchar(20) COLLATE "pg_catalog"."default" NOT NULL,
"cost" varchar(20) COLLATE "pg_catalog"."default" NOT NULL,
"created_at" timestamp(0) DEFAULT now()
)
;
-- ----------------------------
-- Table structure for srl_eid
-- ----------------------------
DROP TABLE IF EXISTS "public"."srl_eid";
CREATE TABLE "public"."srl_eid" (
"id" int4 NOT NULL DEFAULT nextval('srl_eid_id_seq'::regclass),
"selected_sex" varchar(255) COLLATE "pg_catalog"."default",
"selected_regimen" varchar(255) COLLATE "pg_catalog"."default",
"selected_alive" varchar(255) COLLATE "pg_catalog"."default",
"hein_number" varchar COLLATE "pg_catalog"."default",
"patient_name" varchar(255) COLLATE "pg_catalog"."default",
"dob" varchar(255) COLLATE "pg_catalog"."default",
"entry_point" varchar(255) COLLATE "pg_catalog"."default",
"date_collected" varchar(255) COLLATE "pg_catalog"."default" DEFAULT ''::character varying,
"prophylaxis_code" varchar(255) COLLATE "pg_catalog"."default",
"infant_feeding" varchar(255) COLLATE "pg_catalog"."default",
"pcr" varchar(255) COLLATE "pg_catalog"."default",
"alive_dead" varchar(255) COLLATE "pg_catalog"."default",
"mother_age" varchar(255) COLLATE "pg_catalog"."default",
"haart_date" varchar COLLATE "pg_catalog"."default",
"created_at" timestamp(6) NOT NULL DEFAULT now(),
"updated_at" timestamp(6),
"processed" int2 NOT NULL DEFAULT 0,
"facility" int4,
"lab_id" int4,
"lab_name" varchar(255) COLLATE "pg_catalog"."default"
)
;
-- ----------------------------
-- Table structure for srl_hts
-- ----------------------------
DROP TABLE IF EXISTS "public"."srl_hts";
CREATE TABLE "public"."srl_hts" (
"id" int4 NOT NULL DEFAULT nextval('srl_hts_id_seq'::regclass),
"sample_number" varchar(255) COLLATE "pg_catalog"."default",
"client_name" varchar(255) COLLATE "pg_catalog"."default",
"dob" varchar(255) COLLATE "pg_catalog"."default",
"selected_sex" varchar(255) COLLATE "pg_catalog"."default",
"telephone" varchar(255) COLLATE "pg_catalog"."default",
"test_date" varchar(255) COLLATE "pg_catalog"."default",
"selected_delivery_point" varchar(255) COLLATE "pg_catalog"."default",
"selected_test_kit1" varchar(255) COLLATE "pg_catalog"."default",
"lot_number1" varchar(255) COLLATE "pg_catalog"."default",
"expiry_date1" varchar(255) COLLATE "pg_catalog"."default",
"selected_test_kit2" varchar(255) COLLATE "pg_catalog"."default",
"lot_number2" varchar(255) COLLATE "pg_catalog"."default",
"expiry_date2" varchar(255) COLLATE "pg_catalog"."default",
"selected_final_result" varchar(255) COLLATE "pg_catalog"."default",
"sample_tester_name" varchar(255) COLLATE "pg_catalog"."default",
"dbs_date" varchar(255) COLLATE "pg_catalog"."default",
"dbs_dispatch_date" varchar(255) COLLATE "pg_catalog"."default",
"requesting_provider" varchar(255) COLLATE "pg_catalog"."default",
"created_at" timestamp(6) NOT NULL DEFAULT now(),
"updated_at" timestamp(6),
"processed" int2 NOT NULL DEFAULT 0,
"facility" int4,
"lab_id" int4,
"lab_name" varchar(255) COLLATE "pg_catalog"."default"
)
;
-- ----------------------------
-- Table structure for srl_viral_loads
-- ----------------------------
DROP TABLE IF EXISTS "public"."srl_viral_loads";
CREATE TABLE "public"."srl_viral_loads" (
"id" int4 NOT NULL DEFAULT nextval('srl_viral_loads_id_seq'::regclass),
"kdod_number" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"patient_name" varchar(255) COLLATE "pg_catalog"."default",
"dob" varchar(255) COLLATE "pg_catalog"."default",
"date_collected" varchar(255) COLLATE "pg_catalog"."default",
"art_start_date" varchar(255) COLLATE "pg_catalog"."default",
"current_regimen" varchar(255) COLLATE "pg_catalog"."default",
"date_art_regimen" varchar(255) COLLATE "pg_catalog"."default",
"art_line" varchar(255) COLLATE "pg_catalog"."default",
"justification_code" varchar(255) COLLATE "pg_catalog"."default",
"selected_type" varchar(255) COLLATE "pg_catalog"."default",
"selected_sex" varchar(255) COLLATE "pg_catalog"."default",
"created_at" timestamp(6) NOT NULL DEFAULT now(),
"updated_at" timestamp(6),
"processed" int2 NOT NULL DEFAULT 0,
"facility" int4,
"lab_id" int4,
"lab_name" varchar(255) COLLATE "pg_catalog"."default"
)
;
-- ----------------------------
-- Table structure for sub_county
-- ----------------------------
DROP TABLE IF EXISTS "public"."sub_county";
CREATE TABLE "public"."sub_county" (
"id" int4 NOT NULL,
"name" varchar(255) COLLATE "pg_catalog"."default",
"county_id" int4 NOT NULL,
"status" varchar(255) COLLATE "pg_catalog"."default",
"time_stamp" timestamp(6) NOT NULL
)
;
-- ----------------------------
-- Table structure for tb_results
-- ----------------------------
DROP TABLE IF EXISTS "public"."tb_results";
CREATE TABLE "public"."tb_results" (
"tb_result_id" int4 NOT NULL DEFAULT nextval('tbresult_id_seq'::regclass),
"sample_id" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"kdod_number" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"age" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"gender" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"test1" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"result_value1" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"test2" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"result_value2" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"test3" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"result_value3" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"mfl_code" int4 NOT NULL,
"login_date" timestamp(6) NOT NULL,
"date_reviewed" timestamp(6) NOT NULL,
"record_date" timestamp(6) NOT NULL,
"testing_lab" int4 NOT NULL,
"created_at" timestamp(6) NOT NULL DEFAULT now(),
"updated_at" timestamp(6) NOT NULL DEFAULT now(),
"processed" int4 DEFAULT 0
)
;
-- ----------------------------
-- Table structure for unit
-- ----------------------------
DROP TABLE IF EXISTS "public"."unit";
CREATE TABLE "public"."unit" (
"id" int4 NOT NULL DEFAULT nextval('partner_id_seq'::regclass),
"name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"status" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"created_at" timestamp(6) NOT NULL DEFAULT now(),
"updated_at" timestamp(6) NOT NULL DEFAULT now(),
"service_id" int4
)
;
-- ----------------------------
-- Table structure for users
-- ----------------------------
DROP TABLE IF EXISTS "public"."users";
CREATE TABLE "public"."users" (
"id" int4 NOT NULL DEFAULT nextval('users_id_seq'::regclass),
"f_name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"l_name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"email" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"phone_no" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"status" varchar(20) COLLATE "pg_catalog"."default" NOT NULL,
"county_id" int4,
"service_id" int4,
"facility_id" int4,
"user_level" int4,
"first_login" text COLLATE "pg_catalog"."default" NOT NULL,
"created_at" timestamp(6) NOT NULL DEFAULT now(),
"updated_at" timestamp(6) NOT NULL DEFAULT now(),
"password" varchar(255) COLLATE "pg_catalog"."default",
"remember_token" varchar(255) COLLATE "pg_catalog"."default",
"unit_id" int4
)
;
-- ----------------------------
-- View structure for printers_data
-- ----------------------------
DROP VIEW IF EXISTS "public"."printers_data";
CREATE VIEW "public"."printers_data" AS SELECT results.result_type,
results.age,
results.gender,
results.data_key,
results.mfl_code,
results.created_at,
results.date_collected,
results.date_sent,
results.lab_id,
health_facilities."Sub_County_ID",
sub_county.county_id,
health_facilities.unit_id,
service.id
FROM ((((results
JOIN health_facilities ON ((health_facilities.code = results.mfl_code)))
LEFT JOIN unit ON ((health_facilities.unit_id = unit.id)))
LEFT JOIN service ON ((service.id = unit.service_id)))
JOIN sub_county ON ((health_facilities."Sub_County_ID" = sub_county.id)))
WHERE ((health_facilities.unit_id IS NULL) AND (NOT (results.mfl_code IN ( SELECT il_facilities.mfl_code
FROM il_facilities))));
-- ----------------------------
-- View structure for mlab_active_facilities
-- ----------------------------
DROP VIEW IF EXISTS "public"."mlab_active_facilities";
CREATE VIEW "public"."mlab_active_facilities" AS SELECT health_facilities.code
FROM health_facilities
WHERE ((health_facilities.mobile IS NOT NULL) OR (health_facilities.code IN ( SELECT il_facilities.mfl_code
FROM il_facilities)));
-- ----------------------------
-- View structure for hts_summary
-- ----------------------------
DROP VIEW IF EXISTS "public"."hts_summary";
CREATE VIEW "public"."hts_summary" AS SELECT hts_results.hts_result_id,
hts_results.kdod_number,
service.name AS service,
unit.name AS unit,
county.name AS county,
sub_county.name AS sub_county,
health_facilities.name AS facility,
CASE
WHEN (health_facilities.lat IS NULL) THEN 'NAN'::character varying
ELSE health_facilities.lat
END AS lat,
CASE
WHEN (health_facilities.lng IS NULL) THEN 'NAN'::character varying
ELSE health_facilities.lng
END AS lng,
hts_results.test,
hts_results.result_value,
CASE
WHEN ((hts_results.gender)::text = 'F'::text) THEN 'Female'::text
WHEN ((hts_results.gender)::text = 'M'::text) THEN 'Male'::text
ELSE 'Not Available'::text
END AS gender,
CASE
WHEN (hts_results.age IS NOT NULL) THEN hts_results.age
ELSE 'Not Available'::character varying
END AS age,
hts_results.submit_date,
hts_results.date_released,
hts_results.date_sent,
hts_results.date_delivered,
hts_results.date_read,
CASE
WHEN ((hts_results.submit_date IS NULL) OR ((hts_results.date_released)::text ~~ '%000%'::text)) THEN 'NAN'::text
ELSE (((hts_results.submit_date)::date - (hts_results.date_released)::date))::text
END AS submitted_released_tat,
CASE
WHEN (hts_results.date_read IS NULL) THEN 'NAN'::text
ELSE (((hts_results.date_read)::date - (hts_results.date_sent)::date))::text
END AS sent_read_tat,
CASE
WHEN ((hts_results.submit_date IS NULL) OR ((hts_results.submit_date)::text ~~ '%000%'::text) OR (hts_results.date_read IS NULL)) THEN 'NAN'::text
ELSE (((hts_results.date_read)::date - (hts_results.submit_date)::date))::text
END AS overall_tat,
hts_results.updated_at AS updated
FROM (((((hts_results
JOIN health_facilities ON ((hts_results.mfl_code = health_facilities.code)))
LEFT JOIN unit ON ((unit.id = health_facilities.unit_id)))
LEFT JOIN service ON ((service.id = unit.service_id)))
JOIN sub_county ON ((sub_county.id = health_facilities."Sub_County_ID")))
JOIN county ON ((county.id = sub_county.county_id)));
-- ----------------------------
-- View structure for srl_vl_summary
-- ----------------------------
DROP VIEW IF EXISTS "public"."srl_vl_summary";
CREATE VIEW "public"."srl_vl_summary" AS SELECT srl_viral_loads.id,
srl_viral_loads.kdod_number,
srl_viral_loads.patient_name,
srl_viral_loads.lab_name,
srl_viral_loads.selected_sex AS gender,
srl_viral_loads.current_regimen,
srl_viral_loads.date_art_regimen,
srl_viral_loads.selected_type,
srl_viral_loads.justification_code,
srl_viral_loads.date_collected,
health_facilities.name AS facility,
county.name AS county,
sub_county.name AS sub_county,
service.name AS service,
unit.name AS unit,
srl_viral_loads.created_at,
srl_viral_loads.updated_at
FROM (((((srl_viral_loads
LEFT JOIN health_facilities ON ((srl_viral_loads.facility = health_facilities.code)))
LEFT JOIN unit ON ((unit.id = health_facilities.unit_id)))
LEFT JOIN service ON ((service.id = unit.service_id)))
LEFT JOIN sub_county ON ((sub_county.id = health_facilities."Sub_County_ID")))
LEFT JOIN county ON ((county.id = sub_county.county_id)));
-- ----------------------------
-- View structure for srl_eid_summary
-- ----------------------------
DROP VIEW IF EXISTS "public"."srl_eid_summary";
CREATE VIEW "public"."srl_eid_summary" AS SELECT srl_eid.id,
srl_eid.hein_number,
srl_eid.patient_name,
srl_eid.lab_name,
srl_eid.prophylaxis_code,
srl_eid.entry_point,
srl_eid.date_collected,
health_facilities.unit_id AS partner_id,
health_facilities.name AS facility,
county.name AS county,
sub_county.name AS sub_county,
service.name AS service,
unit.name AS unit,
srl_eid.created_at,
srl_eid.updated_at
FROM (((((srl_eid
LEFT JOIN health_facilities ON ((srl_eid.facility = health_facilities.code)))
LEFT JOIN unit ON ((unit.id = health_facilities.unit_id)))
LEFT JOIN service ON ((service.id = unit.service_id)))
LEFT JOIN sub_county ON ((sub_county.id = health_facilities."Sub_County_ID")))
LEFT JOIN county ON ((county.id = sub_county.county_id)));
-- ----------------------------
-- View structure for il_facilities_summary
-- ----------------------------
DROP VIEW IF EXISTS "public"."il_facilities_summary";
CREATE VIEW "public"."il_facilities_summary" AS SELECT health_facilities.code AS mfl_code,
health_facilities.name AS facility,
sub_county.name AS sub_county,
county.name AS county,
CASE
WHEN (health_facilities.unit_id IS NOT NULL) THEN unit.name
ELSE 'NONE'::character varying
END AS unit,
CASE
WHEN (unit.service_id IS NOT NULL) THEN service.name
ELSE 'NONE'::character varying
END AS service,
(il_facilities.created_at)::date AS activated
FROM (((((il_facilities
JOIN health_facilities ON ((health_facilities.code = il_facilities.mfl_code)))
JOIN sub_county ON ((sub_county.id = health_facilities."Sub_County_ID")))
JOIN county ON ((county.id = sub_county.county_id)))
JOIN unit ON ((health_facilities.unit_id = unit.id)))
JOIN service ON ((service.id = unit.service_id)));
-- ----------------------------
-- View structure for facilities_summary
-- ----------------------------
DROP VIEW IF EXISTS "public"."facilities_summary";
CREATE VIEW "public"."facilities_summary" AS SELECT health_facilities.code AS mfl,
health_facilities.name,
unit.name AS unit,
service.name AS service,
sub_county.name AS sub_county,
county.name AS county,
count(results.id) AS results_sent,
max(results.date_sent) AS last_sent_date
FROM (((((health_facilities
LEFT JOIN unit ON ((unit.id = health_facilities.unit_id)))
LEFT JOIN service ON ((service.id = unit.service_id)))
LEFT JOIN results ON ((results.mfl_code = health_facilities.code)))
LEFT JOIN sub_county ON ((sub_county.id = health_facilities."Sub_County_ID")))
LEFT JOIN county ON ((county.id = sub_county.county_id)))
GROUP BY health_facilities.code, health_facilities.name, service.name, unit.name, sub_county.name, county.name;
-- ----------------------------
-- View structure for summary
-- ----------------------------
DROP VIEW IF EXISTS "public"."summary";
CREATE VIEW "public"."summary" AS SELECT results.id,
results.result_content,
results.kdod_number AS client_id,
CASE
WHEN (health_facilities.unit_id IS NULL) THEN 'Empty'::character varying
ELSE unit.name
END AS unit,
CASE
WHEN (unit.service_id IS NULL) THEN 'Empty'::character varying
ELSE service.name
END AS service,
county.name AS county,
sub_county.name AS sub_county,
health_facilities.name AS facility,
CASE
WHEN (health_facilities.lat IS NULL) THEN 'NAN'::character varying
ELSE health_facilities.lat
END AS lat,
CASE
WHEN (health_facilities.lng IS NULL) THEN 'NAN'::character varying
ELSE health_facilities.lng
END AS lng,
CASE
WHEN ((results.result_type)::text = '1'::text) THEN 'Viral Load'::text
WHEN ((results.result_type)::text = '2'::text) THEN 'EID'::text
ELSE 'Indeterminate'::text
END AS result_type,
CASE
WHEN (results.data_key = 1) THEN 'Suppressed'::text
WHEN (results.data_key = 2) THEN 'Unsuppresed'::text
WHEN (results.data_key = 3) THEN 'Invalid'::text
WHEN (results.data_key = 4) THEN 'Negative'::text
WHEN (results.data_key = 5) THEN 'Positive'::text
WHEN (results.data_key = 6) THEN 'Invalid'::text
ELSE 'Indeterminate'::text
END AS data_key,
CASE