Test CCL Script
The most important part of every MPage is the CCL script (or scripts) responsible for delivering data to your MPage. This statement is true for every MPage regardless of the MPage technology you are using (e.g. Angular, React, JQuery). Without a CCL back-end providing data to your MPage, your MPage won't be able to provide anything useful to your users.
While it is possible that your front end code could be responsible for end-user performance issues, it is most likely the case that the CCL script will be the bottleneck. It is critical to the success of your MPages that your MPage development team includes a skilled CCL developer.
The CCL script library that accompanies your Clinical Office: MPage Edition license includes a very useful test script that I find invaluable when developing CCL scripts for MPages. This CCL script is called 1co_mpage_test.prg.
The 1co_mpage_test.prg contains some boilerplate setup followed by a small section of code you can use to insert your test payload data. The final piece executes the Clinical Office: MPage Edition driver script returning the results from your CCL script and any standard Clinical Office scripts you call in your payload.
You should never modify the original 1co_mpage_test.prg script. Instead, you will either make a personal copy for yourself or a copy for each MPage you develop for troubleshooting later. In our lesson we are going to develop a copy specific to our MPage. Your script can be run directly from Discern Visual Developer or through a back-end CCL session. I personally always run the script from a back-end session as it is easier to see performance issues and errors as they are reported.
- Using Discern Visual Developer, open 1co_mpage_test.prg. From the File menu, select "Save As" and save your new script as 1trn_mp_appointment.prg. When prompted to rename the program to match the new file and to save the prompts, leave the options checked and click the OK button.
-
Scroll to line 106 of the CCL source code. You should see the following line of code.
set request->BLOB_IN = concat(^put your payload here^)
Replace the content inside the carets (^) with the payload content you copied from your MPage debugger. The line should have the following content when done.set request->BLOB_IN = concat(^{"payload":{"patientSource":[{"personId":0,"encntrId":0}], "customScript":{"script":[{"name":"1trn_appt_mp:group1","run":"pre","id":"appointments"}]}}}^)
-
Discern Visual Developer will complain that your line is longer than 132 characters. You can leave this as is
without problem or break your code into smaller sections using the included concat statement on line 106 as
follows:
set request->BLOB_IN = concat(^{"payload":{"patientSource":[{"personId":0,"encntrId":0}], ^, ^"customScript":{"script":[{"name":"1trn_appt_mp:group1","run":"pre","id":"appointments"}]}}}^)
-
Include/Compile the script and run it to from Discern Visual Developer to see the initial output. Since you
have a patient in context that you assigned on your MPage, you can skip filling in the FIN and USERNAME prompts
and just click the Execute button. You should see the following JSON text in the output window.
This is the same content returned to your MPage when you first attempted to run the code. You should be able to easily spot the missing script error we saw in our MPage.
-
As mentioned earlier, testing on the back-end is the ideal method. Using a back-end CCL session, run your
script with the following line:
1trn_mp_appointment:group1 "MINE" go
The back-end session returns the same output as through Discern Visual Developer however other helpful information can be seen including the point where the script failed. While not shown here since we do not have our script built yet, the back-end session also offers the ability to cancel mid-run with the CTRL + C keys.
Next Steps
We are now ready to start developing our Appointment CCL script. With this test script in place, we can write our script and test it completely from within CCL before introducing our code to our MPage.
Later, as we add prompts and other functionality to our MPage, we will modify our payload in 1trn_mp_appointment.prg to perform additional tests.