
-------------------------------------------------------------------------------------------------------------------------
create sequence "DoctorSpecializationMap_DoctorSpecializationMapId_seq"
--------------------------------------------------------------------------------------------
create table "DoctorSpecializationMap"(
	"DoctorSpecializationMapId" integer DEFAULT nextval('"DoctorSpecializationMap_DoctorSpecializationMapId_seq"'::regclass),
	"SpecializationId" int,
    "ConsultationTypeId" int,
    "ProviderId" int,
    "FollowUpDays" int,
    "FollowUpDaysLimit" int,
    CONSTRAINT "DoctorSpecializationMap_pkey" PRIMARY KEY ("DoctorSpecializationMapId"),
    CONSTRAINT "DoctorSpecializationMap_SpecializationId" FOREIGN KEY ("SpecializationId")
        REFERENCES public."Specialization" ("SpecializationId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "DoctorSpecializationMap_ConsultationTypeId_fkey" FOREIGN KEY ("ConsultationTypeId")
        REFERENCES public."ConsultationType" ("ConsultationTypeId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "DoctorSpecializationMap_ProviderId_fkey" FOREIGN KEY ("ProviderId")
        REFERENCES public."Provider" ("ProviderId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)
-------------------------------------------------------------------------------------------------------
DROP TABLE IF EXISTS public."DoctorSpecializationChargeModuleDetails";
-------------------------------------------------------------------------------------------------------
DROP TABLE IF EXISTS public."DoctorSpecializationChargeModuleCategory";
-------------------------------------------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS public."DoctorSpecializationChargeModuleCategory"
(
    "DoctorSpecializationChargeModuleCategoryId" integer NOT NULL DEFAULT nextval('"DoctorSpecializationChargeModuleCategory_DoctorSpecializationCh"'::regclass),
    "Active" boolean DEFAULT true,
    "ChargeTypesId" integer,
    "ModulesMasterId" integer,
    "ChargeModuleTemplateId" integer,
    "CreatedBy" integer,
    "CreatedDate" timestamp without time zone,
    "ModifiedBy" integer,
    "ModifiedDate" timestamp without time zone,
    CONSTRAINT "DoctorSpecializationChargeModuleCategory_pkey" PRIMARY KEY ("DoctorSpecializationChargeModuleCategoryId"),
    CONSTRAINT "DoctorSpecializationChargeModuleCategory_ChargeModuleTemplateId" FOREIGN KEY ("ChargeModuleTemplateId")
        REFERENCES public."ChargeModuleTemplate" ("ChargeModuleTemplateId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "DoctorSpecializationChargeModuleCategory_ChargeTypesId_fkey" FOREIGN KEY ("ChargeTypesId")
        REFERENCES public."ChargeTypes" ("ChargeTypesId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "DoctorSpecializationChargeModuleCategory_CreatedBy_fkey" FOREIGN KEY ("CreatedBy")
        REFERENCES public."Account" ("AccountId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "DoctorSpecializationChargeModuleCategory_ModifiedBy_fkey" FOREIGN KEY ("ModifiedBy")
        REFERENCES public."Account" ("AccountId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "DoctorSpecializationChargeModuleCategory_ModulesMasterId_fkey" FOREIGN KEY ("ModulesMasterId")
        REFERENCES public."ModulesMaster" ("ModulesMasterId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)

--------------------------------------------------------------------------------------------------------

CREATE TABLE IF NOT EXISTS public."DoctorSpecializationChargeModuleDetails"
(
    "DoctorSpecializationChargeModuleDetailsId" bigint NOT NULL DEFAULT nextval('"DoctorSpecializationChargeModuleDetails_DoctorSpecializationCha"'::regclass),
    "ReferenceId" integer not null,
    "DoctorSpecializationChargeModuleCategoryId" integer,
    "Amount" numeric(10,2),
    "LocationId" integer,
    "CreatedBy" integer,
    "CreatedDate" timestamp without time zone,
    "ModifiedBy" integer,
    "ModifiedDate" timestamp without time zone,
    CONSTRAINT "DoctorSpecializationChargeModuleDetails_pkey" PRIMARY KEY ("DoctorSpecializationChargeModuleDetailsId"),
    CONSTRAINT "DoctorSpecializationChargeModuleDetails_ReferenceId_fkey" FOREIGN KEY ("ReferenceId")
        REFERENCES public."DoctorSpecializationMap" ("DoctorSpecializationMapId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "DoctorSpecializationChargeModuleDetails_CreatedBy_fkey" FOREIGN KEY ("CreatedBy")
        REFERENCES public."Account" ("AccountId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "DoctorSpecializationChargeModuleDetails_DoctorSpecializationCha" FOREIGN KEY ("DoctorSpecializationChargeModuleCategoryId")
        REFERENCES public."DoctorSpecializationChargeModuleCategory" ("DoctorSpecializationChargeModuleCategoryId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "DoctorSpecializationChargeModuleDetails_LocationId_fkey" FOREIGN KEY ("LocationId")
        REFERENCES public."Location" ("LocationId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "DoctorSpecializationChargeModuleDetails_ModifiedBy_fkey" FOREIGN KEY ("ModifiedBy")
        REFERENCES public."Account" ("AccountId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)

---------------------------------------------------------------------------------------------------------
