---
# System prepended metadata

title: TCM

---

# TCM

#### System-preference
name: `System.TCM.Enabled`
```
{ 
  0: disabled, 
  1: enabled
}
```

### API: Get medication
```get@tcm/invoice-item/medication```

Params :
```jsonld
{
  "visit_id": string
}
```

### API: Update medication self-pay
```put@tcm/invoice-item/medication/{id}/self-pay```

Request :
```jsonld
{
  "is_self_pay": true
}
```

### API: Update prescription precaution
```put@tcm/invoice-item/medication/{id}/precaution```

Request :
```jsonld
{  
  "precaution": "test"
}
```

### API: Create / update prescription

#### Create
```post@api/tcm/order-item/prescription```
#### Update
```put@api/tcm/order-item/prescription/{id}```

```Please note that if change item, order_item need to set to null ```

Request : 
```jsonld
{
　"patient":{
  　　"id":"16904494699700472"
　},
　"visit":{
  　　"id":"17187069733477096"
　},
　"issued_date":"2024-06-18T00:00:00+08:00",
　"item_name":"Prescription 1",
　"route":"infusion",
　"dosage":"1",
　"instruction_uom":"AMP",
　"frequency":"frequency",
　"duration":1,
　"duration_unit":"months",
　"suggested_price":"20",
　"qty":4,
  "tcm_per_qty":4,
　"mixed_drug":[
  　　{
        "order_item":null,
        "item":{
          "id":"17023546732414877"
        },
        "qty":2,
        "tcm_per_Qty": 2,
        "unit_price": 0.5        
  　　},
  　　{
    　　"order_item":null,
        "item":{
        　　"id":"16734265140440719"
   　　　},
        "qty":2,
        "tcm_per_Qty": 2,
        "unit_price": 0.5
  　　}
　]
}
```

### API: Delete prescription
```delete@api/tcm/order-item/prescription/{id}```

### API: Get Drugs
```put@api/tcm/drugs```

Request : 
```jsonld
{
  "p": 1,
  "n": 10,
  "keyword": "test", // optional
  "category_ids": [ // optional
   "category_id1",
   "category_id2" 
  ]
}
```

```If you want to search Tcm Template with category, please include "SYSTEM_TCM_TEMPLATE" in category_ids```

Response :
```jsonld
{
  "pager": {
    "p": 1,
    "n": 10,
    "pages": 4,
    "rows": 32
  },
  "data": [
    {
      "id": "16734265140365636",
      "type": "Drugs",
      "name": "Varivax (Chicken pox) 0.5ml",
      "category": {
        "id": "16734265136532721",
        "name": "Category4"
      },
      "item_branch_info": {
        "qty": 215,
        "selling_price": 74
      }      
    },
    {
      "id": "16734265140365200",
      "type": "Template",
      "name": "TCM Template",
      "category": null,
      "item_branch_info": {
        "qty": 0,
        "selling_price": 0
      }      
    }
    ...
  ]
}
```


# TCM 2024-07-05 新需求

Preference : System.TCM.Dispense.Mode
```
Value : 
  n : Normal (Current Behavior)
  p : Per Qty 
```


New Column for Order Item
```
tcm_per_qty : per qty for tcm order & prescription 
suggested_total_price : suggested_price * tcm_per_qty (**不用傳到後端, 這是後端算完, 會在response附上給你顯示用的)
```
  
For Mode n (Normal) Example

Request : 
```jsonld
{
　...
　"suggested_price":"20", // 跟原本一樣 不用調整
　"qty":4, // 跟原本一樣 不用調整
  "tcm_per_qty":1, // 存1就好 (這樣Suggested Total Price才可以在兩種模式下都回傳正確的值) 
　"mixed_drug":[
  　　{
        ...
        "qty":2, // 存 tcm_per_qty * 計算後的天數 (因為天數永遠都是1 正常來說跟原本一樣 不用調整)
        "tcm_per_qty": 2, // 存per qty的值 (正常來說跟qty一樣)
  　　},
  　　...
　]
}
```
  
For Mode p (Per Qty) Example

Request : 
```jsonld
{
　...
　"suggested_price":"20", // 跟原本一樣 不用調整
　"qty":28, // 原本的數量 * 計算之後的天數
  "tcm_per_qty":7, // 存計算之後的天數 e.g : 1 week = 7 , 1 month = 30
　"mixed_drug":[
  　　{
        ...
        "qty":14, // 存 tcm_per_qty * 計算後的天數
        "tcm_per_qty": 2, // 存per qty的值
  　　},
  　　...
　]
}
```

# TCM 2024-07-12


### API: Update visit's is_tcm_prescription_confirmed
```put@api/tcm/visit/{id}/tcm-prescription-confirmed```

Request :
```jsonld
{
　"is_tcm_prescription_confirmed": true
}
```

# TCM 2024-07-22

### API: Get TCM Template Details
```get@api/tcm/template/{id}/details```

Response :
```jsonld
[
  {
    "id": "16734265140365636",    
    "name": "Varivax (Chicken pox) 0.5ml",    
    "item_branch_info": {
      "qty": 215,
      "selling_price": 74
    },
    "dispense_qty": 3
  },    
  ...
]
```

### API: Get Drugs

```If you want to search Tcm Template with category, please include "SYSTEM_TCM_TEMPLATE" in category_ids```


# TCM 2024-07-26

### API: Get TCM Categories
```get@api/tcm/categories```

Response :
```jsonld
[
  {
    "id": "16734265140365636",    
    "name": "Category 1"    
  },    
  ...
]
```