-- 14-11-21
ALTER TABLE `lab_requisition` ADD `old_price` INT NULL AFTER `price`;
ALTER TABLE `lab_requisition` ADD `client_type` VARCHAR(20) NULL AFTER `group_head`;
ALTER TABLE `lab_requisition` ADD `client_account` VARCHAR(20) NULL AFTER `client_type`;
ALTER TABLE `lab_requisition` ADD `discount` INT NULL AFTER `client_account`, ADD `discount_head` VARCHAR(20) NOT NULL AFTER `discount`, ADD `discount_head_name` VARCHAR(50) NOT NULL AFTER `discount_head`, ADD `discount_amount` INT NULL AFTER `discount_head_name`;

-- 13-11-21
-- ALTER TABLE `lab_requisition` ADD `modeOfPayment` VARCHAR(30) NULL AFTER `patient_name`;
-- ALTER TABLE `lab_requisition` ADD `report_fee_status` VARCHAR(20) NULL AFTER `modeOfPayment`;
-- ALTER TABLE `lab_requisition` ADD `department_head` VARCHAR(30) NULL AFTER `report_fee_status`;
-- ALTER TABLE `lab_requisition` ADD `group_head` VARCHAR(20) NULL AFTER `department_head`;

modify lab_info

-- 06-11-21
import table anesthetics
rearrange fullbloodcount

new procedure query_anesthetics, get_lab_result

modify procedure save_operation_note, consultation_record

ALTER TABLE `operationnotes` ADD `uuid` VARCHAR(50) NULL AFTER `id`;

modified:   config/config.json
        modified:   controller/account.js       
        modified:   controller/diagnosis.js     
        modified:   controller/drugs.js
        modified:   controller/lab.js
        modified:   controller/lab2.js
        modified:   controller/operationnotes.js
        modified:   controller/patientrecords.js
        modified:   controller/pharmacy.js
        modified:   controller/prescriptionrequests.js
        modified:   controller/record.js
        modified:   models/optimum.sql
        modified:   models/prime_changes.sql
        modified:   package-lock.json
        modified:   routes/account.js
        modified:   routes/prescriptionrequests.js

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        models/service_transaction_prime.sql


-- new table transactions3, transaction_entries, 

-- new procedure service_transactions3, new_acc_head

-- modify procedure get_drug_freq, frequency_test, drug_schedule, new_prescription, 
--         get_patient_drug_schedule, save_vitals, consultation_record, bed_allocation
        --    get_prescribed_drugs

-- modify function time_TEST

