/*Capture list of bulding and block for that hospital Primacies*/
CREATE TABLE bulding_block  (
	id int NOT NULL AUTO_INCREMENT,
	block_name varchar(100)	NOT NULL,
	description varchar(1000)	NULL,
	is_active enum('N','Y') default 'Y',
	created_at datetime,
	created_by int,
	updated_at datetime,
	updated_by int,
	primary key (id) using btree
);


/*Capture list of floor for each block */
CREATE TABLE blockwise_floor  (
	id int NOT NULL AUTO_INCREMENT,
	block_id int	NOT NULL, /*Table-bulding_block-ID*/
	floor_name varchar(100)	NOT NULL, 	/*Flor name*/
	floor_num	int not null default 0,	/*Flor number*/
	description varchar(1000)	NULL,
	is_active enum('N','Y') default 'Y',
	created_at datetime,
	created_by int,
	updated_at datetime,
	updated_by int,
	primary key (id) using btree
);


/*Capture list of rooms for each floor and block */
CREATE TABLE floorwise_room  (
	id int NOT NULL AUTO_INCREMENT,
	floor_id int	NOT NULL, /*Table-blockwise_floor-ID*/
	room_type varchar(50)	NOT NULL, /*Lookup - ROOM_TYPE - Emergency Room,OPD Room,IPD Room,ICU etc.*/
	room_ward_type varchar(50)	NULL,	/*Lookup - WARD_TYPE - Male Ward, Female Ward, General Ward*/
	is_slab	enum('N','Y') default 'N', /*Is the slab wise rule applicable*/
	room_name varchar(100)	NOT NULL,	/*Room name*/
	room_num varchar(100)  null,	
	description varchar(1000)	NULL,
	is_active enum('N','Y') default 'Y',
	created_at datetime,
	created_by int,
	updated_at datetime,
	updated_by int,
	primary key (id) using btree
);


/*Capture list of bed for each room, floor and block */
CREATE TABLE bed  (
	id int NOT NULL AUTO_INCREMENT,
	room_id int	NOT NULL,	/*Table - floorwise_room - ID*/
	bed_name	varchar(50)	NOT NULL, /*Bed name and number*/
	is_slab	enum('N','Y') default 'N',	/*Is the slab wise rule applicable*/
	service_item_id INT NULL,	/*Table-service_items-ID, Only null for OPD*/
	service_rate_id INT NULL,	/*Table-service_rates-ID, Only null for OPD*/
	description varchar(1000)	NULL,
	is_occupied	enum('N','Y')	NOT NULL default 'N',
	is_active enum('N','Y') 	NOT NULL default 'Y',
	created_at datetime,
	created_by int,
	updated_at datetime,
	updated_by int,
	primary key (id) using btree
);

