-- SEQUENCE: public.HowDidYouKnow_HowDidYouKnowId_seq

-- DROP SEQUENCE IF EXISTS public."HowDidYouKnow_HowDidYouKnowId_seq";

CREATE SEQUENCE IF NOT EXISTS public."HowDidYouKnow_HowDidYouKnowId_seq"
    INCREMENT 1
    START 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    CACHE 1;

ALTER SEQUENCE public."HowDidYouKnow_HowDidYouKnowId_seq"
    OWNER TO postgres;

-- Table: public.HowDidYouKnow

-- DROP TABLE IF EXISTS public."HowDidYouKnow";

CREATE TABLE IF NOT EXISTS public."HowDidYouKnow"
(
    "HowDidYouKnowId" integer NOT NULL DEFAULT nextval('"HowDidYouKnow_HowDidYouKnowId_seq"'::regclass),
    "Name" text COLLATE pg_catalog."default" NOT NULL,
    "Active" boolean NOT NULL DEFAULT true,
    "CreatedBy" integer NOT NULL,
    "CreatedDate" timestamp(6) without time zone NOT NULL,
    "ModifiedBy" integer,
    "ModifiedDate" timestamp(6) without time zone,
    CONSTRAINT "HowDidYouKnow_pkey" PRIMARY KEY ("HowDidYouKnowId"),
    CONSTRAINT "UQ_HowDidYouKnow_Name" UNIQUE ("Name")
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public."HowDidYouKnow"
    OWNER to postgres;
	
-- SEQUENCE: public.Education_EducationId_seq

-- DROP SEQUENCE IF EXISTS public."Education_EducationId_seq";

CREATE SEQUENCE IF NOT EXISTS public."Education_EducationId_seq"
    INCREMENT 1
    START 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    CACHE 1;

ALTER SEQUENCE public."Education_EducationId_seq"
    OWNER TO postgres;

-- Table: public.Education

-- DROP TABLE IF EXISTS public."Education";

CREATE TABLE IF NOT EXISTS public."Education"
(
    "EducationId" integer NOT NULL DEFAULT nextval('"Education_EducationId_seq"'::regclass),
    "Name" text COLLATE pg_catalog."default" NOT NULL,
    "Active" boolean NOT NULL DEFAULT true,
    "CreatedBy" integer NOT NULL,
    "CreatedDate" timestamp(6) without time zone NOT NULL,
    "ModifiedBy" integer,
    "ModifiedDate" timestamp(6) without time zone,
    CONSTRAINT "Education_pkey" PRIMARY KEY ("EducationId"),
    CONSTRAINT "UQ_Education_Name" UNIQUE ("Name")
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public."Education"
    OWNER to postgres;
	
-- SEQUENCE: public.Occupation_OccupationId_seq

-- DROP SEQUENCE IF EXISTS public."Occupation_OccupationId_seq";

CREATE SEQUENCE IF NOT EXISTS public."Occupation_OccupationId_seq"
    INCREMENT 1
    START 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    CACHE 1;

ALTER SEQUENCE public."Occupation_OccupationId_seq"
    OWNER TO postgres;

-- Table: public.Occupation

-- DROP TABLE IF EXISTS public."Occupation";

CREATE TABLE IF NOT EXISTS public."Occupation"
(
    "OccupationId" integer NOT NULL DEFAULT nextval('"Occupation_OccupationId_seq"'::regclass),
    "Name" text COLLATE pg_catalog."default" NOT NULL,
    "Active" boolean NOT NULL DEFAULT true,
    "CreatedBy" integer NOT NULL,
    "CreatedDate" timestamp(6) without time zone NOT NULL,
    "ModifiedBy" integer,
    "ModifiedDate" timestamp(6) without time zone,
    CONSTRAINT "Occupation_pkey" PRIMARY KEY ("OccupationId"),
    CONSTRAINT "UQ_Occupation_Name" UNIQUE ("Name")
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public."Occupation"
    OWNER to postgres;
----------------------------------------------------------	
ALTER TABLE "Patient" 
ADD COLUMN "HowDidYouKnowId" integer,
ADD COLUMN "EducationId" integer,
ADD COLUMN "OccupationId" integer;
-----------------------------------------------------------
ALTER TABLE "Patient"
ADD CONSTRAINT "Patient_HowDidYouKnowId_fkey" FOREIGN KEY ("HowDidYouKnowId")
        REFERENCES public."HowDidYouKnow" ("HowDidYouKnowId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
ADD CONSTRAINT "Patient_EducationId_fkey" FOREIGN KEY ("EducationId")
        REFERENCES public."Education" ("EducationId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
ADD CONSTRAINT "Patient_OccupationId_fkey" FOREIGN KEY ("OccupationId")
        REFERENCES public."Occupation" ("OccupationId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION;
-------------------------------------------------------------
INSERT INTO public."HowDidYouKnow"(
	"HowDidYouKnowId", "Name", "Active", "CreatedBy", "CreatedDate")
	VALUES (1, 'ABSOLUTE CURIOSITY', true, 6776, current_date),
	(2, 'FAMILY TRADITION', true, 6776, current_date),
	(3, 'HEARD FROM A COLLEAGUE/FRIEND', true, 6776, current_date),
	(4, 'NEWS PAPER', true, 6776, current_date),
	(5, 'PRACTO WEBSITE', true, 6776, current_date),
	(6, 'REFERRED BY COLLEAGUE', true, 6776, current_date),
	(7, 'REFERRED BY DOCTOR', true, 6776, current_date),
	(8, 'REFERRED BY FRIEND', true, 6776, current_date),
	(9, 'SECOND OPINION', true, 6776, current_date),
	(10, 'WEBSEARCH', true, 6776, current_date);
-----------------------------------------------------------
INSERT INTO public."Education"(
	"EducationId", "Name", "Active", "CreatedBy", "CreatedDate")
	VALUES (1, 'ANM', true, 6776, current_date),
	(2, 'B PHARMACY', true, 6776, current_date),
	(3, 'B TECH', true, 6776, current_date),
	(4, 'BDS', true, 6776, current_date),
	(5, 'Below 5th std', true, 6776, current_date),
	(6, 'Below 9th std', true, 6776, current_date),
	(7, 'Bsc Nursing', true, 6776, current_date),
	(8, 'DGO', true, 6776, current_date),
	(9, 'DNB', true, 6776, current_date),
	(10, 'Fellowship', true, 6776, current_date),
	(11, 'FRCOG', true, 6776, current_date),
	(12, 'FRCS', true, 6776, current_date),
	(13, 'GNM', true, 6776, current_date),
	(14, 'Graduate', true, 6776, current_date),
	(15, 'Intermediate', true, 6776, current_date),
	(16, 'M PHARMACY', true, 6776, current_date),
	(17, 'M phil', true, 6776, current_date),
	(18, 'M.TECH', true, 6776, current_date),
	(19, 'MBA', true, 6776, current_date),
	(20, 'MBBS', true, 6776, current_date),
	(21, 'MBBS & ABOVE', true, 6776, current_date),
	(22, 'MCA', true, 6776, current_date),
	(23, 'MD', true, 6776, current_date),
	(24, 'MDS', true, 6776, current_date),
	(25, 'Midwifery', true, 6776, current_date),
	(26, 'MRCOG', true, 6776, current_date),
	(27, 'MS', true, 6776, current_date),
	(28, 'Msc Nursing', true, 6776, current_date),
	(29, 'Not applicable', true, 6776, current_date),
	(30, 'PHD', true, 6776, current_date),
	(31, 'PHD in Nursing', true, 6776, current_date),
	(32, 'Postgraduate', true, 6776, current_date),
	(33, 'SSC', true, 6776, current_date),
	(34, 'Uneducated', true, 6776, current_date);
----------------------------------------------------------
INSERT INTO public."Occupation"(
	"OccupationId", "Name", "Active", "CreatedBy", "CreatedDate")
	VALUES (1, 'Accountant', true, 6776, current_date),
	(2, 'Air Hostess', true, 6776, current_date),
	(3, 'Architecht', true, 6776, current_date),
	(4, 'Army', true, 6776, current_date),
	(5, 'Barber', true, 6776, current_date),
	(6, 'Beautician', true, 6776, current_date),
	(7, 'BUMS', true, 6776, current_date),
	(8, 'Business', true, 6776, current_date),
	(9, 'Chairman', true, 6776, current_date),
	(10, 'Chef', true, 6776, current_date),
	(11, 'Counsellor', true, 6776, current_date),
	(12, 'Doctor', true, 6776, current_date),
	(13, 'Driver', true, 6776, current_date),
	(14, 'Engineer', true, 6776, current_date),
	(15, 'Farmer', true, 6776, current_date),
	(16, 'Front Office', true, 6776, current_date),
	(17, 'GOVT.EMPLOYEE', true, 6776, current_date),
	(18, 'HEAD NURSE', true, 6776, current_date),
	(19, 'Home Maker', true, 6776, current_date),
	(20, 'House Keeping', true, 6776, current_date),
	(21, 'HOUSEWIFE', true, 6776, current_date),
	(22, 'HR', true, 6776, current_date),
	(23, 'IAS/IPS', true, 6776, current_date),
	(24, 'Industrialist', true, 6776, current_date),
	(25, 'IT PROFESSIONAL', true, 6776, current_date),
	(26, 'Labourer', true, 6776, current_date),
	(27, 'Lawyer', true, 6776, current_date),
	(28, 'Lecturer', true, 6776, current_date),
	(29, 'LOBBY MANAGER', true, 6776, current_date),
	(30, 'MAINTAINANCE INCHARGE', true, 6776, current_date),
	(31, 'Manager', true, 6776, current_date),
	(32, 'Managing Director', true, 6776, current_date),
	(33, 'Mandal Revenue Officer', true, 6776, current_date),
	(34, 'Matron', true, 6776, current_date),
	(35, 'Mechanic', true, 6776, current_date),
	(36, 'Navy', true, 6776, current_date),
	(37, 'Nurse', true, 6776, current_date),
	(38, 'NURSING SUPRINDENT', true, 6776, current_date),
	(39, 'Occupationnm', true, 6776, current_date),
	(40, 'OFFICER', true, 6776, current_date),
	(41, 'OTHERS', true, 6776, current_date),
	(42, 'PERSONAL MANAGER', true, 6776, current_date),
	(43, 'Pharmacist', true, 6776, current_date),
	(44, 'Pilot', true, 6776, current_date),
	(45, 'Police Man', true, 6776, current_date),
	(46, 'Politician', true, 6776, current_date),
	(47, 'PRIVATE EMPLOYEE', true, 6776, current_date),
	(48, 'Professor', true, 6776, current_date),
	(49, 'Public Relation Officer', true, 6776, current_date),
	(50, 'Receptionist', true, 6776, current_date),
	(51, 'RETIRED', true, 6776, current_date),
	(52, 'Security', true, 6776, current_date),
	(53, 'Software Engineer', true, 6776, current_date),
	(54, 'SOFTWARE(IT)', true, 6776, current_date),
	(55, 'STUDENT', true, 6776, current_date),
	(56, 'SUPERVISOR', true, 6776, current_date),
	(57, 'Tailor', true, 6776, current_date),
	(58, 'Teacher', true, 6776, current_date),
	(59, 'Technician', true, 6776, current_date),
	(60, 'Unemployed', true, 6776, current_date),
	(61, 'WARD BOY', true, 6776, current_date),
	(62, 'WORKING ABROAD', true, 6776, current_date);
---------------------------------------------------------------