In this article, we will describe an example of a simple custom MPage that obtains data from a CCL query.
The MPage attached to this article displays a simple button. When the user clicks the button, a Laboratory results viewer opens. The viewer is embedded in PowerChart and as such, the viewer does not open in a modal/pop-up window. The MPage obtains the patient’s MRN and the user’s username with a CCL query.
The MPage can easily be adapted to include more links to other viewers. The main advantages to using this MPage as opposed to using the PowerChart web link functionality are the following:
- The viewers can potentially open embedded in PowerChart as opposed to opening in a model/popup window. When you have result viewers in model/pop-up window, it can become easy to have the viewer open for a different patient than the patient in PowerChart. By having the viewer embedded, you always view the results from the patient whose chart is open in PowerChart.
- You have more flexibility on composing the URLs to the viewers (as the URLs are being composed with JavaScript).
- There is no limitation on the number of buttons you can add.
Please note that with some external 3rd party viewers, the approach of having a custom MPage that acts as an index to access different 3rd party viewers may not work well. Once the user is authenticated in one viewer, navigating back to the initial index of viewers and authenticating in another viewer may not be so easy.
This is how the MPage looks:

It is not necessary to display the URL. We are only displaying the URL for testing purposes.
The MPage consists of two files:
- mpage_viewer.html
- mpage_viewer_get_data.prg
The HTML file: mpage_viewer.html #
The mpage_viewer.html file is the actual MPage. It displays the button and uses JavaScript to compose the URL of the button by including the patient’s MRN in the URL. The MPage receives the person id and user id as parameters. It launches the mpage_viewer_get_data CCL object to obtain the MRN and username.
This HTML page has the following tag that allows it to run CCL programs:
<meta http-equiv="Content-Type" content="XMLCCLREQUEST,APPLINK,MPAGES_EVENT" name="discern"/>
It launches the CCL program and manages the result as follows:
<script>
function loadMPageData(){
var personInfo = new XMLCclRequest();
personInfo.onreadystatechange = function () {
if (personInfo.readyState == 4 && personInfo.status == 200) {
var jsonData = personInfo.responseText;
// Parse the JSON string into a JavaScript object
const parsedData = JSON.parse(jsonData);
if (parsedData){
// Access elements
var person_alias = parsedData.MPAGE_DATA.PERSON_ALIAS;
var username = parsedData.MPAGE_DATA.USERNAME;
const url = "http://10.116.145.164/iGestlab/ResultadosPacientePeticiones.aspx?user="+username+"&frame=1&nhc="+person_alias
// Modify link
document.getElementById("iGestLAB").href = url
document.getElementById("enlace").innerText = url
}
};
}
personInfo.open('GET', "mpage_viewer_get_data");
personInfo.send("^MINE^, value($PAT_PersonID$), value($USR_PersonID$)");
return;
}
</script>
Variables $PAT_PersonID$ and $USR_PersonID$ are set in prefmaint. Please see the prefmaint configuration bellow.
The CCL program: mpage_viewer_get_data.prg #
The mpage_viewer_get_data.prg CCL object obtains the MRN of the patient and the username of the user. It stores both data elements in a record variable and then returns the record to the MPage as a JSON formatted string.
The CCL makes select statements and stores results in the following record:
free record mpage_data
record mpage_data(
1 person_alias = vc
1 username = vc
)
Once the data is stored in the record, the record is converted into a JSON string:
declare mpage_data_json = vc
set mpage_data_json = CnvtRecToJson(mpage_data)
This is how the JSON string gets returned to the MPage:
;-- Record to be returned
record putREQUEST (
1 source_dir = vc
1 source_filename = vc
1 nbrlines = i4
1 line [*]
2 lineData = vc
1 OverFlowPage [*]
2 ofr_qual [*]
3 ofr_line = vc
1 IsBlob = c1
1 document_size = i4
1 document = gvc
)
;-- Set parameters
set putRequest->source_dir = $outdev
set putRequest->IsBlob = "1"
set putRequest->document = mpage_data_json
set putRequest->document_size = size(putRequest->document)
;-- Return the record containing the result
execute eks_put_source with replace(Request,putRequest),replace(reply,putReply)
Configuration in PrefMaint #
To add this MPage into PowerChart, we will add a component of type Discern Report on the Chart level:

Regarding the browser selection, the MPage of this example can work either with Internet Explorer or Edge Chromium.
Storing the MPage on the back-end: #
If we want to store the MPage HTML file on the backend nodes, this is how we would set it up in prefmaint:

This is the value for the REPORT_PARAM preference is:
"MINE","CCLUSERDIR:mpage_viewer.html", $PAT_PersonID$, $USR_PersonID$
These are the parameters you can pass into the MPage:
- APP_AppName
- DEV_Location
- PAT_PersonID
- USR_PersonID
- VIS_EncntrID