create table "LabBookingStatus"(
				"LabBookingStatusId" serial primary key,
				"Status" text,
				"Active" boolean default true			
);

insert into "LabBookingStatus"("Status" ,"Active") values ('Booked',true),
('Cancelled',true);

alter table "LabBookingStatus" add column "RowColor" text;


create table "NewLabBookingHeader"(
				"NewLabBookingHeaderId" serial primary key,
				"RequisitionNumber" text,
				"Type" varchar(10),
				"PatientId" int references "Patient"("PatientId"),
				"PatientName" varchar(250),
				"Mobile" varchar(15),
				"DoctorName" varchar(250),
				"DoctorId" int references "Provider"("ProviderId"),
				"EmployeeId" int references "Account"("AccountId"),
				"LocationId" int references "Location"("LocationId"),
				"OverallTotalAmount" numeric(8,2),
				"OverallDiscount" numeric(8,2),
				"OverallNetAmount" numeric(8,2),
				"OverallDiscountPercentage" int,
				"PayTypeId" int references "PayType"("PayTypeId"),
				"PaymentNumber" 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 "NewLabBookingDetail"(
		 "NewLabBookingDetailId" serial primary key,
		 "NewLabBookingHeaderId" int references "NewLabBookingHeader"("NewLabBookingHeaderId"),
		 "LabMainDetailId" int references "LabMainDetail"("LabMainDetailId"),
		 "ChargeCategoryId" int references "ChargeCategory"("ChargeCategoryId"),
		 "LabBookingStatusId" int references "LabBookingStatus"("LabBookingStatusId"),
		 "DiscountPercentage" int,
		 "DiscountAmount" numeric(8,2),
		 "TotalAmount" numeric(8,2),
		 "NetAmount" numeric(8,2)				
);

create table "LabBookingTimeLine"(
			"LabBookingTimeLineId" serial primary key,
			"NewLabBookingHeaderId" int references "NewLabBookingHeader"("NewLabBookingHeaderId"),
			"LabBookingStatusId" int references "LabBookingStatus"("LabBookingStatusId"),
			"Comment" text,
			"CommentedBy" int references "Account"("AccountId"),
			"CreatedDate" timestamp without time zone
);