-- ALTER TABLE `drug_frequency4` ADD `no_times` INT NOT NULL AFTER `drug_time`;
-- ALTER TABLE `dispensary` ADD `no_times` INT NOT NULL AFTER `end_date`;
-- ALTER TABLE `vital_signs` ADD `spo2` VARCHAR(50) NULL AFTER `random_blood_sugar`;
-- ALTER TABLE `patientrecords` CHANGE `patientStatus` `patientStatus` VARCHAR(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL;
-- ALTER TABLE `patientrecords` ADD `seen_by` VARCHAR(50) NULL AFTER `radiology`;
-- ALTER TABLE `patientrecords` ADD `date_seen` DATETIME NULL AFTER `seen_by`;
-- UPDATE `pagenavigation` SET `home_page` = '/me/doctor' WHERE `pagenavigation`.`id` = 5;

-- ALTER TABLE `patientfileno` ADD `payable_head_name` VARCHAR(150) NOT NULL AFTER `approved_at`, 
-- ADD `payable_head` VARCHAR(50) NOT NULL AFTER `payable_head_name`, 
-- ADD `receivable_head_name` VARCHAR(150) NOT NULL AFTER `payable_head`, 
-- ADD `receivable_head` VARCHAR(50) NOT NULL AFTER `receivable_head_name`;

-- UPDATE patientfileno SET payable_head_name='General Patients Payables', payable_head='5000211', 
-- receivable_head_name='General Patients Receivables', receivable_head='4000231';

--end

-- new table with contents: pagenavigation, discount, previous_doc

-- new procedure get_homepage, create_discount, create_org_acc, query_lab_setup, 
--         previous_doc, drug_schedule, frequency_test, update_lab_test

-- new function time_TEST;

-- MODIFY procedure get_nursing_reports,get_prescribed_drugs ,drug_freq_setup,get_drug_freq, drug_schedule

-- ALTER TABLE `dispensary` CHANGE `end_date` `end_date` DATETIME NULL DEFAULT NULL;
-- ALTER TABLE `dispensary` ADD `no_of_days` INT NOT NULL AFTER `period`;


--  modified:   config/config.json
--         modified:   controller/account.js
--         modified:   controller/lab.js
--         modified:   controller/prescriptionrequests.js
--         modified:   controller/transactions.js
--         modified:   models/optimum.sql
--         modified:   models/prime_changes.sql
--         modified:   routes/account.js


-- controller/account.js
--         modified:   controller/lab.js


--          modified:   config/config.json        
--         modified:   controller/lab2.js
--         modified:   models/query_lab_setup.sql
--         modified:   routes/account.js

-- Unmerged paths:
--   (use "git add <file>..." to mark resolution)
--         both modified:   controller/account.js

-- Changes not staged for commit:
--   (use "git add <file>..." to update what will be committed)
--   (use "git restore <file>..." to discard changes in working directory)
--         modified:   config/config.json
--         modified:   controller/lab.js
--         modified:   controller/lab2.js
--         modified:   models/optimum.sql
--         modified:   models/prime_changes.sql

-- 19/10/21
-- MODIFY VIEW drug_schedule_view;
-- CREATE VIEW medication_report;
-- MODIFY PROCEDURE get_prescribed_drugs, new_drug_sale, get_patient_drug_schedule

-- add STAT in hour_list

-- create view medication_report as SELECT patient_id, drug, dosage, route, time_stamp, a.status, served_by, concat(b.firstname,' ',b.lastname) as nurse_name, reason FROM `drug_schedule_view` a JOIN users b ON a.served_by=b.username WHERE a.status in ('Served','Not Served')

-- ALTER TABLE `drug_schedule` CHANGE `allocation_id` `allocation_id` VARCHAR(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL;
-- ALTER TABLE `drug_schedule` ADD `frequency` VARCHAR(50) NULL AFTER `reason`;

-- update procedure consultation_record, get_beneficiary_no;

-- ALTER TABLE `consultations` ADD `treatment_plan_status` VARCHAR(20) NOT NULL DEFAULT 'pending' AFTER `created_at`;
-- ALTER TABLE `consultations` ADD `treatment_by` VARCHAR(20) NULL AFTER `treatment_plan_status`;
-- ALTER TABLE `dispensary` ADD `end_date` DATE NULL AFTER `times_per_day`;

-- modified:   controller/drugs.js
--         modified:   controller/lab.js
--         modified:   controller/lab2.js
--         modified:   controller/patientrecords.js
--         modified:   controller/pharmacy.js      
--         modified:   controller/prescriptionrequests.js
--         modified:   models/optimum.sql
--         modified:   models/prime_changes.sql
--         modified:   routes/drugs.js
--         modified:   routes/lab.js
--         modified:   routes/patientrecords.js




-- -- UPDATE PROCEDURE get_all_lab_services, get_lab_result, get_prescribed_drugs, doctorLabRequest,
-- update view lab_info, lab_request2, lab_process


-- CREATE PROCEDURE drug_freq_setup

-- CREATE TABLE drug_frequency4

-- ALTER TABLE `dispensary` ADD `decision` VARCHAR(10) NOT NULL AFTER `additionalInfo`;
-- ALTER TABLE `dispensary` ADD `drugCount` VARCHAR(10) NOT NULL AFTER `decision`;
-- ALTER TABLE `dispensary` ADD `startTime` VARCHAR(20) NOT NULL AFTER `drugCount`;
-- ALTER TABLE `dispensary` ADD `times_per_day` INT NOT NULL AFTER `startTime`;
-- ALTER TABLE `lab_requisition` ADD `patient_status` VARCHAR(20) NULL AFTER `requested_by`;

xxxxxxxxxxxxxxxxxxx

-- UPDATE PROCEDURE get_all_lab_services,save_pending_lab_tx,consultation_record,get_lab_result;
-- UPDATE VIEW lab_info,lab_request2,lab_process, add a.unit_name,a.unit_code, a.test, a.test_group,


-- ALTER TABLE `lab_requisition` ADD `description` VARCHAR(100) NOT NULL AFTER `patient_name`;


-- UPDATE PROCEDURE get_prescribed_drugs,createbooking_list,createlabcode_list
-- CREATE PROCEDURE doctorLabRequest, save_pending_lab_tx
-- CREATE TABLE pending_lab_tx




-- ALTER TABLE `lab_requisition` ADD `requested_by` VARCHAR(50) NULL AFTER `approval_status`;
-- ALTER TABLE `lab_requisition` ADD `dept_code` INT NOT NULL AFTER `approval_status`;
-- ALTER TABLE `lab_requisition` CHANGE `request_id` `request_id` VARCHAR(50) NULL DEFAULT NULL;

-- UPDATE PROCEDURE save_vitals, assign, new_nursing_report
-- ALTER TABLE `assignpatient` CHANGE `diagDate` `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, CHANGE `patientNo` `patient_id` VARCHAR(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL, CHANGE `seenBy` `assigned_to` VARCHAR(50) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL;


-- ALTER TABLE `consultations` ADD `patient_id` VARCHAR(50) NOT NULL AFTER `id`;
-- ALTER TABLE `consultations` ADD PRIMARY KEY( `id`);
-- ALTER TABLE `consultations` ADD `treatmentPlan` VARCHAR(1500) NOT NULL AFTER `consultation_notes`;
-- ALTER TABLE `consultations` CHANGE `consultation_notes` `consultation_notes` VARCHAR(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, CHANGE `treatmentPlan` `treatmentPlan` VARCHAR(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL;

-- UPDATE PROCEDURE consultation_record
-- -- 

-- update procedure get_patient_drug_schedule, get_patient_list;
-- CREATE PROCEDURE consultation_record, get_pending_nursing_requests;

-- CREATE TABLE `consultations` ( `id` VARCHAR(50) NOT NULL ,  `userId` VARCHAR(50) NOT NULL ,  
--     `consultation_notes` VARCHAR(1500) NOT NULL ,  `decision` VARCHAR(50) NOT NULL ,  
--     `dressing_request` VARCHAR(500) NOT NULL ,  `nursing_request` VARCHAR(500) NOT NULL ,  
--     `nursing_request_status` VARCHAR(20) NOT NULL DEFAULT 'pending' ,  
--     `facilityId` VARCHAR(50) NOT NULL );

-- ALTER TABLE `diagnosis` ADD `dressing_request` VARCHAR(500) NULL AFTER `drugAllergy`, ADD `nursing_request` VARCHAR(500) NULL AFTER `dressing_request`, ADD `nursing_request_status` VARCHAR(50) NULL AFTER `nursing_request`;
-- ALTER
--  VIEW `drug_schedule_view`
--  AS SELECT
--     `a`.`drug` AS `drug`,
--     `a`.`dosage` AS `dosage`,
--     `a`.`patient_id` AS `patient_id`,
--     `a`.`created_at` AS `created_at`,
--     a.id as prescription_id,
--     `b`.`id` AS `id`,
--     `a`.`prescribed_by` AS `prescribed_by`,
--     `b`.`administered_by` AS `administered_by`,
--     `b`.`stopped_by` AS `stopped_by`,
--     `b`.`reason` AS `reason`,
--     `a`.`duration` AS `duration`,
--     `a`.`period` AS `period`,
--     `a`.`frequency` AS `frequency`,
--     `a`.`route` AS `route`,
--     `b`.`time_stamp` AS `time_stamp`,
--     `b`.`status` AS `status`,
--     `a`.`facilityId` AS `facilityId`
-- FROM
--     (
--        `dispensary` `a`
--     JOIN `drug_schedule` `b`
--     ON
--         (`a`.`id` = `b`.`prescription_id`)
--     )



-- -- update PROCEDURE get_lab_result, update_prescription, get_prescribed_drugs
-- -- create procedure update_user, update_dispensary

-- -- create TABLE department

-- -- ALTER TABLE `dispensary` ADD `schedule_status` VARCHAR(50) NOT NULL DEFAULT 'pending' AFTER `status`;


-- -- ALTER TABLE `drug_schedule` ADD `prescription_id` VARCHAR(50) NOT NULL AFTER `patient_id`;
-- -- ALTER TABLE `drug_schedule` ADD INDEX( `prescription_id`);
-- -- create view drug_schedule_view as SELECT drug, dosage, a.patient_id, created_at,a.id,prescribed_by,duration,period,frequency,route,b.time_stamp, b.status, a.facilityId FROM `dispensary` a JOIN drug_schedule b ON a.id = b.prescription_id
-- -- ALTER TABLE `drug_schedule` ADD `stopped_by` VARCHAR(50) NOT NULL AFTER `served_by`;

-- -- update PROCEDURE get_prescribed_drug, update_prescription


-- -- -- update procedure get_patient_drug_schedule;
-- -- -- create procedure surgeon, update_prescription;




-- -- -- ALTER TABLE `drug_schedule` ADD `served_by` VARCHAR(50) NULL AFTER `facilityId`, ADD `reason` VARCHAR(500) NULL AFTER `served_by`;
















-- -- -- CREATE new PROCEDURE get_request_no, lab_summary, createbooking_list, createlabcode_list;
-- -- -- update PROCEDURE get_lab_list;

-- -- -- CREATE TABLE `booking_no` (
-- -- --   `id` int(11) NOT NULL,
-- -- --   `lab_code` int(11) NOT NULL,
-- -- --   `year_code` int(11) NOT NULL,
-- -- --   `booking` int(11) NOT NULL
-- -- -- ) ;
-- -- -- INSERT INTO `booking_no` (`id`, `lab_code`, `year_code`, `booking`) VALUES
-- -- -- (1, 0, 21, 1);

-- -- -- DROP table barcode
-- -- -- CREATE TABLE `barcode` (
-- -- --   `id` int(11) NOT NULL,
-- -- --   `lab_code` int(11) NOT NULL,
-- -- --   `initials` int(11) NOT NULL,
-- -- --   `year_code` int(11) NOT NULL,
-- -- --   `barcode` int(11) NOT NULL
-- -- -- );


-- -- -- INSERT INTO `barcode` (`id`, `lab_code`, `initials`, `year_code`, `barcode`) VALUES
-- -- -- (1, 2000, 2, 21, 1),
-- -- -- (2, 3000, 3, 21, 1),
-- -- -- (3, 4000, 4, 21, 1),
-- -- -- (4, 5000, 5, 21, 1);


-- -- -- CREATE TABLE `lab_codes` (
-- -- --   `lab_code_number` int(10) NOT NULL,
-- -- --   `code_initial` int(5) NOT NULL,
-- -- --   `lab_year` int(5) NOT NULL,
-- -- --   `lab_id` int(10) NOT NULL
-- -- -- );

-- -- -- INSERT INTO `lab_codes` (`lab_code_number`, `code_initial`, `lab_year`, `lab_id`) VALUES
-- -- -- (2000, 2, 21, 0),
-- -- -- (3000, 3, 21, 0),
-- -- -- (4000, 4, 21, 0),
-- -- -- (5000, 5, 21, 0);

-- -- -- ALTER TABLE `lab_requisition` ADD `approval_status` VARCHAR(50) NOT NULL DEFAULT 'pending' AFTER `print_type`;
-- -- -- DROP VIEW lab_info
-- -- -- create view lab_info as SELECT
-- -- --     `b`.`sort_index` AS `sn`,
-- -- --     `a`.`created_at` AS `created_at`,
-- -- --     `a`.`facilityId` AS `facilityId`,
-- -- --     `a`.`id` AS `id`,
-- -- --     `a`.`code` AS `code`,
-- -- --     `a`.`booking_no` AS `booking_no`,
-- -- --     `a`.`request_id` AS `request_id`,
-- -- --     `a`.`patient_id` AS `patient_id`,
-- -- --     `b`.`qms_dept_id` AS `qms_dept_id`,
-- -- --     `b`.`head` AS `head`,
-- -- --     `b`.`subhead` AS `subhead`,
-- -- --     `b`.`unit` AS `unit`,
-- -- --     `b`.`range_from` AS `range_from`,
-- -- --     `b`.`range_to` AS `range_to`,
-- -- --     `b`.`price` AS `price`,
-- -- --     `b`.`old_price` AS `old_price`,
-- -- --     `b`.`commission_type` AS `commission_type`,
-- -- --     `b`.`percentage` AS `percentage`,
-- -- --     `b`.`description` AS `description`,
-- -- --     `b`.`specimen` AS `specimen`,
-- -- --     `a`.`noOfLabels` AS `noOfLabels`,
-- -- --     `a`.`label_type` AS `label_type`,
-- -- --     `b`.`label_name` AS `label_name`,
-- -- --     `a`.`department` AS `department`,
-- -- --     `a`.`result` AS `result`,
-- -- --     `a`.`h_value` AS `h_value`,
-- -- --     `a`.`o_value` AS `o_value`,
-- -- --     `a`.`appearance` AS `appearance`,
-- -- --     `a`.`serology` AS `serology`,
-- -- --     `a`.`culture_yielded` AS `culture_yielded`,
-- -- --     `a`.`sensitivity` AS `sensitivity`,
-- -- --     `a`.`resistivity` AS `resistivity`,
-- -- --     `a`.`intermediaryTo` AS `intermediaryTo`,
-- -- --     `b`.`lab_code` AS `lab_code`,
-- -- --     `b`.`selectable` AS `selectable`,
-- -- --     `a`.`status` AS `status`,
-- -- --     `a`.`print_type` AS `print_type`,
-- -- --     `b`.`report_type` AS `report_type`,
-- -- --     `b`.`collect_sample` AS `collect_sample`,
-- -- --     `b`.`to_be_reported` AS `to_be_reported`,
-- -- --     `b`.`to_be_analyzed` AS `to_be_analyzed`,
-- -- --     `a`.`created_by` AS `created_by`,
-- -- --     `a`.`sample_collected_by` AS `sample_collected_by`,
-- -- --     `a`.`sample_collected_at` AS `sample_collected_at`,
-- -- --     `a`.`analyzed_by` AS `analyzed_by`,
-- -- --     `a`.`analyzed_at` AS `analyzed_at`,
-- -- --     `a`.`result_by` AS `result_by`,
-- -- --     `a`.`result_at` AS `result_at`,
-- -- --     `a`.`reviewed_by` AS `reviewed_by`,
-- -- --     `a`.`reviewed_at` AS `reviewed_at`,
-- -- --     `a`.`printed_by` AS `printed_by`,
-- -- --     `a`.`printed_at` AS `printed_at`,
-- -- --     `a`.`unit` AS `n_unit`,
-- -- --     `a`.`range_from` AS `n_range_from`,
-- -- --     `a`.`range_to` AS `n_range_to`,
-- -- --     `a`.`receiptNo` AS `receiptNo`,
-- -- --     `a`.`sop_instance_id` AS `sop_instance_id`,
-- -- --     `a`.`uploaded_at` AS `uploaded_at`,
-- -- --     `a`.`uploaded_by` AS `uploaded_by`,
-- -- --     `a`.`payment_status` AS `payment_status`,
-- -- --     `a`.`approval_status` AS `approval_status`
-- -- -- FROM
-- -- --     (
-- -- --         `lab_setup` `b`
-- -- --     JOIN `lab_requisition` `a`
-- -- --     ON
-- -- --         (`b`.`subhead` = `a`.`test`)
-- -- --     )
-- -- -- WHERE
-- -- --     `a`.`facilityId` = `b`.`facilityId`;

-- -- -- drop view lab_request2;
-- -- -- CREATE VIEW lab_request2 AS SELECT
-- -- --     `a`.`sn` AS `sn`,
-- -- --     `a`.`created_at` AS `created_at`,
-- -- --     `a`.`facilityId` AS `facilityId`,
-- -- --     `a`.`id` AS `id`,
-- -- --     `a`.`qms_dept_id` AS `qms_dept_id`,
-- -- --     `a`.`code` AS `code`,
-- -- --     `a`.`booking_no` AS `booking_no`,
-- -- --     `a`.`request_id` AS `request_id`,
-- -- --     `a`.`patient_id` AS `patient_id`,
-- -- --     `a`.`head` AS `head`,
-- -- --     `a`.`subhead` AS `subhead`,
-- -- --     `a`.`unit` AS `unit`,
-- -- --     `a`.`range_from` AS `range_from`,
-- -- --     `a`.`range_to` AS `range_to`,
-- -- --     `a`.`price` AS `price`,
-- -- --     `a`.`old_price` AS `old_price`,
-- -- --     `a`.`commission_type` AS `commission_type`,
-- -- --     `a`.`percentage` AS `percentage`,
-- -- --     `a`.`description` AS `description`,
-- -- --     `a`.`specimen` AS `specimen`,
-- -- --     `a`.`noOfLabels` AS `noOfLabels`,
-- -- --     `a`.`label_type` AS `label_type`,
-- -- --     `a`.`label_name` AS `label_name`,
-- -- --     `b`.`description` AS `group_head`,
-- -- --     `a`.`department` AS `department`,
-- -- --     `a`.`result` AS `result`,
-- -- --     `a`.`h_value` AS `h_value`,
-- -- --     `a`.`o_value` AS `o_value`,
-- -- --     `a`.`appearance` AS `appearance`,
-- -- --     `a`.`serology` AS `serology`,
-- -- --     `a`.`culture_yielded` AS `culture_yielded`,
-- -- --     `a`.`sensitivity` AS `sensitivity`,
-- -- --     `a`.`resistivity` AS `resistivity`,
-- -- --     `a`.`intermediaryTo` AS `intermediaryTo`,
-- -- --     `a`.`lab_code` AS `lab_code`,
-- -- --     `a`.`selectable` AS `selectable`,
-- -- --     `a`.`status` AS `status`,
-- -- --     `a`.`print_type` AS `print_type`,
-- -- --     `a`.`report_type` AS `report_type`,
-- -- --     `b`.`collect_sample` AS `collect_sample`,
-- -- --     `b`.`to_be_reported` AS `to_be_reported`,
-- -- --     `b`.`to_be_analyzed` AS `to_be_analyzed`,
-- -- --     `a`.`created_by` AS `created_by`,
-- -- --     `a`.`sample_collected_by` AS `sample_collected_by`,
-- -- --     `a`.`sample_collected_at` AS `sample_collected_at`,
-- -- --     `a`.`analyzed_by` AS `analyzed_by`,
-- -- --     `a`.`analyzed_at` AS `analyzed_at`,
-- -- --     `a`.`result_by` AS `result_by`,
-- -- --     `a`.`result_at` AS `result_at`,
-- -- --     `a`.`reviewed_by` AS `reviewed_by`,
-- -- --     `a`.`reviewed_at` AS `reviewed_at`,
-- -- --     `a`.`printed_by` AS `printed_by`,
-- -- --     `a`.`printed_at` AS `printed_at`,
-- -- --     `a`.`n_unit` AS `n_unit`,
-- -- --     `a`.`n_range_from` AS `n_range_from`,
-- -- --     `a`.`n_range_to` AS `n_range_to`,
-- -- --     `a`.`receiptNo` AS `receiptNo`,
-- -- --     `a`.`sop_instance_id` AS `sop_instance_id`,
-- -- --     `a`.`uploaded_at` AS `uploaded_at`,
-- -- --     `a`.`uploaded_by` AS `uploaded_by`,
-- -- --     `a`.`payment_status` AS `payment_status`,
-- -- --     `a`.`approval_status` AS `approval_status`
-- -- -- FROM
-- -- --     (
-- -- --         `lab_info` `a`
-- -- --     JOIN `lab_setup` `b`
-- -- --     ON
-- -- --         (`b`.`subhead` = `a`.`head`)
-- -- --     )
-- -- -- WHERE
-- -- --     `a`.`facilityId` = `b`.`facilityId`;

-- -- -- drop view lab_process;
-- -- -- create view lab_process AS SELECT
-- -- --     `a`.`sn` AS `sn`,
-- -- --     `a`.`created_at` AS `created_at`,
-- -- --     `a`.`facilityId` AS `facilityId`,
-- -- --     `a`.`id` AS `id`,
-- -- --     `a`.`qms_dept_id` AS `qms_dept_id`,
-- -- --     `a`.`code` AS `code`,
-- -- --     `a`.`booking_no` AS `booking_no`,
-- -- --     `a`.`request_id` AS `request_id`,
-- -- --     `a`.`patient_id` AS `patient_id`,
-- -- --     CONCAT(`c`.`firstname`, ' ', `c`.`surname`) AS `name`,
-- -- --     `c`.`DOB` AS `DOB`,
-- -- --     `c`.`Gender` AS `Gender`,
-- -- --     `a`.`head` AS `head`,
-- -- --     `a`.`subhead` AS `subhead`,
-- -- --     `a`.`unit` AS `unit`,
-- -- --     `a`.`range_from` AS `range_from`,
-- -- --     `a`.`range_to` AS `range_to`,
-- -- --     `a`.`price` AS `price`,
-- -- --     `a`.`old_price` AS `old_price`,
-- -- --     `a`.`commission_type` AS `commission_type`,
-- -- --     `a`.`percentage` AS `percentage`,
-- -- --     `a`.`description` AS `description`,
-- -- --     `a`.`specimen` AS `specimen`,
-- -- --     `a`.`noOfLabels` AS `noOfLabels`,
-- -- --     `a`.`label_type` AS `label_type`,
-- -- --     `a`.`label_name` AS `label_name`,
-- -- --     `a`.`group_head` AS `group_head`,
-- -- --     `a`.`department` AS `department`,
-- -- --     `b`.`description` AS `department_head`,
-- -- --     `a`.`result` AS `result`,
-- -- --     `a`.`h_value` AS `h_value`,
-- -- --     `a`.`o_value` AS `o_value`,
-- -- --     `a`.`appearance` AS `appearance`,
-- -- --     `a`.`serology` AS `serology`,
-- -- --     `a`.`culture_yielded` AS `culture_yielded`,
-- -- --     `a`.`sensitivity` AS `sensitivity`,
-- -- --     `a`.`resistivity` AS `resistivity`,
-- -- --     `a`.`intermediaryTo` AS `intermediaryTo`,
-- -- --     `a`.`lab_code` AS `lab_code`,
-- -- --     `a`.`selectable` AS `selectable`,
-- -- --     `a`.`status` AS `status`,
-- -- --     `a`.`print_type` AS `print_type`,
-- -- --     `a`.`report_type` AS `report_type`,
-- -- --     `a`.`collect_sample` AS `collect_sample`,
-- -- --     `a`.`to_be_reported` AS `to_be_reported`,
-- -- --     `a`.`to_be_analyzed` AS `to_be_analyzed`,
-- -- --     `a`.`created_by` AS `created_by`,
-- -- --     `a`.`sample_collected_by` AS `sample_collected_by`,
-- -- --     `a`.`sample_collected_at` AS `sample_collected_at`,
-- -- --     `a`.`analyzed_by` AS `analyzed_by`,
-- -- --     `a`.`analyzed_at` AS `analyzed_at`,
-- -- --     `a`.`result_by` AS `result_by`,
-- -- --     `a`.`result_at` AS `result_at`,
-- -- --     `a`.`reviewed_by` AS `reviewed_by`,
-- -- --     `a`.`reviewed_at` AS `reviewed_at`,
-- -- --     `a`.`printed_by` AS `printed_by`,
-- -- --     `a`.`printed_at` AS `printed_at`,
-- -- --     `a`.`n_unit` AS `n_unit`,
-- -- --     `a`.`n_range_from` AS `n_range_from`,
-- -- --     `a`.`n_range_to` AS `n_range_to`,
-- -- --     `a`.`receiptNo` AS `receiptNo`,
-- -- --     `a`.`sop_instance_id` AS `sop_instance_id`,
-- -- --     `a`.`uploaded_at` AS `uploaded_at`,
-- -- --     `a`.`uploaded_by` AS `uploaded_by`,
-- -- --     `a`.`payment_status` AS `payment_status`,
-- -- --     `a`.`approval_status` AS `approval_status`
-- -- -- FROM
-- -- --     (
-- -- --         (
-- -- --             `lab_request2` `a`
-- -- --         JOIN `lab_setup` `b`
-- -- --         )
-- -- --     JOIN `patientrecords` `c`
-- -- --     )
-- -- -- WHERE
-- -- --     `a`.`department` = `b`.`subhead` AND `a`.`patient_id` = `c`.`id` AND `a`.`facilityId` = `b`.`facilityId`;

-- -- -- CREATE TABLE `patient_history` (
-- -- --  `id` int(11) NOT NULL AUTO_INCREMENT,
-- -- --  `patient_id` varchar(50) NOT NULL,
-- -- --  `request_id` int(11) NOT NULL,
-- -- --  `history` varchar(1000) NOT NULL,
-- -- --  `file` varchar(200) NOT NULL,
-- -- --  `createdAt` timestamp NOT NULL DEFAULT current_timestamp(),
-- -- --  `facilityId` varchar(50) NOT NULL,
-- -- --  PRIMARY KEY (`id`)
-- -- -- )

-- -- -- -- 20-19-2021
-- -- -- -- modify PROCEDURE customer_deposit;
-- -- -- -- create PROCEDURE move_items_to_dispensary, new_drug_sale, service_transaction;
-- -- -- -- import new lab_setup from optimum and update the facilityId and the lab main head to prime;


-- -- -- -- ALTER TABLE `dispensary` ADD `request_id` VARCHAR(50) NOT NULL AFTER `status`;
-- -- -- -- ALTER TABLE `account_entries` ADD `client_id` VARCHAR(50) NOT NULL AFTER `createdAt`, ADD `txn_status` VARCHAR(50) NOT NULL AFTER `client_id`, ADD `quantity` INT NOT NULL AFTER `txn_status`;
-- -- -- -- ALTER TABLE `dispensary` ADD `route` VARCHAR(20) NOT NULL AFTER `request_id`, ADD `additionalInfo` VARCHAR(500) NOT NULL AFTER `route`;
-- -- -- -- ALTER TABLE `dispensary` CHANGE `id` `id` VARCHAR(50) NOT NULL;
-- -- -- -- ALTER TABLE `dispensary` CHANGE `additionalInfo` `additionalInfo` VARCHAR(500) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL;

-- -- -- -- DROP TABLE lab_requisition;
-- -- -- -- CREATE TABLE `lab_requisition` (
-- -- -- --  `facilityId` varchar(50) DEFAULT NULL,
-- -- -- --  `id` int(100) NOT NULL AUTO_INCREMENT,
-- -- -- --  `code` varchar(50) DEFAULT NULL,
-- -- -- --  `booking_no` varchar(100) DEFAULT NULL,
-- -- -- --  `token` varchar(64) DEFAULT NULL,
-- -- -- --  `request_id` int(50) DEFAULT NULL,
-- -- -- --  `patient_id` varchar(50) DEFAULT NULL,
-- -- -- --  `test` varchar(100) DEFAULT NULL,
-- -- -- --  `price` int(11) DEFAULT NULL,
-- -- -- --  `percentage` int(11) DEFAULT NULL,
-- -- -- --  `result` varchar(200) DEFAULT NULL,
-- -- -- --  `h_value` varchar(20) DEFAULT NULL,
-- -- -- --  `o_value` varchar(20) DEFAULT NULL,
-- -- -- --  `appearance` varchar(200) DEFAULT NULL,
-- -- -- --  `serology` varchar(200) DEFAULT NULL,
-- -- -- --  `culture_yielded` varchar(100) DEFAULT NULL,
-- -- -- --  `sensitivity` varchar(200) DEFAULT NULL,
-- -- -- --  `resistivity` varchar(200) DEFAULT NULL,
-- -- -- --  `intermediaryTo` varchar(200) DEFAULT NULL,
-- -- -- --  `department` varchar(50) DEFAULT NULL,
-- -- -- --  `test_group` varchar(50) DEFAULT NULL,
-- -- -- --  `status` varchar(20) DEFAULT NULL,
-- -- -- --  `created_at` timestamp NULL DEFAULT current_timestamp(),
-- -- -- --  `updated_at` varchar(100) DEFAULT NULL,
-- -- -- --  `created_by` varchar(50) DEFAULT NULL,
-- -- -- --  `sample_collected_by` varchar(50) DEFAULT NULL,
-- -- -- --  `sample_collected_at` datetime DEFAULT NULL,
-- -- -- --  `analyzed_by` varchar(50) DEFAULT NULL,
-- -- -- --  `analyzed_at` datetime DEFAULT NULL,
-- -- -- --  `result_by` varchar(50) DEFAULT NULL,
-- -- -- --  `result_at` datetime DEFAULT NULL,
-- -- -- --  `sop_instance_id` varchar(200) DEFAULT NULL,
-- -- -- --  `uploaded_at` timestamp NULL DEFAULT NULL,
-- -- -- --  `uploaded_by` varchar(100) DEFAULT NULL,
-- -- -- --  `reviewed_by` varchar(50) DEFAULT NULL,
-- -- -- --  `reviewed_at` datetime DEFAULT NULL,
-- -- -- --  `printed_by` varchar(50) DEFAULT NULL,
-- -- -- --  `printed_at` datetime DEFAULT NULL,
-- -- -- --  `unit` varchar(20) DEFAULT NULL,
-- -- -- --  `range_from` varchar(20) DEFAULT NULL,
-- -- -- --  `range_to` varchar(20) DEFAULT NULL,
-- -- -- --  `receiptNo` varchar(50) DEFAULT NULL,
-- -- -- --  `payment_status` varchar(20) NOT NULL,
-- -- -- --  `label_type` varchar(20) NOT NULL,
-- -- -- --  `noOfLabels` int(11) NOT NULL,
-- -- -- --  `print_type` varchar(20) NOT NULL,
-- -- -- --  PRIMARY KEY (`id`),
-- -- -- --  KEY `test` (`test`),
-- -- -- --  KEY `patient_id` (`patient_id`)
-- -- -- -- )