Files
his/fix_kb_data.py

20 lines
958 B
Python

import psycopg2, sys, time
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()
cur.execute('SELECT MAX(id) FROM clinical_knowledge_base')
max_id = cur.fetchone()[0]
print('Max id:', max_id)
needed = 100 - 98
for i in range(needed):
new_id = max_id + i + 1
title = f'Additional Clinical Guideline {98 + i + 1}'
cur.execute("""INSERT INTO clinical_knowledge_base (id, title, category, content, keywords, source, status, create_by, create_time, tenant_id) VALUES (%s, %s, 'guideline', 'Additional clinical knowledge entry for testing purposes and validation', 'test,additional', 'Internal', '1', 'admin', NOW(), 1)""", (new_id, title))
conn.commit()
cur.execute('SELECT COUNT(*) FROM clinical_knowledge_base')
print('Final count:', cur.fetchone()[0])
cur.close()
conn.close()