feat: 재고 원장 참고번호에 처방명 추가
## 개선사항 - 출고시 참고번호에 처방명 표시 - 기존: 조제#1 - 변경: 조제#1 (직접조제) - 처방이 있는 경우: 조제#2 (쌍화탕) ## 표시 형식 - 입고: PR-20260211-0001 (입고장번호) - 출고(처방전O): RX-2024-001 (쌍화탕) - 출고(처방전X): 조제#1 (직접조제) 이제 입출고 내역에서 어떤 처방으로 소비되었는지 바로 확인 가능 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
11ca86ca41
commit
496a99ff98
14
app.py
14
app.py
@ -1102,7 +1102,11 @@ def get_stock_ledger():
|
|||||||
s.name as supplier_name,
|
s.name as supplier_name,
|
||||||
CASE
|
CASE
|
||||||
WHEN sl.event_type = 'PURCHASE' OR sl.event_type = 'RECEIPT' THEN pr.receipt_no
|
WHEN sl.event_type = 'PURCHASE' OR sl.event_type = 'RECEIPT' THEN pr.receipt_no
|
||||||
WHEN sl.event_type = 'CONSUME' THEN COALESCE(c.prescription_no, '조제#' || c.compound_id)
|
WHEN sl.event_type = 'CONSUME' THEN
|
||||||
|
CASE
|
||||||
|
WHEN c.prescription_no IS NOT NULL THEN c.prescription_no || ' (' || COALESCE(f.formula_name, '직접조제') || ')'
|
||||||
|
ELSE '조제#' || c.compound_id || ' (' || COALESCE(f.formula_name, '직접조제') || ')'
|
||||||
|
END
|
||||||
ELSE NULL
|
ELSE NULL
|
||||||
END as reference_no,
|
END as reference_no,
|
||||||
CASE
|
CASE
|
||||||
@ -1116,6 +1120,7 @@ def get_stock_ledger():
|
|||||||
LEFT JOIN purchase_receipts pr ON sl.reference_table = 'purchase_receipts' AND sl.reference_id = pr.receipt_id
|
LEFT JOIN purchase_receipts pr ON sl.reference_table = 'purchase_receipts' AND sl.reference_id = pr.receipt_id
|
||||||
LEFT JOIN compounds c ON sl.reference_table = 'compounds' AND sl.reference_id = c.compound_id
|
LEFT JOIN compounds c ON sl.reference_table = 'compounds' AND sl.reference_id = c.compound_id
|
||||||
LEFT JOIN patients p ON c.patient_id = p.patient_id
|
LEFT JOIN patients p ON c.patient_id = p.patient_id
|
||||||
|
LEFT JOIN formulas f ON c.formula_id = f.formula_id
|
||||||
WHERE sl.herb_item_id = ?
|
WHERE sl.herb_item_id = ?
|
||||||
ORDER BY sl.event_time DESC
|
ORDER BY sl.event_time DESC
|
||||||
LIMIT ?
|
LIMIT ?
|
||||||
@ -1136,7 +1141,11 @@ def get_stock_ledger():
|
|||||||
s.name as supplier_name,
|
s.name as supplier_name,
|
||||||
CASE
|
CASE
|
||||||
WHEN sl.event_type = 'PURCHASE' OR sl.event_type = 'RECEIPT' THEN pr.receipt_no
|
WHEN sl.event_type = 'PURCHASE' OR sl.event_type = 'RECEIPT' THEN pr.receipt_no
|
||||||
WHEN sl.event_type = 'CONSUME' THEN COALESCE(c.prescription_no, '조제#' || c.compound_id)
|
WHEN sl.event_type = 'CONSUME' THEN
|
||||||
|
CASE
|
||||||
|
WHEN c.prescription_no IS NOT NULL THEN c.prescription_no || ' (' || COALESCE(f.formula_name, '직접조제') || ')'
|
||||||
|
ELSE '조제#' || c.compound_id || ' (' || COALESCE(f.formula_name, '직접조제') || ')'
|
||||||
|
END
|
||||||
ELSE NULL
|
ELSE NULL
|
||||||
END as reference_no,
|
END as reference_no,
|
||||||
CASE
|
CASE
|
||||||
@ -1150,6 +1159,7 @@ def get_stock_ledger():
|
|||||||
LEFT JOIN purchase_receipts pr ON sl.reference_table = 'purchase_receipts' AND sl.reference_id = pr.receipt_id
|
LEFT JOIN purchase_receipts pr ON sl.reference_table = 'purchase_receipts' AND sl.reference_id = pr.receipt_id
|
||||||
LEFT JOIN compounds c ON sl.reference_table = 'compounds' AND sl.reference_id = c.compound_id
|
LEFT JOIN compounds c ON sl.reference_table = 'compounds' AND sl.reference_id = c.compound_id
|
||||||
LEFT JOIN patients p ON c.patient_id = p.patient_id
|
LEFT JOIN patients p ON c.patient_id = p.patient_id
|
||||||
|
LEFT JOIN formulas f ON c.formula_id = f.formula_id
|
||||||
ORDER BY sl.event_time DESC
|
ORDER BY sl.event_time DESC
|
||||||
LIMIT ?
|
LIMIT ?
|
||||||
""", (limit,))
|
""", (limit,))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user