42 lines
2.1 KiB
Python
42 lines
2.1 KiB
Python
import psycopg2, sys
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
conn = psycopg2.connect(host='192.168.110.252', port=15432, dbname='postgresql', user='postgresql', password='Jchl1528', options='-c search_path=healthlink_his')
|
|
cur = conn.cursor()
|
|
|
|
# Check knowledge base current count and types
|
|
cur.execute('SELECT category, COUNT(*) FROM clinical_knowledge_base GROUP BY category')
|
|
for row in cur.fetchall():
|
|
print(f' {row[0]}: {row[1]}')
|
|
|
|
# Add 2 more to reach 100
|
|
cur.execute("""
|
|
INSERT INTO clinical_knowledge_base (id, title, category, content, keywords, source, status, create_by, create_time, tenant_id)
|
|
VALUES
|
|
(gen_random_uuid(), '急性心肌梗死诊疗指南2024', '临床指南', '急性心肌梗死的早期识别、急救处理和后续治疗方案...', '心肌梗死,胸痛,急救', '中华医学会', '1', 'admin', NOW(), 1),
|
|
(gen_random_uuid(), '抗菌药物临床应用指导原则', '药物知识', '抗菌药物分类、适应症、用法用量及注意事项...', '抗菌药物,抗生素,感染', '国家卫健委', '1', 'admin', NOW(), 1)
|
|
""")
|
|
conn.commit()
|
|
|
|
# Add participants for preop discussions
|
|
cur.execute('SELECT id FROM sys_preop_discussion LIMIT 30')
|
|
discussion_ids = [r[0] for r in cur.fetchall()]
|
|
|
|
participant_sql = ''
|
|
for did in discussion_ids:
|
|
participant_sql += f"""
|
|
INSERT INTO sys_preop_participant (id, discussion_id, participant_name, participant_role, participate_time, opinion, create_by, create_time, tenant_id)
|
|
VALUES (gen_random_uuid(), '{did}', '张主任', '主刀医生', NOW(), '同意手术方案', 'admin', NOW(), 1);
|
|
INSERT INTO sys_preop_participant (id, discussion_id, participant_name, participant_role, participate_time, opinion, create_by, create_time, tenant_id)
|
|
VALUES (gen_random_uuid(), '{did}', '李麻醉师', '麻醉医生', NOW(), '麻醉评估通过', 'admin', NOW(), 1);
|
|
"""
|
|
cur.execute(participant_sql)
|
|
conn.commit()
|
|
|
|
cur.execute('SELECT COUNT(*) FROM clinical_knowledge_base')
|
|
print('knowledge_base total:', cur.fetchone()[0])
|
|
cur.execute('SELECT COUNT(*) FROM sys_preop_participant')
|
|
print('preop_participant total:', cur.fetchone()[0])
|
|
|
|
cur.close()
|
|
conn.close()
|
|
print('Done!') |