feat: 대체조제 표시 기능 추가
- PS_Type=9 (원본 처방) 숨김 - PS_Type=4 (대체조제) '대)' 배지 표시 - 원처방 펼쳐보기 (details/summary) - 순서: 4(대체) → 9(원본) 패턴 매칭 관련: 3월5일 개선지시서.md
This commit is contained in:
@@ -188,7 +188,10 @@ def get_prescription_detail(prescription_id):
|
||||
return jsonify({'success': False, 'error': '처방전을 찾을 수 없습니다'}), 404
|
||||
|
||||
# 처방 약품 목록 (PS_sub_pharm + CD_GOODS + CD_MC JOIN)
|
||||
# PS_Type: 0,1=일반, 4=대체조제(실제), 9=대체조제(원본)
|
||||
medications = []
|
||||
original_prescriptions = {} # PS_Type=9인 원본 처방 저장
|
||||
|
||||
cursor.execute("""
|
||||
SELECT
|
||||
s.DrugCode,
|
||||
@@ -197,6 +200,7 @@ def get_prescription_detail(prescription_id):
|
||||
s.QUAN_TIME,
|
||||
s.PS_Type,
|
||||
s.INV_QUAN,
|
||||
s.SUB_SERIAL,
|
||||
g.GoodsName,
|
||||
g.SUNG_CODE,
|
||||
m.PRINT_TYPE,
|
||||
@@ -208,10 +212,30 @@ def get_prescription_detail(prescription_id):
|
||||
ORDER BY s.SUB_SERIAL
|
||||
""", (prescription_id,))
|
||||
|
||||
for row in cursor.fetchall():
|
||||
all_rows = cursor.fetchall()
|
||||
|
||||
# 1차: PS_Type=9 (원본 처방) 수집 - 인덱스로 저장
|
||||
for i, row in enumerate(all_rows):
|
||||
if row.PS_Type == '9':
|
||||
original_prescriptions[i] = {
|
||||
'drug_code': row.DrugCode or '',
|
||||
'drug_name': row.GoodsName or row.DrugCode or '',
|
||||
'add_info': row.PRINT_TYPE or row.SIM_EFFECT or ''
|
||||
}
|
||||
|
||||
# 2차: 실제 조제약만 추가 (PS_Type != 9)
|
||||
for i, row in enumerate(all_rows):
|
||||
if row.PS_Type == '9':
|
||||
continue # 원본 처방은 스킵
|
||||
|
||||
# 효능: PRINT_TYPE > SIM_EFFECT > 없음
|
||||
add_info = row.PRINT_TYPE or row.SIM_EFFECT or ''
|
||||
|
||||
# 대체조제 여부 확인: PS_Type=4이고 바로 다음이 PS_Type=9
|
||||
# 순서: 4(대체) → 9(원본)
|
||||
is_substituted = row.PS_Type == '4' and (i + 1) in original_prescriptions
|
||||
original_drug = original_prescriptions.get(i + 1) if is_substituted else None
|
||||
|
||||
medications.append({
|
||||
'medication_code': row.DrugCode or '',
|
||||
'med_name': row.GoodsName or row.DrugCode or '',
|
||||
@@ -221,7 +245,10 @@ def get_prescription_detail(prescription_id):
|
||||
'duration': row.Days or 0,
|
||||
'total_qty': float(row.INV_QUAN) if row.INV_QUAN else 0,
|
||||
'type': '급여' if row.PS_Type in ['0', '4'] else '비급여' if row.PS_Type == '1' else row.PS_Type,
|
||||
'sung_code': row.SUNG_CODE or ''
|
||||
'sung_code': row.SUNG_CODE or '',
|
||||
'ps_type': row.PS_Type or '0',
|
||||
'is_substituted': is_substituted,
|
||||
'original_drug': original_drug
|
||||
})
|
||||
|
||||
# 나이/성별 계산
|
||||
|
||||
Reference in New Issue
Block a user