/*List of screen
1.	Blood Donner Detail
2.	Blood Container and Item ID
3.	Blood donation tracking / add, donation , vitals 
4.	Blood issue tracking and vitals
5.	Blood stock
*/

/*Blood Donner details*/
Create TABLE	blood_donners
(	id		int NOT NULL AUTO_INCREMENT,
	donner_name	
	dob
	age
	blood_group	/*Lookup*/
	gender	/*Lookup*/
	marital_status	/*Lookup*/
	contact_no
	email
	address
	pin
	location
	guardian_name
	guardian_contact
	guardian_address
	is_active	enum('Y', 'N') NOT NULL DEFAULT 'Y',
	created_at datetime NOT NULL,
	created_by int NOT NULL,
	updated_at datetime,
	updated_by int,
	PRIMARY KEY (id) USING BTREE
) ENGINE = InnoDB;


/*Blood bag container ID - Use Items and item_prices*/



/*Adding new blood for donation*/
Create TABLE	blood_donation_details
(	id		int NOT NULL AUTO_INCREMENT,
	blood_donner_id	int NOT NULL, /*Table blood_donners - ID*/
	donation_date	date NOT NULL,
	blood_group	/*Fetch from blood_donner master*/
	expiry_date
	lot_number
	container_id	/*Table items-ID*/
	container_serial
	other_modical_history
	blood_unit	/*Lookup*/
	blood_qty
	status enum('T', 'A', 'R') DEFAULT 'T' /*T-Taken, A-Acepted, R-Rejected*/
	approve_date
	is_any_costing  enum('Y', 'N') DEFAULT 'N'
	created_at datetime NOT NULL,
	created_by int NOT NULL,
	updated_at datetime,
	updated_by int,
	PRIMARY KEY (id) USING BTREE
) ENGINE = InnoDB;


/*Blood donation team during donation*/
Create TABLE	blood_donation_issue_staff
(	id		int NOT NULL AUTO_INCREMENT,
	data_source enum('D', 'I') /*D-Donation, I-Issue*/
	blood_donation_detail_id	/*Table-D-Donation=blood_donation_detail-ID, I-Issue=blood_issue_patient-ID*/
	staff_designation_id	/*Table-staff_designation-ID*/
	staff_id	/*Table-users-ID*/
	role_play /*Lookup*/
	is_any_costing  enum('Y', 'N') DEFAULT 'N'
	created_at datetime NOT NULL,
	created_by int NOT NULL,
	updated_at datetime,
	updated_by int,
	PRIMARY KEY (id) USING BTREE
) ENGINE = InnoDB;


/*Blood issue to patient*/
Create TABLE	blood_issue_patient
(	id		int NOT NULL AUTO_INCREMENT,
	patient_id	/*Table-Patients-ID*/
	treatment_source	enum('O','I', 'T', 'E', 'NA') DEFAULT 'NA', /*O-OPD, I-IPD, T-OT, E-Emergency*/
	treatment_source_id		int NULL
	issue_time datetime
	case_id	/*Table-case_detail-ID*/
	visit_id	/*Table-visit_detail-ID*/
	bag_no	/*Fetch from blood_donation_details*/
	blood_donner_id	int NOT NULL, /*Table blood_donners - ID*/
	blood_group /*Lookup*/
	lot	/*autogenerated by bag_no*/
	remarks
	blood_unit	/*Lookup*/
	blood_qty
	is_any_costing  enum('Y', 'N') DEFAULT 'N'
	status enum('U', 'A', ) DEFAULT 'U' /*U-UnApprove, A-Approve*/
	created_at datetime NOT NULL,
	created_by int NOT NULL,
	updated_at datetime,
	updated_by int,
	PRIMARY KEY (id) USING BTREE
) ENGINE = InnoDB;


/*Doner vital for blood taken and blood issue vitals capture at patient_vitals new column added at this table donner_id, either we enter value at patient_id or donner_id*/