---
title: RxPrime Embed Tutorial
tags: RxPrime as IFrame
disqus: hackmd
---
{%hackmd BJrTq20hE %}
# RxPrime As IFrame
## **Trigger RxPrime**
**"POST" input JSONs to url: https://ehr.aesoptek.com/RxPrime-IFrame, the format of the JSON is explained [below](https://hackmd.io/SBucutWUQVu4-Pr1nRC3FQ?view#Complete-Input-Format).**
Note:
* **Please provide me the domain name that will host RxPrime**, I need to add it to the "allow-iframing" list. Otherwise, RxPrime may refuse to render.
* RxPrime includes two states, which requires the host to expand/shrink the iframe width in certain scenarios. More details explained in the [last section](https://hackmd.io/SBucutWUQVu4-Pr1nRC3FQ?view#Signal-to-ExpandShrink-IFrame) of this doc.
---
## Complete Input Format
```json=
{
"DoctorSerial": "DoctorCode", //※醫生代碼
"PatientGender": 0, //※性別:1 = M, else = F
"Location": "zh-TW", //語系代碼:default = en-US
"PatientSerial": "A6CFB65C-433E-4317-90B1-35C6F0205C8C", //※看診處方唯一代碼
"PatientAge": 9, //※年齡
"DivisionCode": "04", //健保科別代碼
"Detail": true, //輸出進階資訊 *1
"PreDraw": false, //預先繪製InfoGraph *2
"DiseaseContent": [ //診斷陣列
{
"Code": "E11.21", //※診斷代碼
"Name": "Type 2 diabetes mellitus with diabetic nephropathy" //診斷名稱
"ResourceId": "{99534C56-A0B1-4D56-9CC5-8125C3566678}", //※項目代號 *3
"Rules": "icd10" //診斷代碼編碼種類 *4
"Date": "1909-02-02T00:00:00.0000000" //※年-月-日T時-分-秒
}
],
"MedContent": [ //藥品陣列
{
"QuantityPerDose": 1, //每次使用劑量
"QuantityPerUnit": "mg",
"Frequency": "QD", //使用方式
"Route": "-", //使用途徑
"Duration": 28, //使用天數
"TotalQuantity": 28, //※總劑量
"TotalQuantityUnit": "d", //單位
"Code": "BC24131100", //※藥品代碼
"Name": "Crestor *10mg/tab", //藥品名稱
"ResourceId": "{8F506951-C566-4A91-BC10-C8F531FAF79A}", //※項目代號
"Rules": "nhi" //藥品代碼編碼種類 *4
"Date": "1909-02-02T00:00:00.0000000" //※年-月-日T時-分-秒
}
]
}
```
* **※項目,為必要輸入項**
* *1 預先輸出完整資訊,默認true較好
* *2 預先繪製InfoGraph圖片,默認false較好
* 3 用於識別每一個項目的***唯一***代碼,***不得重複***,否則會視為同一項目。
* *4 如果輸入編碼種類,可以增加資料搜尋速度,內容皆為小寫。但輸入錯誤編碼種類,則會影響搜尋結果 (如混投或是未知)。
---
## **Sample JSON**
### **Sample 1 JSON**
#### ==Request==
```json=
{
"Detail": true,
"DivisionCode": "02",
"Patientserial": "768be7ac-743f-4c24-aa0f-fed5a3a38b6a",
"PatientGender": 0,
"PatientAge": 88,
"DiseaseContent": [
{
"Code": "C18.7",
"Name": "Malignant neoplasm of sigmoid colon",
"Rules": "ICD10",
"ResourceId": "C18.7.ICD10",
"Date": "1909-02-02T00:00:00.0000000"
}
],
"MedContent": [
{
"Code": "AC22908100",
"Name": "spironolactone",
"Rules": "nhi",
"ResourceId": "AC22908100.nhi",
"Date": "1909-02-02T00:00:00.0000000",
"TotalQuantity": 1.0,
"QuantityPerDose": 40.0,
"QuantityPerUnit": "MG",
"Frequency": "0900, 1800",
"Duration": 1,
"TotalQuantityUnit": "Table",
"Route": "Oral"
},
{
"Code": "A023521100",
"Name": "magnesium oxide",
"Rules": "nhi",
"ResourceId": "A023521100.nhi",
"Date": "1909-02-02T00:00:00.0000000",
"TotalQuantity": 1.0,
"QuantityPerDose": 200.0,
"QuantityPerUnit": "ML",
"Frequency": "0900, 1800",
"Duration": 1,
"TotalQuantityUnit": "Table",
"Route": "Oral"
},
{
"Code": "AB46991157",
"Name": "megestrol",
"Rules": "nhi",
"ResourceId": "AB46991157.nhi",
"Date": "1909-02-02T00:00:00.0000000",
"TotalQuantity": 1.0,
"QuantityPerDose": 4.2,
"QuantityPerUnit": "MG",
"Frequency": "0900, 1800",
"Duration": 1,
"TotalQuantityUnit": "Table",
"Route": "Oral"
},
{
"Code": "AB307491G0",
"Name": "furosemide",
"Rules": "nhi",
"ResourceId": "AB307491G0.nhi",
"Date": "1909-02-02T00:00:00.0000000",
"TotalQuantity": 1.0,
"QuantityPerDose": 202.0,
"QuantityPerUnit": "MG",
"Frequency": "0900, 1800",
"Duration": 1,
"TotalQuantityUnit": "Table",
"Route": "Oral"
},
{
"Code": "BC030771G0",
"Name": "clonazepam",
"Rules": "nhi",
"ResourceId": "BC030771G0.nhi",
"Date": "1909-02-02T00:00:00.0000000",
"TotalQuantity": 1.0,
"QuantityPerDose": 0.42,
"QuantityPerUnit": "MG",
"Frequency": "QID",
"Duration": 1,
"TotalQuantityUnit": "Table",
"Route": "Oral"
},
{
"Code": "BC21571100",
"Name": "amlodipine",
"Rules": "nhi",
"ResourceId": "BC21571100.nhi",
"Date": "1909-02-02T00:00:00.0000000",
"TotalQuantity": 1.0,
"QuantityPerDose": 402.0,
"QuantityPerUnit": "MG",
"Frequency": "QID",
"Duration": 1,
"TotalQuantityUnit": "Table",
"Route": "Oral"
},
{
"Code": "AC44248100",
"Name": "calcium folinate",
"Rules": "nhi",
"ResourceId": "AC44248100.nhi",
"Date": "1909-02-02T00:00:00.0000000",
"TotalQuantity": 1.0,
"QuantityPerDose": 403.0,
"QuantityPerUnit": "MG",
"Frequency": "QID",
"Duration": 1,
"TotalQuantityUnit": "Table",
"Route": "Oral"
},
{
"Code": "AC43698100",
"Name": "tegafur, combinations",
"Rules": "nhi",
"ResourceId": "AC43698100.nhi",
"Date": "1909-02-02T00:00:00.0000000",
"TotalQuantity": 1.0,
"QuantityPerDose": 404.0,
"QuantityPerUnit": "MG",
"Frequency": "0900, 1800",
"Duration": 1,
"TotalQuantityUnit": "Table",
"Route": "Oral"
}
]
}
```
### **Sample 2 JSON**
#### ==Request==
```json=
{
"Detail": true,
"DivisionCode": "02",
"Patientserial": "768be7ac-743f-4c24-aa0f-fed5a3a38b6a",
"PatientGender": 0,
"PatientAge": 60,
"DiseaseContent": [
{
"Code": "N39.41",
"Name": "Urge incontinence",
"Rules": "ICD10",
"ResourceId": "N39.41.ICD10",
"Date": "2011-03-12T12:21:10.4310233Z"
},
{
"Code": "K59.09",
"Name": "Other constipation",
"Rules": "ICD10",
"ResourceId": "K59.09.ICD10",
"Date": "2011-03-12T12:21:10.4310233Z"
},
{
"Code": "N39.0",
"Name": "Urinary tract infection, site not specified",
"Rules": "ICD10",
"ResourceId": "N39.0.ICD10",
"Date": "2007-07-07T17:21:10.4310233Z"
},
{
"Code": "R35.0",
"Name": "Frequency of micturition",
"Rules": "ICD10",
"ResourceId": "R35.0.ICD10",
"Date": "2007-07-07T17:21:10.4310233Z"
}
],
"MedContent": [
{
"Code": "BC22783100",
"Name": "tolterodine",
"Rules": "nhi",
"ResourceId": "BC22783100.nhi",
"Date": "2011-03-12T12:21:10.4310233Z",
"TotalQuantity": 1.0,
"QuantityPerDose": 25.0,
"QuantityPerUnit": "MG",
"Frequency": "0900",
"Route": "Oral",
"Duration": 0
},
{
"Code": "A020444100",
"Name": "paracetamol",
"Rules": "nhi",
"ResourceId": "A020444100.nhi",
"Date": "2007-07-07T17:21:10.4310233Z",
"TotalQuantity": 1.0,
"QuantityPerDose": 0.8,
"QuantityPerUnit": "ML",
"Frequency": "2 times daily as needed",
"Route": "Oral",
"Duration": 0
},
{
"Code": "NC017831G0",
"Name": "phenazopyridine",
"Rules": "nhi",
"ResourceId": "NC017831G0.nhi",
"Date": "2007-07-07T17:21:10.4310233Z",
"TotalQuantity": 1.0,
"QuantityPerDose": 8,
"QuantityPerUnit": "MG",
"Frequency": "when needed",
"Route": "Oral",
"Duration": 0
},
{
"Code": "AC29172100",
"Name": "cefalexin",
"Rules": "nhi",
"ResourceId": "AC29172100.nhi",
"Date": "2007-07-07T17:21:10.4310233Z",
"TotalQuantity": 1.0,
"QuantityPerDose": 100,
"QuantityPerUnit": "MG",
"Frequency": "",
"Route": "Oral",
"Duration": 0
}
]
}
```
### **Sample 3 JSON**
#### ==Request==
```json=
{
"Detail": true,
"DivisionCode": "02",
"Patientserial": "768be7ac-743f-4c24-aa0f-fed5a3a38b6a",
"PatientGender": 0,
"PatientAge": 86,
"DiseaseContent": [
{
"Code": "J06.9",
"Name": "Acute upper respiratory infection, unspecified",
"Rules": "ICD10",
"ResourceId": "J06.9.ICD10",
"Date": "2021-08-27T02:46:01.4010233Z"
},
{
"Code": "L30.9",
"Name": "Dermatitis, unspecified",
"Rules": "ICD10",
"ResourceId": "L30.9.ICD10",
"Date": "2021-08-27T02:46:01.4010233Z"
},
{
"Code": "M19.90",
"Name": "Unspecified osteoarthritis, unspecified site",
"Rules": "ICD10",
"ResourceId": "M19.90.ICD10",
"Date": "2021-08-27T02:46:01.4010233Z"
},
{
"Code": "K59.9",
"Name": "Functional intestinal disorder, unspecified",
"Rules": "ICD10",
"ResourceId": "K59.9.ICD10",
"Date": "2021-08-27T02:46:01.4010233Z"
},
{
"Code": "G47.09",
"Name": "Other insomnia",
"Rules": "ICD10",
"ResourceId": "G47.09.ICD10",
"Date": "2021-08-27T02:46:01.4010233Z"
},
{
"Code": "F41.9",
"Name": "Anxiety disorder, unspecified",
"Rules": "ICD10",
"ResourceId": "F41.9.ICD10",
"Date": "2021-08-27T02:46:01.4010233Z"
}
],
"MedContent": [
{
"Code": "AC59035157",
"Name": "opium derivatives and expectorants",
"Rules": "nhi",
"ResourceId": "AC59035157.nhi",
"Date": "2021-08-27T02:46:01.4010233Z",
"TotalQuantity": 1.0,
"QuantityPerDose": 12.0,
"QuantityPerUnit": "MG",
"Frequency": "QID",
"Duration": 1,
"TotalQuantityUnit": "Table",
"Route": "Oral"
},
{
"Code": "A012876100",
"Name": "multienzymes (lipase, protease etc.)",
"Rules": "nhi",
"ResourceId": "A012876100.nhi",
"Date": "2021-08-27T02:46:01.4010233Z",
"TotalQuantity": 1.0,
"QuantityPerDose": 21.0,
"QuantityPerUnit": "MG",
"Frequency": "QID",
"Duration": 1,
"TotalQuantityUnit": "Table",
"Route": "Oral"
},
{
"Code": "AC433061G0",
"Name": "cetirizine",
"Rules": "nhi",
"ResourceId": "AC433061G0.nhi",
"Date": "2021-08-27T02:46:01.4010233Z",
"TotalQuantity": 1.0,
"QuantityPerDose": 20.0,
"QuantityPerUnit": "MG",
"Frequency": "QID",
"Duration": 1,
"TotalQuantityUnit": "Table",
"Route": "Oral"
},
{
"Code": "BC187411G0",
"Name": "lorazepam",
"Rules": "nhi",
"ResourceId": "BC187411G0.nhi",
"Date": "2021-08-27T02:46:01.4010233Z",
"TotalQuantity": 1.0,
"QuantityPerDose": 200.0,
"QuantityPerUnit": "MG",
"Frequency": "QID",
"Duration": 1,
"TotalQuantityUnit": "Table",
"Route": "Oral"
},
{
"Code": "A023521100",
"Name": "magnesium oxide",
"Rules": "nhi",
"ResourceId": "A023521100.nhi",
"Date": "2021-08-27T02:46:01.4010233Z",
"TotalQuantity": 1.0,
"QuantityPerDose": 20.0,
"QuantityPerUnit": "MG",
"Frequency": "QID",
"Duration": 1,
"TotalQuantityUnit": "Table",
"Route": "Oral"
},
{
"Code": "AC33664100",
"Name": "trazodone",
"Rules": "nhi",
"ResourceId": "AC33664100.nhi",
"TotalQuantity": 1.0,
"QuantityPerDose": 70.0,
"QuantityPerUnit": "MG",
"Frequency": "QID",
"Duration": 1,
"TotalQuantityUnit": "Table",
"Route": "Oral"
},
{
"Code": "AC46729100",
"Name": "fludiazepam",
"Rules": "nhi",
"ResourceId": "AC46729100.nhi",
"Date": "2021-08-27T02:46:01.4010233Z",
"TotalQuantity": 1.0,
"QuantityPerDose": 120.0,
"QuantityPerUnit": "MG",
"Frequency": "QID",
"Duration": 1,
"TotalQuantityUnit": "Table",
"Route": "Oral"
}
]
}
```
---
## Signal to Expand/Shrink IFrame
### Two states of RxPrime (Examples below)
#### **State One**

#### **State Two**

> As we can see, state two requires the host to provide double-width on the IFrame, we may call it the "expanded" state.
### My suggestions on signaling host to switch to "expanded" state
1. **RxPrime makes a "GET" request** to https://hostexample.com?expanded=true (Host creates and determines this endpoint. expanded=true: expand the IFrame width, aka [state two](https://hackmd.io/SBucutWUQVu4-Pr1nRC3FQ?view#State-Two); expanded=false: shrink the IFrame width, aka [state one](https://hackmd.io/SBucutWUQVu4-Pr1nRC3FQ?view#State-One)). (More straightforward)
2. Or we can try **using the function "postMessage"** to build communication between RxPrime and the parent site. Details are available here: https://stackoverflow.com/questions/9153445/how-to-communicate-between-iframe-and-the-parent-site (More efficient, less data transferring)