alter table "NewLabBookingDetail"
add column "Emergency" boolean default false;

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


DELETE FROM "PackageModule";
DELETE FROM "AdmissionPackage";

INSERT INTO "Lookup" ("Name") VALUES ('Module Type');
INSERT INTO "Lookup" ("Name") VALUES ('Package Type');

SELECT "LookupId", "Name" FROM "Lookup" WHERE "Name" = 'Module Type';
INSERT INTO "LookupValue" ("LookupId", "Name", "CreatedDate") VALUES ((SELECT "LookupId" FROM "Lookup" WHERE "Name" = 'Module Type'), 'Cash', NOW());
INSERT INTO "LookupValue" ("LookupId", "Name", "CreatedDate") VALUES ((SELECT "LookupId" FROM "Lookup" WHERE "Name" = 'Module Type'), 'Insurance', NOW());
SELECT * FROM "LookupValue" WHERE "LookupId" = 25;

SELECT "LookupId", "Name" FROM "Lookup" WHERE "Name" = 'Package Type';
INSERT INTO "LookupValue" ("LookupId", "Name", "CreatedDate") VALUES ((SELECT "LookupId" FROM "Lookup" WHERE "Name" = 'Package Type'), 'OP', NOW());
INSERT INTO "LookupValue" ("LookupId", "Name", "CreatedDate") VALUES ((SELECT "LookupId" FROM "Lookup" WHERE "Name" = 'Package Type'), 'IP', NOW());
INSERT INTO "LookupValue" ("LookupId", "Name", "CreatedDate") VALUES ((SELECT "LookupId" FROM "Lookup" WHERE "Name" = 'Package Type'), 'OP & IP', NOW());
SELECT * FROM "LookupValue" WHERE "LookupId" = 26;

SELECT * FROM "PackageModule";
ALTER TABLE "PackageModule" DROP COLUMN "PackageType";
ALTER TABLE "PackageModule" DROP COLUMN "ModuleType";
ALTER TABLE "PackageModule" ADD COLUMN "PackageTypeId" INT NOT NULL
CONSTRAINT "FK_PackageModule_PackageTypeId" REFERENCES "LookupValue" ("LookupValueId") ON UPDATE NO ACTION ON DELETE NO ACTION;
ALTER TABLE "PackageModule" ADD COLUMN "ModuleTypeId" INT NOT NULL
CONSTRAINT "FK_PackageModule_ModuleTypeId" REFERENCES "LookupValue" ("LookupValueId") ON UPDATE NO ACTION ON DELETE NO ACTION;

ALTER TABLE "Admission" DROP CONSTRAINT "Admission_AdmissionPayTypeId_fkey";
ALTER TABLE "Admission" ADD CONSTRAINT "FK_Admission_AdmissionPayTypeId" 
FOREIGN KEY ("AdmissionPayTypeId") REFERENCES "LookupValue" ("LookupValueId") ON UPDATE NO ACTION ON DELETE NO ACTION;

ALTER TABLE "AdmissionPackage" DROP CONSTRAINT "FK_AdmissionPackage_PackageId";
ALTER TABLE "AdmissionPackage" ADD CONSTRAINT "FK_AdmissionPackage_PackageId" 
FOREIGN KEY ("PackageId") REFERENCES "PackageModule" ("PackageModuleId") ON UPDATE NO ACTION ON DELETE NO ACTION;
