feat: 대체조제 표시 기능 추가
- PS_Type=9 (원본 처방) 숨김 - PS_Type=4 (대체조제) '대)' 배지 표시 - 원처방 펼쳐보기 (details/summary) - 순서: 4(대체) → 9(원본) 패턴 매칭 관련: 3월5일 개선지시서.md
This commit is contained in:
parent
a144a091b9
commit
4968735a80
@ -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
|
||||
})
|
||||
|
||||
# 나이/성별 계산
|
||||
|
||||
@ -942,6 +942,47 @@
|
||||
tr.row-removed { background: #fef2f2 !important; opacity: 0.7; }
|
||||
tr.row-changed { background: #fffbeb !important; }
|
||||
|
||||
/* 대체조제 표시 */
|
||||
.subst-badge {
|
||||
display: inline-block;
|
||||
background: linear-gradient(135deg, #f59e0b, #d97706);
|
||||
color: white;
|
||||
padding: 1px 5px;
|
||||
border-radius: 4px;
|
||||
font-size: 0.65rem;
|
||||
font-weight: 700;
|
||||
margin-right: 4px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.original-rx {
|
||||
margin-top: 4px;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
.original-rx summary {
|
||||
cursor: pointer;
|
||||
color: #6b7280;
|
||||
user-select: none;
|
||||
}
|
||||
.original-rx summary:hover {
|
||||
color: #4b5563;
|
||||
}
|
||||
.original-drug-info {
|
||||
margin-top: 4px;
|
||||
padding: 6px 10px;
|
||||
background: #fef3c7;
|
||||
border-radius: 4px;
|
||||
border-left: 3px solid #f59e0b;
|
||||
}
|
||||
.orig-name {
|
||||
display: block;
|
||||
font-weight: 500;
|
||||
color: #92400e;
|
||||
}
|
||||
.orig-code {
|
||||
font-size: 0.7rem;
|
||||
color: #b45309;
|
||||
}
|
||||
|
||||
.change-arrow {
|
||||
color: #94a3b8;
|
||||
margin: 0 4px;
|
||||
@ -1362,12 +1403,23 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
${data.medications.map(m => `
|
||||
<tr data-add-info="${escapeHtml(m.add_info || '')}">
|
||||
<tr data-add-info="${escapeHtml(m.add_info || '')}" ${m.is_substituted ? 'class="substituted-row"' : ''}>
|
||||
<td><input type="checkbox" class="med-check" data-code="${m.medication_code}" ${m.is_auto_print ? 'checked' : ''}></td>
|
||||
<td>
|
||||
<div class="med-name">${m.med_name || m.medication_code}</div>
|
||||
<div class="med-name">
|
||||
${m.is_substituted ? '<span class="subst-badge" title="대체조제">대)</span> ' : ''}${m.med_name || m.medication_code}
|
||||
</div>
|
||||
<div class="med-code">${m.medication_code}</div>
|
||||
${m.add_info ? `<div style="font-size:0.75rem;color:#6b7280;">${escapeHtml(m.add_info)}</div>` : ''}
|
||||
${m.is_substituted && m.original_drug ? `
|
||||
<details class="original-rx">
|
||||
<summary>원처방 보기</summary>
|
||||
<div class="original-drug-info">
|
||||
<span class="orig-name">${escapeHtml(m.original_drug.drug_name)}</span>
|
||||
<span class="orig-code">${m.original_drug.drug_code}</span>
|
||||
</div>
|
||||
</details>
|
||||
` : ''}
|
||||
</td>
|
||||
<td>${m.formulation ? `<span class="med-form">${m.formulation}</span>` : '-'}</td>
|
||||
<td><span class="med-dosage">${m.dosage || '-'}</span></td>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user