/*

R12:โรต้า2-2 2 เดือนอายุไม่เกิน 15 สัปดาห์

*/

# person_vaccine

DELETE FROM person_vaccine WHERE export_vaccine_code ='R12';

SET @R12 = (select max(person_vaccine_id)+1 from person_vaccine) ;

INSERT IGNORE INTO person_vaccine ( person_vaccine_id , vaccine_name , vaccine_code , vaccine_group , export_vaccine_code , hos_guid , combine_vaccine , icode ) VALUES (@R12, 'R12: โรต้า 2-2 2 เดือน (อายุไม่เกิน 15 สัปดาห์)', 'RV2-2', 'RV', 'R12', NULL, 'N', NULL);

-- SELECT * FROM person_vaccine wHERE export_vaccine_code = 'R12';

# vaccine_combination

SET @c11 = ( SELECT MAX(vaccine_combination_id)+1 FROM vaccine_combination) ;

DELETE FROM vaccine_combination WHERE vaccine_code= 'RV2-2';

INSERT IGNORE INTO vaccine_combination (vaccine_combination_id, vaccine_code, vaccine_combine_code, hos_guid) VALUES (@c11, 'RV2-2', 'RV2-2', NULL);

UPDATE serial

SET serial_no = (SELECT MAX(vaccine_combination_id) FROM vaccine_combination)

WHERE serial.name = 'vaccine_combination_id';

-- select * FROM vaccine_combination WHERE vaccine_code= 'RV2-2';

# wbc_vaccine

DELETE FROM wbc_vaccine WHERE export_vaccine_code='R12';

SET @w11 = (

SELECT MAX(wbc_vaccine_id)+1

FROM wbc_vaccine) ;

INSERT IGNORE INTO wbc_vaccine (wbc_vaccine_id, wbc_vaccine_name, wbc_vaccine_code, age_min, age_max, export_vaccine_code, check_code, vaccine_in_use, hos_guid, icode, price, combine_vaccine) VALUES (@w11, 'R12: โรต้า 2-2 2 เดือน (อายุไม่เกิน 15 สัปดาห์)', 'RV2-2', 16, 32, 'R12', 'R12', NULL, NULL, NULL, NULL, 'N');

-- select * FROM wbc_vaccine WHERE export_vaccine_code='R12';

# provis_vcctype

DELETE FROM provis_vcctype WHERE code='R12';

INSERT IGNORE INTO provis_vcctype (code, name, hos_guid) VALUES ('R12', 'RV2-2', NULL);

-- SELECT * FROM provis_vcctype v WHERE v.code ='R12';

# provis_aptype

delete FROM provis_aptype where code = 'R12';

INSERT IGNORE INTO provis_aptype (code,name,hos_guid,hos_guid_ext) VALUES ('R12','RV2-2',NULL,NULL);

-- SELECT * FROM provis_aptype as v where v.code = 'R12';

# baby_items

delete FROM baby_items where export_code = 'R12';

set @b11 = (SELECT max(baby_code)+1 FROM baby_items);

INSERT IGNORE INTO baby_items (baby_code, baby_group, service_code, baby_name, vaccine_code, display_order, export_code, hos_guid) VALUES (@b11, 4, NULL, 'โรต้า 2-2 2 เดือน (อายุไม่เกิน 15 สัปดาห์)', 'RV2-2', NULL, 'R12', NULL);

-- SELECT * FROM baby_items where export_code = 'R12';

# person_vaccine_group_lot

delete FROM person_vaccine_group_lot where vaccine_group = 'RV2-2';

SET @G11 = (select max(person_vaccine_group_lot_id)+1 from person_vaccine_group_lot) ;

INSERT IGNORE INTO person_vaccine_group_lot (person_vaccine_group_lot_id, vaccine_group, vaccine_lot, receive_date, expire_date, receive_qty, left_qty, vaccine_lot_active, hos_guid) VALUES (@G11, 'RV2-2', NULL, NULL, NULL, NULL, NULL, 'Y', NULL);

UPDATE serial

SET serial_no = (

select person_vaccine_group_lot_id

from person_vaccine_group_lot

where vaccine_group = 'RV2-2')

WHERE serial.name = 'person_vaccine_group_lot_id';

SELECT * FROM person_vaccine_group_lot o where o.vaccine_group = 'RV2-2';