-- Table: public.ProviderAvailabilityChargeType

 DROP TABLE IF EXISTS public."ProviderAvailabilityChargeType";

CREATE TABLE IF NOT EXISTS public."ProviderAvailabilityChargeType"
(
    "ProviderAvailabilityChargeTypeId" integer NOT NULL DEFAULT nextval('"ProviderAvailabilityChargeType_ProviderAvailabilityChargeTypeId"'::regclass),
    "ChargeTypesId" integer NOT NULL,
    "Charge" integer,
    "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,
    "ProviderId" integer,
    "LocationId" integer,
    "StartDate" timestamp(6) without time zone,
    "EndDate" timestamp(6) without time zone,
    "SpecializationId" integer,
    "ConsultationTypeId" integer,
    "PartsOfDayId" integer,
    CONSTRAINT "ProviderAvailabilityChargeType_pkey" PRIMARY KEY ("ProviderAvailabilityChargeTypeId"),
    CONSTRAINT "ProviderAvailabilityChargeType_ChargeTypesId_fkey" FOREIGN KEY ("ChargeTypesId")
        REFERENCES public."ChargeTypes" ("ChargeTypesId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "ProviderAvailabilityChargeType_ConsultationTypeId_fkey" FOREIGN KEY ("ConsultationTypeId")
        REFERENCES public."ConsultationType" ("ConsultationTypeId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "ProviderAvailabilityChargeType_LocationId_fkey" FOREIGN KEY ("LocationId")
        REFERENCES public."Location" ("LocationId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "ProviderAvailabilityChargeType_PartsOfDayId_fkey" FOREIGN KEY ("PartsOfDayId")
        REFERENCES public."PartsOfDay" ("PartsOfDayId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "ProviderAvailabilityChargeType_ProviderId_fkey" FOREIGN KEY ("ProviderId")
        REFERENCES public."Provider" ("ProviderId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "ProviderAvailabilityChargeType_SpecializationId_fkey" FOREIGN KEY ("SpecializationId")
        REFERENCES public."Specialization" ("SpecializationId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public."ProviderAvailabilityChargeType"
    OWNER to postgres;

COMMENT ON COLUMN public."ProviderAvailabilityChargeType"."ProviderAvailabilityChargeTypeId"
    IS ' ';
	
---------------------------------------------------------------------------------------------------------------------------------------
-- Table: public.ProviderAvailabilityVisitType

DROP TABLE IF EXISTS public."ProviderAvailabilityVisitType";

CREATE TABLE IF NOT EXISTS public."ProviderAvailabilityVisitType"
(
    "ProviderAvailabilityVisitTypeId" integer NOT NULL DEFAULT nextval('"ProviderAvailabilityVisitType_ProviderAvailabilityVisitTypeId_s"'::regclass),
    "VisitTypeId" integer NOT NULL,
    "Duration" integer,
    "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,
    "LocationId" integer,
    "ProviderId" integer,
    "SpecializationId" integer,
    CONSTRAINT "ProviderAvailabilityVisitType_pkey" PRIMARY KEY ("ProviderAvailabilityVisitTypeId"),
    CONSTRAINT "ProviderAvailabilityVisitType_LocationId_fkey" FOREIGN KEY ("LocationId")
        REFERENCES public."Location" ("LocationId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "ProviderAvailabilityVisitType_ProviderId_fkey" FOREIGN KEY ("ProviderId")
        REFERENCES public."Provider" ("ProviderId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "ProviderAvailabilityVisitType_SpecializationId_fkey" FOREIGN KEY ("SpecializationId")
        REFERENCES public."Specialization" ("SpecializationId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT "ProviderAvailabilityVisitType_VisitTypeId_fkey" FOREIGN KEY ("VisitTypeId")
        REFERENCES public."VisitType" ("VisitTypeId") MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public."ProviderAvailabilityVisitType"
    OWNER to postgres;

COMMENT ON COLUMN public."ProviderAvailabilityVisitType"."ProviderAvailabilityVisitTypeId"
    IS ' ';	
	