Commit f0b314d4 authored by Sandeep Sagar Panjala's avatar Sandeep Sagar Panjala

initial commit

parent 3a1ccff9
ALTER TABLE public."Admission"
ADD COLUMN "CounsellingId" integer;
ALTER TABLE public."Admission"
ADD CONSTRAINT "FK_Admission_CounsellingId" FOREIGN KEY ("CounsellingId")
REFERENCES public."Counselling" ("CounsellingId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE CASCADE;
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
create table "CallHistory" (
"Id" SERIAL PRIMARY KEY,
"MobileNumber" VARCHAR,
"FirstName" VARCHAR,
"LastName" VARCHAR,
"Comments" VARCHAR,
"CallStart" text,
"CallEnd" text,
"CallDuration" text,
"Status" boolean,
"Type" integer,
"CreatedDate" timestamp without time zone,
"CreatedBy" integer,
"ModifiedBy" integer,
"ModifiedDate" timestamp without time zone,
"IsActive" boolean NOT NULL
);
\ No newline at end of file
create table "ContactDetails" (
"Id" SERIAL PRIMARY KEY,
"Details" text,
"PatientId" integer,
"Type" integer,
"CreatedDate" timestamp without time zone,
"CreatedBy" integer,
"ModifiedBy" integer,
"ModifiedDate" timestamp without time zone,
"IsActive" boolean NOT NULL
);
\ No newline at end of file
create table "FeedbackDetails" (
"Id" SERIAL PRIMARY KEY,
"MobileNumber" VARCHAR,
"PatientName" VARCHAR,
"Rating" integer,
"Comments" VARCHAR,
"Type" integer,
"CreatedDate" timestamp without time zone,
"CreatedBy" integer,
"ModifiedBy" integer,
"ModifiedDate" timestamp without time zone,
"IsActive" boolean NOT NULL
);
\ No newline at end of file
INSERT INTO "HowDidYouKnow"("Name", "Active", "CreatedBy","CreatedDate")
VALUES ('CALL CENTER', 'true', '6776', '2022-11-28 00:00:00' );
\ No newline at end of file
Alter table "FinalBillServiceOrder" add column "PackageModuleId" integer;
ALTER TABLE public."FinalBillServiceOrder"
ADD CONSTRAINT "FK_FinalBillServiceOrder_PackageModuleId" FOREIGN KEY ("PackageModuleId")
REFERENCES public."PackageModule" ("PackageModuleId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE CASCADE;
\ No newline at end of file
-- ----------------------------
-- Table structure for MenuButton
-- ----------------------------
DROP TABLE IF EXISTS "public"."MenuButton";
CREATE SEQUENCE "MenuButton_MenuButtonId_seq";
CREATE TABLE "public"."MenuButton" (
"MenuButtonId" int4 NOT NULL DEFAULT nextval('"MenuButton_MenuButtonId_seq"'::regclass),
"Code" varchar(6) COLLATE "pg_catalog"."default" NOT NULL,
"Name" varchar(255) COLLATE "pg_catalog"."default" NOT NULL,
"MenuId" int4 NOT NULL
)
;
ALTER TABLE "public"."MenuButton" OWNER TO "postgres";
-- ----------------------------
-- Primary Key structure for table MenuButton
-- ----------------------------
ALTER TABLE "public"."MenuButton" ADD CONSTRAINT "MenuButton_pkey" PRIMARY KEY ("MenuButtonId");
-- ----------------------------
-- Foreign Keys structure for table MenuButton
-- ----------------------------
ALTER TABLE "public"."MenuButton" ADD CONSTRAINT "FK_MenuButton_MenuId" FOREIGN KEY ("MenuId") REFERENCES "public"."Menu" ("MenuId") ON DELETE NO ACTION ON UPDATE NO ACTION;
-- ----------------------------
-- Table structure for MenuButtonRelationship
-- ----------------------------
DROP TABLE IF EXISTS "public"."MenuButtonRelationship";
CREATE SEQUENCE "MenuButtonRelationship_MenuButtonRelationshipId_seq";
CREATE TABLE "public"."MenuButtonRelationship" (
"MenuButtonRelationshipId" int4 NOT NULL DEFAULT nextval('"MenuButtonRelationship_MenuButtonRelationshipId_seq"'::regclass),
"RoleId" int4 NOT NULL,
"MenuButtonId" int4 NOT NULL
)
;
ALTER TABLE "public"."MenuButtonRelationship" OWNER TO "postgres";
-- ----------------------------
-- Primary Key structure for table MenuButtonRelationship
-- ----------------------------
ALTER TABLE "public"."MenuButtonRelationship" ADD CONSTRAINT "MenuButtonRelationship_pkey" PRIMARY KEY ("MenuButtonRelationshipId");
-- ----------------------------
-- Foreign Keys structure for table MenuButtonRelationship
-- ----------------------------
ALTER TABLE "public"."MenuButtonRelationship" ADD CONSTRAINT "FK_MenuButton_MenuButtonId" FOREIGN KEY ("MenuButtonId") REFERENCES "public"."MenuButton" ("MenuButtonId") ON DELETE NO ACTION ON UPDATE NO ACTION;
ALTER TABLE "public"."MenuButtonRelationship" ADD CONSTRAINT "FK_MenuButton_RoleId" FOREIGN KEY ("RoleId") REFERENCES "public"."Role" ("RoleId") ON DELETE NO ACTION ON UPDATE NO ACTION;
-- ALTER TABLE IF EXISTS public."ServiceOrder" DROP COLUMN IF EXISTS "AdmissionPackageId";
ALTER TABLE IF EXISTS public."ServiceOrder"
ADD COLUMN "AdmissionPackageId" integer;
-- ALTER TABLE IF EXISTS public."ServiceOrder" DROP COLUMN IF EXISTS "PackageModuleDetailId";
ALTER TABLE IF EXISTS public."ServiceOrder"
ADD COLUMN "PackageModuleDetailId" integer;
-- ALTER TABLE IF EXISTS public."ServiceOrder" DROP COLUMN IF EXISTS "UsedQuantity";
ALTER TABLE IF EXISTS public."ServiceOrder"
ADD COLUMN "UsedQuantity" integer;
-- ALTER TABLE IF EXISTS public."ServiceOrder" DROP COLUMN IF EXISTS "UsedCost";
ALTER TABLE IF EXISTS public."ServiceOrder"
ADD COLUMN "UsedCost" numeric(10,2);
-- ALTER TABLE IF EXISTS public."ServiceOrder" DROP CONSTRAINT IF EXISTS "FK_ServiceOrder_AdmissionPackageId";
ALTER TABLE IF EXISTS public."ServiceOrder"
ADD CONSTRAINT "FK_ServiceOrder_AdmissionPackageId" FOREIGN KEY ("AdmissionPackageId")
REFERENCES public."AdmissionPackage" ("AdmissionPackageId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID;
-- ALTER TABLE IF EXISTS public."ServiceOrder" DROP CONSTRAINT IF EXISTS "FK_ServiceOrder_PackageModuleDetailId";
ALTER TABLE IF EXISTS public."ServiceOrder"
ADD CONSTRAINT "FK_ServiceOrder_PackageModuleDetailId" FOREIGN KEY ("PackageModuleDetailId")
REFERENCES public."PackageModuleDetail" ("PackageModuleDetailId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID;
\ No newline at end of file
-- ALTER TABLE IF EXISTS public."ServiceOrder" DROP COLUMN IF EXISTS "AdmissionPackageId";
ALTER TABLE IF EXISTS public."LabServices"
ADD COLUMN "AdmissionPackageId" integer;
-- ALTER TABLE IF EXISTS public."ServiceOrder" DROP COLUMN IF EXISTS "PackageModuleDetailId";
ALTER TABLE IF EXISTS public."LabServices"
ADD COLUMN "PackageModuleDetailId" integer;
-- ALTER TABLE IF EXISTS public."ServiceOrder" DROP COLUMN IF EXISTS "UsedQuantity";
ALTER TABLE IF EXISTS public."LabServices"
ADD COLUMN "UsedQuantity" integer;
-- ALTER TABLE IF EXISTS public."ServiceOrder" DROP COLUMN IF EXISTS "UsedCost";
ALTER TABLE IF EXISTS public."LabServices"
ADD COLUMN "UsedCost" numeric(10,2);
-- ALTER TABLE IF EXISTS public."ServiceOrder" DROP CONSTRAINT IF EXISTS "FK_ServiceOrder_AdmissionPackageId";
ALTER TABLE IF EXISTS public."LabServices"
ADD CONSTRAINT "FK_LabServices_AdmissionPackageId" FOREIGN KEY ("AdmissionPackageId")
REFERENCES public."AdmissionPackage" ("AdmissionPackageId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID;
-- ALTER TABLE IF EXISTS public."ServiceOrder" DROP CONSTRAINT IF EXISTS "FK_ServiceOrder_PackageModuleDetailId";
ALTER TABLE IF EXISTS public."LabServices"
ADD CONSTRAINT "FK_LabServices_PackageModuleDetailId" FOREIGN KEY ("PackageModuleDetailId")
REFERENCES public."PackageModuleDetail" ("PackageModuleDetailId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID;
\ No newline at end of file
----ran this query in QA, UAT, IVF------
INSERT INTO public."Settings"(
"Name", "Active", "Type", "Value", "ImageUrl", "Description", "Numeral")
VALUES ( 'AppointmentReschedule', true, 'Appointment', null, null, 'Choose to Enable/Disable the reschedule button in mobile applications and patient web application.', null);
INSERT INTO public."Settings"(
"Name", "Active", "Type", "Value", "ImageUrl", "Description", "Numeral")
VALUES ( 'AppointmentCancel', true, 'Appointment', null, null, 'Choose to enable/disable Appointment Cancel Buttion for mobile applications and patient web application', null);
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
CREATE SEQUENCE IF NOT EXISTS public."GatePassType_Seq"
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 9223372036854775807
CACHE 1;
-------------------------
CREATE TABLE IF NOT EXISTS public."GatePassType"
(
"GatePassTypeId" integer NOT NULL DEFAULT nextval('"GatePassType_Seq"'::regclass),
"Name" character varying(50) COLLATE pg_catalog."default" NOT NULL,
"Active" boolean NOT NULL DEFAULT true,
CONSTRAINT "GatePassType_pkey" PRIMARY KEY ("GatePassTypeId")
)
TABLESPACE pg_default;
----------------------------------
insert into "GatePassType"("Name","Active") values('Provisional',true);
insert into "GatePassType"("Name","Active") values('Final',true);
---------------------------------
ALTER TABLE "GatePass"
ADD COLUMN "TypeId" integer not null DEFAULT 2;
ALTER TABLE "GatePass"
ADD CONSTRAINT "FK_GatePass_TypeId" FOREIGN KEY ("TypeId")
REFERENCES public."GatePassType" ("GatePassTypeId") ;
--------------------------------------------
alter table "BookScanAppointment"
add column "ProviderId" integer Null,
ADD CONSTRAINT "FK_BookScanAppointment_ProviderId" FOREIGN KEY ("ProviderId")
REFERENCES public."Provider" ("ProviderId") ;
\ No newline at end of file
alter table public."PharmacyProduct" drop column if exists "MaxQuantity",
drop column if exists "MinQuantity",drop column if exists "RolQuantity",
drop column if exists "RackId",drop column if exists "Pharmacy_Source";
alter table public."PharmacyProduct" add column if not exists "Potency" text,
add column if not exists "DrugRiskId" int references "LookupValue"("LookupValueId"),
add column if not exists "Dosage" text,add column if not exists "Formula" text,
add column if not exists "NABHCategoryId" int references "LookupValue"("LookupValueId"),
add column if not exists "DosageTypeId" int references "LookupValue"("LookupValueId"),
add column if not exists "Strength" text,add column if not exists "FixedDose" numeric,
add column if not exists "MedFrequencyMasterId" int references public."MedFrequencyMaster"("MedFrequencyMasterId"),
add column if not exists "NoOfTimes" int,add column if not exists "SaleLoose" boolean,
add column if not exists "InventoryExpiry" int,add column if not exists "FormulationId" int references "LookupValue"("LookupValueId"),
add column if not exists "MedRouteId" int references "LookupValue"("LookupValueId");
insert into "Lookup" ("Name","Description")
values
('PharmacyDrugRisk', 'For pharmacy drug risks');
insert into "LookupValue" ("LookupId","Name","CreatedBy", "CreatedDate")
values
((select "LookupId" from "Lookup" where "Name"= 'PharmacyDrugRisk'),'Low Risk',1029, now()),
((select "LookupId" from "Lookup" where "Name"= 'PharmacyDrugRisk'),'Medium Risk',1029, now()),
((select "LookupId" from "Lookup" where "Name"= 'PharmacyDrugRisk'),'High Risk',1029, now());
insert into "Lookup" ("Name","Description")
values
('NABHCategory', 'For NABH Authority');
insert into "LookupValue" ("LookupId","Name","CreatedBy", "CreatedDate")
values
((select "LookupId" from "Lookup" where "Name"= 'NABHCategory'),'Vital',1029, now()),
((select "LookupId" from "Lookup" where "Name"= 'NABHCategory'),'Essential',1029, now()),
((select "LookupId" from "Lookup" where "Name"= 'NABHCategory'),'Desirable',1029, now());
insert into "Lookup" ("Name","Description")
values
('PharmacyDosageType', 'To set dose for pharmacy product');
insert into "LookupValue" ("LookupId","Name","CreatedBy", "CreatedDate")
values
((select "LookupId" from "Lookup" where "Name"= 'PharmacyDosageType'),'Regular Items',1029, now()),
((select "LookupId" from "Lookup" where "Name"= 'PharmacyDosageType'),'Weight Wise',1029, now()),
((select "LookupId" from "Lookup" where "Name"= 'PharmacyDosageType'),'Age Wise',1029, now());
insert into "Lookup" ("Name","Description")
values
('PharmacyFormulation', 'To set formulation for pharmacy product');
alter table public."PharmacyProduct" add column if not exists "AlchoholInteraction" text,
add column if not exists "PregnancyInteraction" text,
add column if not exists "ExpertAdvice" text,
add column if not exists "CommonSideEffects" text,
add column if not exists "MedicineFaq" text,
add column if not exists "MedicineInteraction" text,
add column if not exists "Usage" text;
create table public."VaccineAgeGroup"(
"VaccineAgeGroupId" serial primary key,
"AgeGroupName" text
);
insert into public."VaccineAgeGroup"( "AgeGroupName")
values
('At Birth'),
('1 to 6 Weeks'),
('7 to 10 Weeks'),
('3 to 4 Months'),
('5 to 6 Months'),
('7 to 8 Months'),
('8 to 9 Months'),
('10 to 11 Months'),
('12 to 13 Months'),
('13 to 15 Months'),
('16 to 17 Months'),
('17 to 18 Months'),
('2 to 4 Years'),
('4 to 6 Years'),
('6 to 9 Years'),
('10 to 12 Years'),
('12 to 18 Years'),
('18 to 100 Years');
alter table public."VaccineMaster" add column if not exists "VaccineAgeGroupId" int references "VaccineAgeGroup"("VaccineAgeGroupId");
drop table "VaccineMasterPharmacyLink" ;
create table public."VaccinePharmacyLinkHeader"(
"VaccinePharmacyLinkHeaderId" serial primary key,
"PharmacyProductId" int references "PharmacyProduct"("PharmacyProductId"),
"CreatedBy" int references "Account"("AccountId"),
"CreatedDate" timestamp without time zone,
"ModifiedBy" int references "Account"("AccountId"),
"ModifiedDate" timestamp without time zone
);
create table public."VaccinePharmacyLinkDetail"(
"VaccinePharmacyLinkDetailId" serial primary key,
"VaccinePharmacyLinkHeaderId" int references "VaccinePharmacyLinkHeader"("VaccinePharmacyLinkHeaderId"),
"VaccineMasterId" int references "VaccineMaster"("VaccineMasterId")
);
create table public."ImmunizationHistory"(
"ImmunizationHistoryId" serial primary key,
"PharmacyProductId" int references "PharmacyProduct"("PharmacyProductId"),
"VaccineMasterId" int references "VaccineMaster"("VaccineMasterId"),
"ProductName" text,
"BillNumber" varchar(300),
"BatchNumber" varchar(300),
"ExpiryDate" date,
"CreatedBy" int references "Account"("AccountId"),
"CreatedDate" timestamp without time zone
);
alter table public."ImmunizationHistory" add column if not exists
"Status" varchar(50);
alter table public."ImmunizationHistory" add column if not exists
"PatientId" int references "Patient"("PatientId");
alter table "ImmunizationHistory"
add column if not exists "VaccineGivenBy" int references "Account"("AccountId"),
add column if not exists "VaccineGivenDate" timestamp without time zone;
alter table "PediatricEncounter" add column if not exists "VaccineDetail" text;
UPDATE public."Menu"
SET "EncounterKey"='vaccineDetail'
where "Url"='/app/pediatric-encounter/:id/:type/immunization';
alter table "PediatricAgeWiseData"
add column if not exists "M" numeric,
add column if not exists "L" numeric,
add column if not exists "P999" numeric,
add column if not exists "P01" numeric,
add column if not exists "P10" numeric,
add column if not exists "P90" numeric,
add column if not exists "S" numeric,
add column if not exists "Minus3SD" numeric,
add column if not exists "Minus2SD" numeric,
add column if not exists "Minus1SD" numeric,
add column if not exists "Median" numeric,
add column if not exists "1SD" numeric,
add column if not exists "2SD" numeric,
add column if not exists "3SD" numeric;
create table vendors."SupplierProductHeader"(
"SupplierProductHeaderId" serial primary key,
"SupplierId" int references "Supplier"("SupplierId"),
"StartDate" timestamp without time zone,
"EndDate" timestamp without time zone,
"CreatedBy" int references "Account"("AccountId"),
"CreatedDate" timestamp without time zone,
"ModifiedBy" int references "Account"("AccountId"),
"ModifiedDate" timestamp without time zone
);
create table vendors."SupplierProductFormulation"(
"SupplierProductFormulationId" serial primary key,
"SupplierProductHeaderId" int references vendors."SupplierProductHeader"("SupplierProductHeaderId"),
"Operator" varchar(50),
"Condition" varchar(50),
"FOCQuantity" int
);
CREATE TABLE if not exists vendors."SupplierProductDetail" (
"SupplierProductDetailId" serial primary key,
"SupplierProductHeaderId" int ,
"PharmacyProductId" int ,
"PurchaseRate" numeric ,
"Mrp" numeric
);
ALTER TABLE vendors."SupplierProductDetail" ADD CONSTRAINT if not exists "SupplierProductDetail_PharmacyProductId_fkey" FOREIGN KEY ("PharmacyProductId") REFERENCES public."PharmacyProduct"("PharmacyProductId");
ALTER TABLE vendors."SupplierProductDetail" ADD CONSTRAINT if not exists "SupplierProductDetail_SupplierProductHeaderId_fkey" FOREIGN KEY ("SupplierProductHeaderId") REFERENCES vendors."SupplierProductHeader"("SupplierProductHeaderId");
alter table vendors."PharmacyProductApproval" add column if not exists "Free" int;
alter table vendors."PurchaseOrderDetail" add column if not exists "Free" int;
alter table public."PharmacyProduct" add column "InventoryItem" boolean default false;
create table public."PharmacyInPatientReturn"(
"PharmacyInPatientReturnId" bigserial primary key,
"PharmacyIssueDetailId" int references "PharmacyIssueDetail"("PharmacyIssueDetailId"),
"ReturnQuantity" int,
"CreatedBy" int references "Account"("AccountId"),
"CreatedDate" timestamp without time zone,
"AcceptedBy" int references "Account"("AccountId"),
"AcceptedDate" timestamp without time zone
);
alter table "PharmacyIssueDetail" add column "PharmacyIndentDetailId" int references "PharmacyIndentDetail"("PharmacyIndentDetailId");
\ No newline at end of file
1. Keep all your development Queries into "1. QA" folder
2. Person who moved to QA run all the scripts from "1. QA" once done move those scripts to "2. Prod"
3. person who moved to prod run all the scripts from "2. Prod" once done move those scripts to "3. Complete"
ALTER TABLE "FinalBillServiceOrder" ADD COLUMN "Discount" numeric(10,2) DEFAULT 0;
\ No newline at end of file
This diff is collapsed.
DROP TABLE IF EXISTS vendors."PharmacyProductApproval";
CREATE TABLE vendors."PharmacyProductApproval" (
"PharmacyProductApprovalId" bigserial NOT NULL,
"PharmacyProductId" int4 NULL,
"PharmacyStockId" int4 NULL,
"PurchaseRate" numeric NULL,
"Mrp" numeric NULL,
"SupplierId" int4 NULL,
"TenderStatusId" int4 NULL,
"PharmacyProductRequestId" int4 NULL,
"CreatedBy" int4 NULL,
"CreatedDate" timestamp NULL,
CONSTRAINT "PharmacyProductApproval_pkey" PRIMARY KEY ("PharmacyProductApprovalId"),
CONSTRAINT "PharmacyProductApproval_CreatedBy_fkey" FOREIGN KEY ("CreatedBy") REFERENCES public."Account"("AccountId"),
CONSTRAINT "PharmacyProductApproval_PharmacyProductId_fkey" FOREIGN KEY ("PharmacyProductId") REFERENCES public."PharmacyProduct"("PharmacyProductId"),
CONSTRAINT "PharmacyProductApproval_PharmacyProductRequestId_fkey" FOREIGN KEY ("PharmacyProductRequestId") REFERENCES vendors."PharmacyProductRequest"("PharmacyProductRequestId"),
CONSTRAINT "PharmacyProductApproval_PharmacyStockId_fkey" FOREIGN KEY ("PharmacyStockId") REFERENCES public."PharmacyStock"("PharmacyStockId"),
CONSTRAINT "PharmacyProductApproval_SupplierId_fkey" FOREIGN KEY ("SupplierId") REFERENCES public."Supplier"("SupplierId"),
CONSTRAINT "PharmacyProductApproval_TenderStatusId_fkey" FOREIGN KEY ("TenderStatusId") REFERENCES vendors."TendorStatus"("TenderStatusId")
);
insert into vendors."TendorStatus" ("Status")
values ('Moved To Tender');
-------------
create table vendors."TenderRequestSupplierHeader"(
"TenderRequestSupplierHeaderId" bigserial primary key,
"TenderStatusId" int references vendors."TendorStatus"("TenderStatusId"),
"TenderRaisedBy" int references "Account"("AccountId"),
"SupplierId" int references "Supplier"("SupplierId"),
"TenderRaisedDate" timestamp without time zone,
"IsCompleteAccepted" boolean default false,
"AcceptedDate" timestamp without time zone,
"IsCompleteRejected" boolean default false,
"CompleteRejectedDate" timestamp without time zone ,
"CompleteRejectionComment" text
);
create table vendors."TenderRequestSupplierDetail"(
"TenderRequestSupplierDetailId" bigserial primary key,
"TenderRequestSupplierHeaderId" bigint references vendors."TenderRequestSupplierHeader"("TenderRequestSupplierHeaderId"),
"PharmacyProductApprovalId" bigint references vendors."PharmacyProductApproval"("PharmacyProductApprovalId"),
"VendorMrp" numeric,
"VendorPurchaseRate" numeric,
"TenderStatusId" int references vendors."TendorStatus"("TenderStatusId"),
"VendorRejected" boolean default false,
"VendorRejectedDate" timestamp without time zone,
"RejectionComment" text
);
-------
insert into vendors."TendorStatus" ("Status")
values ('Pending Vendor Acceptance');
insert into vendors."TendorStatus" ("Status")
values ('PO Sent');
-----------
\ No newline at end of file
insert into vendors."TendorStatus" ("Status") values
('VendorAccepted'),
('VendorRejected'),
('PartialAccepted');
create table "PharmacyProductType"(
"PharmacyProductTypeId" serial primary key,
"TypeName" text,
"Active" boolean,
"CreatedBy" int references "Account"("AccountId"),
"CreatedDate" timestamp without time zone,
"ModifiedBy" int references "Account"("AccountId"),
"ModifiedDate" timestamp without time zone
);
alter table "PharmacyProductType" add column "IsGeneralItem" boolean default false;
create table "PharmacyProductSubType"(
"PharmacyProductSubTypeId" serial primary key,
"PharmacyProductTypeId" int references "PharmacyProductType"("PharmacyProductTypeId"),
"SubTypeName" text,
"Active" boolean,
"CreatedBy" int references "Account"("AccountId"),
"CreatedDate" timestamp without time zone,
"ModifiedBy" int references "Account"("AccountId"),
"ModifiedDate" timestamp without time zone
);
alter table "PharmacyProduct" add column "StorageTypeId" int references "LookupValue"("LookupValueId"),
add column "PharmacyProductTypeId" int references "PharmacyProductType"("PharmacyProductTypeId"),
add column "PharmacyProductSubTypeId" int references "PharmacyProductSubType"("PharmacyProductSubTypeId");
alter table "PharmacyProduct"
add column "OnlyConsumable" boolean default false;
alter table vendors."TenderRequestSupplierDetail" add column if not exists "VendorQuantity" int;
create table if not exists vendors."IncomingQuotationHeader"(
"IncomingQuotationHeaderId" bigserial primary key,
"TenderRequestSupplierHeaderId" bigint references vendors."TenderRequestSupplierHeader"("TenderRequestSupplierHeaderId"),
"TenderStatusId" int references vendors."TendorStatus"("TenderStatusId"),
"DeliveryDate" date,
"RaisedBy" int references "Account"("AccountId"),
"RaisedDate" timestamp without time zone,
"ApprovedBy" int references "Account"("AccountId"),
"ApprovedDate" timestamp without time zone
);
create table if not exists vendors."IncomingQuotationDetail"(
"IncomingQuotationDetailId" bigserial primary key,
"IncomingQuotationHeaderId" bigint references vendors."IncomingQuotationHeader"("IncomingQuotationHeaderId"),
"TenderRequestSupplierDetailId" bigint references vendors."TenderRequestSupplierDetail"("TenderRequestSupplierDetailId")
);
alter table vendors."PharmacyProductRequest" drop column if exists "PharmacyStockId", drop column if exists "RolStocksId";
alter table vendors."PharmacyProductRequest" add column if not exists "PharmacyWareHouseId" int references "PharmacyWareHouse"("PharmacyWareHouseId");
alter table vendors."PharmacyProductApproval" drop column if exists "PharmacyStockId";
alter table vendors."PharmacyProductApproval" add column if not exists "PharmacyWareHouseId" int references "PharmacyWareHouse"("PharmacyWareHouseId");
alter table "Supplier" add column if not exists "DeliverDays" int ;
alter table vendors."PharmacyProductApproval" add column if not exists "Quantity" int;
create table vendors."PurchaseOrderHeader"(
"PurchaseOrderHeaderId" bigserial primary key,
"PONumber" varchar(250),
"PORaiseDate" timestamp without time zone,
"EstimatedDeliveryDate" date,
"CreatedBy" int references "Account"("AccountId"),
"CreatedDate" timestamp without time zone,
"TenderStatusId" int references vendors."TendorStatus"("TenderStatusId"),
"TotalAmount" numeric,
"TotalTax" numeric,
"TotalNetAmount" numeric,
"SupplierId" int references "Supplier"("SupplierId"),
"PharmacyWareHouseId" int references "PharmacyWareHouse"("PharmacyWareHouseId")
);
create table vendors."PurchaseOrderDetail"(
"PurchaseOrderDetailId" bigserial primary key,
"PurchaseOrderHeaderId" bigint references vendors."PurchaseOrderHeader"("PurchaseOrderHeaderId"),
"PharmacyProductApprovalId" bigint references vendors."PharmacyProductApproval"("PharmacyProductApprovalId"),
"Quantity" int ,
"Amount" numeric,
"TaxAmount" numeric,
"NetAmount" numeric
);
alter table "PharmacyPurchaseHeader" add column "PurchaseOrderHeaderId" bigint references vendors."PurchaseOrderHeader"("PurchaseOrderHeaderId");
alter table "PharmacyPurchaseDetail" add column "PurchaseOrderDetailId" bigint references vendors."PurchaseOrderDetail"("PurchaseOrderDetailId");
insert into vendors."TendorStatus"("Status") values
('Partial PO'),
('Completed') ;
alter table vendors."PurchaseOrderDetail" add column if not exists "IsAddedByGrn" bool default false;
------------latest--------
insert into vendors."TendorStatus" ("Status") values ('Awaits Approval');
alter table vendors."PharmacyProductRequest"
add column if not exists "ApprovalGivenBy" int references "Account"("AccountId"),
add column if not exists "ApprovalGivenDate" timestamp without time zone;
--- 20 07 23
drop table if exists vendors."TenderRequestSupplierDetail" ;
drop table if exists vendors."TenderRequestSupplierHeader" ;
drop table if exists vendors."IncomingQuotationDetail" ;
drop table if exists vendors."IncomingQuotationHeader" ;
\ No newline at end of file
create table if not exists vendors."ProductForQuotationHeader"(
"ProductForQuotationHeaderId" bigserial primary key,
"QuotationNumber" text,
"CreatedBy" int references "Account"("AccountId"),
"CreatedDate" timestamp without time zone,
"TenderStatusId" int references vendors."TendorStatus"("TenderStatusId")
);
create table if not exists vendors."ProductForQuotationDetail"(
"ProductForQuotationDetailId" bigserial primary key,
"PharmacyProductApprovalId" bigint references vendors."PharmacyProductApproval"("PharmacyProductApprovalId"),
"ProductForQuotationHeaderId" bigint references vendors."ProductForQuotationHeader"("ProductForQuotationHeaderId"),
"TenderStatusId" int references vendors."TendorStatus"("TenderStatusId")
);
insert into vendors."TendorStatus" ("Status") values ('Waiting For Quotation');
\ No newline at end of file
drop table if exists vendors."IncomingQuotationDetail";
drop table if exists vendors."IncomingQuotationHeader";
------------
drop table if exists vendors."TenderRequestSupplierDetail";
drop table if exists vendors."TenderRequestSupplierHeader";
---------------------
create table if not exists vendors."IncomingQuotationHeader"(
"IncomingQuotationHeaderId" bigserial primary key,
"ProductForQuotationHeaderId" bigint references vendors."ProductForQuotationHeader",
"SupplierId" int references public."Supplier"("SupplierId"),
"CreatedBy" int references "Account"("AccountId"),
"CreatedDate" timestamp without time zone,
"ModifiedBy" int references "Account"("AccountId"),
"ModifiedDate" timestamp without time zone,
"IsFinalized" boolean default false,
"FinalizedBy" int references "Account"("AccountId"),
"FinalizedDate" timestamp without time zone,
"DeliveryDate" date,
"TotalAmount" numeric,
"TotalTax" numeric,
"TotalNetAmount" numeric,
"TotalDiscount" numeric
);
create table if not exists vendors."IncomingQuotationDetail"(
"IncomingQuotationDetailId" bigserial primary key,
"PharmacyProductApprovalId" bigint references vendors."PharmacyProductApproval"("PharmacyProductApprovalId"),
"IncomingQuotationHeaderId" bigint references vendors."IncomingQuotationHeader"("IncomingQuotationHeaderId"),
"ProductForQuotationDetailId" bigint references vendors."ProductForQuotationDetail"("ProductForQuotationDetailId"),
"PharmacyProductId" int references public."PharmacyProduct"("PharmacyProductId"),
"Tax" int,
"PurchaseRate" numeric,
"MRP" numeric,
"Amount" numeric,
"TaxAmount" numeric,
"DiscountPercentage" numeric,
"DiscountAmount" numeric,
"NetAmount" numeric,
"Quantity" int,
"Free" int
);
----------
insert into vendors."TendorStatus" ("Status") values ('Quoatation Received');
alter table vendors."SupplierProductFormulation" drop column if exists "SupplierProductHeaderId";
alter table vendors."SupplierProductFormulation" add column if not exists "SupplierProductDetailId" int references vendors."SupplierProductDetail"("SupplierProductDetailId");
-----
alter table vendors."SupplierProductHeader" add column if not exists "RateCardUrl" text;
------
drop TABLE if exists public."InventoryRequest";
drop TABLE if exists public."CpxRelatedToDepartment";
drop TABLE if exists public."RequestDepartment";
drop TABLE if exists public."TicketType";
----------
create table vendors."InventoryProductRequest"(
"InventoryProductRequestId" serial primary key,
"PharmacyProductId" int references "PharmacyProduct"("PharmacyProductId"),
"RequestProductName" text,
"ReasonForRequest" text,
"RequestedQuantity" int,
"RequestType" varchar(50),
"CreatedBy" int references "Account"("AccountId"),
"CreatedDate" timestamp without time zone,
"PharmacyProductRequestId" bigint references vendors."PharmacyProductRequest"("PharmacyProductRequestId"),
"RejectedBy" int references "Account"("AccountId"),
"RejectedDate" timestamp without time zone,
"RejectReason" text
);
alter table vendors."InventoryProductRequest" add column if not exists "ModifiedBy" int references "Account"("AccountId"),
add column if not exists "ModifiedDate" timestamp without time zone,add column if not exists "DocumentUrl" text,
add column if not exists "LocationId" int references "Location"("LocationId");
alter table vendors."PharmacyProductRequest" add column if not exists "RequestedQuantity" int default null;
----
INSERT INTO vendors."TendorStatus" ("Status")
SELECT 'Quotation Selected' as "Status"
WHERE
NOT EXISTS (
SELECT "Status" FROM vendors."TendorStatus" WHERE "Status" = 'Quotation Selected'
);
-----
alter table vendors."PharmacyProductApproval" add column if not exists "ProductForQuotationHeaderId" bigint references vendors."ProductForQuotationHeader"("ProductForQuotationHeaderId");
This diff is collapsed.
alter table "BirthCertificate" add column "BabyWeight" INTEGER
alter table "BirthCertificate" add column "TypeOfDelivery" character varying
alter table "BirthCertificate" add column "MethodOfDelivery" character varying
alter table "BirthCertificate" add column "DurationOfPregnancy" character varying
alter table "BirthCertificate" add column "NoOfChildBorn" character varying
\ No newline at end of file
ALTER TABLE "Denverchart"
ADD COLUMN if not exists "AppointmentId" integer,
ADD COLUMN if not exists "DenverChartData" text,
ADD COLUMN if not exists "Question" text;
\ No newline at end of file
CREATE SEQUENCE IF NOT EXISTS public."EmergencyType_EmergencyTypeId_seq"
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 9223372036854775807
CACHE 1;
----------------------------------------------------
CREATE TABLE IF NOT EXISTS public."EmergencyType"
(
"EmergencyTypeId" integer NOT NULL DEFAULT nextval('"EmergencyType_EmergencyTypeId_seq"'::regclass),
"EmergencyTypeName" text COLLATE pg_catalog."default",
"Active" boolean DEFAULT true,
CONSTRAINT "EmergencyType_pkey" PRIMARY KEY ("EmergencyTypeId")
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS public."EmergencyType"
OWNER to postgres;
--------------------------------------------------------
INSERT INTO "EmergencyType" ("EmergencyTypeId", "EmergencyTypeName","Active")
VALUES (1,'Red',true),(2,'Yellow',true),(3,'Green',true);
-----------------------------------------------------------
CREATE SEQUENCE IF NOT EXISTS public."EmergencyDetail_EmergencyDetailId_seq"
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 9223372036854775807
CACHE 1;
------------------------------------
CREATE TABLE IF NOT EXISTS public."EmergencyDetail"
(
"EmergencyDetailId" integer NOT NULL DEFAULT nextval('"EmergencyDetail_EmergencyDetailId_seq"'::regclass),
"DetailName" text COLLATE pg_catalog."default",
"Active" boolean DEFAULT true,
"EmergencyTypeId" integer not null,
CONSTRAINT "EmergencyDetail_pkey" PRIMARY KEY ("EmergencyDetailId"),
CONSTRAINT "FK_EmergencyDetail_EmergencyTypeId" FOREIGN KEY ("EmergencyTypeId")
REFERENCES public."EmergencyType" ("EmergencyTypeId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
);
-------------------------------------------------------------------
insert into "EmergencyDetail" ("EmergencyDetailId","DetailName","Active","EmergencyTypeId")
values(1,'CARDIAC ARREST',true,1),(2,'CARDIO RESPIRATORY DISTRESS',true,1),(3,'ECLAMPSIA OR IMMINENT SYMPTOMS',TRUE,1),(4,'SEVERE OR HEAVY BLEEDING',TRUE,1),
(5,'LIFE THREATENING CONDITION',TRUE,1),(6,'URGE TO PUSH',TRUE,1),(7,'OBJECTS PROTRUDING FROM VAGINA',TRUE,1),(8,'NO FETAL MOVEMENTS',TRUE,1),(9,'DIABETIC COMA',TRUE,1),
(10,'TRAUMA',TRUE,1);
insert into "EmergencyDetail" ("EmergencyDetailId","DetailName","Active","EmergencyTypeId")
values(11,'UTERINE CONTRACTIONS EVERY 2 MINS UNCOMFORTABLE',true,2),(12,'MULTIPARA IN ACTIVE LABOUR',true,2),(13,'ABDOMINAL PAIN',TRUE,2),(14,'PRETERM LABOUR/PPROM',TRUE,2),
(15,'PRE-ECLAMPSIA',TRUE,2),(16,'RUPTURE OF MEMBRANCES',TRUE,2),(17,'WOUND INFECTION',TRUE,2),(18,'BLEEDING P/V NOT HEAVY',TRUE,2),(19,'ELECTIVE LSCS ADMISSION',TRUE,2),
(20,'IOL ADMISSION',TRUE,2);
insert into "EmergencyDetail" ("EmergencyDetailId","DetailName","Active","EmergencyTypeId")
values(21,'NAUSEA VOMITNG',true,3),(22,'URINARY COMPLAINTS',true,2),(23,'STABLE GESTATIONAL HTN',TRUE,3),(24,'UPPER RESPIRATORY INFECTION',TRUE,3),
(25,'VAGINAL DISCHARGE',TRUE,3),(26,'WOUND CHECKS/SUTURE REMOVAL',TRUE,3),(27,'INJECTIONS AND LAB TESTS',TRUE,3),(28,'REPORTS/OUTSIDE REPORT OF CYST/TORSION/ECTOPIC/ PUL BUT ASYMPTOMATIC',TRUE,3),(29,'ANC BOOKING VISIT',TRUE,3),
(30,'SYMPTOMS OF FLU/COLD/UTI',TRUE,3),(31,'TRAVEL HISTORY',TRUE,3),(32,'CONTACT / EXPOSURE TO COV',TRUE,3);
----------------------------------------------------------------
CREATE SEQUENCE IF NOT EXISTS public."EmergencyEncounter_EmergencyEncounterId_seq"
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 9223372036854775807
CACHE 1;
----------------------------------------------------
CREATE TABLE IF NOT EXISTS public."EmergencyEncounter"
(
"EmergencyEncounterId" integer NOT NULL DEFAULT nextval('"EmergencyEncounter_EmergencyEncounterId_seq"') ,
"AppointmentId" integer,
"EmergencyTriage" text,
"NursingERForm" text,
"Active" boolean DEFAULT true,
"PatientId" INTEGER,
CONSTRAINT "EmergencyEncounter_PatientId_fkey" FOREIGN KEY ("PatientId")
REFERENCES public."Patient" ("PatientId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
);
alter table "EmergencyEncounter" add column "CreatedBy" integer;
alter table "EmergencyEncounter" add column "ModifiedBy" integer;
alter table "EmergencyEncounter" add column "CreatedDate" timestamp(6) without time zone;
alter table "EmergencyEncounter" add column "ModifiedDate" timestamp(6) without time zone;
\ No newline at end of file
alter table "GynEncounter"
add "RefferalOrder" text
\ No newline at end of file
alter table "GynEncounter"
add column "GyneacAdmissionSheet" text
alter table "GynEncounter"
add column "GyneacSurgery" text
alter table "GynEncounter"
add column "GyneacDiscargeSummary" text
\ No newline at end of file
alter table "GynEncounter"
add "Measure" text
\ No newline at end of file
alter table "GynEncounter"
add column "SpeacialFeature" text,
add column "ReferralForm" text
\ No newline at end of file
alter table "GynEncounter"
add column "Colposcopic" text,
add column "Ectopic" text
\ No newline at end of file
DROP FUNCTION IF EXISTS public."udf_FetchPatientsFilter_For_Appointment"(character varying, character varying, character varying, character varying);
CREATE OR REPLACE FUNCTION public."udf_FetchPatientsFilter_For_Appointment"(
filter character varying DEFAULT NULL::text,
"patientMobile" character varying DEFAULT NULL::text,
"uMRNo" character varying DEFAULT NULL::text,
"patientName" character varying DEFAULT NULL::text)
RETURNS TABLE("PatientId" integer, "Salutation" character varying, "FirstName" text, "MiddleName" text, "LastName" text, "FullName" text, "DateOfBirth" date, "Age" smallint, "Gender" character, "UMRNo" character varying, "Email" character varying, "Mobile" character varying, "CountryId" integer, "ProfileImageUrl" text,"TempPatient" boolean, "HowDidYouKnowId" integer, "Active" boolean, "PaymentStatus" boolean, "ThumbnailUrl" text, "AppointmentDate" timestamp without time zone, "isActiveAppointmentExists" boolean, "isActiveAdmissionExists" boolean)
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
ROWS 1000
AS $BODY$
BEGIN
return query
with cts as (
select row_number() over(partition by a."PatientId" order by a."AppointmentId" desc, a."AppointmentDate" desc )"Max" ,a."PatientId",a."AppointmentId" from "Appointment" a
join "Patient" pat on a."PatientId" =pat."PatientId"
where a."Active"=true
and case when "filter" is null then 1=1 else TRIM(UPPER(pat."FullName")) ilike'%'|| "filter"||'%' OR TRIM(UPPER(pat."UMRNo")) ilike'%'|| "filter"||'%' OR TRIM(UPPER(pat."Mobile")) ilike'%'|| "filter"||'%' end
and case when "uMRNo" is null then 1=1 else pat."UMRNo" ilike'%'|| "uMRNo"||'%' end
and case when "patientMobile" is null then 1=1 else pat."Mobile" ilike'%'|| "patientMobile"||'%' end
and case when "patientName" is null then 1=1 else pat."FullName" ilike'%'|| "patientName"||'%' end
)
, maxapt as (
select a.* from "Appointment" a
join cts on a."AppointmentId"=cts."AppointmentId"
where "Max"=1)
,ctsadmission as (
select distinct max(a."AdmissionId") over(partition by a."PatientId" )"MaxAdmissionId" ,a."PatientId",
a."AppointmentId" from "Admission" a
join "Patient" pat on a."PatientId" =pat."PatientId"
where a."Active"=true
and case when "filter" is null then 1=1 else TRIM(UPPER(pat."FullName")) ilike'%'|| "filter"||'%' OR TRIM(UPPER(pat."UMRNo")) ilike'%'|| "filter"||'%' OR TRIM(UPPER(pat."Mobile")) ilike'%'|| "filter"||'%' end
and case when "uMRNo" is null then 1=1 else pat."UMRNo" ilike'%'|| "uMRNo"||'%' end
and case when "patientMobile" is null then 1=1 else pat."Mobile" ilike'%'|| "patientMobile"||'%' end
and case when "patientName" is null then 1=1 else pat."FullName" ilike'%'|| "patientName"||'%' end
)
, maxadmision as (
select a.* from "Admission" a
join ctsadmission cts on a."AdmissionId"=cts."MaxAdmissionId"
)
SELECT DISTINCT pat."PatientId" ,
pat."Salutation" ,
pat."FirstName" ,
pat."MiddleName" ,
pat."LastName" ,
pat."FullName" ,
pat."DateOfBirth" ,
pat."Age" ,
pat."Gender" ,
pat."UMRNo" ,
pat."Email" ,
pat."Mobile" ,
pat."CountryId" ,
pat."ProfileImageUrl" ,
pat."TempPatient",
pat."HowDidYouKnowId",
-- pat."ThumbnailUrl" ,
pat."Active" ,
pat."PaymentStatus",
(CASE WHEN pat."ThumbnailUrl" IS NOT NULL THEN CONCAT('https://hims-qa.s3.amazonaws.com/', pat."Guid", '/', pat."ThumbnailUrl") ELSE NULL END) AS "ThumbnailUrl"
,(max(apt."AppointmentDate")over(partition by apt."PatientId")::text ||' ' || max(apt."AppointmentTime")over(partition by apt."PatientId",apt."AppointmentDate")::text)::timestamp as "AppointmentDate",
(case when (max(apt."AppointmentDate")over(partition by apt."PatientId")::text ||' ' || max(apt."AppointmentTime")over(partition by apt."PatientId")::text)::timestamp > now() at time zone 'UTC-5:30' then true else false end)"isActiveAppointmentExists"
,(case when max(adm."AdmissionId")over(partition by adm."PatientId") is null then false
when max(adm."AdmissionId")over(partition by adm."PatientId") is not null and max(dc."DischargeId")over(partition by pat."PatientId") is null then true
when max(adm."AdmissionId")over(partition by adm."PatientId") is not null and max(dc."DischargeId")over(partition by pat."PatientId") is not null then false end
)"isActiveAdmissionExists"
FROM "Patient" pat
left join maxapt apt on apt."PatientId" = pat."PatientId" and apt."Status" <> 'C' and apt."Active"=true
left join maxadmision adm on adm."PatientId" = pat."PatientId" and adm."Active"=true
left join "Discharge" dc on dc."AdmissionId" = adm."AdmissionId"
WHERE pat."Active" IS TRUE
and case when "filter" is null then 1=1 else TRIM(UPPER(pat."FullName")) ilike'%'|| "filter"||'%' OR TRIM(UPPER(pat."UMRNo")) ilike'%'|| "filter"||'%' OR TRIM(UPPER(pat."Mobile")) ilike'%'|| "filter"||'%' end
and case when "uMRNo" is null then 1=1 else pat."UMRNo" ilike'%'|| "uMRNo"||'%' end
and case when "patientMobile" is null then 1=1 else pat."Mobile" ilike'%'|| "patientMobile"||'%' end
and case when "patientName" is null then 1=1 else pat."FullName" ilike'%'|| "patientName"||'%' end
;
END
$BODY$;
ALTER FUNCTION public."udf_FetchPatientsFilter_For_Appointment"(character varying, character varying, character varying, character varying)
OWNER TO postgres;
-- added this line "and case when pat."TempPatient" = TRUE THEN pat."HowDidYouKnowId" <> 11 ELSE 1 = 1 END"
DROP FUNCTION IF EXISTS public."udf_FetchPatients_For_QuickScheduleFollowUp"(character varying, character varying, character varying, character varying);
CREATE OR REPLACE FUNCTION public."udf_FetchPatients_For_QuickScheduleFollowUp"(
filter character varying DEFAULT NULL::text,
"patientMobile" character varying DEFAULT NULL::text,
"patientName" character varying DEFAULT NULL::text,
"urlLink" character varying DEFAULT NULL::text)
RETURNS TABLE("PatientId" integer, "Salutation" character varying, "FirstName" text, "MiddleName" text, "LastName" text, "FullName" text, "DateOfBirth" date, "Age" smallint, "Gender" character, "UMRNo" character varying, "Email" character varying, "Mobile" character varying, "CountryId" integer, "ProfileImageUrl" text, "Active" boolean, "PaymentStatus" boolean, "HowDidYouKnowId" integer, "EducationId" integer, "OccupationId" integer, "ProviderId" integer, "ProviderName" character varying, "ThumbnailUrl" text, "AppointmentDate" timestamp without time zone, "isActiveAppointmentExists" boolean, "isActiveAdmissionExists" boolean, "HWCName" character varying, "HWCPatientId" integer, "Description" text, "RowColor" text)
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
ROWS 1000
AS $BODY$
BEGIN
return query
with cts as (
select row_number() over(partition by a."PatientId" order by a."AppointmentId" desc,
a."AppointmentDate" desc )"Max" ,a."PatientId",a."AppointmentId"
from "Appointment" a
join "Patient" pat on a."PatientId" =pat."PatientId"
join "Provider" pr on a."ProviderId" = pr."ProviderId"
where a."Active"=true
--and case when "filter" is null then 1=1 else (TRIM(UPPER(pat."FullName")) ILIKE '%' OR pat."UMRNo" ilike'%' OR pat."Mobile" ILIKE '%')|| "filter"||'%' end
and case when "filter" is null then 1=1 else TRIM(UPPER(pat."FullName")) ilike'%'|| "filter"||'%' OR TRIM(UPPER(pat."UMRNo")) ilike'%'|| "filter"||'%' OR TRIM(UPPER(pat."Mobile")) ilike'%'|| "filter"||'%' end
and case when "patientMobile" is null then 1=1 else pat."Mobile" ilike'%'|| "patientMobile"||'%' end
and case when "patientName" is null then 1=1 else pat."FullName" ilike'%'|| "patientName"||'%' end
)
, maxapt as (
select a.* from "Appointment" a
join cts on a."AppointmentId"=cts."AppointmentId"
where "Max"=1)
,ctsadmission as (
select distinct max(a."AdmissionId") over(partition by a."PatientId" )"MaxAdmissionId" ,a."PatientId",
a."AppointmentId" from "Admission" a
join "Patient" pat on a."PatientId" =pat."PatientId"
where a."Active"=true
--and case when "filter" is null then 1=1 else (TRIM(UPPER(pat."FullName")) ILIKE '%' OR pat."UMRNo" ilike'%' OR pat."Mobile" ILIKE '%') || "filter"||'%' end
and case when "filter" is null then 1=1 else TRIM(UPPER(pat."FullName")) ilike'%'|| "filter"||'%' OR TRIM(UPPER(pat."UMRNo")) ilike'%'|| "filter"||'%' OR TRIM(UPPER(pat."Mobile")) ilike'%'|| "filter"||'%' end
and case when "patientMobile" is null then 1=1 else pat."Mobile" ilike'%'|| "patientMobile"||'%' end
and case when "patientName" is null then 1=1 else pat."FullName" ilike'%'|| "patientName"||'%' end
)
, maxadmision as (
select a.* from "Admission" a
join ctsadmission cts on a."AdmissionId"=cts."MaxAdmissionId"
)
SELECT DISTINCT pat."PatientId" ,
pat."Salutation" ,
pat."FirstName" ,
pat."MiddleName" ,
pat."LastName" ,
pat."FullName" ,
pat."DateOfBirth" ,
pat."Age" ,
pat."Gender" ,
pat."UMRNo" ,
pat."Email" ,
pat."Mobile" ,
pat."CountryId" ,
pat."ProfileImageUrl" ,
-- pat."ThumbnailUrl" ,
pat."Active" ,
pat."PaymentStatus",
pat."HowDidYouKnowId",
pat."EducationId",
pat."OccupationId",
apt."ProviderId",
pr."FullName" as "ProviderName",
(CASE WHEN pat."ThumbnailUrl" IS NOT NULL THEN CONCAT("urlLink", pat."Guid", '/', pat."ThumbnailUrl") ELSE NULL END) AS "ThumbnailUrl"
,(max(apt."AppointmentDate")over(partition by apt."PatientId")::text ||' ' || max(apt."AppointmentTime")over(partition by apt."PatientId",apt."AppointmentDate")::text)::timestamp as "AppointmentDate",
(case when (max(apt."AppointmentDate")over(partition by apt."PatientId")::text ||' ' || max(apt."AppointmentTime")over(partition by apt."PatientId")::text)::timestamp > now() at time zone 'UTC-5:30' then true else false end)"isActiveAppointmentExists"
,(case when max(adm."AdmissionId")over(partition by adm."PatientId") is null then false
when max(adm."AdmissionId")over(partition by adm."PatientId") is not null and max(dc."DischargeId")over(partition by pat."PatientId") is null then true
when max(adm."AdmissionId")over(partition by adm."PatientId") is not null and max(dc."DischargeId")over(partition by pat."PatientId") is not null then false end
)"isActiveAdmissionExists", HWC."HWCName",HWC."HWCPatientId", HWC."Description", HWC."RowColor"
FROM "Patient" pat
left join maxapt apt on apt."PatientId" = pat."PatientId" and apt."Status" <> 'C' and apt."Active"=true
left join "Provider" pr on pr."ProviderId" = apt."ProviderId"
left join maxadmision adm on adm."PatientId" = pat."PatientId" and adm."Active"=true
left join "Discharge" dc on dc."AdmissionId" = adm."AdmissionId"
left join "HWCPatient" HWC on HWC."HWCPatientId" = pat."HWCPatientId"
WHERE pat."Active" IS TRUE
--and case when "filter" is null then 1=1 else (TRIM(UPPER(pat."FullName")) ILIKE '%' OR pat."UMRNo" ilike'%' OR pat."Mobile" ILIKE '%')|| "filter"||'%' end
and case when "filter" is null then 1=1 else TRIM(UPPER(pat."FullName")) ilike'%'|| "filter"||'%' OR TRIM(UPPER(pat."UMRNo")) ilike'%'|| "filter"||'%' OR TRIM(UPPER(pat."Mobile")) ilike'%'|| "filter"||'%' end
and case when "patientMobile" is null then 1=1 else pat."Mobile" ilike'%'|| "patientMobile"||'%' end
and case when "patientName" is null then 1=1 else pat."FullName" ilike'%'|| "patientName"||'%' end
;
END
$BODY$;
ALTER FUNCTION public."udf_FetchPatients_For_QuickScheduleFollowUp"(character varying, character varying, character varying, character varying)
OWNER TO postgres;
\ No newline at end of file
ALTER TABLE "ObEncounter"
ADD "Allergies" text;
\ No newline at end of file
-- FUNCTION: public.udf_FetchPatients_For_AppointmentScheduleFollowUp(character varying, character varying, character varying, character varying, integer)
-- DROP FUNCTION IF EXISTS public."udf_FetchPatients_For_AppointmentScheduleFollowUp"(character varying, character varying, character varying, character varying, integer);
CREATE OR REPLACE FUNCTION public."udf_FetchPatients_For_AppointmentScheduleFollowUp"(
filter character varying DEFAULT NULL::text,
"patientMobile" character varying DEFAULT NULL::text,
"patientName" character varying DEFAULT NULL::text,
"urlLink" character varying DEFAULT NULL::text,
"appointmentId" integer DEFAULT NULL::integer)
RETURNS TABLE("IdProofName" character varying, "RelativeName" character varying, "Relation" character varying, "EducationName" text, "HowDidYouKnow" text, "OccupationName" text, "PatientId" integer, "Salutation" character varying, "FirstName" text, "MiddleName" text, "LastName" text, "FullName" text, "DateOfBirth" date, "Age" smallint, "Gender" character, "MaritalStatus" character, "UMRNo" character varying, "Email" character varying, "Mobile" character varying, "StreetAddress" character varying, "Area" character varying, "City" character varying, "State" character varying, "Zipcode" character varying, "CountryId" integer, "ProfileImageUrl" text, "ThumbnailUrl" text, "Active" boolean, "CreatedBy" integer, "CreatedDate" timestamp without time zone, "ModifiedBy" integer, "ModifiedDate" timestamp without time zone, "Guid" uuid, "ReferralBy" integer, "ReferralCode" character varying, "AadharNo" character varying, "ReferredBy" character varying, "ReferredByName" character varying, "FatherOrHusband" text, "HWCPatientId" integer, "Education" character varying, "Occupation" character varying, "Religion" character varying, "Nationality" character varying, "PatientReferredById" integer, "IdProofValue" character varying, "IdProofId" integer, "BloodGroup" character varying, "Amount" numeric, "PaymentStatus" boolean, "TempPatient" boolean, "HowDidYouKnowId" integer, "EducationId" integer, "OccupationId" integer, "BirthMark1" text, "BirthMark2" text, "RelationType" text, "OccupationDetail" text, "IsNewPatient" boolean, "REGID" character varying, "REGNO" integer, "InsuranceCompanyId" integer, "ProviderId" integer, "AppointmentId" integer, "PatientType" character, "AppointmentNo" character varying, "AppointmentTime" time without time zone, "AppointmentEndTime" time without time zone, "AppointmentNotes" character varying, "CouponId" integer, "AppointmentAmount" numeric, "Discount" numeric, "Total" numeric, "Status" character, "PatientFamilyId" integer, "DepartmentId" integer, "PaymentType" character varying, "PaymentNumber" character varying, "AppointmentPaymentStatus" boolean, "VisitTypeId" integer, "ChargeTypesId" integer, "LocationId" integer, "AppointmentTypeId" integer, "PayTypeId" integer, "TokenNumber" integer, "SpecializationId" integer, "ProviderAvailabilityId" integer, "ConsultationTypeId" integer, "DoctorSpecializationChargeModuleDetailsId" integer, "OtherRemarks" character varying, "AuthorityMasterId" integer, "ReasonsId" integer, "Remarks" character varying, "ProviderName" character varying, "AppointmentDate" timestamp without time zone, "isActiveAppointmentExists" boolean, "HWCName" character varying, "Description" text, "RowColor" text)
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
ROWS 1000
AS $BODY$
BEGIN
return query
with cts as (
select row_number() over(partition by a."PatientId" order by a."AppointmentId" desc,
a."AppointmentDate" desc )"Max" ,a."PatientId",a."AppointmentId"
from "Appointment" a
join "Patient" pat on a."PatientId" =pat."PatientId"
join "Provider" pr on a."ProviderId" = pr."ProviderId"
where a."Active"=true
--and case when "filter" is null then 1=1 else (TRIM(UPPER(pat."FullName")) ILIKE '%' OR pat."UMRNo" ilike'%' OR pat."Mobile" ILIKE '%')|| "filter"||'%' end
and case when "filter" is null then 1=1 else TRIM(UPPER(pat."FullName")) ilike'%'|| "filter"||'%' OR TRIM(UPPER(pat."UMRNo")) ilike'%'|| "filter"||'%' OR TRIM(UPPER(pat."Mobile")) ilike'%'|| "filter"||'%' end
and case when "patientMobile" is null then 1=1 else pat."Mobile" ilike'%'|| "patientMobile"||'%' end
and case when "patientName" is null then 1=1 else pat."FullName" ilike'%'|| "patientName"||'%' end
and case when "appointmentId" is null then 1=1 else a."AppointmentId" = "appointmentId" end
)
, maxapt as (
select a.* from "Appointment" a
join cts on a."AppointmentId"=cts."AppointmentId"
where "Max"=1)
SELECT DISTINCT
id."IdProofName",pf."FullName" as "RelativeName",pf."Relation",
eid."Name" as "EducationName",hid."Name" as "HowDidYouKnow",oid."Name" as "OccupationName",
pat."PatientId",pat. "Salutation",pat. "FirstName",pat. "MiddleName",pat. "LastName",pat. "FullName",pat. "DateOfBirth",pat. "Age",pat. "Gender",pat. "MaritalStatus",pat. "UMRNo",pat. "Email",pat. "Mobile",pat. "StreetAddress",pat. "AddressLine2" as "Area",pat. "City",pat. "State",pat. "Zipcode",pat. "CountryId"
,(CASE WHEN pat."ProfileImageUrl" IS NOT NULL THEN CONCAT("urlLink",'/', pat."Guid", '/', pat."ProfileImageUrl") ELSE '' END) AS "ProfileImageUrl"
,(CASE WHEN pat."ThumbnailUrl" IS NOT NULL THEN CONCAT("urlLink", '/', pat."Guid", '/', pat."ThumbnailUrl") ELSE '' END) AS "ThumbnailUrl"
,pat. "Active",pat. "CreatedBy",pat. "CreatedDate",pat. "ModifiedBy",pat. "ModifiedDate",pat. "Guid",pat. "ReferralBy",pat. "ReferralCode",pat. "AadharNo",referred."Name" as "ReferredBy",pat. "ReferredByName",pat. "FatherOrHusband",pat. "HWCPatientId",pat. "Education",pat. "Occupation",pat. "Religion",pat. "Nationality",pat. "PatientReferredById",pat. "IdProofValue",pat. "IdProofId",pat. "BloodGroup",pat. "Amount",pat. "PaymentStatus",pat. "TempPatient",pat. "HowDidYouKnowId",pat. "EducationId",pat. "OccupationId",pat. "BirthMark1",pat. "BirthMark2",pat. "RelationType",pat. "OccupationDetail",pat. "IsNewPatient",pat. "REGID",pat. "REGNO",pat. "InsuranceCompanyId",
apt."ProviderId",
apt."AppointmentId",
apt."PatientType",
apt."AppointmentNo"
,apt."AppointmentTime"
,apt. "AppointmentEndTime"
,apt. "AppointmentNotes",
apt."CouponId",
apt. "Amount" as "AppointmentAmount",
apt."Discount"
,apt. "Total"
,apt. "Status"
,apt. "PatientFamilyId"
,apt. "DepartmentId"
,apt. "PaymentType"
,apt. "PaymentNumber"
,apt. "PaymentStatus"
, apt."VisitTypeId"
, apt."ChargeTypesId"
, apt."LocationId"
, apt."AppointmentTypeId"
, apt."PayTypeId"
, apt."TokenNumber"
, apt."SpecializationId"
, apt."ProviderAvailabilityId"
, apt."ConsultationTypeId"
, apt."DoctorSpecializationChargeModuleDetailsId"
, apt."OtherRemarks"
, apt."AuthorityMasterId"
, apt."ReasonsId"
, apt."Remarks"
,pr."FullName" as "ProviderName"
,(max(apt."AppointmentDate")over(partition by apt."PatientId")::text ||' ' || max(apt."AppointmentTime")over(partition by apt."PatientId",apt."AppointmentDate")::text)::timestamp as "AppointmentDate",
(case when (max(apt."AppointmentDate")over(partition by apt."PatientId")::text ||' ' || max(apt."AppointmentTime")over(partition by apt."PatientId")::text)::timestamp > now() at time zone 'UTC-5:30' then true else false end)"isActiveAppointmentExists"
, HWC."HWCName", HWC."Description", HWC."RowColor"
FROM "Patient" pat
left join maxapt apt on apt."PatientId" = pat."PatientId" and apt."Status" <> 'C' and apt."Active"=true
left join "Provider" pr on pr."ProviderId" = apt."ProviderId"
left join "HWCPatient" HWC on HWC."HWCPatientId" = pat."HWCPatientId"
LEFT JOIN "PatientReferredBy" referred ON referred."PatientReferredById" = pat."PatientReferredById"
left join "IdProof" id on id."IdProofId" = pat."IdProofId"
left join "HowDidYouKnow" hid on hid."HowDidYouKnowId" = pat."HowDidYouKnowId"
left join "Education" eid on eid."EducationId" = pat."EducationId"
left join "Occupation" oid on oid."OccupationId" = pat."OccupationId"
left join "PatientFamily" pf on pf."PatientId" = pat."PatientId"
WHERE pat."Active" IS TRUE
--and case when "filter" is null then 1=1 else (TRIM(UPPER(pat."FullName")) ILIKE '%' OR pat."UMRNo" ilike'%' OR pat."Mobile" ILIKE '%')|| "filter"||'%' end
and case when "filter" is null then 1=1 else TRIM(UPPER(pat."FullName")) ilike'%'|| "filter"||'%' OR TRIM(UPPER(pat."UMRNo")) ilike'%'|| "filter"||'%' OR TRIM(UPPER(pat."Mobile")) ilike'%'|| "filter"||'%' end
and case when "patientMobile" is null then 1=1 else pat."Mobile" ilike'%'|| "patientMobile"||'%' end
and case when "patientName" is null then 1=1 else pat."FullName" ilike'%'|| "patientName"||'%' end
and case when "appointmentId" is null then 1=1 else apt."AppointmentId" = "appointmentId" end
;
END
$BODY$;
ALTER FUNCTION public."udf_FetchPatients_For_AppointmentScheduleFollowUp"(character varying, character varying, character varying, character varying, integer)
OWNER TO postgres;
update "Menu" set "EncounterKey"='gynIUI' where "Url" ilike '%/app/gyn-encounter/:id/:type/gyneac-iui%';
update "Menu" set "EncounterKey"='gynIUI' where "Url" ilike '%/app/gyn-encounter/:id/:type/gyneac-iui%';
update "Menu" set "EncounterKey"='gyneacCard' where "Url" ilike '%/app/gyn-encounter/:id/:type/gynaec-card-generation%';
update "Menu" set "EncounterKey"='vitals'where "Url" ilike '%/app/gyn-encounter/:id/:type/vital-signs%';
update "Menu" set "EncounterKey"='breastScreening'where "Url" ilike '%/app/gyn-encounter/:id/:type/breast-screening%';
update "Menu" set "EncounterKey"='additionalLabs'where "Url" ilike '%/app/gyn-encounter/:id/:type/additional-labs%';
update "Menu" set "EncounterKey"='lastBreastUltraSound'where "Url" ilike '%/app/gyn-encounter/:id/:type/last-breast-ultra-sound%';
update "Menu" set "EncounterKey"='skin'where "Url" ilike '%/app/gyn-encounter/:id/:type/skin%';
update "Menu" set "EncounterKey"='physicalExam'where "Url" ilike '%/app/gyn-encounter/:id/:type/physical-exam%';
update "Menu" set "EncounterKey"='pelvic'where "Url" ilike '%/app/gyn-encounter/:id/:type/pelvic%';
update "Menu" set "EncounterKey"='gynUltraSound'where "Url" ilike '%/app/gyn-encounter/:id/:type/gyn-ultra-sound%';
update "Menu" set "EncounterKey"='patientDeferred'where "Url" ilike '%/app/gyn-encounter/:id/:type/patient-deferred%';
update "Menu" set "EncounterKey"='abdomen'where "Url" ilike '%/app/gyn-encounter/:id/:type/abdomen%';
update "Menu" set "EncounterKey"='gynLabs'where "Url" ilike '%/app/gyn-encounter/:id/:type/gyn-lab%';
update "Menu" set "EncounterKey"='heent'where "Url" ilike '%/app/gyn-encounter/:id/:type/heent%';
update "Menu" set "EncounterKey"='menopausalHistory'where "Url" ilike '%/app/gyn-encounter/:id/:type/menopausal-history%';
update "Menu" set "EncounterKey"='mensutralHistory'where "Url" ilike '%/app/gyn-encounter/:id/:type/menstural-history%';
update "Menu" set "EncounterKey"='cardiovascular'where "Url" ilike '%/app/gyn-encounter/:id/:type/cv%';
update "Menu" set "EncounterKey"='breast'where "Url" ilike '%/app/gyn-encounter/:id/:type/breast%';
update "Menu" set "EncounterKey"='birthControl'where "Url" ilike '%/app/gyn-encounter/:id/:type/birth-control%';
update "Menu" set "EncounterKey"='gynIUI'where "Url" ilike '%/app/gyn-encounter/:id/:type/gyn-iui%';
update "Menu" set "EncounterKey"='gynaecVisit'where "Url" ilike '%/app/gyn-encounter/:id/:type/gynaec-visit%';
update "Menu" set "EncounterKey"='gynaecOrders'where "Url" ilike '%/app/gyn-encounter/:id/:type/gyneac-orders%';
update "Menu" set "EncounterKey"='procedure'where "Url" ilike '%/app/gyn-encounter/:id/:type/procedure-form%';
update "Menu" set "EncounterKey"='proformaForOasi'where "Url" ilike '%/app/gyn-encounter/:id/:type/proforma-For-Oasi%';
update "Menu" set "EncounterKey"='gynHistory'where "Url" ilike '%/app/gyn-encounter/:id/:type/gynaec-history-new%';
update "Menu" set "EncounterKey"='allergies'where "Url" ilike '%/app/gyn-encounter/:id/:type/obAllergies%';
update "Menu" set "EncounterKey"='cancerHistory'where "Url" ilike '%/app/gyn-encounter/:id/:type/cancer-history%';
update "Menu" set "EncounterKey"='surgeries'where "Url" ilike '%/app/gyn-encounter/:id/:type/procedure-surgeries%';
update "Menu" set "EncounterKey"='problemList'where "Url" ilike '%/app/gyn-encounter/:id/:type/problem-list%';
update "Menu" set "EncounterKey"='familyHistory'where "Url" ilike '%/app/gyn-encounter/:id/:type/family-history%';
update "Menu" set "EncounterKey"='gyneacPartner'where "Url" ilike '%/app/gyn-encounter/:id/:type/gyneac-partner%';
update "Menu" set "EncounterKey"='musculoSkeletal'where "Url" ilike '%/app/gyn-encounter/:id/:type/musculoskeletal%';
update "Menu" set "EncounterKey"='lymphatic'where "Url" ilike '%/app/gyn-encounter/:id/:type/lymphatic%';
update "Menu" set "EncounterKey"='respiratory'where "Url" ilike '%/app/gyn-encounter/:id/:type/respiratory%';
update "Menu" set "EncounterKey"='lastMammogram'where "Url" ilike '%/app/gyn-encounter/:id/:type/last-mammogram%';
update "Menu" set "EncounterKey"='lastDexaScan'where "Url" ilike '%/app/gyn-encounter/:id/:type/last-dexa-scan%';
update "Menu" set "EncounterKey"='lastPelvicUltraSound'where "Url" ilike '%/app/gyn-encounter/:id/:type/last-pelvic-ultra-sounds%';
\ No newline at end of file
alter table "LabBookingTimeLine"
add column if not exists "NewLabBookingDetailId" integer null,
ADD CONSTRAINT "FK_LabBookingTimeLine_NewLabBookingDetailId" FOREIGN KEY ("NewLabBookingDetailId")
REFERENCES public."NewLabBookingDetail" ("NewLabBookingDetailId") ;
alter table "ObEncounter" add "OutPatientManagement" TEXT;
alter table "ObEncounter" add "PrePregnancyPlan" TEXT;
alter table "ObEncounter" add "SpecialFeature" TEXT;
create table "TemplateHeader"(
"TemplateHeaderId" serial primary key,
"ModulesMasterId" int references "ModulesMaster"("ModulesMasterId"),
"TemplateName" text,
"CreatedBy" int references "Account"("AccountId"),
"CreatedDate" timestamp without time zone,
"ModifiedBy" int references "Account"("AccountId"),
"ModifiedDate" timestamp without time zone,
"Active" boolean default true
);
create table "TemplateDetail"(
"TemplateDetailId" serial primary key,
"TemplateHeaderId" int references "TemplateHeader"("TemplateHeaderId"),
"JSONValue" text
);
---------
insert into "Lookup" ("Name","Description") values ('MedRoute','For medication taking ways') returning "LookupId"; -- 23;
-------
insert into "LookupValue" ("LookupId","Name","CreatedBy","CreatedDate")
values
(23,'Oral',1029,now()),
(23,'IV', 1029,now()),
(23,'SC',1029,now()),
(23,'SL',1029,now()),
(23,'INS',1029,now()),
(23,'LA',1029,now()),
(23,'PR',1029,now()),
(23,'PV',1029,now()),
(23,'ID',1029,now()),
(23,'External',1029,now()),
(23,'Intramuscular',1029,now());
--------
create table "MedFrequencyMaster"(
"MedFrequencyMasterId" serial primary key,
"FrequencyName" text,
"FrequencyDescription" text,
"FreqType" varchar(10),
"CalculationUnit" int default 0,
"Active" bool default true,
"CreatedBy" int references "Account"("AccountId"),
"CreatedDate" timestamp without time zone
);
------
INSERT INTO "MedFrequencyMaster"
("FrequencyName", "FrequencyDescription", "CalculationUnit")
values
('Once Daily','Once Daily',1),
('0.5 ml SOS','0.5 ml SOS',0),
('1st Booster','1st Booster',0),
('1st Dose','1st Dose',0),
('2 Tab. Once daily','2 Tab. Once daily',2),
('2 Tab. Twice daily','2 Tab. Twice daily',4),
('2nd Booster','2nd Booster ',0),
('2nd Dose','2nd Dose',0),
('3rd Dose','3rd Dose',0),
('5 ml / 3 times / day','5 ml / 3 times / day',0),
('HS (Bed Time)','HS (Bed Time)',0),
('Monthly','Monthly',1),
('Once a Week','Once a Week',1),
('SOS - AS AND WHEN REQUIRED','SOS - AS AND WHEN REQUIRED',0),
('Stat','Stat (Single Dose)',1),
('Thrice a Day','Thrice Daily',3),
('Twice a Week','Twice a Week',2),
('Twice a Day','Twice Daily',2),
('6th hourly',NULL,4),
('5 minutes','Every 5 minutes',288),
('30 minutes','Every 30 minutes',48),
('PRN','IP',1),
('1 drop every three hours','1 drop every three hours',0),
('15 minutes','Every 15 minutes',96),
('2 Tab. thrice daily','2 Tab. thrice daily',12),
('Hourly','Every 60 minutes',24),
('Once Daily',NULL,1),
('12th hourly',' ',2),
('8th hourly',NULL,3),
('6th hourly',NULL,4),
('4th hourly',' ',6),
('2nd hourly','ÿ ',12),
('Hourly',NULL,24),
('30 minutes',NULL,42),
('15 minutes',NULL,96),
('5 minutes',NULL,288),
('HS (Bed Time)',NULL,NULL),
('Monthly',NULL,NULL),
('SOS',NULL,NULL),
('Stat',NULL,NULL),
('Once a Week',NULL,NULL),
('1st Dose',NULL,NULL),
('2nd Dose',NULL,NULL),
('3rd Dose',NULL,NULL),
('1st Booster',NULL,NULL),
('2nd Booster',NULL,NULL),
('Alternate Days',NULL,NULL),
('4 times a day',NULL,4),
('12 th hourly',NULL,2),
('8th hourly',NULL,3),
('4th hourly','For IP EMR',6),
('5 times a day',NULL,5);
update "MedFrequencyMaster" set "CreatedBy" = 1029, "FreqType" = 'G' , "CreatedDate" = now();
--------
alter table "PatientMedicationDetail" add column "Route" text;
\ No newline at end of file
create schema vendors;
create table vendors."TendorStatus"(
"TenderStatusId" serial primary key,
"Status" varchar(300)
);
create table vendors."PharmacyProductRequest"(
"PharmacyProductRequestId" bigserial primary key,
"PharmacyProductId" int references "PharmacyProduct"("PharmacyProductId"),
"PharmacyStockId" int references "PharmacyStock"("PharmacyStockId"),
"RolStocksId" text,
"TenderStatusId" int references vendors."TendorStatus"( "TenderStatusId"),
"RaisedBy" int references "Account"("AccountId"),
"RaisedDate" timestamp without time zone,
"ApprovedBy" int references "Account"("AccountId"),
"ApprovedDate" timestamp without time zone
);
insert into vendors."TendorStatus"("Status") values ('Pending');
alter table "SupplierProduct" add column "Mrp" numeric(10,2);
create sequence "ANCCardGeneration_ANCCardGenerationId_seq";
CREATE TABLE IF NOT EXISTS public."ANCCardGeneration"
(
"ANCCardGenerationId" integer NOT NULL DEFAULT nextval('"ANCCardGeneration_ANCCardGenerationId_seq"'::regclass),
"Department" text,
"ANCNo" character varying(255),
"HusbandName"character varying(255),
"HusbandAge" int,
"Remarks" text,
"RegistrationDate" text,
"ANCNoExists" text,
"Active" boolean DEFAULT true,
"ProviderId" integer NOT NULL,
"PatientId" integer NOT NULL,
CONSTRAINT "ANCCardGeneration_pkey" PRIMARY KEY ("ANCCardGenerationId"),
CONSTRAINT "FK_ANCCardGeneration_PatientId" FOREIGN KEY ("PatientId")
REFERENCES public."Patient" ("PatientId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT "FK_ANCCardGeneration_ProviderId" FOREIGN KEY ("ProviderId")
REFERENCES public."Provider" ("ProviderId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
\ No newline at end of file
DROP TABLE IF EXISTS public."PackageModuleDetail" cascade;
------------------------------------------------------
DROP TABLE IF EXISTS public."PackageModule" cascade;
------------------------------------------------------
CREATE TABLE IF NOT EXISTS public."PackageModule"
(
"PackageModuleId" integer NOT NULL DEFAULT nextval('"PackageModule_PackageIdModule_Seq"'::regclass),
"PackageName" character varying(50) COLLATE pg_catalog."default" NOT NULL,
"PackageType" character varying(2) COLLATE pg_catalog."default" NOT NULL,
"ModuleType" character varying(10) COLLATE pg_catalog."default" NOT NULL DEFAULT 'Package'::character varying,
"LocationId" integer NOT NULL,
"ProviderId" integer,
"ChargeModuleTemplateId" integer NOT NULL,
"ModulesMasterIds" text COLLATE pg_catalog."default" NOT NULL,
"Notes" character varying(500) COLLATE pg_catalog."default",
"Quantity" smallint NOT NULL DEFAULT 0,
"FreeQuantity" smallint DEFAULT 0,
"Exclusions" character varying(1000) COLLATE pg_catalog."default",
"Active" boolean NOT NULL DEFAULT true,
"CreatedBy" integer NOT NULL,
"CreatedDate" timestamp without time zone NOT NULL DEFAULT now(),
"ModifiedBy" integer,
"ModifiedDate" timestamp without time zone,
CONSTRAINT "PK_PackageModule_PackageModuleId" PRIMARY KEY ("PackageModuleId"),
CONSTRAINT "FK_PackageModule_ChargeModuleTemplateId" FOREIGN KEY ("ChargeModuleTemplateId")
REFERENCES public."ChargeModuleTemplate" ("ChargeModuleTemplateId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT "FK_PackageModule_ProviderId" FOREIGN KEY ("ProviderId")
REFERENCES public."Provider" ("ProviderId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
);
------------------------------------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS public."PackageModuleDetail"
(
"PackageModuleDetailId" integer NOT NULL DEFAULT nextval('"PackageModuleDetail_PackageIdModuleDetail_Seq"'::regclass),
"PackageModuleId" integer NOT NULL,
"ModulesMasterId" integer,
"ReferenceId" integer NOT NULL,
"Quantity" smallint NOT NULL DEFAULT 1,
"IsFree" boolean NOT NULL DEFAULT false,
"Amount" numeric(8,2),
"Active" boolean NOT NULL DEFAULT true,
"CreatedBy" numeric NOT NULL,
"CreatedDate" timestamp without time zone NOT NULL DEFAULT now(),
"ModifiedBy" numeric,
"ModifiedDate" timestamp without time zone,
CONSTRAINT "PackageModuleDetail_pkey" PRIMARY KEY ("PackageModuleDetailId"),
CONSTRAINT "FK_PackageModuleDetail_PackageModuleId" FOREIGN KEY ("PackageModuleId")
REFERENCES public."PackageModule" ("PackageModuleId") MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE CASCADE
);
------------------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION public."udf_fetch_moduleChargeDetails"(
"@modulesMasterId" integer DEFAULT NULL::integer,
"@locationId" integer DEFAULT NULL::integer)
RETURNS TABLE("LocationId" integer, "ModulesMasterId" integer, "ModuleName" character varying, "ModuleIcon" character varying, "ReferenceId" integer, "ChargeName" text, "DepartmentId" integer, "DepartmentName" text, "ChargeGroupId" integer, "ChargeGroupName" text, "RepeatTypeId" integer, "RepeatTypeName" text)
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
ROWS 1000
AS $BODY$
BEGIN
RETURN query SELECT distinct
-- CMD."ChargeModuleDetailsId",
-- CMD."ChargeModuleCategoryId",
CMD."LocationId",
CMC."ModulesMasterId",
MM."ModuleName",
MM."ModuleIcon",
-- CMD."Amount",
CMD."ReferenceId",
LMD."TestName" AS "ChargeName",
NULL :: INT AS "DepartmentId",
NULL :: TEXT AS "DepartmentName",
NULL :: INT AS "ChargeGroupId",
NULL :: TEXT AS "ChargeGroupName",
NULL :: INT "RepeatTypeId",
NULL :: TEXT "RepeatTypeName"
FROM
"ChargeModuleDetails" CMD
JOIN "ChargeModuleCategory" CMC ON CMC."ChargeModuleCategoryId" = CMD."ChargeModuleCategoryId"
JOIN "ModulesMaster" MM ON MM."ModulesMasterId" = CMC."ModulesMasterId"
JOIN "LabMainDetail" LMD ON LMD."LabMainDetailId" = CMD."ReferenceId"
AND MM."ModuleName" = 'Lab'
WHERE
MM."ModulesMasterId" = "@modulesMasterId"
AND CMD."LocationId" = "@locationId"
UNION ALL
SELECT DIstinct
-- CMD."ChargeModuleDetailsId",
-- CMD."ChargeModuleCategoryId",
CMD."LocationId",
CMC."ModulesMasterId",
MM."ModuleName",
MM."ModuleIcon",
-- CMD."Amount",
CMD."ReferenceId",
STM."ScanTestName" AS "ChargeName",
NULL :: INT AS "DepartmentId",
NULL :: TEXT AS "DepartmentName",
NULL :: INT AS "ChargeGroupId",
NULL :: TEXT AS "ChargeGroupName",
NULL :: INT "RepeatTypeId",
NULL :: TEXT "RepeatTypeName"
FROM
"ChargeModuleDetails" CMD
JOIN "ChargeModuleCategory" CMC ON CMC."ChargeModuleCategoryId" = CMD."ChargeModuleCategoryId"
JOIN "ModulesMaster" MM ON MM."ModulesMasterId" = CMC."ModulesMasterId"
JOIN "ScanTestMaster" STM ON STM."ScanTestMasterId" = CMD."ReferenceId"
AND MM."ModuleName" = 'Scan'
WHERE
MM."ModulesMasterId" = "@modulesMasterId"
AND CMD."LocationId" = "@locationId"
UNION ALL
SELECT distinct
-- CMD."ChargeModuleDetailsId",
-- CMD."ChargeModuleCategoryId",
CMD."LocationId",
CMC."ModulesMasterId",
MM."ModuleName",
MM."ModuleIcon",
-- CMD."Amount",
CMD."ReferenceId",
s."Name" AS "ChargeName",
NULL :: INT AS "DepartmentId",
NULL :: TEXT AS "DepartmentName",
NULL :: INT AS "ChargeGroupId",
NULL :: TEXT AS "ChargeGroupName",
NULL :: INT "RepeatTypeId",
NULL :: TEXT "RepeatTypeName"
FROM
"ChargeModuleDetails" CMD
JOIN "ChargeModuleCategory" CMC ON CMC."ChargeModuleCategoryId" = CMD."ChargeModuleCategoryId"
JOIN "ModulesMaster" MM ON MM."ModulesMasterId" = CMC."ModulesMasterId"
JOIN "Surgery" s ON s."SurgeryId" = CMD."ReferenceId"
AND MM."ModuleName" = 'OT'
WHERE
MM."ModulesMasterId" = "@modulesMasterId"
AND CMD."LocationId" = "@locationId"
UNION ALL
SELECT DISTINCT
-- CMD."ChargeModuleDetailsId",
-- CMD."ChargeModuleCategoryId",
CMD."LocationId",
CMC."ModulesMasterId",
MM."ModuleName",
MM."ModuleIcon",
-- CMD."Amount",
CMD."ReferenceId",
c."ChargeName",
d."DepartmentId" AS "DepartmentId",
d."DepartmentName" AS "DepartmentName",
g."ChargeGroupId",
g."ChargeGroupName",
c."RepeatTypeId",
t."RepeatTypeName" "Unit"
FROM
"ChargeModuleDetails" CMD
JOIN "ChargeModuleCategory" CMC ON CMC."ChargeModuleCategoryId" = CMD."ChargeModuleCategoryId"
JOIN "ModulesMaster" MM ON MM."ModulesMasterId" = CMC."ModulesMasterId"
JOIN "Charge" C ON C."ModulesMasterId" = CMC."ModulesMasterId"
AND C."ChargeId" = CMD."ReferenceId"
LEFT JOIN "ChargeGroup" G ON G."ChargeGroupId" = C."ChargeGroupId"
LEFT JOIN "Department" d ON G."DepartmentId" = d."DepartmentId"
LEFT JOIN "RepeatType" t ON t."RepeatTypeId" = c."RepeatTypeId"
WHERE
1 = 1
AND MM."ModulesMasterId" = "@modulesMasterId"
AND MM."ModuleName" = 'Services'
AND CMD."LocationId" = "@locationId" ;
END
$BODY$;
-- FUNCTION: public.udf_fetchProviderAvailabilityDatesNew(integer, integer, integer, text, text, integer)
-- DROP FUNCTION IF EXISTS public."udf_fetchProviderAvailabilityDatesNew"(integer, integer, integer, text, text, integer);
CREATE OR REPLACE FUNCTION public."udf_fetchProviderAvailabilityDatesNew"(
providerid integer,
locationid integer,
specializationid integer,
startdate text,
enddate text,
consultationtypeid integer)
RETURNS TABLE("Date" date, "DateNumber" integer, "DayName" character varying, "Status" character)
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
ROWS 1000
AS $BODY$
begin
return query
with TotalDates as (
SELECT DISTINCT regexp_split_to_table(A."AvailableDate",',') ::date "Dates" ,
A."ProviderId",A."ProviderAvailabilityId",A."LocationId", A."StartDate", A."EndDate", A."LocationId", S."SpecializationId" , A."ConsultationTypeId"
from "ProviderAvailability" A
JOIN "Location" PL ON A."LocationId" = PL."LocationId" AND PL."Active" = TRUE
JOIN "Provider" PR on A."ProviderId" = PR."ProviderId" AND PR."Active" = TRUE
JOIN "Specialization" S on S."SpecializationId" =A."SpecializationId" AND S."Active" IS TRUE
--JOIN "Practice" P ON P."PracticeId" = PL."PracticeId" AND P."Active" = TRUE
where A."ProviderId"=providerid AND A."LocationId" = locationid And S."SpecializationId" = specializationid And A."ConsultationTypeId" = consultationTypeId and A."Active" IS TRUE
)
,Availability as (
select A."AvailableDay", A."ProviderAvailabilityId",A."AvailableDate"
--A."ProviderId"
--,A."ProviderLocationId"
,A."LocationId", A."StartDate", A."EndDate", S."SpecializationId", A."ConsultationTypeId"
--,json_array_elements(case when (A."Availability" is null or A."Availability"='') then '[]' else (A."Availability"::json)end) "Availability"
from "ProviderAvailability" A
--left join "ProviderAvailabilitySlot" PAS on PAS."ProviderAvailabilityId" = A."ProviderAvailabilityId"
JOIN "Location" PL ON A."LocationId" = PL."LocationId" AND PL."Active" = TRUE
JOIN "Provider" PR on A."ProviderId" = PR."ProviderId" AND PR."Active" = TRUE
JOIN "Specialization" S on S."SpecializationId" = ANY(PR."Specializations") AND S."Active" IS TRUE
--JOIN "Location" PL ON A."LocationId" = PL."LocationId" AND PL."Active" = TRUE
--JOIN "Practice" P ON P."PracticeId" = PL."PracticeId" AND P."Active" = TRUE
where A."ProviderId"=providerid AND A."LocationId" = locationid And S."SpecializationId" = specializationid and A."ConsultationTypeId" = consultationTypeId And A."Active" IS TRUE
--and case when providerLocationId is null then 1=1 else A."ProviderLocationId"=providerLocationId end
)
,Avail as (
SELECT unnest(string_to_array(A."AvailableDay", ',')) AS "Day",unnest(string_to_array(A."AvailableDate", ',')) AS "AvailableDate", A."ProviderAvailabilityId",A."LocationId", A."StartDate", A."EndDate", A."SpecializationId"
from Availability A
)
, LeaveAvailability as (
select A."ProviderId",A."LeaveDate",coalesce(A."ProviderAvailabilityId"::text,
(
select string_agg(D."ProviderAvailabilityId"::text,',') "ProviderAvailabilityId" from "ProviderAvailability" D where D."ProviderId"= providerid and D."LocationId" = locationid
))
"ProviderAvailabilityId" from "ProviderLeave" A where A."ProviderId"=providerid and A."LocationId" = locationid
)
,LeaveData as (
select A."ProviderId",A."LeaveDate",regexp_split_to_table(A."ProviderAvailabilityId",',') ::int "ProviderAvailabilityId"
from LeaveAvailability A
)
,FinalData as (
select DISTINCT C."LeaveDate", A."Dates" "Date", A."ProviderId",A."ProviderAvailabilityId",A."StartDate",A."EndDate"
--,A."LocationId"
,extract(ISODOW from "Dates")"DateNo", CASE
WHEN extract(ISODOW from "Dates") =1 THEN 'Monday'
WHEN extract(ISODOW from "Dates") =2 THEN 'Tuesday'
WHEN extract(ISODOW from "Dates")=3 THEN 'Wednesday'
WHEN extract(ISODOW from "Dates")=4 THEN 'Thursday'
WHEN extract(ISODOW from "Dates")=5 THEN 'Friday'
WHEN extract(ISODOW from "Dates")=6 THEN 'Saturday'
WHEN extract(ISODOW from "Dates")=7 THEN 'Sunday' end "Day" ,
case when C."LeaveDate" is not null then 'L' when "AvailableDate"::date is not null is not null then 'A' else '' end "Status"
from TotalDates A
left join Avail B on "AvailableDate"::date= A."Dates" ::date and A."ProviderId"=A."ProviderId" and A."ProviderAvailabilityId"=B."ProviderAvailabilityId"
--and A."LocationId"=B."LocationId"
left join LeaveData C on C."LeaveDate"::date =A."Dates" and A."ProviderAvailabilityId"=C."ProviderAvailabilityId"
where
A."Dates"::Date between startdate::Date and enddate::Date
)
select DISTINCT A."Date",A."DateNo"::int,A."Day"::text::character varying(10),A."Status"::char
from FinalData A
where trim(A."Status") <> ''
--A."Date" >= A."StartDate"::Date or
--A."Date" <= A."EndDate"::Date
order by A."Date";
end
$BODY$;
ALTER FUNCTION public."udf_fetchProviderAvailabilityDatesNew"(integer, integer, integer, text, text, integer)
OWNER TO postgres;
alter table "ObEncounter" add "FamilyHistory" text;
\ No newline at end of file
create sequence "Tpa_TpaId_seq";
-----------------------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS public."Tpa"
(
"TpaId" integer NOT NULL DEFAULT nextval('"Tpa_TpaId_seq"'::regclass),
"Name" Character Varying(150) unique,
"Active" boolean DEFAULT true,
"CreatedBy" integer,
"CreatedDate" timestamp without time zone,
"ModifiedBy" integer,
"ModifiedDate" timestamp without time zone,
CONSTRAINT "Tpa_pkey" PRIMARY KEY ("TpaId"),
CONSTRAINT "Tpa_CreatedBy_fkey" FOREIGN KEY ("CreatedBy")
REFERENCES public."Account" ("AccountId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT "Tpa_ModifiedBy_fkey" FOREIGN KEY ("ModifiedBy")
REFERENCES public."Account" ("AccountId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
);
----------------------------------
alter table "Admission"
add column "TpaId" integer,
add column "PatientOrganization" character varying(150),
add CONSTRAINT "Admission_TpaId_fkey" FOREIGN KEY ("TpaId")
REFERENCES public."Tpa" ("TpaId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION;
\ No newline at end of file
ALTER TABLE "OTRegister" ALTER COLUMN "AssitantId" DROP NOT NULL;
ALTER TABLE "OTRegister" ALTER COLUMN "AnaesthetistId" DROP NOT NULL;
ALTER TABLE "OTRegister" ALTER COLUMN "AnaesthetistId" DROP NOT NULL;
ALTER TABLE "OTRegister" ALTER COLUMN "NurseId" DROP NOT NULL;
ALTER TABLE "OTRegister" ALTER COLUMN "OREntryDate" DROP NOT NULL;
ALTER TABLE "OTRegister" ALTER COLUMN "SignInDate" DROP NOT NULL;
ALTER TABLE "OTRegister" ALTER COLUMN "SignOutDate" DROP NOT NULL;
ALTER TABLE "OTRegister" ALTER COLUMN "ShiftWardToDate" DROP NOT NULL;
ALTER TABLE "OTRegister" ALTER COLUMN "AnaesthesiaTypeId" DROP NOT NULL;
ALTER TABLE "OTRegister" ALTER COLUMN "SurgeryTypeId" DROP NOT NULL;
\ No newline at end of file
DROP FUNCTION IF EXISTS public."udf_PatientMedicationReport"(integer, text, text, text, integer, timestamp without time zone, timestamp without time zone, text);
CREATE OR REPLACE FUNCTION public."udf_PatientMedicationReport"(
"patientId" integer DEFAULT NULL::integer,
"uMRNo" text DEFAULT NULL::text,
"patientMobile" text DEFAULT NULL::text,
"billNumber" text DEFAULT NULL::text,
"payTypeId" integer DEFAULT NULL::integer,
"fromDate" timestamp without time zone DEFAULT (now())::timestamp without time zone,
"toDate" timestamp without time zone DEFAULT (now())::timestamp without time zone,
"locationId" text DEFAULT NULL::text)
RETURNS TABLE("PatientName" text, "UMRNo" character varying, "PatientMobile" character varying, "BillNumber" character varying, "BillType" character varying, "SaleDate" timestamp without time zone, "OverallNetAmount" numeric, "ProductName" character varying, "GenericName" text, "CategoryName" character varying, "CompanyName" text, "BatchNumber" character varying, "PaidVia" character varying, "PaymentNumber" character varying, "Quantity" integer, "NetAmount" numeric, "TotalAmount" numeric)
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
ROWS 1000
AS $BODY$
Declare
BEGIN
return query
select P."FullName" "PatientName",P."UMRNo",p."Mobile" "PatientMobile" ,Ph."BillNumber",PH."BillType",
PH."CreatedDate" "SaleDate",PH."OverallNetAmount",PP."ProductName",pp."GenericName",
ci."Name" "CategoryName ",c."Name" "CompanyName",PRS."BatchNumber", PT."PayTypeName" as "PaidVia",PH."PaymentNumber" ,sum(PS."Quantity")::int "Quantity",
PS."NetAmount" ,sum(PS."NetAmount") "TotalAmount"
from "PharmacySaleHeader" PH
join "PharmacySaleDetail" PS on PH."PharmacySaleHeaderId"=PS."PharmacySaleHeaderId"
join "PharmacyProduct" pp on PS."PharmacyProductId"=PP."PharmacyProductId"
join "PharmacyRetailStock" PRS on PRS."PharmacyRetailStockId"=PS."PharmacyRetailStockId" and PRS."PharmacyProductId"=PP."PharmacyProductId"
join "Company" c on c."CompanyId"=PP."CompanyId"
join "LookupValue" ci on ci."LookupValueId"=pp."CategoryId"
join "Patient" P on P."PatientId"=ph."PatientId"
left join "PayType" PT on PT."PayTypeId"=PH."PayTypeId"
--where p."UMRNo" ='UMR21050206'
where case when "uMRNo" ='' then 1=1 when "uMRNo" is null then 1=1 else p."UMRNo" ilike '%'||"uMRNo"||'%' end and
--case when "patientName" ='' then 1=1 when "patientName" is null then 1=1 else P."FullName" ilike '%'||"patientName"||'%' end and
case when "patientId" is null then 1=1 else P."PatientId"="patientId" end and
case when "patientMobile" ='' then 1=1 when "patientMobile" is null then 1=1 else p."Mobile" ilike '%'||"patientMobile"||'%' end and
case when "billNumber" ='' then 1=1 when "billNumber" is null then 1=1 else Ph."BillNumber" ilike '%'||"billNumber"||'%' end
and case when "payTypeId" is null then 1=1 else PT."PayTypeId" ="payTypeId" end
and case when "fromDate" is null then 1=1 else "fromDate" <= PH."CreatedDate" and PH."CreatedDate" <= "toDate" end
and case when "locationId" is null then 1=1 else PH."LocationId" = "locationId"::int end
GROUP BY GROUPING SETS(( P."FullName",P."UMRNo",p."Mobile" ,Ph."BillNumber",PH."CreatedDate",PH."BillType",
PH."OverallNetAmount",PP."ProductName",pp."GenericName",
ci."Name" ,c."Name" ,PRS."BatchNumber",PT."PayTypeName", PH."PaymentNumber" ,PS."Quantity",PS."NetAmount" ),
( P."FullName",Ph."BillNumber",PH."BillType"), ())
order by Ph."CreatedDate" desc
;
END
$BODY$;
ALTER FUNCTION public."udf_PatientMedicationReport"(integer, text, text, text, integer, timestamp without time zone, timestamp without time zone, text)
OWNER TO postgres;
\ No newline at end of file
DROP FUNCTION IF EXISTS public."udf_PharmacyBills_Report"(text, integer, character varying, character varying, integer, integer, integer, timestamp without time zone, timestamp without time zone, text, integer, text);
CREATE OR REPLACE FUNCTION public."udf_PharmacyBills_Report"(
"billNumber" text DEFAULT NULL::text,
"patientId" integer DEFAULT NULL::integer,
"patientMobile" character varying DEFAULT NULL::text,
"uMRNo" character varying DEFAULT NULL::text,
"payTypeId" integer DEFAULT NULL::integer,
"providerId" integer DEFAULT NULL::integer,
"createdBy" integer DEFAULT NULL::integer,
"fromDate" timestamp without time zone DEFAULT (now())::timestamp without time zone,
"toDate" timestamp without time zone DEFAULT (now())::timestamp without time zone,
"retailName" text DEFAULT NULL::text,
"retailPharmacyId" integer DEFAULT NULL::integer,
"locationId" text DEFAULT NULL::text)
RETURNS TABLE("PharmacySaleHeaderId" integer, "BillNumber" character varying, "SaleDate" timestamp without time zone, "PatientName" character varying, "PatientMobile" character varying, "UMRNo" character varying, "PaidVia" character varying, "PaymentNumber" character varying, "CreatedByName" text, "RoleName" character varying, "ProviderName" character varying, "TotalAmount" numeric, "RetailName" text, "OverallTaxes" numeric, "LocationName" character varying)
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
ROWS 1000
AS $BODY$
BEGIN
return query
select PH."PharmacySaleHeaderId" ,PH."BillNumber",PH."CreatedDate" "SaleDate",PH."PatientName",PH."Mobile"
,Pa."UMRNo",PT."PayTypeName" as "PaidVia",PH."PaymentNumber",A."FullName"
"CreatedByName",R."RoleName" "Role" ,
PH."ProviderName", PH."OverallNetAmount" ,RP."RetailName",PH."OverallTaxes",L."Name" as "LocationName"
from "PharmacySaleHeader" PH
left join "Patient" Pa on Pa."PatientId"::text=PH."PatientId"::text
--join "Provider" pr on pr."ProviderId"::text=PH."ProviderId"::text
join "Account" A on A."AccountId"=PH."CreatedBy"
join "Role" R on R."RoleId"=A."RoleId"
join "PharmacySaleDetail" PSD on PSD."PharmacySaleHeaderId"=PH."PharmacySaleHeaderId"
join "PharmacyRetailStock" PRS on PRS."PharmacyRetailStockId"=PSD."PharmacyRetailStockId"
join "RetailWareHouseLink" RWL on RWL."RetailWareHouseLinkId" = PRS."RetailWareHouseLinkId"
join "RetailPharmacy" RP on RP."RetailPharmacyId"=RWL."RetailPharmacyId"
join "Location" L on L."LocationId" = PH."LocationId"
left join "PayType" PT on PT."PayTypeId"=PH."PayTypeId"
where case when "billNumber" is null then 1=1 else PH."BillNumber" ilike '%' || "billNumber" ||'%' end and
case when "patientId" is null then 1=1 else PH."PatientId"="patientId" end and
case when "patientMobile" is null then 1=1 else PH."Mobile" ilike '%' || "patientMobile" ||'%' end and
case when "uMRNo" is null then 1=1 else Pa."UMRNo" ilike '%' || "uMRNo" ||'%' end and
case when "payTypeId" is null then 1=1 else PT."PayTypeId" = "payTypeId" end and
case when "providerId" is null then 1=1 else PH."ProviderId" ="providerId" end and
case when "createdBy" is null then 1=1 else A."AccountId"="createdBy" end and
case when "fromDate" is null then 1=1 else PH."SaleDate" >= "fromDate" end and
case when "toDate" is null then 1=1 else PH."SaleDate" <= "toDate" end and
case when "retailName" is null then 1=1 else RP."RetailName" ilike '%' || "retailName" ||'%' end and
case when "retailPharmacyId" is null then 1=1 else RP."RetailPharmacyId" = "retailPharmacyId" end and
case when "locationId" is null then 1=1 else PH."LocationId" = "locationId"::int end
group by PH."PharmacySaleHeaderId" ,PH."BillNumber",PH."SaleDate", PH."OverallNetAmount",PH."PatientName",PH."Mobile",Pa."UMRNo",PT."PayTypeName", PH."PaymentNumber", A."FullName"
,R."RoleName" ,PH."ProviderName",RP."RetailName",PH."OverallTaxes",L."Name"
order by PH."SaleDate" desc;
END
$BODY$;
\ No newline at end of file
DROP FUNCTION IF EXISTS public."udf_pharmacypatientbills_finalreport"(text, integer, integer, character varying, character varying, integer, integer, integer, date, date, text, integer, text, boolean);
CREATE OR REPLACE FUNCTION public."udf_pharmacypatientbills_finalreport"(
"billNumber" text DEFAULT NULL::text,
"accountId" integer DEFAULT NULL::integer,
"patientId" integer DEFAULT NULL::integer,
"patientMobile" character varying DEFAULT NULL::text,
"uMRNo" character varying DEFAULT NULL::text,
"payTypeId" integer DEFAULT NULL::integer,
"providerId" integer DEFAULT NULL::integer,
"createdBy" integer DEFAULT NULL::integer,
"fromDate" timestamp without time zone DEFAULT (now())::timestamp without time zone,
"toDate" timestamp without time zone DEFAULT (now())::timestamp without time zone,
"retailName" text DEFAULT NULL::text,
"retailPharmacyId" integer DEFAULT NULL::integer,
"locationId" text DEFAULT NULL::text,
"pharmacyBillType" boolean DEFAULT NULL::boolean)
RETURNS TABLE("PharmacySaleHeaderId" integer, "BillNumber" character varying, "PaidVia" character varying, "PaymentNumber" character varying, "SaleDate" timestamp without time zone, "PatientName" character varying, "PatientMobile" character varying, "UMRNo" character varying, "ProviderName" character varying, "CreatedByName" text, "RoleName" character varying, "TotalAmount" numeric, "SaleReturnHeaderId" integer, "OverallTaxes" numeric, "RetailName" text)
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
ROWS 1000
AS $BODY$
BEGIN
return query
select PH."PharmacySaleHeaderId" ,PH."BillNumber",PH."PaidVia",PH."PaymentNumber",PH."SaleDate" "SaleDate",PH."PatientName",
PH."Mobile" ,Ph."UMRNo",PH."ProviderName",ph."CreatedByName",
ph."Role", PH."OverallNetAmount",PH."SaleReturnHeaderId" ,PH."OverallTaxes",PH."RetailName"
from
(
select PH."PharmacySaleHeaderId" ,PH."BillNumber",PT."PayTypeName" as "PaidVia",PH."PaymentNumber",PH."CreatedDate" "SaleDate",
PH."PatientName",PH."Mobile" ,Pa."UMRNo",PH."ProviderName",A."FullName"
"CreatedByName",R."RoleName" "Role" ,
PH."OverallNetAmount",true "PharmacyBillType",null "SaleReturnHeaderId",PH."OverallTaxes",
RP."RetailName"
from "PharmacySaleHeader" PH
join "Account" A on A."AccountId"=PH."CreatedBy"
join "Role" R on R."RoleId"=A."RoleId"
join "PharmacySaleDetail" PSD on PSD."PharmacySaleHeaderId"=PH."PharmacySaleHeaderId"
join "PharmacyRetailStock" PRS on PRS."PharmacyRetailStockId"=PSD."PharmacyRetailStockId"
join "RetailWareHouseLink" RWL on RWL."RetailWareHouseLinkId" = PRS."RetailWareHouseLinkId"
join "RetailPharmacy" RP on RP."RetailPharmacyId"=RWL."RetailPharmacyId"
left join "Patient" Pa on Pa."PatientId"::text=PH."PatientId"::text
left join "PayType" PT on PT."PayTypeId"=PH."PayTypeId"
where case when "billNumber" is null then 1=1 else PH."BillNumber" ilike '%' || "billNumber" ||'%' end and
case when "accountId" is null then 1=1 else PH."CreatedBy"="accountId" end and
case when "patientId" is null then 1=1 else PH."PatientId"="patientId" end and
case when "patientMobile" is null then 1=1 else PH."Mobile" ilike '%' || "patientMobile" ||'%' end and
case when "uMRNo" is null then 1=1 else Pa."UMRNo" ilike '%' || "uMRNo" ||'%' end and
case when "payTypeId" is null then 1=1 else PT."PayTypeId" = "payTypeId" end and
case when "providerId" is null then 1=1 else PH."ProviderId" = "providerId" end and
case when "createdBy" is null then 1=1 else A."AccountId"="createdBy" end and
case when "fromDate" is null then 1=1 else "fromDate"<= PH."SaleDate" end and
case when "toDate" is null then 1=1 else PH."SaleDate"<= "toDate" end and
case when "retailName" is null then 1=1 else RP."RetailName" ilike '%' || "retailName" ||'%' end and
case when "retailPharmacyId" is null then 1=1 else RP."RetailPharmacyId" = "retailPharmacyId" end and
case when "locationId" is null then 1=1 else PH."LocationId" = "locationId"::int end
group by PH."PharmacySaleHeaderId" ,PH."BillNumber",PT."PayTypeName", PH."PaymentNumber",PH."SaleDate", PH."OverallNetAmount",
PH."PatientName",PH."ProviderName",Pa."UMRNo",A."FullName"
,R."RoleName",RP."RetailName"
union
select PH."PharmacySaleHeaderId" ,PH."BillNumber",PT."PayTypeName" as "PaidVia",PH."PaymentNumber",srh."ReturnDate" "SaleDate",PH."PatientName",
Ph."Mobile" ,Pa."UMRNo",PH."ProviderName",A."FullName"
"CreatedByName",R."RoleName" "Role", -srh."OverallNetAmount" "TotalAmount",false "PharmacyBillType"
,srh."SaleReturnHeaderId",srh."OverallTaxes",
RP."RetailName"
from "SaleReturnHeader" srh
Join "PharmacySaleHeader" ph on ph."PharmacySaleHeaderId"= srh."PharmacySaleHeaderId"
join "Account" A on A."AccountId"=srh."CreatedBy"
join "Role" R on R."RoleId"=A."RoleId"
join "PharmacySaleDetail" PSD on PSD."PharmacySaleHeaderId"=PH."PharmacySaleHeaderId"
join "PharmacyRetailStock" PRS on PRS."PharmacyRetailStockId"=PSD."PharmacyRetailStockId"
join "RetailWareHouseLink" RWL on RWL."RetailWareHouseLinkId" = PRS."RetailWareHouseLinkId"
join "RetailPharmacy" RP on RP."RetailPharmacyId"=RWL."RetailPharmacyId"
left join "Patient" Pa on Pa."PatientId"::text=PH."PatientId"::text
left join "PayType" PT on PT."PayTypeId"=PH."PayTypeId"
where case when "billNumber" is null then 1=1 else PH."BillNumber" ilike '%' || "billNumber" ||'%' end and
case when "accountId" is null then 1=1 else srh."CreatedBy"="accountId" end and
case when "patientId" is null then 1=1 else PH."PatientId"="patientId" end and
case when "patientMobile" is null then 1=1 else PH."Mobile" ilike '%' || "patientMobile" ||'%' end and
case when "uMRNo" is null then 1=1 else Pa."UMRNo" ilike '%' || "uMRNo" ||'%' end and
case when "payTypeId" is null then 1=1 else PT."PayTypeId" = "payTypeId" end and
case when "providerId" is null then 1=1 else PH."ProviderId" = "providerId" end and
case when "createdBy" is null then 1=1 else A."AccountId"="createdBy" end and
case when "fromDate" is null then 1=1 else srh."ReturnDate" >= "fromDate" end and
case when "toDate" is null then 1=1 else srh."ReturnDate" <= "toDate" end and
case when "retailName" is null then 1=1 else RP."RetailName" ilike '%' || "retailName" ||'%' end and
case when "retailPharmacyId" is null then 1=1 else RP."RetailPharmacyId" = "retailPharmacyId" end and
case when "locationId" is null then 1=1 else ph."LocationId" = "locationId"::int end
group by PH."PharmacySaleHeaderId" ,PH."BillNumber",PT."PayTypeName", PH."PaymentNumber",srh."ReturnDate", srh."OverallNetAmount",
PH."PatientName",Pa."Mobile",Pa."UMRNo",PH."ProviderName",A."FullName"
,R."RoleName",srh."SaleReturnHeaderId", RP."RetailName"
) Ph
where case when "pharmacyBillType" is null then 1=1
when "pharmacyBillType" = true then "PharmacyBillType" = true
when "pharmacyBillType" = false then "PharmacyBillType" = false
end
order by PH."SaleDate" desc, PH."PharmacySaleHeaderId";
END
$BODY$;
ALTER FUNCTION public."udf_pharmacypatientbills_finalreport"(text, integer, integer, character varying, character varying, integer, integer, integer, timestamp without time zone, timestamp without time zone, text, integer, text, boolean)
OWNER TO postgres;
\ No newline at end of file
This diff is collapsed.
-- FUNCTION: public.udf_FetchPatients_For_AppointmentScheduleFollowUp(character varying, character varying, character varying, character varying, integer)
-- DROP FUNCTION IF EXISTS public."udf_FetchPatients_For_AppointmentScheduleFollowUp"(character varying, character varying, character varying, character varying, integer);
CREATE OR REPLACE FUNCTION public."udf_FetchPatients_For_AppointmentScheduleFollowUp"(
filter character varying DEFAULT NULL::text,
"patientMobile" character varying DEFAULT NULL::text,
"patientName" character varying DEFAULT NULL::text,
"urlLink" character varying DEFAULT NULL::text,
"appointmentId" integer DEFAULT NULL::integer)
RETURNS TABLE("IdProofName" character varying, "RelativeName" character varying, "Relation" character varying, "EducationName" text, "HowDidYouKnow" text, "OccupationName" text, "PatientId" integer, "Salutation" character varying, "FirstName" text, "MiddleName" text, "LastName" text, "FullName" text, "DateOfBirth" date, "Age" smallint, "Gender" character, "MaritalStatus" character, "UMRNo" character varying, "Email" character varying, "Mobile" character varying, "StreetAddress" character varying, "Area" character varying, "City" character varying, "State" character varying, "Zipcode" character varying, "CountryId" integer, "ProfileImageUrl" text, "ThumbnailUrl" text, "Active" boolean, "CreatedBy" integer, "CreatedDate" timestamp without time zone, "ModifiedBy" integer, "ModifiedDate" timestamp without time zone, "Guid" uuid, "ReferralBy" integer, "ReferralCode" character varying, "AadharNo" character varying, "ReferredBy" character varying, "ReferredByName" character varying, "FatherOrHusband" text, "HWCPatientId" integer, "Education" character varying, "Occupation" character varying, "Religion" character varying, "Nationality" character varying, "PatientReferredById" integer, "IdProofValue" character varying, "IdProofId" integer, "BloodGroup" character varying, "Amount" numeric, "PaymentStatus" boolean, "TempPatient" boolean, "HowDidYouKnowId" integer, "EducationId" integer, "OccupationId" integer, "BirthMark1" text, "BirthMark2" text, "RelationType" text, "OccupationDetail" text, "IsNewPatient" boolean, "REGID" character varying, "REGNO" integer, "InsuranceCompanyId" integer, "ProviderId" integer, "AppointmentId" integer, "PatientType" character, "AppointmentNo" character varying, "AppointmentTime" time without time zone, "AppointmentEndTime" time without time zone, "AppointmentNotes" character varying, "CouponId" integer, "AppointmentAmount" numeric, "Discount" numeric, "Total" numeric, "Status" character, "PatientFamilyId" integer, "DepartmentId" integer, "PaymentType" character varying, "PaymentNumber" character varying, "AppointmentPaymentStatus" boolean, "VisitTypeId" integer, "ChargeTypesId" integer, "LocationId" integer, "AppointmentTypeId" integer, "PayTypeId" integer, "TokenNumber" integer, "SpecializationId" integer, "ProviderAvailabilityId" integer, "ConsultationTypeId" integer, "DoctorSpecializationChargeModuleDetailsId" integer, "OtherRemarks" character varying, "AuthorityMasterId" integer, "ReasonsId" integer, "Remarks" character varying, "ProviderName" character varying , "ModuleName" character varying, "AppointmentDate" timestamp without time zone, "isActiveAppointmentExists" boolean, "HWCName" character varying, "Description" text, "RowColor" text)
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
ROWS 1000
AS $BODY$
BEGIN
return query
with cts as (
select row_number() over(partition by a."PatientId" order by a."AppointmentId" desc,
a."AppointmentDate" desc )"Max" ,a."PatientId",a."AppointmentId"
from "Appointment" a
join "Patient" pat on a."PatientId" =pat."PatientId"
join "Provider" pr on a."ProviderId" = pr."ProviderId"
where a."Active"=true
--and case when "filter" is null then 1=1 else (TRIM(UPPER(pat."FullName")) ILIKE '%' OR pat."UMRNo" ilike'%' OR pat."Mobile" ILIKE '%')|| "filter"||'%' end
and case when "filter" is null then 1=1 else TRIM(UPPER(pat."FullName")) ilike'%'|| "filter"||'%' OR TRIM(UPPER(pat."UMRNo")) ilike'%'|| "filter"||'%' OR TRIM(UPPER(pat."Mobile")) ilike'%'|| "filter"||'%' end
and case when "patientMobile" is null then 1=1 else pat."Mobile" ilike'%'|| "patientMobile"||'%' end
and case when "patientName" is null then 1=1 else pat."FullName" ilike'%'|| "patientName"||'%' end
and case when "appointmentId" is null then 1=1 else a."AppointmentId" = "appointmentId" end
)
, maxapt as (
select a.* from "Appointment" a
join cts on a."AppointmentId"=cts."AppointmentId"
where "Max"=1)
SELECT DISTINCT
id."IdProofName",pf."FullName" as "RelativeName",pf."Relation",
eid."Name" as "EducationName",hid."Name" as "HowDidYouKnow",oid."Name" as "OccupationName",
pat."PatientId",pat. "Salutation",pat. "FirstName",pat. "MiddleName",pat. "LastName",pat. "FullName",pat. "DateOfBirth",pat. "Age",pat. "Gender",pat. "MaritalStatus",pat. "UMRNo",pat. "Email",pat. "Mobile",pat. "StreetAddress",pat. "AddressLine2" as "Area",pat. "City",pat. "State",pat. "Zipcode",pat. "CountryId"
,(CASE WHEN pat."ProfileImageUrl" IS NOT NULL THEN CONCAT("urlLink",'/', pat."Guid", '/', pat."ProfileImageUrl") ELSE '' END) AS "ProfileImageUrl"
,(CASE WHEN pat."ThumbnailUrl" IS NOT NULL THEN CONCAT("urlLink", '/', pat."Guid", '/', pat."ThumbnailUrl") ELSE '' END) AS "ThumbnailUrl"
,pat. "Active",pat. "CreatedBy",pat. "CreatedDate",pat. "ModifiedBy",pat. "ModifiedDate",pat. "Guid",pat. "ReferralBy",pat. "ReferralCode",pat. "AadharNo",referred."Name" as "ReferredBy",pat. "ReferredByName",pat. "FatherOrHusband",pat. "HWCPatientId",pat. "Education",pat. "Occupation",pat. "Religion",pat. "Nationality",pat. "PatientReferredById",pat. "IdProofValue",pat. "IdProofId",pat. "BloodGroup",pat. "Amount",pat. "PaymentStatus",pat. "TempPatient",pat. "HowDidYouKnowId",pat. "EducationId",pat. "OccupationId",pat. "BirthMark1",pat. "BirthMark2",pat. "RelationType",pat. "OccupationDetail",pat. "IsNewPatient",pat. "REGID",pat. "REGNO",pat. "InsuranceCompanyId",
apt."ProviderId",
apt."AppointmentId",
apt."PatientType",
apt."AppointmentNo"
,apt."AppointmentTime"
,apt. "AppointmentEndTime"
,apt. "AppointmentNotes",
apt."CouponId",
apt. "Amount" as "AppointmentAmount",
apt."Discount"
,apt. "Total"
,apt. "Status"
,apt. "PatientFamilyId"
,apt. "DepartmentId"
,apt. "PaymentType"
,apt. "PaymentNumber"
,apt. "PaymentStatus"
, apt."VisitTypeId"
, apt."ChargeTypesId"
, apt."LocationId"
, apt."AppointmentTypeId"
, apt."PayTypeId"
, apt."TokenNumber"
, apt."SpecializationId"
, apt."ProviderAvailabilityId"
, apt."ConsultationTypeId"
, apt."DoctorSpecializationChargeModuleDetailsId"
, apt."OtherRemarks"
, apt."AuthorityMasterId"
, apt."ReasonsId"
, apt."Remarks"
,pr."FullName" as "ProviderName",MM."ModuleName"
,(max(apt."AppointmentDate")over(partition by apt."PatientId")::text ||' ' || max(apt."AppointmentTime")over(partition by apt."PatientId",apt."AppointmentDate")::text)::timestamp as "AppointmentDate",
(case when (max(apt."AppointmentDate")over(partition by apt."PatientId")::text ||' ' || max(apt."AppointmentTime")over(partition by apt."PatientId")::text)::timestamp > now() at time zone 'UTC-5:30' then true else false end)"isActiveAppointmentExists"
, HWC."HWCName", HWC."Description", HWC."RowColor"
FROM "Patient" pat
left join maxapt apt on apt."PatientId" = pat."PatientId" and apt."Status" <> 'C' and apt."Active"=true
left join "Provider" pr on pr."ProviderId" = apt."ProviderId"
left join "HWCPatient" HWC on HWC."HWCPatientId" = pat."HWCPatientId"
LEFT JOIN "PatientReferredBy" referred ON referred."PatientReferredById" = pat."PatientReferredById"
left join "IdProof" id on id."IdProofId" = pat."IdProofId"
left join "HowDidYouKnow" hid on hid."HowDidYouKnowId" = pat."HowDidYouKnowId"
left join "Education" eid on eid."EducationId" = pat."EducationId"
left join "Occupation" oid on oid."OccupationId" = pat."OccupationId"
left join "PatientFamily" pf on pf."PatientId" = pat."PatientId"
left join "WebNotification" wn on wn."PatientId" = pat."PatientId"
left join "ModulesMaster" MM on MM."ModulesMasterId" = wn."ModulesMasterId"
WHERE pat."Active" IS TRUE
--and case when "filter" is null then 1=1 else (TRIM(UPPER(pat."FullName")) ILIKE '%' OR pat."UMRNo" ilike'%' OR pat."Mobile" ILIKE '%')|| "filter"||'%' end
and case when "filter" is null then 1=1 else TRIM(UPPER(pat."FullName")) ilike'%'|| "filter"||'%' OR TRIM(UPPER(pat."UMRNo")) ilike'%'|| "filter"||'%' OR TRIM(UPPER(pat."Mobile")) ilike'%'|| "filter"||'%' end
and case when "patientMobile" is null then 1=1 else pat."Mobile" ilike'%'|| "patientMobile"||'%' end
and case when "patientName" is null then 1=1 else pat."FullName" ilike'%'|| "patientName"||'%' end
and case when "appointmentId" is null then 1=1 else apt."AppointmentId" = "appointmentId" end
;
END
$BODY$;
ALTER FUNCTION public."udf_FetchPatients_For_AppointmentScheduleFollowUp"(character varying, character varying, character varying, character varying, integer)
OWNER TO postgres;
INSERT INTO public."ModulesMaster"(
"ModulesMasterId", "ModuleName", "ModuleIcon", "ModuleDescription", "CreatedBy", "CreatedDate", "ModifiedBy", "ModifiedDate", "PackageType", "IsChargeCategoryApplicable", "IsDoctorChargeCategoryApplicable")
VALUES (11, 'NewPatients','mdi mdi-eye', 'This is for New Patient Booking Appointment with pay later',null,null,null,null,null,false,false);
INSERT INTO public."ModulesMaster"(
"ModulesMasterId", "ModuleName", "ModuleIcon", "ModuleDescription", "CreatedBy", "CreatedDate", "ModifiedBy", "ModifiedDate", "PackageType", "IsChargeCategoryApplicable", "IsDoctorChargeCategoryApplicable")
VALUES (12, 'Emergency','mdi mdi-eye', 'This is for Emergency Patient Booking Appointment with pay later',null,null,null,null,null,false,false);
INSERT INTO public."ModulesMaster"(
"ModulesMasterId", "ModuleName", "ModuleIcon", "ModuleDescription", "CreatedBy", "CreatedDate", "ModifiedBy", "ModifiedDate", "PackageType", "IsChargeCategoryApplicable", "IsDoctorChargeCategoryApplicable")
VALUES (13, 'WalkIn','mdi mdi-eye', 'This is for walk- inPatient Booking Appointment with pay later',null,null,null,null,null,false,false);
Alter table "LocationAccountMap" Add column "Active" boolean;
Alter table "LocationAccountMap" Add column "CreatedBy" integer;
Alter table "LocationAccountMap" Add column "CreatedDate" timestamp without time zone;
Alter table "LocationAccountMap" Add column "ModifiedBy" integer;
Alter table "LocationAccountMap" Add column "ModifiedDate" timestamp without time zone;
ALTER TABLE "LocationAccountMap" ALTER COLUMN "Active" SET DEFAULT true;
update "LocationAccountMap" set "Active" = true;
---------function query for fetching doctors while booking appointments query where location is not available query change ----------
-- FUNCTION: public.udf_FetchDoctor_With_Availability_Specialization_Op(character varying, integer, integer, character varying)
-- DROP FUNCTION IF EXISTS public."udf_FetchDoctor_With_Availability_Specialization_Op"(character varying, integer, integer, character varying);
CREATE OR REPLACE FUNCTION public."udf_FetchDoctor_With_Availability_Specialization_Op"(
filter character varying DEFAULT NULL::text,
"locationId" integer DEFAULT NULL::integer,
"consultationTypeId" integer DEFAULT NULL::integer,
"appointmentDate" character varying DEFAULT NULL::text)
RETURNS TABLE("ProviderAvailabilityId" integer, "FullName" character varying, "DepartmentName" character varying, "DepartmentId" integer, "ProviderId" integer, "SpecializationId" integer, "SpecializationName" character varying, "LocationId" integer, "ConsultationTypeId" integer)
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
ROWS 1000
AS $BODY$
BEGIN
return query
SELECT DISTINCT on (pr2."ProviderId", s."SpecializationId") prl."ProviderAvailabilityId" ,pr2."FullName"
, d."DepartmentName" , d."DepartmentId"
,pr2."ProviderId"
, s. "SpecializationId", s."SpecializationName"
, CMT."LocationId", prl."ConsultationTypeId"
FROM "ProviderAvailability" prl
Join "DoctorSpecializationMap" LSM on LSM."ProviderId" = prl."ProviderId" and LSM."SpecializationId" = prl."SpecializationId" and LSM."ConsultationTypeId" = prl."ConsultationTypeId"
join "DoctorSpecializationChargeModuleDetails" DSCD on DSCD."ReferenceId" = LSM."DoctorSpecializationMapId"
join "DoctorSpecializationChargeModuleCategory" DSCC on DSCC."DoctorSpecializationChargeModuleCategoryId" = DSCD."DoctorSpecializationChargeModuleCategoryId"
join "ChargeModuleTemplate" CMT on CMT."ChargeModuleTemplateId" = DSCC."ChargeModuleTemplateId"
JOIN "Provider" pr2 on pr2."ProviderId" = LSM."ProviderId" and pr2."Active" is true
join "Account" pa on pa."ReferenceId" = pr2."ProviderId" and pa."Active" is true and pa."RoleId" = 3
JOin "LocationAccountMap" LAM on LAM."AccountId" = pa."AccountId" and LAM."Active" IS TRUE
join "Specialization" s on s."SpecializationId" = ANY (pr2."Specializations")
JOIN "Location" pral on pral."LocationId" = CMT."LocationId" AND pral."Active" IS TRUE
JOIN "Practice" pra on pra."PracticeId" = pral."PracticeId" AND pra."Active" IS TRUE
JOIN "Department" d on d."DepartmentId" = pr2."DepartmentId"
where pr2."Active" is true and CMT."LocationId" = "locationId" and s."Active" = true
--and CMT."StartDate"::date <= "appointmentDate"::date and CMT."EndDate"::date >= "appointmentDate"::date
and "IsInUse" is true
and case when "filter" is null then 1=1 else TRIM(UPPER(pr2."FullName")) ilike'%'|| "filter"||'%' OR TRIM(UPPER(s."SpecializationName")) ilike'%'|| "filter"||'%' end
and case when "consultationTypeId" is null then 1=1 else prl."ConsultationTypeId" = "consultationTypeId" end
and case when "appointmentDate" is null then CMT."StartDate"::date <= current_date::date and CMT."EndDate"::date >= current_date::date else CMT."StartDate"::date <= "appointmentDate"::date and CMT."EndDate"::date >= "appointmentDate"::date end
--and case when "locationId" is null then 1=1 else LAM."LocationId" = "LocationId" end
--order by "FullName" asc
;
END
$BODY$;
ALTER FUNCTION public."udf_FetchDoctor_With_Availability_Specialization_Op"(character varying, integer, integer, character varying)
OWNER TO postgres;
-- FUNCTION: public.widget_Table_OnlineAppointmentDashboard(date, integer, integer)
-- DROP FUNCTION IF EXISTS public."widget_Table_OnlineAppointmentDashboard"(date, integer, integer);
CREATE OR REPLACE FUNCTION public."widget_Table_OnlineAppointmentDashboard"(
"fromDate" date DEFAULT NULL::date,
"referenceId" integer DEFAULT NULL::integer,
"locationId" integer DEFAULT NULL::integer)
RETURNS TABLE("Salutation" character varying, "PatientName" text, "UMRNo" character varying, "AppointmentNo" character varying, "AppointmentTime" text, "AppointmentId" integer, "SpecializationName" character varying)
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
ROWS 1000
AS $BODY$
begin
return query
select Pa."Salutation", Pa."FullName" as "PatientName",Pa."UMRNo",
apt."AppointmentNo" ,-- apt."AppointmentTime"::text
TO_CHAR(apt."AppointmentTime", 'hh12:mi AM'),
apt."AppointmentId",s."SpecializationName"
from "Appointment" apt
join "ConsultationType" AT on AT."ConsultationTypeId" =apt."ConsultationTypeId"
join "Patient" Pa on Pa."PatientId" = apt."PatientId"
join "Provider" Pr on Pr."ProviderId" = apt."ProviderId"
join "Specialization" s on s."SpecializationId" = ANY (Pr."Specializations")
where apt."AppointmentDate"::date="fromDate" and apt."Active" is true and AT."ConsultationTypeId" =2
and case when "referenceId" is null then 1=1 else apt."ProviderId"= "referenceId" end
and case when "locationId" is null then 1=1 else apt."LocationId"= "locationId" end
;
end
$BODY$;
ALTER FUNCTION public."widget_Table_OnlineAppointmentDashboard"(date, integer, integer)
OWNER TO postgres;
CREATE SEQUENCE "NurseNote_NurseNoteId_seq";
CREATE TABLE IF NOT EXISTS public."NurseNote"
(
"NurseNoteId" integer NOT NULL DEFAULT nextval('"NurseNote_NurseNoteId_seq"'::regclass),
"Note" text COLLATE pg_catalog."default" NOT NULL,
"CreatedBy" bigint NOT NULL,
"CreatedDate" timestamp without time zone NOT NULL,
"AdmissionId" integer NOT NULL,
CONSTRAINT "PK_NurseNoteId" PRIMARY KEY ("NurseNoteId"),
CONSTRAINT "FK_NurseNote_AdmissionId" FOREIGN KEY ("AdmissionId")
REFERENCES public."Admission" ("AdmissionId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT "FK_NurseNote_CreatedById" FOREIGN KEY ("CreatedBy")
REFERENCES public."Account" ("AccountId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
\ No newline at end of file
alter table IF EXISTS "PatientMedicationHeader"
add column IF NOT EXISTS "AdmissionId" integer,
add CONSTRAINT "PatientMedicationHeader" FOREIGN KEY ("AdmissionId")
REFERENCES public."Admission" ("AdmissionId") MATCH SIMPLE;
---------------------------------------
alter table IF EXISTS "PatientLabHeader"
add column IF NOT EXISTS "AdmissionId" integer,
add CONSTRAINT "PatientLabHeader_AdmissionId_fkey" FOREIGN KEY ("AdmissionId")
REFERENCES public."Admission" ("AdmissionId") MATCH SIMPLE;
\ No newline at end of file
-- SEQUENCE: public.DoctorAvailabilityVisitType_DoctorAvailabilityVisitTypeId_seq
-- DROP SEQUENCE IF EXISTS public."DoctorAvailabilityVisitType_DoctorAvailabilityVisitTypeId_seq";
CREATE SEQUENCE IF NOT EXISTS public."DoctorAvailabilityVisitType_DoctorAvailabilityVisitTypeId_seq"
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 9223372036854775807
CACHE 1;
ALTER SEQUENCE public."DoctorAvailabilityVisitType_DoctorAvailabilityVisitTypeId_seq"
OWNER TO postgres;
-------------------------------------------------------
-- Table: public.DoctorAvailabilityVisitType
-- DROP TABLE IF EXISTS public."DoctorAvailabilityVisitType";
CREATE TABLE IF NOT EXISTS public."DoctorAvailabilityVisitType"
(
"DoctorAvailabilityVisitTypeId" integer NOT NULL DEFAULT nextval('"DoctorAvailabilityVisitType_DoctorAvailabilityVisitTypeId_seq"'::regclass),
"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 "DoctorAvailabilityVisitType_pkey" PRIMARY KEY ("DoctorAvailabilityVisitTypeId"),
CONSTRAINT "DoctorAvailabilityVisitType_LocationId_fkey" FOREIGN KEY ("LocationId")
REFERENCES public."Location" ("LocationId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT "DoctorAvailabilityVisitType_ProviderId_fkey" FOREIGN KEY ("ProviderId")
REFERENCES public."Provider" ("ProviderId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT "DoctorAvailabilityVisitType_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."DoctorAvailabilityVisitType"
OWNER to postgres;
COMMENT ON COLUMN public."DoctorAvailabilityVisitType"."DoctorAvailabilityVisitTypeId"
IS ' ';
\ No newline at end of file
create table "VaccineGroup"(
"VaccineGroupId" serial primary key,
"VaccineGroupName" text,
"Description" text,
"CreatedBy" int references "Account"("AccountId"),
"CreatedDate" timestamp without time zone,
"ModifiedBy" int references "Account"("AccountId"),
"ModifiedDate" timestamp without time zone
);
create table "VaccineType"(
"VaccineTypeId" serial primary key,
"TypeName" varchar(300),
"RowColor" varchar(250)
);
create table "VaccineMaster"(
"VaccineMasterId" serial primary key,
"VaccineGroupId" int references "VaccineGroup"("VaccineGroupId"),
"VaccineName" text,
"DisplayName" text,
"VaccineInstruction" text,
"Order" int,
"VaccineTypeId" int references "VaccineType"("VaccineTypeId"),
"AllowedDays" int,
"AllowedYear" int,
"AllowedMonth" int,
"ExclusionDays" text,
"AllowedLapsDays" int,
"CreatedBy" int references "Account"("AccountId"),
"CreatedDate" timestamp without time zone,
"ModifiedBy" int references "Account"("AccountId"),
"ModifiedDate" timestamp without time zone
);
create table "VaccineDependency"(
"VaccineDependencyId" serial primary key,
"VaccineMasterId" int references "VaccineMaster"("VaccineMasterId"),
"DependentOn" int references "VaccineMaster"("VaccineMasterId")
);
insert into "VaccineType" ("TypeName", "RowColor")
values
('Compulsory','#ffff'),
('Additional Vaccine','#90ee90'),
('Special Vaccine','#ffc0cb');
alter table "VaccineMaster" drop column"AllowedYear",drop column"AllowedMonth" ,
add column "AllowedType" varchar(10);
alter table "ProviderLeave" add column "ProviderLeaveStartTime" time without time zone;
alter table "ProviderLeave" add column "ProviderLeaveEndTime" time without time zone;
\ No newline at end of file
CREATE OR REPLACE FUNCTION public.upgrade_chargetemplate(
chargetemplateid integer,
locationid integer,
templatename text,
startdate timestamp without time zone,
endtdate timestamp without time zone,
modulesmasterid integer,
increasetype character varying,
increasevalue numeric)
RETURNS integer
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
AS $BODY$
DECLARE
new_id INTEGER;
BEGIN
-- Insert the new user and retrieve the value of the id column into the new_id variable
INSERT INTO public."ChargeModuleTemplate"(
"StartDate", "EndDate", "Active", "TemplateName", "CreatedBy", "CreatedDate", "LocationId")
VALUES (startdate,endtdate,True,TemplateName,6776,now(),LocationId)
RETURNING "ChargeModuleTemplateId" INTO new_id;
INSERT INTO public."ChargeModuleCategory"(
"Active", "ChargeCategoryId", "ModulesMasterId", "ChargeModuleTemplateId", "ChargeModuleRefTemplateId", "CreatedBy", "CreatedDate")
--VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);
select "Active", "ChargeCategoryId", "ModulesMasterId",new_id as "ChargeModuleTemplate", ChargeTemplateId as "ChargeModuleRefTemplateId"
, 6776 "CreatedBy",now () as "CreatedDate"
from public."ChargeModuleCategory" where "ChargeModuleTemplateId"=ChargeTemplateId
and case when ModulesMasterId is null then 1=1 else "ModulesMasterId"=ModulesMasterId end
;
INSERT INTO public."ChargeModuleDetails"(
"ReferenceId", "ChargeModuleCategoryId", "Amount", "LocationId", "CreatedBy", "CreatedDate")
--VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);
select b."ReferenceId",a."Refcatid",
case when IncreaseType='P' then b."Amount"+round((b."Amount"*IncreaseValue)/100,2)
when IncreaseType='P' then b."Amount"+IncreaseValue else b."Amount" end
, b."LocationId",6776,now() from (
select a."ChargeModuleCategoryId",b."ChargeModuleCategoryId" as "Refcatid" from "ChargeModuleCategory" a
join "ChargeModuleCategory" b on a."ChargeCategoryId"=b."ChargeCategoryId"
where a."ChargeModuleRefTemplateId" is null and b."ChargeModuleRefTemplateId" is not null
and b."ChargeModuleRefTemplateId"=ChargeTemplateId and a."ChargeModuleTemplateId"=ChargeTemplateId ) a
join "ChargeModuleDetails" b on a."ChargeModuleCategoryId"=b."ChargeModuleCategoryId";
INSERT INTO "ChargeModuleTemplateByLog" ("TemplateId","StartDate" ,"EndDate" ,"LocationId",
"RefTemplateId","ModulesMasterId" ,"IncreaseType","IncreaseValue" )
select new_id,startdate,endtdate,LocationId,ChargeTemplateId,ModulesMasterId,IncreaseType,IncreaseValue
;
-- Return the new_id value
RETURN new_id;
END;
$BODY$;
--------------------------------------------------------------------------------------------------------------------------
ALTER TABLE "LabMainDetail"
ADD COLUMN "NablRequired" boolean DEFAULT false;
\ No newline at end of file
alter table "ObEncounter"
add column "IsAppointmentClosed" boolean default false
\ No newline at end of file
INSERT INTO "Lookup" ( "Name", "Description")
VALUES ('DoctorWeek', 'To select what are the weeks available');
INSERT INTO "LookupValue" ( "LookupId", "Name", "CreatedDate", "CreatedBy")
VALUES (22, 'EveryDay', Current_date, 1029);
INSERT INTO "LookupValue" ( "LookupId", "Name", "CreatedDate", "CreatedBy")
VALUES (22, 'Weekly', Current_date, 1029);
INSERT INTO "LookupValue" ( "LookupId", "Name", "CreatedDate", "CreatedBy")
VALUES (22, 'Biweekly', Current_date, 1029);
alter table "ProviderAvailability" add column "DoctorWeekId" integer;
alter table "ProviderBreak" add column "DoctorWeekId" integer;
\ No newline at end of file
-- FUNCTION: public.udf_uiReport_fetch_Appointments_Location(integer, text, integer[], integer[], integer[], text, integer[], text, text, integer, date, date, integer[], boolean, text[], integer, integer)
-- DROP FUNCTION public."udf_uiReport_fetch_Appointments_Location"(integer, text, integer[], integer[], integer[], text, integer[], text, text, integer, date, date, integer[], boolean, text[], integer, integer);
CREATE OR REPLACE FUNCTION public."udf_uiReport_fetch_Appointments_Location"(
locationid integer DEFAULT NULL::integer,
"appointmentNo" text DEFAULT NULL::text,
"departmentId" integer[] DEFAULT NULL::integer[],
"providerId" integer[] DEFAULT NULL::integer[],
"patientId" integer[] DEFAULT NULL::integer[],
"uMRNo" text DEFAULT NULL::text,
"patientReferredById" integer[] DEFAULT NULL::integer[],
"referredByName" text DEFAULT NULL::text,
mobile text DEFAULT NULL::text,
"payTypeId" integer DEFAULT NULL::integer,
"fromDate" date DEFAULT NULL::date,
"toDate" date DEFAULT NULL::date,
"appointmentTypeId" integer[] DEFAULT NULL::integer[],
"paymentStatus" boolean DEFAULT NULL::boolean,
status text[] DEFAULT NULL::text[],
"pageIndex" integer DEFAULT 0,
"pageSize" integer DEFAULT 10)
RETURNS TABLE("DepartmentId" text, "DepartmentName" character varying, "ProviderId" text, "ProviderName" character varying, "AppointmentTypeName" character varying, "AppointmentDate" date, "AppointmentNo" character varying, "PatientId" integer, "VisitorName" character varying, "ReferredByName" character varying, "PatientName" character varying, "PatientAge" smallint, "UMRNo" character varying, "Mobile" character varying, "PatientGender" character, "AppointmentTime" time without time zone, "VisitType" character, "PaymentType" character varying, "PaymentNumber" character varying, "TotalAppointments" bigint, "TotalAmount" bigint, "TotalAmountStr" text, "ReceiptCreatedByName" text, "ReceiptDate" timestamp without time zone, "ReceiptId" integer, "StreetAdress" character varying, "City" character varying, "State" character varying, "FatherOrHusband" text, "PaymentStatus" boolean, "EncounterType" encountertype_elements, "Status" text)
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
ROWS 1000
AS $BODY$
BEGIN
return query
with cts as (select coalesce(A."DepartmentId"::text,'GrandTotal') "DepartmentId",
A."ProviderId"::text as "ProviderId",
A."AppointmentDate",A."AppointmentTypeId",
ATN."VisitorName" "AppointmentTypeName",
A."AppointmentNo",A."PatientId" "PatientId",PRB."Name",Pa."ReferredByName",
Pa."FullName",Pa."UMRNo",Pa."Mobile",A."AppointmentTime",A."VisitType",
case when ATN."VisitorName"='Follow Up' and sum(A."Total")=0 then 'Free Follow Up'
else PT."PayTypeName" end as "PaymentType" ,A."PaymentNumber",
A."AppointmentId",
case when A."Status"='B' then 'Booked' when A."Status"='R' then 'Rescheduled' when A."Status"='C' then 'Cancel' end::text as "Status",
COUNT(A."AppointmentNo") as "TotalAppointments" ,sum(A."Total")::text as "TotalAmountStr" ,
sum(A."Total")::bigint as "TotalAmount" ,
Pa."FatherOrHusband",
A."PaymentStatus",
A."EncounterType"
from "Appointment" A
left join "Patient" Pa on Pa."PatientId"::text=A."PatientId"::text
left join "PayType" PT on PT."PayTypeId"=A."PayTypeId"
left join "PatientReferredBy" PRB on PRB."PatientReferredById"::text=Pa."PatientReferredById"::text
left join "VisitType" ATN on A."VisitTypeId"=ATN."VisitTypeId"
where
--A."Status"<>'C' and
case when "departmentId" is null then 1=1 else A."DepartmentId" = any("departmentId") end and
CASE WHEN (locationId IS NULL OR locationId=0) THEN 1=1 ELSE A."LocationId"=locationId END and
case when "patientId" is null then 1=1 else Pa."PatientId" = any("patientId") end and
case when "appointmentNo" is null then 1=1 when "appointmentNo" ='' then 1=1 else A."AppointmentNo" ilike'%'||"appointmentNo" ||'%' end and
case when "providerId" is null then 1=1 else A."ProviderId" = any("providerId") end and
case when "uMRNo" is null then 1=1 when "uMRNo" ='' then 1=1 else Pa."UMRNo" ilike'%'||"uMRNo" ||'%' end and
case when "patientReferredById" is null then 1=1 else Pa."PatientReferredById" = any("patientReferredById") end and
case when "appointmentTypeId" is null then 1=1 else ATN."VisitTypeId" = any("appointmentTypeId") end and
case when "referredByName" is null then 1=1 when "referredByName" ='' then 1=1 else Pa."ReferredByName" ilike'%'||"referredByName" ||'%' end and
case when "mobile" is null then 1=1 when "mobile" ='' then 1=1 else Pa."Mobile" ilike'%'||"mobile" ||'%' end and
case when "payTypeId" is null then 1=1 else A."PayTypeId" ="payTypeId" end and
case when "fromDate" is null then 1=1 else "fromDate" <=A."AppointmentDate" and A."AppointmentDate" <="toDate" end and
case when "paymentStatus" is null then 1=1 else A."PaymentStatus" ="paymentStatus" end
and case when "status" is null then 1=1 else A."Status" =any("status") end
GROUP BY GROUPING SETS((A."DepartmentId",A."ProviderId",A."PatientId",PRB."Name",
Pa."ReferredByName",Pa."FullName",Pa."UMRNo",Pa."Mobile",A."AppointmentDate",A."AppointmentTime",
A."AppointmentNo",A."AppointmentTypeId",
ATN."VisitorName" ,
A."VisitType",
PT."PayTypeName",A."PaymentNumber",
A."AppointmentId",
A."Status",Pa."FatherOrHusband",A."PaymentStatus",A."EncounterType"), (A."DepartmentId",A."ProviderId"), ())
order by A."AppointmentId")
select A."DepartmentId",coalesce(D."DepartmentName",'GrandTotal') "DepartmentName",
case when A."AppointmentNo" is null then 'Total' else A."ProviderId" end "ProviderId",
case when A."AppointmentNo" is null then 'Total' else Pr."FullName" end as "ProviderName",
ATN."Name" "AppointmentTypeName",
A."AppointmentDate",
A."AppointmentNo",A."PatientId",
case when A."AppointmentNo" is null then null else PRB."Name"::varchar end as "Name",
case when A."AppointmentNo" is null then null else Pa."ReferredByName"::varchar end as "ReferredByName",
case when A."AppointmentNo" is null then null else Pa."FullName"::varchar end as "PatientName",
case when A."AppointmentNo" is null then null else Pa."Age" end "PatientAge",
case when A."AppointmentNo" is null then null else Pa."UMRNo" end "UMRNo",
case when A."AppointmentNo" is null then null else Pa."Mobile" end "Mobile",
case when A."AppointmentNo" is null then null else Pa."Gender" end "PatientGender",
A."AppointmentTime",
A."VisitType",A."PaymentType",A."PaymentNumber",A."TotalAppointments",A."TotalAmount",A."TotalAmountStr",
CA."FullName" "ReceiptCreatedByName", R."CreatedDate" "ReceiptDate",R."ReceiptId",
case when A."AppointmentNo" is null then null else Pa."StreetAddress" end "StreetAddress",
case when A."AppointmentNo" is null then null else Pa."City" end "City",
case when A."AppointmentNo" is null then null else Pa."State" end "State",
A."FatherOrHusband",
A."PaymentStatus",A."EncounterType",A."Status"
from cts A
left join "Department" D on A."DepartmentId"=D."DepartmentId"::text
left join "Provider" Pr on Pr."ProviderId"::text=A."ProviderId"
left join "Patient" Pa on Pa."PatientId"::text=A."PatientId"::text
left Join "Receipt" R on R."RespectiveId"=A."AppointmentId" and R."ReceiptAreaTypeId"=4
Left Join "Account" CA on CA."AccountId"=R."CreatedBy"
left join "PatientReferredBy" PRB on PRB."PatientReferredById"::text=Pa."PatientReferredById"::text
left join "AppointmentType" ATN on ATN."AppointmentTypeId"=A."AppointmentTypeId"
order by A."AppointmentId"
;
END
$BODY$;
ALTER FUNCTION public."udf_uiReport_fetch_Appointments_Location"(integer, text, integer[], integer[], integer[], text, integer[], text, text, integer, date, date, integer[], boolean, text[], integer, integer)
OWNER TO postgres;
alter table "Menu" add "EncounterKey" varchar(150)
\ No newline at end of file
-- FUNCTION: public.widget_Table_otAppointmentDashboard1(date, integer, integer)
-- DROP FUNCTION IF EXISTS public."widget_Table_otAppointmentDashboard1"(date, integer, integer);
CREATE OR REPLACE FUNCTION public."widget_Table_otAppointmentDashboard1"(
"fromDate" date DEFAULT NULL::date,
"referenceId" integer DEFAULT NULL::integer,
"locationId" integer DEFAULT NULL::integer)
RETURNS TABLE("Salutation" character varying, "PatientName" text, "UMRNo" character varying, "AppointmentTime" text, "SpecializationName" character varying, "SurgeryId" integer, "SurgeryName" text)
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
ROWS 1000
AS $BODY$
begin
return query
select Pa."Salutation",Pa."FullName" as "PatientName",Pa."UMRNo",
TO_CHAR(ot."SignInDate", 'hh12:mi AM') as "AppointmentTime",
s."SpecializationName",ot."SurgeryId",s1."Name" as "SurgeryName"
from "OTRegister" ot
--join "AppointmentType" AT on AT."AppointmentTypeId" =apt."AppointmentTypeId"
join "Patient" Pa on Pa."PatientId" = ot."PatientId"
join "Provider" Pr on Pr."ProviderId" = ot."ProviderId"
join "Specialization" s on s."SpecializationId" = ANY (Pr."Specializations")
join "Surgery" s1 on s1."SurgeryId"=ot."SurgeryId"
where
ot."SignInDate"::date="fromDate" and ot."Active" is true
and case when "referenceId" is null then 1=1 else ot."ProviderId"= "referenceId" end
and case when "locationId" is null then 1=1 else ot."LocationId"= "locationId" end
;
end
$BODY$;
ALTER FUNCTION public."widget_Table_otAppointmentDashboard1"(date, integer, integer)
OWNER TO postgres;
ALTER TYPE encountertype_elements ADD VALUE 'DietPlanEncounter' after 'PediatricEncounter' ;
CREATE TABLE IF NOT EXISTS public."DietPlanEncounter"
(
"DietPlanEncounterId" serial primary key,
"AppointmentId" integer,
"DietPlanEncounterDate" timestamp(6) without time zone NOT NULL,
"DietPlanPrescribed" text COLLATE pg_catalog."default",
"OpNutritionScreening" text COLLATE pg_catalog."default",
"OpNutritionAssessment" text COLLATE pg_catalog."default",
"IpNutritionScreening" text COLLATE pg_catalog."default",
"PediatricCDCScreening" text COLLATE pg_catalog."default",
"DietGuidlines" text COLLATE pg_catalog."default",
"AdmissionId" integer,
CONSTRAINT "UQ_DietPlanEncounter" UNIQUE ("AppointmentId")
);
alter table "Admission" add column "BedAssociatedData" text;
alter table "Admission" add column "NRIData" text;
alter table "Admission" add column "SurrogacyData" text;
alter table "Admission" add column "EmergencyInfo" text;
alter table "ChargeModuleDetails" drop CONSTRAINT "ChargeModuleDetails_LocationId_fkey";
\ No newline at end of file
create sequence "DynamicTemplateConfig_DynamicTemplateConfigId_seq"
CREATE TABLE IF NOT EXISTS public."DynamicTemplateConfig"
(
"DynamicTemplateConfigId" bigint NOT NULL DEFAULT nextval('"DynamicTemplateConfig_DynamicTemplateConfigId_seq"'::regclass),
"ReportName" character varying(255) COLLATE pg_catalog."default",
"DynamicReportId" bigint NOT NULL,
"Active" boolean DEFAULT true,
"CreatedBy" bigint NOT NULL,
"CreatedDate" timestamp without time zone NOT NULL,
"ModifiedBy" bigint,
"ModifiedDate" timestamp without time zone,
CONSTRAINT "DynamicTemplateConfig_pkey" PRIMARY KEY ("DynamicTemplateConfigId"),
CONSTRAINT "FK_DynamicTemplateConfig_CreatedBy" FOREIGN KEY ("CreatedBy")
REFERENCES public."Account" ("AccountId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT "FK_DynamicTemplateConfig_ModifiedBy" FOREIGN KEY ("ModifiedBy")
REFERENCES public."Account" ("AccountId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT "FK_DynamicTemplateConfig_DynamicReportId" FOREIGN KEY ("DynamicReportId")
REFERENCES public."DynamicReport" ("DynamicReportId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
--------------------------------------------------------------------------------------------------------------------------
insert into "LogType" values (77, 'DynamicTemplateConfig', true)
Alter Table "GynEncounter"
add column "ProformaForOasi" text
\ No newline at end of file
alter table "VaccineMaster" alter column "AllowedDays" type numeric(8,2);
alter table "VaccineMaster" add column "Active" boolean default true;
\ No newline at end of file
alter table "ChargeModuleCategory" add "ChargeModuleRefTemplateId" int
--------------------------------------------------------------------------------------------------------------------------------------------
create sequence "ChargeModuleTemplateByLog_ChargeModuleTemplateByLogId_seq";
CREATE TABLE IF NOT EXISTS public."ChargeModuleTemplateByLog"
(
"ChargeModuleTemplateByLogId" integer NOT NULL DEFAULT nextval('"ChargeModuleTemplateByLog_ChargeModuleTemplateByLogId_seq"'::regclass),
"TemplateId" integer,
"StartDate" date,
"EndDate" date,
"LocationId" integer,
"RefTemplateId" integer,
"ModulesMasterId" integer,
"IncreaseType" character varying(10) COLLATE pg_catalog."default",
"IncreaseValue" numeric,
"CreatedDate" timestamp without time zone DEFAULT now(),
CONSTRAINT "ChargeModuleTemplateByLog_pkey" PRIMARY KEY ("ChargeModuleTemplateByLogId")
);
--------------------------------------------------------------------------------------------------------------------------------------------
DROP FUNCTION IF EXISTS public.upgrade_chargetemplate(integer, integer, text, timestamp without time zone, timestamp without time zone, integer, character varying, numeric);
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION public.upgrade_chargetemplate(
chargetemplateid integer,
locationid integer,
templatename text,
startdate timestamp without time zone,
endtdate timestamp without time zone,
modulesmasterid integer,
increasetype character varying,
increasevalue numeric)
RETURNS integer
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
AS $BODY$
DECLARE
new_id INTEGER;
BEGIN
-- Insert the new user and retrieve the value of the id column into the new_id variable
INSERT INTO public."ChargeModuleTemplate"(
"StartDate", "EndDate", "Active", "TemplateName", "CreatedBy", "CreatedDate", "LocationId")
VALUES (startdate,endtdate,True,TemplateName,6776,now(),LocationId)
RETURNING "ChargeModuleTemplateId" INTO new_id;
INSERT INTO public."ChargeModuleCategory"(
"Active", "ChargeCategoryId", "ModulesMasterId", "ChargeModuleTemplateId", "ChargeModuleRefTemplateId", "CreatedBy", "CreatedDate")
--VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);
select "Active", "ChargeCategoryId", "ModulesMasterId",new_id as "ChargeModuleTemplate", ChargeTemplateId as "ChargeModuleRefTemplateId"
, 6776 "CreatedBy",now () as "CreatedDate"
from public."ChargeModuleCategory" where "ChargeModuleTemplateId"=ChargeTemplateId
and case when ModulesMasterId is null then 1=1 else "ModulesMasterId"=ModulesMasterId end
;
INSERT INTO public."ChargeModuleDetails"(
"ReferenceId", "ChargeModuleCategoryId", "Amount", "LocationId", "CreatedBy", "CreatedDate")
--VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);
select b."ReferenceId",a."Refcatid",
case when IncreaseType='P' then b."Amount"+round((b."Amount"*IncreaseValue)/100,2)
when IncreaseType='A' then b."Amount"+IncreaseValue else b."Amount" end
, b."LocationId",6776,now() from (
select a."ChargeModuleCategoryId",b."ChargeModuleCategoryId" as "Refcatid" from "ChargeModuleCategory" a
right join "ChargeModuleCategory" b on a."ChargeModuleTemplateId"=b."ChargeModuleRefTemplateId"
and a."ChargeCategoryId"=b."ChargeCategoryId" and a."ModulesMasterId"=b."ModulesMasterId"
where b."ChargeModuleRefTemplateId"=ChargeTemplateId and b."ChargeModuleTemplateId"=new_id
and a."ChargeModuleTemplateId"=ChargeTemplateId
) a
join "ChargeModuleDetails" b on a."ChargeModuleCategoryId"=b."ChargeModuleCategoryId";
INSERT INTO "ChargeModuleTemplateByLog" ("TemplateId","StartDate" ,"EndDate" ,"LocationId",
"RefTemplateId","ModulesMasterId" ,"IncreaseType","IncreaseValue" )
select new_id,startdate,endtdate,LocationId,ChargeTemplateId,ModulesMasterId,IncreaseType,IncreaseValue
;
-- Return the new_id value
RETURN new_id;
END;
$BODY$;
-------------------------------------------------------------------------------------------------------------------------------------------------
insert into "LabLogType" ("LogTypeName","Active")
values('Lab_Masters_Machine',true),('Lab_Masters_Parameter',true),
('Lab_Masters_Component',true),('Lab_Masters_Template',true),
('Lab_Cancelling_Test',true),('Lab_Sample_Collection',true),
('Lab_Sample_Transfer',true),('Lab_Sample_Receive',true);
---------------------------------------------------------------------------------------
ALTER TABLE IF EXISTS public."PackageModule" ADD COLUMN "ExpiresIn" smallint;
\ No newline at end of file
alter table "GynEncounter" add "GyneacPartner" text
alter table "GynEncounter" add "Procedure" text
\ No newline at end of file
delete from "DoctorSpecializationChargeModuleDetails" cascade;
---------------------------------------------------------------------------
delete from "DoctorSpecializationChargeModuleCategory" cascade;
---------------------------------------------------------------------------
delete from "DoctorSpecializationMap" cascade;
---------------------------------------------------------------------------
alter table "DoctorSpecializationMap"
add column "LocationId" int,
add CONSTRAINT "DoctorSpecializationMap_LocationId" FOREIGN KEY ("LocationId")
REFERENCES public."Location" ("LocationId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION;
\ No newline at end of file
CREATE SEQUENCE IF NOT EXISTS public."HealthCard_HealthCardId_seq"
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 9223372036854775807
CACHE 1;
ALTER SEQUENCE public."HealthCard_HealthCardId_seq"
OWNER TO postgres;
---------------------------------------------------------------------------------------------------------------------
-- Table: public.HealthCard
-- DROP TABLE IF EXISTS public."HealthCard";
CREATE TABLE IF NOT EXISTS public."HealthCard"
(
"HealthCardId" integer NOT NULL DEFAULT nextval('"HealthCard_HealthCardId_seq"'::regclass),
"HealthCardName" character varying(50) COLLATE pg_catalog."default" NOT NULL,
"Amount" bigint NOT NULL,
"AllowMembers" integer,
"ValidityType" character varying COLLATE pg_catalog."default",
"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,
CONSTRAINT "HealthCard_pkey" PRIMARY KEY ("HealthCardId"),
CONSTRAINT "UQ_HealthCard_HealthCardName" UNIQUE ("HealthCardName"),
CONSTRAINT "FK_HealthCard_CreatedBy" FOREIGN KEY ("CreatedBy")
REFERENCES public."Account" ("AccountId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE CASCADE,
CONSTRAINT "FK_HealthCard_ModifiedBy" FOREIGN KEY ("ModifiedBy")
REFERENCES public."Account" ("AccountId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE CASCADE
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS public."HealthCard"
OWNER to postgres;
------------------------------------------------------------------------------------------------------------
CREATE SEQUENCE IF NOT EXISTS public."HealthCardMember_HealthCardMemberId_seq"
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 9223372036854775807
CACHE 1;
ALTER SEQUENCE public."HealthCardMember_HealthCardMemberId_seq"
OWNER TO postgres;
----------------------------------------------------------------------------------------------------
-- SEQUENCE: public.IssueHealthCard_IssueHealthCardId_seq
-- DROP SEQUENCE IF EXISTS public."IssueHealthCard_IssueHealthCardId_seq";
CREATE SEQUENCE IF NOT EXISTS public."IssueHealthCard_IssueHealthCardId_seq"
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 9223372036854775807
CACHE 1;
ALTER SEQUENCE public."IssueHealthCard_IssueHealthCardId_seq"
OWNER TO postgres;
------------------------------------------------------------------------------------------
-- Table: public.HealthCardMember
-- DROP TABLE IF EXISTS public."HealthCardMember";
CREATE TABLE IF NOT EXISTS public."HealthCardMember"
(
"HealthCardMemberId" integer NOT NULL DEFAULT nextval('"HealthCardMember_HealthCardMemberId_seq"'::regclass),
"IssueHealthCardId" integer,
"DependentPatientId" integer,
CONSTRAINT "HealthCardMember_pkey" PRIMARY KEY ("HealthCardMemberId"),
CONSTRAINT "HealthCardMember_DependentPatientId_fkey" FOREIGN KEY ("DependentPatientId")
REFERENCES public."Patient" ("PatientId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT "HealthCardMember_IssueHealthCardId_fkey" FOREIGN KEY ("IssueHealthCardId")
REFERENCES public."IssueHealthCard" ("IssueHealthCardId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS public."HealthCardMember"
OWNER to postgres;
------------------------------------------------------------------------------------------------------------
-- Table: public.IssueHealthCard
-- DROP TABLE IF EXISTS public."IssueHealthCard";
CREATE TABLE IF NOT EXISTS public."IssueHealthCard"
(
"IssueHealthCardId" integer NOT NULL DEFAULT nextval('"IssueHealthCard_IssueHealthCardId_seq"'::regclass),
"HealthCardId" integer NOT NULL,
"CardNumber" text COLLATE pg_catalog."default",
"PatientId" integer,
"CreatedBy" integer,
"CreatedDate" timestamp without time zone,
"ModifiedBy" integer,
"ModifiedDate" timestamp without time zone,
"IssuedDate" date NOT NULL,
"Active" boolean DEFAULT true,
"PayTypeId" integer,
"PaymentNumber" character varying(50) COLLATE pg_catalog."default",
"NetAmount" numeric(8,2),
"ValidTill" date,
CONSTRAINT "IssueHealthCard_pkey" PRIMARY KEY ("IssueHealthCardId"),
CONSTRAINT "IssueHealthCard_CreatedBy_fkey" FOREIGN KEY ("CreatedBy")
REFERENCES public."Account" ("AccountId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT "IssueHealthCard_HealthCardId_fkey" FOREIGN KEY ("HealthCardId")
REFERENCES public."HealthCard" ("HealthCardId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT "IssueHealthCard_ModifiedBy_fkey" FOREIGN KEY ("ModifiedBy")
REFERENCES public."Account" ("AccountId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT "IssueHealthCard_PatientId_fkey" FOREIGN KEY ("PatientId")
REFERENCES public."Patient" ("PatientId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT "IssueHealthCard_PayTypeId_fkey" FOREIGN KEY ("PayTypeId")
REFERENCES public."PayType" ("PayTypeId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS public."IssueHealthCard"
OWNER to postgres;
-------------------------------------------------------
INSERT INTO "LogType" ("LogTypeId","LogTypeName","Active")
VALUES (79,'HealthCard',TRUE);
\ No newline at end of file
CREATE TABLE IF NOT EXISTS public."Ambulance"
(
"AmbulanceId" serial,
"AmbulanceNo" character varying(50) COLLATE pg_catalog."default" NOT NULL,
"AssignedNo" character varying(50) COLLATE pg_catalog."default" NOT NULL,
"Active" boolean NOT NULL DEFAULT true,
"CreatedDate" timestamp(6) without time zone NOT NULL,
"CreatedBy" integer NOT NULL,
"ModifiedBy" integer,
"ModifiedDate" timestamp(6) without time zone,
"LocationId" integer,
CONSTRAINT "Ambulance_pkey" PRIMARY KEY ("AmbulanceId"),
CONSTRAINT "UQ_Ambulance_AmbulanceNo" UNIQUE ("AmbulanceNo"),
CONSTRAINT "UQ_Ambulance_AssignedNo" UNIQUE ("AssignedNo"),
CONSTRAINT "Ambulance_LocationId_fkey" FOREIGN KEY ("LocationId")
REFERENCES public."Location" ("LocationId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS public."Ambulance"
OWNER to postgres;
------------------------------------------------------------------------------------------------------
-- Table: public.DriverDetail
-- DROP TABLE IF EXISTS public."DriverDetail";
CREATE TABLE IF NOT EXISTS public."DriverDetail"
(
"DriverDetailId" serial,
"DriverDetailName" character varying(255) COLLATE pg_catalog."default",
"MobileNo" character varying(10) COLLATE pg_catalog."default",
"AadharNo" character varying(12) COLLATE pg_catalog."default",
"Address" character varying(255) COLLATE pg_catalog."default",
"Active" boolean,
"CreatedBy" integer,
"CreatedDate" timestamp without time zone,
"ModifiedBy" integer,
"ModifiedDate" timestamp without time zone,
"FromTime" character varying(10) COLLATE pg_catalog."default",
"ToTime" character varying(10) COLLATE pg_catalog."default",
CONSTRAINT "DriverDetail_pkey" PRIMARY KEY ("DriverDetailId"),
CONSTRAINT "DriverDetail_CreatedBy_fkey" FOREIGN KEY ("CreatedBy")
REFERENCES public."Account" ("AccountId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT "DriverDetail_ModifiedBy_fkey" 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."DriverDetail"
OWNER to postgres;
--------------------------------------------------------------------------------------------------------
-- Table: public.AmbulanceReciept
-- DROP TABLE IF EXISTS public."AmbulanceReciept";
CREATE TABLE IF NOT EXISTS public."AmbulanceReciept"
(
"AmbulanceRecieptId" integer NOT NULL DEFAULT nextval('"AmbulanceReciept_AmbulanceRecieptId_seq"'::regclass),
"RecieptNo" text COLLATE pg_catalog."default",
"FromLocation" character varying(50) COLLATE pg_catalog."default",
"Address" character varying(255) COLLATE pg_catalog."default",
"ToLocation" character varying(50) COLLATE pg_catalog."default",
"PatientName" character varying(50) COLLATE pg_catalog."default",
"PatientMobile" character varying(10) COLLATE pg_catalog."default",
"CreatedBy" integer,
"CreatedDate" timestamp without time zone,
"DriverDetailId" integer,
"AmbulanceId" integer,
"Amount" numeric(8,2),
"ModifiedBy" integer,
"ModifiedDate" timestamp without time zone,
CONSTRAINT "AmbulanceReciept_pkey" PRIMARY KEY ("AmbulanceRecieptId"),
CONSTRAINT "AmbulanceReciept_CreatedBy_fkey" FOREIGN KEY ("CreatedBy")
REFERENCES public."Account" ("AccountId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT "AmbulanceReciept_ModifiedBy_fkey" 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."AmbulanceReciept"
OWNER to postgres;
alter table "AmbulanceReciept" add column "LocationId" integer references "Location"("LocationId");
---------------------------------------------------------------------------------------------------------------
\ No newline at end of file
alter table "NewLabBookingDetail" add column "ReportUrl" text,add column "ExternalLab" bool default false;
alter table "NewLabBookingDetail" add column "UploadedBy" int references "Account"("AccountId"),
add column "UploadedDate" timestamp without time zone;
alter table "Ambulance" add column "LocationId" integer references "Location"("LocationId");
alter table "AmbulanceReciept" add column "LocationId" integer references "Location"("LocationId");
update "Ambulance" set "LocationId"=1;
update "AmbulanceReciept" set "LocationId"=1;
insert into "LogType"( "LogTypeId","LogTypeName",true) values (80,'DriverDetail',true)
,(81,'AmbulanceReciept',true);
\ No newline at end of file
UPDATE public."LogType"
SET "LogTypeName"='OTAppointment'
WHERE "LogTypeId"=71;
\ No newline at end of file
create sequence "DynamicReportImages_DynamicReportImagesId_seq";
CREATE TABLE "DynamicReportImages"
(
"DynamicReportImagesId" bigint NOT NULL DEFAULT nextval('"DynamicReportImages_DynamicReportImagesId_seq"'::regclass),
"ImagePath" text ,
"Guid" uuid,
"CreatedBy" bigint NOT NULL,
"CreatedDate" timestamp without time zone NOT NULL,
CONSTRAINT "DynamicReportImages_pkey" PRIMARY KEY ("DynamicReportImagesId"),
CONSTRAINT "FK_DynamicReportImages_CreatedBy" FOREIGN KEY ("CreatedBy")
REFERENCES public."Account" ("AccountId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
);
INSERT INTO public."LogType"(
"LogTypeId", "LogTypeName", "Active")
VALUES (82, 'OTAvailability', true);
\ No newline at end of file
INSERT INTO public."LogType"(
"LogTypeId", "LogTypeName", "Active")
VALUES (78, 'OTRoom', true);
\ No newline at end of file
create table "VaccineMasterPharmacyLink"(
"VaccineMasterPharmacyLinkId" serial primary key,
"VaccineMasterId" int references "VaccineMaster"("VaccineMasterId"),
"PharmacyProductId" int references "PharmacyProduct"("PharmacyProductId"),
"CreatedBy" int references "Account"("AccountId"),
"CreatedDate" timestamp without time zone,
"ModifiedBy" int references "Account"("AccountId"),
"ModifiedDate" timestamp without time zone
);
alter table "LabTransferHeader"
add column "TransferredTemperature" int,
add column "ReceivedTemperature" int,
add column "TransferredTemperatureComments" text,
add column "ReceivedTemperatureComments" text;
\ No newline at end of file
update "Settings" set "Value"='{
"salutation":false,
"showSalutation":false,
"dateOfBirth":false,
"showDateOfBirth":false,
"email":false,
"showEmail":false,
"maritalStatus":false,
"showMaritalStatus":false,
"religion":false,
"showReligion":null,
"nationality":false,
"showNationality":null,
"city":false,
"showCity":null,
"state":false,
"showState":null,
"streetAddress":false,
"showStreetAddress":null,
"zipcode":false,
"showZipcode":null,
"hwcPatientId":false,
"showHwcPatientId":null,
"idProofId":false,
"showIdProofId":null,
"referredBy":false,
"showReferredBy":null,
"bloodGroup":false,
"showBloodGroup":null,
"relativeMobile":false,
"showRelativeMobile":false,
"relativeEducation":false,
"showRelativeEducation":null,
"relativeOccupation":false,
"showRelativeOccupation":false,
"dob":false,
"showDob":false,
"howDidYouKnowId":false,
"showHowDidYouKnowId":null,
"educationId":false,
"showEducationId":null,
"occupationId":false,
"showOccupationId":false,
"birthMark1":false,
"showBirthMark1":null,
"birthMark2":false,
"showBirthMark2":null,
"insuranceId":null,
"showInsuranceId":null,
"occupationDetail":null,
"showOccupationDetail":null,
"addressLine2":null,
"showAddressLine2":null,
"occupationDetails":null,
"showOccupationDetails":null
}' where "Name"='Patient Validation'
\ No newline at end of file
alter table "Patient"
add column "ReferredByNameId" integer;
\ No newline at end of file
create sequence "ICDValues_ICDValuesId_seq"
CREATE TABLE IF NOT EXISTS public."ICDValues"
(
"ICDValuesId" integer NOT NULL DEFAULT nextval('"ICDValues_ICDValuesId_seq"'::regclass),
"Code" character varying(255) COLLATE pg_catalog."default",
"Usable" text,
"ShortDesc" text
)
-- FUNCTION: public.udf_FetchDoctor_With_Availability_Specialization_Op(character varying, integer, integer, character varying)
-- DROP FUNCTION IF EXISTS public."udf_FetchDoctor_With_Availability_Specialization_Op"(character varying, integer, integer, character varying);
CREATE OR REPLACE FUNCTION public."udf_FetchDoctor_With_Availability_Specialization_Op"(
filter character varying DEFAULT NULL::text,
"locationId" integer DEFAULT NULL::integer,
"consultationTypeId" integer DEFAULT NULL::integer,
"appointmentDate" character varying DEFAULT NULL::text)
RETURNS TABLE("ProviderAvailabilityId" integer, "FullName" character varying, "DepartmentName" character varying, "DepartmentId" integer, "ProviderId" integer, "SpecializationId" integer, "SpecializationName" character varying, "LocationId" integer, "ConsultationTypeId" integer)
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
ROWS 1000
AS $BODY$
BEGIN
return query
SELECT DISTINCT on (pr2."ProviderId", s."SpecializationId") prl."ProviderAvailabilityId" ,pr2."FullName"
, d."DepartmentName" , d."DepartmentId"
,pr2."ProviderId"
, s. "SpecializationId", s."SpecializationName"
, CMT."LocationId", prl."ConsultationTypeId"
FROM "ProviderAvailability" prl
left Join "DoctorSpecializationMap" LSM on LSM."ProviderId" = prl."ProviderId" and LSM."SpecializationId" = prl."SpecializationId" and LSM."ConsultationTypeId" = prl."ConsultationTypeId"
left join "DoctorSpecializationChargeModuleDetails" DSCD on DSCD."ReferenceId" = LSM."DoctorSpecializationMapId"
left join "DoctorSpecializationChargeModuleCategory" DSCC on DSCC."DoctorSpecializationChargeModuleCategoryId" = DSCD."DoctorSpecializationChargeModuleCategoryId"
left join "ChargeModuleTemplate" CMT on CMT."ChargeModuleTemplateId" = DSCC."ChargeModuleTemplateId"
left JOIN "Provider" pr2 on pr2."ProviderId" = LSM."ProviderId" and pr2."Active" is true
left join "Account" pa on pa."ReferenceId" = pr2."ProviderId" and pa."Active" is true and pa."RoleId" = 3
left JOin "LocationAccountMap" LAM on LAM."AccountId" = pa."AccountId" and LAM."Active" IS TRUE
join "Specialization" s on s."SpecializationId" = ANY (pr2."Specializations")
JOIN "Location" pral on pral."LocationId" = CMT."LocationId" AND pral."Active" IS TRUE
JOIN "Practice" pra on pra."PracticeId" = pral."PracticeId" AND pra."Active" IS TRUE
JOIN "Department" d on d."DepartmentId" = pr2."DepartmentId"
where pr2."Active" is true and CMT."LocationId" = "locationId" and s."Active" = true and prl."Active" is true
--and CMT."StartDate"::date <= "appointmentDate"::date and CMT."EndDate"::date >= "appointmentDate"::date
and "IsInUse" is true
and case when "filter" is null then 1=1 else TRIM(UPPER(pr2."FullName")) ilike'%'|| "filter"||'%' OR TRIM(UPPER(s."SpecializationName")) ilike'%'|| "filter"||'%' end
and case when "consultationTypeId" is null then 1=1 else prl."ConsultationTypeId" = "consultationTypeId" end
and case when "appointmentDate" is null then CMT."StartDate"::date <= current_date::date and CMT."EndDate"::date >= current_date::date else CMT."StartDate"::date <= "appointmentDate"::date and CMT."EndDate"::date >= "appointmentDate"::date end
--and case when "locationId" is null then 1=1 else LAM."LocationId" = "LocationId" end
--order by "FullName" asc
;
END
$BODY$;
ALTER FUNCTION public."udf_FetchDoctor_With_Availability_Specialization_Op"(character varying, integer, integer, character varying)
OWNER TO postgres;
create sequence "AuthorityMaster_AuthorityMasterId_seq";
CREATE TABLE "AuthorityMaster"
(
"AuthorityMasterId" int NOT NULL DEFAULT nextval('"AuthorityMaster_AuthorityMasterId_seq"'::regclass),
"Authority" character varying(255),
"Active" boolean DEFAULT true,
"CreatedBy" int NOT NULL,
"CreatedDate" timestamp without time zone NOT NULL,
"ModifiedBy" int,
"ModifiedDate" timestamp without time zone,
CONSTRAINT "AuthorityMaster_pkey" PRIMARY KEY ("AuthorityMasterId"),
CONSTRAINT "FK_AuthorityMaster_CreatedBy" FOREIGN KEY ("CreatedBy")
REFERENCES public."Account" ("AccountId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT "FK_AuthorityMaster_ModifiedBy" FOREIGN KEY ("ModifiedBy")
REFERENCES public."Account" ("AccountId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
);
----------------------------------------------------------------------------------------------------------------------
insert into "LogType" values(84, 'AuthorityMaster', true);
drop table if exists "PatientQueue" cascade;
\ No newline at end of file
create sequence "Reasons_ReasonsId_seq";
CREATE TABLE "Reasons"
(
"ReasonsId" int NOT NULL DEFAULT nextval('"Reasons_ReasonsId_seq"'::regclass),
"Reason" character varying(255),
"Active" boolean DEFAULT true,
"CreatedBy" int NOT NULL,
"CreatedDate" timestamp without time zone NOT NULL,
"ModifiedBy" int,
"ModifiedDate" timestamp without time zone,
CONSTRAINT "Reasons_pkey" PRIMARY KEY ("ReasonsId"),
CONSTRAINT "FK_Reasons_CreatedBy" FOREIGN KEY ("CreatedBy")
REFERENCES public."Account" ("AccountId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
CONSTRAINT "FK_Reasons_ModifiedBy" FOREIGN KEY ("ModifiedBy")
REFERENCES public."Account" ("AccountId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
);
---------------------------------------------------------------------------------------------------------------------
insert into "LogType" values(83, 'Reasons', true)
alter table "WebNotification" add column "ModulesMasterId" int references "ModulesMaster"("ModulesMasterId");
update "WebNotification" set "ModulesMasterId" = (select "ModulesMasterId" from "ModulesMaster" mm where "ModuleName" = 'Pharmacy') where "WebNotificationTypeId" = 1;
update "WebNotification" set "ModulesMasterId" = (select "ModulesMasterId" from "ModulesMaster" mm where "ModuleName" = 'Lab') where "WebNotificationTypeId" = 2;
alter table "WebNotification" drop column "WebNotificationTypeId";
drop table "WebNotificationType" cascade;
ALTER SEQUENCE "ModulesMaster_ModulesMasterId_seq" RESTART WITH 10;
ALTER TABLE "GynEncounter"
ADD COLUMN "FamilyHistory" text ,
ADD COLUMN "ProblemList" text ,
ADD COLUMN "Surgeries" text ,
ADD COLUMN "BirthHistory" text ,
ADD COLUMN "Allergies" text
\ No newline at end of file
CREATE SEQUENCE IF NOT EXISTS public."BillStatusType_Seq"
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 9223372036854775807
CACHE 1;
CREATE TABLE IF NOT EXISTS public."BillStatusType"
(
"BillStatusTypeId" integer NOT NULL DEFAULT nextval('"BillStatusType_Seq"'::regclass),
"Name" character varying(50) COLLATE pg_catalog."default" NOT NULL,
"Active" boolean NOT NULL DEFAULT true,
CONSTRAINT "BillStatusType_pkey" PRIMARY KEY ("BillStatusTypeId")
)
TABLESPACE pg_default;
\ No newline at end of file
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;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment