Files
pharmacy-pos-qr-system/docs/환산계수.md

264 lines
7.9 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 건조시럽 환산계수 시스템
> 작성일: 2026-03-19
> 작성자: 용림 🐉
---
## 1. 개요
건조시럽(dry syrup)은 물로 희석하여 복용하는 시럽 형태의 의약품입니다.
**환산계수(conversion_factor)**를 사용하여 복용량(mL)을 실제 분말량(g)으로 변환합니다.
### 계산 예시
```
오구멘틴듀오시럽 228mg/5ml
├─ 환산계수: 0.11
├─ 총량: 120mL
└─ 필요 분말량: 120 × 0.11 = 13.2g
```
---
## 2. 데이터베이스 정보
### PostgreSQL 연결
| 항목 | 값 |
|------|-----|
| **Host** | 192.168.0.39 |
| **Port** | 5432 |
| **Database** | label10 |
| **User** | admin |
| **Password** | trajet6640 |
### Connection String
```
postgresql://admin:trajet6640@192.168.0.39:5432/label10
```
### Python 연결 코드
```python
import psycopg2
conn = psycopg2.connect(
host='192.168.0.39',
port=5432,
database='label10',
user='admin',
password='trajet6640'
)
```
---
## 3. 테이블 스키마
### drysyrup 테이블
| 컬럼명 | 타입 | 설명 |
|--------|------|------|
| `idx` | INTEGER | PK, 자동증가 |
| `ingredient_code` | VARCHAR | 성분코드 (MSSQL SUNG_CODE와 매칭) |
| `ingredient_name` | VARCHAR | 성분명 |
| `product_name` | VARCHAR | 대표 제품명 |
| `post_prep_amount` | VARCHAR | 조제 후 농도 (예: 25mg/ml) |
| `main_ingredient_amt` | VARCHAR | 주성분량 (예: 0.75g/16.7g) |
| `conversion_factor` | DOUBLE PRECISION | **환산계수** (mL → g) |
| `storage_conditions` | VARCHAR | 보관조건 (냉장, 상온 등) |
| `expiration_date` | VARCHAR | 조제 후 유효기간 |
### 매핑 관계
```
MSSQL (PIT3000) PostgreSQL (label10)
───────────────── ────────────────────
PM_DRUG.CD_GOODS drysyrup
└─ SUNG_CODE ──────▶ └─ ingredient_code
```
---
## 4. 데이터 샘플 (23건)
| idx | ingredient_code | 성분명 | 제품명 | 환산계수 | 보관 | 유효기간 |
|-----|-----------------|--------|--------|----------|------|----------|
| 18 | 125333ASY | 세파드록실수화물 | 보령듀리세프 125mg/5ml | 0.557 | 냉장 | 14일 |
| 19 | 125332ASY | 세파드록실수화물 | 보령듀리세프 250mg/5ml | 0.557 | 냉장 | 14일 |
| 20 | 125237ASY | 세파클러수화물 | 크로세프 | 0.667 | 냉장 | 14일 |
| 21 | 128931ASY | 세푸록심악세틸 | 올세프 | 1.0 | 25℃이하 | 10일 |
| 22 | 127931ASY | 세프포독심프록세틸 | 포독스 | 0.2 | 냉장 | 14일 |
| 23 | 128030ASY | 세프프로질수화물 | 세프질시럽 | 0.5 | 냉장 | 14일 |
| 24 | 108130ASY | 아목시실린수화물 | 파목신시럽 | 0.775 | 냉장 | 14일 |
| 25 | 535000ASY | 아목시실린+클라불란산 | 오구멘틴듀오 228mg/5ml | **0.11** | 냉장 | 7일 |
| 26 | 536300ASY | 아목시실린+클라불란산 | 아목클란네오시럽 | 0.22 | 냉장 | 7일 |
| 27 | 112732ASY | 아지트로마이신수화물 | 지스로맥스 | 0.867 | 상온 | 5일 |
---
## 5. API 엔드포인트
### 환산계수 조회
```
GET /api/drug-info/conversion-factor/<sung_code>
```
#### 요청 예시
```bash
curl https://mile.0bin.in/api/drug-info/conversion-factor/535000ASY
```
#### 응답 (성공)
```json
{
"success": true,
"sung_code": "535000ASY",
"conversion_factor": 0.11,
"ingredient_name": "아목시실린수화물·클라불란산칼륨",
"product_name": "일성오구멘틴듀오시럽 228mg/5ml"
}
```
#### 응답 (데이터 없음)
```json
{
"success": true,
"sung_code": "NOTEXIST",
"conversion_factor": null,
"ingredient_name": null,
"product_name": null
}
```
---
## 6. 쿼리 예시
### 환산계수 조회
```sql
SELECT conversion_factor, ingredient_name, product_name,
storage_conditions, expiration_date
FROM drysyrup
WHERE ingredient_code = '535000ASY';
```
### 전체 목록 조회
```sql
SELECT * FROM drysyrup ORDER BY idx;
```
### 특정 성분 검색
```sql
SELECT * FROM drysyrup
WHERE ingredient_name LIKE '%아목시실린%';
```
---
## 7. Python 사용 예시
### 환산계수 조회 함수
```python
import psycopg2
def get_conversion_factor(sung_code):
"""성분코드로 환산계수 조회"""
conn = psycopg2.connect(
host='192.168.0.39',
port=5432,
database='label10',
user='admin',
password='trajet6640'
)
cursor = conn.cursor()
cursor.execute("""
SELECT conversion_factor, ingredient_name, product_name,
storage_conditions, expiration_date
FROM drysyrup
WHERE ingredient_code = %s
""", (sung_code,))
row = cursor.fetchone()
conn.close()
if row:
return {
'conversion_factor': row[0],
'ingredient_name': row[1],
'product_name': row[2],
'storage_conditions': row[3],
'expiration_date': row[4]
}
return None
# 사용 예시
result = get_conversion_factor('535000ASY')
print(result)
# {'conversion_factor': 0.11, 'ingredient_name': '아목시실린...', ...}
```
### 분말량 계산 함수
```python
def calculate_powder_amount(sung_code, total_ml):
"""총 mL로 필요한 분말량(g) 계산"""
data = get_conversion_factor(sung_code)
if data and data['conversion_factor']:
return round(total_ml * data['conversion_factor'], 2)
return None
# 사용 예시
powder = calculate_powder_amount('535000ASY', 120)
print(f"필요 분말량: {powder}g") # 필요 분말량: 13.2g
```
---
## 8. 관련 파일
| 파일 | 위치 | 설명 |
|------|------|------|
| app.py | `backend/app.py` | Flask API 라우트 |
| DRYSYRUP_CONVERSION.md | `docs/` | 기존 문서 |
### Flask 라우트 위치
```python
# backend/app.py
@app.route('/api/drug-info/conversion-factor/<sung_code>')
def get_drug_conversion_factor(sung_code):
...
```
---
## 9. 아키텍처
```
┌─────────────────────────────────────────────────────────┐
│ 클라이언트 │
│ (POS, 라벨 프린터, 웹 UI) │
└─────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────┐
│ Flask Backend (7001) │
│ GET /api/drug-info/conversion-factor/<sung_code> │
└─────────────────────────────────────────────────────────┘
┌───────────────┴───────────────┐
▼ ▼
┌─────────────────────┐ ┌─────────────────────┐
│ MSSQL (PIT3000) │ │ PostgreSQL │
│ 192.168.0.4 │ │ 192.168.0.39:5432 │
├─────────────────────┤ ├─────────────────────┤
│ PM_DRUG.CD_GOODS │ │ label10.drysyrup │
│ └─ SUNG_CODE ─────┼──────▶│ └─ ingredient_code│
│ └─ GoodsName │ │ └─ conversion_factor
│ └─ DrugCode │ │ └─ storage_conditions
└─────────────────────┘ └─────────────────────┘
```
---
*총 23개 건조시럽 환산계수 등록됨*