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

CREATE TABLE IF NOT EXISTS public."MasterBill"
(
    "MasterBillId" integer NOT NULL DEFAULT nextval('"MasterBill_Seq"'::regclass),
    "PatientId" integer,
	"ModulesMasterId" integer NOT NULL,
	
    "Total" numeric(10,2) NOT NULL,    
	"BillDate" timestamp without time zone NOT NULL,
    "BillNumber" character varying COLLATE pg_catalog."default",
    "BillStatusTypeId" integer NOT NULL, 
	
    "CreatedBy" integer NOT NULL,
    "CreatedDate" timestamp without time zone NOT NULL,
    "ModifiedDate" timestamp without time zone,
    "ModifiedBy" integer,
    "Active" boolean NOT NULL DEFAULT true,
	
    CONSTRAINT "MasterBill_pkey" PRIMARY KEY ("MasterBillId"),
    CONSTRAINT "FK_Receipt_BillStatusTypeId" FOREIGN KEY ("BillStatusTypeId")
        REFERENCES public."BillStatusType" ("BillStatusTypeId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE CASCADE,
	CONSTRAINT "FK_Receipt_ModulesMasterId" FOREIGN KEY ("ModulesMasterId")
        REFERENCES public."ModulesMaster" ("ModulesMasterId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE CASCADE,
    CONSTRAINT "FK_Receipt_CreatedBy" FOREIGN KEY ("CreatedBy")
        REFERENCES public."Account" ("AccountId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE CASCADE,
    CONSTRAINT "FK_Receipt_ModifiedBy" FOREIGN KEY ("ModifiedBy")
        REFERENCES public."Account" ("AccountId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE CASCADE
    
)

TABLESPACE pg_default;
