# OMOP PostgREST
## 連結
- Swagger: http://10.221.252.51:3080/
- PostgREST API: http://10.221.252.51:3000
- Github: https://github.com/PostgREST/postgrest
- 文檔: https://postgrest.org/en/stable/references/api/tables_views.html#operators
## OMOP 原生 Table 端點
### 範例1 (對照csv)
- 拿`person`全部
- `curl http://10.221.252.51:3000/person > person.json`
- 
- 拿`obseravtion`全部
- `curl http://10.221.252.51:3000/observation > observation.json`
### 範例2 (person_id篩)
- 取得`person_id = 1`所有`procedure_occurrence`
- http://10.221.252.51:3000/procedure_occurrence?person_id=eq.1
- 
- 
- 確認`person_id = 1`所有`procedure_occurrenc`回覆`11`筆對照`OMOP`的`11`筆數量正確
- 
- 
### 範例3 (person_id, concept_id篩,日期排序)
- 取得`person_id = 5`中`measurement`最新身高
- http://10.221.252.51:3000/measurement?person_id=eq.5&measurement_concept_id=eq.903133&order=measurement_date.desc&limit=1
- 
- 確認`person_id = 5`最新身高與`OMOP`相符
- 
- 
## OMOP Stored Procedure
- 輸入病歷號到`patient_id`,拿`PAS`資料表需要欄位
- 
### 範例1 (申請資料)
- http://10.221.252.51:3000/rpc/get_claim?patient_id=10669860
- 
```json=
{
"applType": 1,
"funcType": null,
"medicalLicense": "DOC3511A",
"docIdCard": "T100163189",
"docName": "趙灌中",
"applDate": null,
"tmhbType": null,
"oldAcptNo": null,
"patId": "10669860",
"patIdSystem": "https://www.vghtpe.gov.tw/",
"idCard": "L201297732",
"name": "劉芸伶",
"birthday": "1954-11-24",
"gender": "2",
"weight": "70.200",
"height": "161.800",
"pregnant": null
}
```
### 範例2 (影像報告,文字)
- http://10.221.252.51:3000/rpc/get_imaging_report?patient_id=10669860
- 
```json=
[
{
"idCard": null,
"medicalLicense": null,
"docName": null,
"imgItem": "26072B",
"imgCategory": "Photographic image",
"imgResult": "hypodense lesion with hypermetabolism at S5/8 showing \nincreased uptake, r/o recurrent/ residual metastasis.\n> No hypermetabolic lesions are noted elsewhere in the whole \nbody.\n\n\n[ Conclusion ]\n> Right breast cancer s/p treatment.\n> Endometrial cancer s/p hysterectomy + BSO.\n> A lobulated hypodense lesion with hypermetabolism at S5/8 \nshowing increased uptake, r/o recurrent/ residual metastasis.\n\nscanner (since 20191001). Serum glucose level at the time of \nat 60 min post-injection on GE Discovery MI DR PET/CT hybrid \nposition was performed after injection of 8.18 mCi of F-18 FDG \ninjection (mg/dl): 97\n \n\n[ Findings ]\n> Correlated with: 20240904 CT, 20240608 CT, 20231207 PET\n> History of right breast cancer s/p wide excision.\n> Endometrial cancer s/p hysterectomy + BSO.\n> Liver metastases in right lobe s/p treatment; a lobulated \n5301B\nWhole body PET imaging from vertex to upper thigh with arm-up \n[ Procedure ]\n130904\n20240905\n5301B\n \n64\n17:33\n2024/09/05\n[RPTARTICLE] CLOB DATA SAVE TO OTHER TABLE",
"imgDate": "2024-09-05"
}
]
```
### 範例3 (放射治療)
- http://10.221.252.51:3000/rpc/get_radiotherapy?patient_id=10669860
- 
```json=
[
{
"rt": "DM0",
"realInspectTime": "2022-08-22",
"rtDose": 6020,
"rtUnit": null
}
]
```
## OMOP Stored Procedure 修正
- 已加入起始與結束日期參數,可供日期區間查詢
- 
### 2 ClaimItem (申請項目)
- 醫師自填,已移除
### 3 Diagnosis
- 簡要病摘: 醫師自填
### 4 CancerStage
- assessItem: TNM 筆誤已更正
- assessScoreString: TNM 個別T, N, M標注
- 
### 5 ExaminationReport
- speType: 已更正
- 
### 6. ImagingReport (影像報告)
- drugCode: 為健保碼
- 加入`reqNo`
- 移除`get_imaging_report_req`
- 
- 
### 8. MedicationRequestTreat (用藥品項)
- dose: 非數字部分已排除
- 
- doseUnit: 只留下單位,並排除NULL之狀況
- 
### 11 Test
- inspect: inspect拆開成inspectCode(健保碼)和inspectName(項目名)
- consultValueLower: 原始資料非結構,有試圖拆,留下min
- consultValueMax: 原始資料非結構,有試圖拆,留下max
- consultValueCat: x
- consultValueDesc: x
- isGrouped: 已帶入,目前邏輯是reqNo對上>1的檢驗項目歸類為`Y`套組
- 
### 14 Patient
- 有新增
- 
### 15 Practitioner
- 有新增
- 