-
Notifications
You must be signed in to change notification settings - Fork 1
/
schema.sql
3180 lines (2318 loc) · 89.3 KB
/
schema.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
--
-- PostgreSQL database dump
--
SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;
SET search_path = public, pg_catalog;
ALTER TABLE ONLY public.vf_testing_sites DROP CONSTRAINT vf_testing_sites_location_id_fkey;
ALTER TABLE ONLY public.tests DROP CONSTRAINT tests_user_id_fkey;
ALTER TABLE ONLY public.result_lookups DROP CONSTRAINT result_lookups_user_id_fkey;
ALTER TABLE ONLY public.patients DROP CONSTRAINT patients_vf_testing_site_fkey;
ALTER TABLE ONLY public.patients DROP CONSTRAINT patients_occupation_id_fkey;
ALTER TABLE ONLY public.patients DROP CONSTRAINT patients_marital_status_id_fkey;
ALTER TABLE ONLY public.patients DROP CONSTRAINT patients_location_id_fkey;
ALTER TABLE ONLY public.patients DROP CONSTRAINT patients_inactive_reason_id_fkey;
ALTER TABLE ONLY public.patients DROP CONSTRAINT patients_education_id_fkey;
ALTER TABLE ONLY public.medical_informations DROP CONSTRAINT medical_informations_transfer_in_district_id_fkey;
ALTER TABLE ONLY public.medical_informations DROP CONSTRAINT medical_informations_pid_fkey;
ALTER TABLE ONLY public.medical_informations DROP CONSTRAINT medical_informations_patient_source_id_fkey;
ALTER TABLE ONLY public.medical_informations DROP CONSTRAINT medical_informations_hiv_positive_test_location_id_fkey;
ALTER TABLE ONLY public.medical_informations DROP CONSTRAINT medical_informations_funding_id_fkey;
ALTER TABLE ONLY public.medical_informations DROP CONSTRAINT medical_informations_art_service_type_id_fkey;
ALTER TABLE ONLY public.medical_informations DROP CONSTRAINT medical_informations_art_indication_id_fkey;
ALTER TABLE ONLY public.archive_patients DROP CONSTRAINT archive_patients_user_id_fkey;
ALTER TABLE ONLY public.archive_patients DROP CONSTRAINT archive_patients_archive_vf_testing_site_fkey;
ALTER TABLE ONLY public.archive_patients DROP CONSTRAINT archive_patients_archive_occupation_id_fkey;
ALTER TABLE ONLY public.archive_patients DROP CONSTRAINT archive_patients_archive_marital_status_id_fkey;
ALTER TABLE ONLY public.archive_patients DROP CONSTRAINT archive_patients_archive_location_id_fkey;
ALTER TABLE ONLY public.archive_patients DROP CONSTRAINT archive_patients_archive_inactive_reason_id_fkey;
ALTER TABLE ONLY public.archive_patients DROP CONSTRAINT archive_patients_archive_education_id_fkey;
ALTER TABLE ONLY public.archive_medical_informations DROP CONSTRAINT archive_medical_informations_user_id_fkey;
ALTER TABLE ONLY public.archive_medical_informations DROP CONSTRAINT archive_medical_informations_archive_transfer_in_district__fkey;
ALTER TABLE ONLY public.archive_medical_informations DROP CONSTRAINT archive_medical_informations_archive_pid_fkey;
ALTER TABLE ONLY public.archive_medical_informations DROP CONSTRAINT archive_medical_informations_archive_patient_source_id_fkey;
ALTER TABLE ONLY public.archive_medical_informations DROP CONSTRAINT archive_medical_informations_archive_hiv_positive_test_loc_fkey;
ALTER TABLE ONLY public.archive_medical_informations DROP CONSTRAINT archive_medical_informations_archive_funding_id_fkey;
ALTER TABLE ONLY public.archive_medical_informations DROP CONSTRAINT archive_medical_informations_archive_art_starting_regimen__fkey;
ALTER TABLE ONLY public.archive_medical_informations DROP CONSTRAINT archive_medical_informations_archive_art_service_type_id_fkey;
ALTER TABLE ONLY public.archive_medical_informations DROP CONSTRAINT archive_medical_informations_archive_art_indication_id_fkey;
DROP INDEX public.aro_aco_key;
ALTER TABLE ONLY public.vf_testing_sites DROP CONSTRAINT vf_testing_sites_site_name_key;
ALTER TABLE ONLY public.vf_testing_sites DROP CONSTRAINT vf_testing_sites_pkey;
ALTER TABLE ONLY public.users DROP CONSTRAINT users_pkey;
ALTER TABLE ONLY public.tests DROP CONSTRAINT tests_pkey;
ALTER TABLE ONLY public.results DROP CONSTRAINT results_pkey;
ALTER TABLE ONLY public.result_values DROP CONSTRAINT result_values_pkey;
ALTER TABLE ONLY public.result_lookups DROP CONSTRAINT result_lookups_pkey;
ALTER TABLE ONLY public.regimens DROP CONSTRAINT regimens_pkey;
ALTER TABLE ONLY public.regimens DROP CONSTRAINT regimens_name_key;
ALTER TABLE ONLY public.pep_reasons DROP CONSTRAINT pep_reasons_pkey;
ALTER TABLE ONLY public.patients DROP CONSTRAINT patients_vfcc_key;
ALTER TABLE ONLY public.patients DROP CONSTRAINT patients_upn_key;
ALTER TABLE ONLY public.patients DROP CONSTRAINT patients_pkey;
ALTER TABLE ONLY public.patients DROP CONSTRAINT patients_arvid_key;
ALTER TABLE ONLY public.patient_sources DROP CONSTRAINT patient_sources_pkey;
ALTER TABLE ONLY public.patient_sources DROP CONSTRAINT patient_sources_name_key;
ALTER TABLE ONLY public.occupations DROP CONSTRAINT occupations_pkey;
ALTER TABLE ONLY public.occupations DROP CONSTRAINT occupations_name_key;
ALTER TABLE ONLY public.medical_informations DROP CONSTRAINT medical_informations_pkey;
ALTER TABLE ONLY public.marital_statuses DROP CONSTRAINT marital_statuses_pkey;
ALTER TABLE ONLY public.marital_statuses DROP CONSTRAINT marital_statuses_name_key;
ALTER TABLE ONLY public.locations DROP CONSTRAINT locations_pkey;
ALTER TABLE ONLY public.inactive_reasons DROP CONSTRAINT inactive_reasons_pkey;
ALTER TABLE ONLY public.inactive_reasons DROP CONSTRAINT inactive_reasons_name_key;
ALTER TABLE ONLY public.groups DROP CONSTRAINT groups_pkey;
ALTER TABLE ONLY public.fundings DROP CONSTRAINT fundings_pkey;
ALTER TABLE ONLY public.fundings DROP CONSTRAINT fundings_name_key;
ALTER TABLE ONLY public.educations DROP CONSTRAINT educations_pkey;
ALTER TABLE ONLY public.educations DROP CONSTRAINT educations_name_key;
ALTER TABLE ONLY public.art_substitutions DROP CONSTRAINT art_substitutions_pkey;
ALTER TABLE ONLY public.art_service_types DROP CONSTRAINT art_service_types_pkey;
ALTER TABLE ONLY public.art_service_types DROP CONSTRAINT art_service_types_name_key;
ALTER TABLE ONLY public.art_regimens DROP CONSTRAINT art_regimens_pkey;
ALTER TABLE ONLY public.art_interruptions DROP CONSTRAINT art_interruptions_pkey;
ALTER TABLE ONLY public.art_indications DROP CONSTRAINT art_indications_pkey;
ALTER TABLE ONLY public.art_indications DROP CONSTRAINT art_indications_name_key;
ALTER TABLE ONLY public.aros DROP CONSTRAINT aros_pkey;
ALTER TABLE ONLY public.aros_acos DROP CONSTRAINT aros_acos_pkey;
ALTER TABLE ONLY public.archive_users DROP CONSTRAINT archive_users_pkey;
ALTER TABLE ONLY public.archive_tests DROP CONSTRAINT archive_tests_pkey;
ALTER TABLE ONLY public.archive_results DROP CONSTRAINT archive_results_pkey;
ALTER TABLE ONLY public.archive_result_values DROP CONSTRAINT archive_result_values_pkey;
ALTER TABLE ONLY public.archive_result_lookups DROP CONSTRAINT archive_result_lookups_pkey;
ALTER TABLE ONLY public.archive_patients DROP CONSTRAINT archive_patients_pkey;
ALTER TABLE ONLY public.archive_medical_informations DROP CONSTRAINT archive_medical_informations_pkey;
ALTER TABLE ONLY public.archive_groups DROP CONSTRAINT archive_groups_pkey;
ALTER TABLE ONLY public.acos DROP CONSTRAINT acos_pkey;
ALTER TABLE public.vf_testing_sites ALTER COLUMN site_code DROP DEFAULT;
ALTER TABLE public.users ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.tests ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.results ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.result_values ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.result_lookups ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.regimens ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.patient_sources ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.occupations ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.marital_statuses ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.locations ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.inactive_reasons ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.groups ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.fundings ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.educations ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.art_substitutions ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.art_service_types ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.art_regimens ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.art_interruptions ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.art_indications ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.aros_acos ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.aros ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.archive_users ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.archive_tests ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.archive_results ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.archive_result_values ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.archive_result_lookups ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.archive_patients ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.archive_medical_informations ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.archive_groups ALTER COLUMN id DROP DEFAULT;
ALTER TABLE public.acos ALTER COLUMN id DROP DEFAULT;
DROP SEQUENCE public.vf_testing_sites_site_code_seq;
DROP TABLE public.vf_testing_sites;
DROP SEQUENCE public.users_id_seq;
DROP TABLE public.users;
DROP SEQUENCE public.tests_tid_seq;
DROP SEQUENCE public.tests_id_seq;
DROP TABLE public.tests;
DROP TABLE public.second_line_reasons;
DROP SEQUENCE public.results_id_seq;
DROP TABLE public.results;
DROP SEQUENCE public.result_values_id_seq;
DROP TABLE public.result_values;
DROP SEQUENCE public.result_lookups_id_seq;
DROP TABLE public.result_lookups;
DROP SEQUENCE public.regimens_id_seq;
DROP TABLE public.regimens;
DROP TABLE public.pep_reasons;
DROP TABLE public.patients;
DROP SEQUENCE public.patient_sources_id_seq;
DROP TABLE public.patient_sources;
DROP SEQUENCE public.occupations_id_seq;
DROP TABLE public.occupations;
DROP TABLE public.medical_informations;
DROP SEQUENCE public.marital_statuses_id_seq;
DROP TABLE public.marital_statuses;
DROP SEQUENCE public.locations_id_seq;
DROP TABLE public.locations;
DROP SEQUENCE public.inactive_reasons_id_seq;
DROP TABLE public.inactive_reasons;
DROP SEQUENCE public.groups_id_seq;
DROP TABLE public.groups;
DROP SEQUENCE public.fundings_id_seq;
DROP TABLE public.fundings;
DROP SEQUENCE public.educations_id_seq;
DROP TABLE public.educations;
DROP SEQUENCE public.art_substitutions_id_seq;
DROP TABLE public.art_substitutions;
DROP TABLE public.art_substitution_reasons;
DROP SEQUENCE public.art_service_types_id_seq;
DROP TABLE public.art_service_types;
DROP TABLE public.art_second_line_reasons;
DROP SEQUENCE public.art_regimens_id_seq;
DROP TABLE public.art_regimens;
DROP SEQUENCE public.art_interruptions_id_seq;
DROP TABLE public.art_interruptions;
DROP TABLE public.art_interruption_reasons;
DROP SEQUENCE public.art_indications_id_seq;
DROP TABLE public.art_indications;
DROP SEQUENCE public.aros_id_seq;
DROP SEQUENCE public.aros_acos_id_seq;
DROP TABLE public.aros_acos;
DROP TABLE public.aros;
DROP SEQUENCE public.archive_users_id_seq;
DROP TABLE public.archive_users;
DROP SEQUENCE public.archive_tests_id_seq;
DROP TABLE public.archive_tests;
DROP SEQUENCE public.archive_results_id_seq;
DROP TABLE public.archive_results;
DROP SEQUENCE public.archive_result_values_id_seq;
DROP TABLE public.archive_result_values;
DROP SEQUENCE public.archive_result_lookups_id_seq;
DROP TABLE public.archive_result_lookups;
DROP SEQUENCE public.archive_patients_id_seq;
DROP TABLE public.archive_patients;
DROP SEQUENCE public.archive_medical_informations_id_seq;
DROP TABLE public.archive_medical_informations;
DROP SEQUENCE public.archive_groups_id_seq;
DROP TABLE public.archive_groups;
DROP SEQUENCE public.acos_id_seq;
DROP TABLE public.acos;
DROP PROCEDURAL LANGUAGE plpgsql;
DROP SCHEMA public;
--
-- Name: public; Type: SCHEMA; Schema: -; Owner: -
--
CREATE SCHEMA public;
--
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON SCHEMA public IS 'standard public schema';
--
-- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -
--
CREATE PROCEDURAL LANGUAGE plpgsql;
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: acos; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE acos (
id integer NOT NULL,
parent_id integer,
model character varying(255) DEFAULT NULL::character varying,
foreign_key integer,
alias character varying(255) DEFAULT NULL::character varying,
lft integer,
rght integer
);
--
-- Name: acos_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE acos_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: acos_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE acos_id_seq OWNED BY acos.id;
--
-- Name: acos_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--
SELECT pg_catalog.setval('acos_id_seq', 1, true);
--
-- Name: archive_groups; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE archive_groups (
id integer NOT NULL,
archive_id integer,
user_id integer NOT NULL,
created timestamp without time zone,
archive_reason character varying,
archive_name character varying,
archive_description character varying,
archive_created timestamp without time zone,
archive_modified timestamp without time zone
);
--
-- Name: archive_groups_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE archive_groups_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: archive_groups_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE archive_groups_id_seq OWNED BY archive_groups.id;
--
-- Name: archive_groups_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--
SELECT pg_catalog.setval('archive_groups_id_seq', 1, false);
--
-- Name: archive_medical_informations; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE archive_medical_informations (
id integer NOT NULL,
user_id integer NOT NULL,
created timestamp without time zone DEFAULT now() NOT NULL,
archive_reason character varying,
archive_pid integer NOT NULL,
archive_patient_source_id integer,
archive_funding_id integer,
archive_hiv_positive_date date,
archive_hiv_positive_test_location_id integer,
archive_hiv_positive_clinic_start_date date,
archive_hiv_positive_who_stage integer,
archive_art_naive boolean,
archive_art_service_type_id integer,
archive_art_starting_regimen_id integer,
archive_art_start_date date,
archive_art_eligibility_date date,
archive_art_indication_id integer,
archive_transfer_in_date date,
archive_transfer_in_district_id integer,
archive_transfer_in_facility text,
archive_transfer_out_date date,
archive_date_pep_start date,
archive_pep_reason_id integer,
archive_art_eligible_who_stage integer,
archive_art_eligible_cd4 integer,
archive_art_start_weight integer,
archive_art_start_height integer,
archive_art_start_who_stage integer,
archive_art_second_start_date date,
archive_art_second_line_reason_id integer,
archive_drug_allergies character varying,
archive_created timestamp without time zone,
archive_modified timestamp without time zone
);
--
-- Name: archive_medical_informations_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE archive_medical_informations_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: archive_medical_informations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE archive_medical_informations_id_seq OWNED BY archive_medical_informations.id;
--
-- Name: archive_medical_informations_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--
SELECT pg_catalog.setval('archive_medical_informations_id_seq', 1, true);
--
-- Name: archive_patients; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE archive_patients (
id integer NOT NULL,
user_id integer NOT NULL,
created timestamp without time zone DEFAULT now() NOT NULL,
archive_reason character varying,
archive_pid integer NOT NULL,
archive_upn character varying,
archive_arvid character varying,
archive_vfcc character varying,
archive_surname character varying NOT NULL,
archive_forenames character varying NOT NULL,
archive_date_of_birth date,
archive_year_of_birth integer,
archive_sex character varying,
archive_mother character varying,
archive_occupation_id integer,
archive_education_id integer,
archive_marital_status_id integer,
archive_telephone_number character varying,
archive_treatment_supporter text,
archive_location_id integer,
archive_village character varying,
archive_home character varying,
archive_nearest_church character varying,
archive_nearest_school character varying,
archive_nearest_health_centre character varying,
archive_nearest_major_landmark character varying,
archive_vf_testing_site integer,
archive_status boolean NOT NULL,
archive_inactive_reason_id integer,
archive_status_timestamp date,
archive_treatment_supporter_name character varying,
archive_treatment_supporter_relationship character varying,
archive_treatment_supporter_address character varying,
archive_treatment_supporter_telephone_number character varying,
archive_created timestamp without time zone,
archive_modified timestamp without time zone
);
--
-- Name: archive_patients_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE archive_patients_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: archive_patients_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE archive_patients_id_seq OWNED BY archive_patients.id;
--
-- Name: archive_patients_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--
SELECT pg_catalog.setval('archive_patients_id_seq', 1, true);
--
-- Name: archive_result_lookups; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE archive_result_lookups (
id integer NOT NULL,
user_id integer NOT NULL,
created timestamp without time zone,
archive_reason character varying,
archive_id integer,
archive_test_id integer NOT NULL,
archive_value character varying NOT NULL,
archive_description character varying,
archive_comment character varying,
archive_user_id integer NOT NULL,
archive_modified timestamp without time zone NOT NULL
);
--
-- Name: archive_result_lookups_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE archive_result_lookups_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: archive_result_lookups_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE archive_result_lookups_id_seq OWNED BY archive_result_lookups.id;
--
-- Name: archive_result_lookups_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--
SELECT pg_catalog.setval('archive_result_lookups_id_seq', 1, true);
--
-- Name: archive_result_values; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE archive_result_values (
id integer NOT NULL,
user_id integer NOT NULL,
created timestamp without time zone,
archive_reason character varying,
archive_id integer NOT NULL,
archive_result_id integer NOT NULL,
archive_value_decimal double precision,
archive_value_text character varying,
archive_value_lookup character varying,
archive_user_id integer NOT NULL,
archive_created timestamp without time zone NOT NULL,
archive_modified timestamp without time zone NOT NULL
);
--
-- Name: archive_result_values_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE archive_result_values_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: archive_result_values_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE archive_result_values_id_seq OWNED BY archive_result_values.id;
--
-- Name: archive_result_values_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--
SELECT pg_catalog.setval('archive_result_values_id_seq', 1, false);
--
-- Name: archive_results; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE archive_results (
id integer NOT NULL,
user_id integer NOT NULL,
created timestamp without time zone,
archive_reason character varying,
archive_id integer NOT NULL,
archive_pid integer NOT NULL,
archive_test_id integer NOT NULL,
archive_test_performed timestamp without time zone,
archive_created timestamp without time zone NOT NULL,
archive_modified timestamp without time zone NOT NULL,
archive_requesting_clinician character varying,
archive_user_id integer NOT NULL
);
--
-- Name: archive_results_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE archive_results_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: archive_results_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE archive_results_id_seq OWNED BY archive_results.id;
--
-- Name: archive_results_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--
SELECT pg_catalog.setval('archive_results_id_seq', 1, false);
--
-- Name: archive_tests; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE archive_tests (
id integer NOT NULL,
user_id integer NOT NULL,
created timestamp without time zone,
archive_reason character varying,
archive_id integer,
archive_name character varying NOT NULL,
archive_abbreiviation character varying,
archive_type character varying NOT NULL,
archive_upper_limit double precision,
archive_lower_limit double precision,
archive_description character varying,
archive_comment character varying,
archive_active boolean DEFAULT true,
archive_user_id integer NOT NULL,
archive_modified timestamp without time zone NOT NULL
);
--
-- Name: archive_tests_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE archive_tests_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: archive_tests_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE archive_tests_id_seq OWNED BY archive_tests.id;
--
-- Name: archive_tests_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--
SELECT pg_catalog.setval('archive_tests_id_seq', 1, true);
--
-- Name: archive_users; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE archive_users (
id integer NOT NULL,
archive_id integer,
user_id integer NOT NULL,
created timestamp without time zone,
archive_reason character varying,
archive_username character varying NOT NULL,
archive_password character varying NOT NULL,
archive_group_id integer NOT NULL,
archive_name character varying,
archive_created timestamp without time zone,
archive_modified timestamp without time zone
);
--
-- Name: archive_users_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE archive_users_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: archive_users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE archive_users_id_seq OWNED BY archive_users.id;
--
-- Name: archive_users_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--
SELECT pg_catalog.setval('archive_users_id_seq', 1, true);
--
-- Name: aros; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE aros (
id integer NOT NULL,
parent_id integer,
model character varying(255) DEFAULT NULL::character varying,
foreign_key integer,
alias character varying(255) DEFAULT NULL::character varying,
lft integer,
rght integer
);
--
-- Name: aros_acos; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE aros_acos (
id integer NOT NULL,
aro_id integer NOT NULL,
aco_id integer NOT NULL,
_create character varying(2) DEFAULT '0'::character varying NOT NULL,
_read character varying(2) DEFAULT '0'::character varying NOT NULL,
_update character varying(2) DEFAULT '0'::character varying NOT NULL,
_delete character varying(2) DEFAULT '0'::character varying NOT NULL
);
--
-- Name: aros_acos_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE aros_acos_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: aros_acos_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE aros_acos_id_seq OWNED BY aros_acos.id;
--
-- Name: aros_acos_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--
SELECT pg_catalog.setval('aros_acos_id_seq', 1, true);
--
-- Name: aros_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE aros_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: aros_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE aros_id_seq OWNED BY aros.id;
--
-- Name: aros_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--
SELECT pg_catalog.setval('aros_id_seq', 10, true);
--
-- Name: art_indications; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE art_indications (
id integer NOT NULL,
name character varying NOT NULL,
description character varying,
comment character varying
);
--
-- Name: art_indications_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE art_indications_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: art_indications_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE art_indications_id_seq OWNED BY art_indications.id;
--
-- Name: art_indications_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--
SELECT pg_catalog.setval('art_indications_id_seq', 3, true);
--
-- Name: art_interruption_reasons; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE art_interruption_reasons (
id integer NOT NULL,
name character varying NOT NULL,
description character varying,
comment character varying
);
--
-- Name: art_interruptions; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE art_interruptions (
id integer NOT NULL,
pid integer NOT NULL,
interruption_date date NOT NULL,
art_interruption_reason_id integer NOT NULL,
restart_date date
);
--
-- Name: art_interruptions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE art_interruptions_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: art_interruptions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE art_interruptions_id_seq OWNED BY art_interruptions.id;
--
-- Name: art_interruptions_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--
SELECT pg_catalog.setval('art_interruptions_id_seq', 5, true);
--
-- Name: art_regimens; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE art_regimens (
id integer NOT NULL,
pid integer NOT NULL,
regimen_id integer NOT NULL,
art_line integer NOT NULL
);
--
-- Name: art_regimens_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE art_regimens_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: art_regimens_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE art_regimens_id_seq OWNED BY art_regimens.id;
--
-- Name: art_regimens_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--
SELECT pg_catalog.setval('art_regimens_id_seq', 28, true);
--
-- Name: art_second_line_reasons; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE art_second_line_reasons (
id integer NOT NULL,
name character varying NOT NULL,
description character varying,
comment character varying
);
--
-- Name: art_service_types; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE art_service_types (
id integer NOT NULL,
name character varying NOT NULL,
description character varying,
comment character varying
);
--
-- Name: art_service_types_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE art_service_types_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: art_service_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE art_service_types_id_seq OWNED BY art_service_types.id;
--
-- Name: art_service_types_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--
SELECT pg_catalog.setval('art_service_types_id_seq', 5, true);
--
-- Name: art_substitution_reasons; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE art_substitution_reasons (
id integer NOT NULL,
name character varying NOT NULL,
description character varying,
comment character varying
);
--
-- Name: art_substitutions; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE art_substitutions (
id integer NOT NULL,
pid integer NOT NULL,
regimen_id integer NOT NULL,
art_substitution_reason_id integer NOT NULL,
art_line integer NOT NULL,
date date
);
--
-- Name: art_substitutions_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE art_substitutions_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: art_substitutions_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE art_substitutions_id_seq OWNED BY art_substitutions.id;
--
-- Name: art_substitutions_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--
SELECT pg_catalog.setval('art_substitutions_id_seq', 34, true);
--
-- Name: educations; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE educations (
id integer NOT NULL,
name character varying NOT NULL,
description character varying,
comment character varying
);
--
-- Name: educations_id_seq; Type: SEQUENCE; Schema: public; Owner: -