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

ALTER SEQUENCE public."DietPlan_DietPlanId_seq"
    OWNER TO postgres;
	
-----------------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS public."DietPlan"
(
    "DietPlanId" integer NOT NULL DEFAULT nextval('"DietPlan_DietPlanId_seq"'::regclass),
    "AppointmentId" integer not NULL,
    "PatientId" integer not NULL,
    "DietGuidLinesId" integer not NULL,
	"EncounterType" text,
	"EncounterId" INTEGER,
    "Status" BOOLEAN,
    "CreatedBy" integer not NULL,
    "CreatedDate" timestamp without time zone,
    "ModifiedBy" INTEGER,
	"ModifiedDate" timestamp without time zone,
    "Active" boolean DEFAULT true,
    CONSTRAINT "DietPlan_pkey" PRIMARY KEY ("DietPlanId"),
    CONSTRAINT "FK_DietPlan_PatientId" FOREIGN KEY ("PatientId")
        REFERENCES public."Patient" ("PatientId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "FK_DietPlan_AppointmentId" FOREIGN KEY ("AppointmentId")
        REFERENCES public."Appointment" ("AppointmentId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
	CONSTRAINT "FK_DietPlan_DietGuidLinesId" FOREIGN KEY ("DietGuidLinesId")
        REFERENCES public."DietGuidLines" ("DietGuidLinesId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
	CONSTRAINT "FK_DietPlan_CreatedBy" FOREIGN KEY ("CreatedBy")
        REFERENCES public."Account" ("AccountId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "FK_DietPlan_ModifiedBy" FOREIGN KEY ("ModifiedBy")
        REFERENCES public."Account" ("AccountId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public."DietPlan"
    OWNER to postgres;	
	
------------------------------------------------------
CREATE SEQUENCE IF NOT EXISTS public."DietType_DietTypeId_seq"
    INCREMENT 1
    START 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    CACHE 1;

ALTER SEQUENCE public."DietType_DietTypeId_seq"
    OWNER TO postgres;
	
-----------------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS public."DietType"
(
    "DietTypeId" integer NOT NULL DEFAULT nextval('"DietType_DietTypeId_seq"'::regclass),
    "Name" text
    
)
----------------------------------------------------------
INSERT INTO "DietType" ("DietTypeId","Name")
VALUES (1, 'Diet'),(2,'Pediatric');	

------------------------------------------------
alter table "DietGuidLines" add column "DietTypeId" integer
	
	