\connect sova_cabinet_test

INSERT INTO users (email, roles, password, uid, token, full_name, phone, confirm)
VALUES (
    '6c6f63616c2e636162696e6574406578616d706c652e74657374',
    '["ROLE_USER","ROLE_ADMIN"]',
    '$2y$12$hqHoZsKN01W.IBcfZYRf.OygGbGIMM7RW0M8fZxo.DNjswjj07S2u',
    200001,
    'Yjd4N6Xlvfay4sNPfPf6PBeosTdmpfCl6+xg9a9V7BnHmfocaw6YSD4NF6Vrvqrm9+nwzNsm5KzpoFV23nG8Lw==',
    'qpHB5XVk6VcuthTcmGV7zqBFN805ejONu+ciwz5nwC4AyEjJ0oH7Ci5ISfgpvwbn2NhLHyTA5tCnN2jd4qQogQ==',
    '2I/vmVgNZC98ben0LPkqxmZX1oiAP/k+aXCn3+/dxTBCPBlN7VLR9uiSoWcOuxeBi2rAzfl9t1N1b/PJkJO6MQ==',
    true
);

INSERT INTO city (name, region_id, time_zone)
VALUES
    ('Саратов Local', 91, 4),
    ('Волгоград Local', 92, 3),
    ('Воронеж Local', 93, 3),
    ('Краснодар Local', 94, 3);

INSERT INTO filial (fid, name, address, address_name, site_id, city_id, company)
VALUES
    (1, 'Сова Саратов', 'Localhost, 1', 'Саратов', 1, 1, 'ООО Local Clinic'),
    (2, 'Сова Волгоград', 'Localhost, 2', 'Волгоград', 2, 2, 'ООО Local Clinic'),
    (3, 'Сова Воронеж', 'Localhost, 3', 'Воронеж', 3, 3, 'ООО Local Clinic'),
    (4, 'Сова Краснодар', 'Localhost, 4', 'Краснодар', 4, 4, 'ООО Local Clinic');

INSERT INTO banner (href, src, city_id)
VALUES ('http://localhost:8082', '/banners/local.png', 1);

INSERT INTO review_source (city_id, name, count_row, rating, filial_id)
VALUES (1, 'Local Reviews', 1, 5, 1);

INSERT INTO category_page (name, active) VALUES ('Local категория', true);
INSERT INTO page (name, description, active, alias, category_id)
VALUES ('Local страница', 'Контент локальной страницы', true, 'local-page', 1);

INSERT INTO department (did, name, group_name, online_mode, alias, middle_name)
VALUES (10, 'Терапия', 'Взрослые специалисты', true, 'terapiya', 'терапевта');

INSERT INTO price_department (name, group_id, group_name, doct_count, view_in_web)
VALUES ('Консультации', 100, 'Врачи', 1, true);

INSERT INTO specialist_view (name, kinder, speciality, category, experience, description, alias, dcode, s_type, active, region_id, kodoper, accepts_dms, degree)
VALUES ('Иванов Иван Иванович', 0, 'Терапевт', 'Первая категория', '12', 'Локальный врач', 'ivanov-ivan', 101, 1, true, 91, '[1001]', true, 'к.м.н.');

INSERT INTO location_view (dcode, department, filial, specialist_id, online_mode, active, nearest_date)
VALUES (101, 10, 1, 1, true, true, CURRENT_DATE + interval '1 day');

INSERT INTO price_list_view (kodoper, schname, specname, speccode, price_info, discpercent, discprice, structname, fname, filial, group_id)
VALUES (1001, 'Прием терапевта', 'Иванов Иван Иванович', 101, '{"base":1500,"discount":1200}', 10, 1200, 'Терапия', 'Сова Local', 1, 100);

INSERT INTO remote_review (external_id, specialist_id, message, author, rating, source)
VALUES (1, 1, 'Тестовый отзыв для локальной базы', 'Пациент Local', 5, 'local');

INSERT INTO record (specialist_id, phone, hash, reserve)
VALUES (1, '+70000000000', 'c2018e2ee0f7d39af2c8f696e7003424', '{"local":true}');

INSERT INTO alert_sms (record_id, response)
VALUES (1, '{"status":"local-ok"}');

INSERT INTO widget_form (id, name) OVERRIDING SYSTEM VALUE VALUES
    (1, 'Local форма'),
    (2, 'Вызов врача на дом');

INSERT INTO widget_form_input (text, type, bitrix24_id, widget_form_id, sort) VALUES
    ('Телефон', 'phone', 'PHONE', 1, 10),
    ('ФИО пациента', 'text', 'NAME', 2, 10),
    ('Телефон', 'phone', 'PHONE', 2, 20),
    ('Адрес выезда', 'text', 'ADDRESS', 2, 30),
    ('Комментарий / симптомы', 'textarea', 'COMMENTS', 2, 40);

SELECT setval(pg_get_serial_sequence('widget_form', 'id'), (SELECT MAX(id) FROM widget_form));
SELECT setval(pg_get_serial_sequence('widget_form_input', 'id'), (SELECT MAX(id) FROM widget_form_input));

INSERT INTO usrlog (pcode, agent, client_ip, method)
VALUES (200001, 'local-agent', '127.0.0.1', 'seed');
