Precision Healthcare Solutions
CLINICAL OFFICE MPAGE SUITE DEVELOPER REPORTS DESIGNER shopping_cart mail
SALES CONTACT US
TutorialsWorkflow Component1. Getting Started2. Data Retrieval3. Tabbed Menu4. Building Reusable Parts5. Information Tab6. Relationship Tab7. Provider Relationship Tab8. Final StepsFull Page MPage1. Getting Started2. User Prompts3. Custom Script - Part 14. Add a Table5. Click to View Details6. Custom Script - Part 27. Add Remaining Details8. Bonus - Deploy to DA2Third Party IntegrationExcelJS

Appointments by Resource Tutorial - User Prompts

Our MPage will consist of a section of user prompts along with a table containing the output data. This tutorial will be keeping the number of prompts limited to a date range and a resource select drop-down. You can, however, use this tutorial as a basis to add other prompts.

We will be creating a new component to handle the prompts and will add it to our application component. First, however, we need to switch our MPage to run as an organization level MPage.

  1. Open the app.ts file found in your src folder. In the ngOnInit() method, change the mode parameter of the MPage.setMaxInstances() method to 'ORGANIZER'.
    ngOnInit() {
        this.MPage.setMaxInstances(2, true, 'ORGANIZER', false);
        this.MPage.defaultDateFormats = CUSTOM_DATE_FORMATS;
    }
    Technically you can use any value other than 'CHART' and the MPage will run at the organizer level.
  2. Open a terminal window in Visual Studio Code.
  3. Next, from the command terminal, create a new component called components\prompts. This is done with the ng generate component command (or shortened to ng g c).
    ng generate component components/prompts
    ng g c components/prompts
    A new folder called components will be added to your src/app folder containing your prompts folder.
  4. Return to your app.ts file and add a line to import your Prompts component. You will also need to add Prompts to your imports array in your component decorator.
    import {ChangeDetectionStrategy, Component, inject, OnInit} from '@angular/core';
    import {CUSTOM_DATE_FORMATS} from './app.config';
    import {... MPage Developer Imports ...
    } from '@clinicaloffice/mpage-developer';
    import { Prompts } from "./components/prompts/prompts";
    
    @Component({
      selector: 'app-root',
      imports: [MpageLogComponent, Prompts],
      templateUrl: './app.html',
      standalone: true,
      changeDetection: ChangeDetectionStrategy.OnPush,
      providers: [MPageService, AddressService, AllergyService, CodeValueService, ConfigService, CustomService,
        DiagnosisService, EncounterService, Dialog, OrganizationService, PersonService, PhoneService,
        ProblemService, PrsnlService, ReferenceService]
    })
  5. Open app.html and add <app-prompts /> to the beginning of the document.
    <app-prompts />
    
    <mpage-log-component />
  6. Open the prompts.ts file found in src/app/components/prompts. This component will make use of the Angular forms module as well as the MPage Developer button directive, icon component, date range picker component, select component, and custom service. Ensure the following imports are at the top of prompts.ts
    import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
    import { FormsModule } from '@angular/forms';
    import { ButtonDirective, MpageIconComponent, MpageDateRangePickerComponent, MpageSelectComponent, ISelectValue, IDateRange, CustomService } from '@clinicaloffice/mpage-developer';
  7. We must add the forms module, our button directive and three MPage Developer components to the imports array before they can be used in our template. Add them to your @Component decorator as shown below.

    You should also identify your component as standalone

    As a final step, you can also optionally remove the styleUrl reference and delete the prompts.scss file from your project.

    @Component({
      selector: 'app-prompts',
      imports: [FormsModule, ButtonDirective, MpageIconComponent, MpageDateRangePickerComponent, MpageSelectComponent],
      templateUrl: './prompts.html',
      changeDetection: ChangeDetectionStrategy.OnPush,
      standalone: true
    })
  8. In our Prompts class definition, we need to inject the CustomService service. This will be used later to make a CCL call to retrieve our table data.
    export class Prompts {
      protected customService = inject(CustomService);
    }
  9. For this MPage, we want to make sure our users can only pick a date range between two values. Allowing access to <=, =>, or not between would result in an enormous data collection call. We also need to define a variable that we will use to contain our date range prompt.

    Immediately below the line containing our injected custom service, add the following two lines of code:

    protected rangeTypes: ISelectValue[] = [{ key: 'between', value: 'Between' }];
    protected datePrompt: IDateRange = { range: 'between', fromDate: new Date(), toDate: new Date() };
  10. Next, add a numeric array called resourcePrompt to hold our resource selections.
    protected resourcePrompt: number[] = [];
  11. Before we move to the prompts.html file, open the main project styles.scss file. Navigate to the --accent-color and -accent-color-alternate section of the specialty colors. Changes these values to the values shown below or colors of your choosing.
      --accent-color: #d5f6fe;
      --accent-color-content: darkblue;
      --accent-color-alternate: #3a6a82;
  12. Navigate to the bottom of styles.scss and add the following block of custom CSS.
    /* Custom Styles for this Page */
    div.prompts {
      padding: 0.5em;
      background-color: var(--accent-color);
      border: 1px solid var(--accent-color-alternate);
      border-radius: 4px;
    }
  13. Open prompts.html and add the following code:
    <div class="prompts flex flex-gap flex-center-items">
        <mpage-date-range-picker [(ngModel)]="datePrompt" [rangeTypes]="rangeTypes" label="Appointment Date(s)" />
        <mpage-select [(ngModel)]="resourcePrompt" [codeSet]="14231" label="Resource(s)" [multiple]="true" class="co-w30" />
        <button coButton color="primary" title="Refresh View">
            <mpage-icon>refresh</mpage-icon>
        </button>
    </div>
    If you view your MPage, you should see the following:

    Before we move on, let's discuss the code we just added. First, we have wrapped everything in a <div> tag that has a class definition containing our newly added prompts CSS class as well as the MPage Developer flex, flex-gap and flex-center-items classes. This ensures that our prompts will be displayed with proper colors and spacing.

    The first prompt is the mpage-date-range-picker prompt. We have set the model to our datePrompt variable and the rangeTypes to our rangeTypes variable. We have also assigned a title called "Appointment Date(s)".

    If you open the date prompt on the MPage, you will have the ability to choose a date range. Selecting multiple dates will change the prompt to show the range.

    The mpage-select prompt creates a select drop-down with resourcePrompt as the model variable using code set 14231. We have added a label called "Resource(s)", set the multiple indicator to true allowing for multiple selections and assigned a class of "co-w30" which represents 30%.

    On opening this prompt, we see that there are 9,781 possible records with a limit of 100. Loading that many resources into a single prompt would be inefficient, so the mpage-select prompt prevents the user from loading so much data. Instead, the user is given the opportunity to search for values.

    Our final piece of the HTML code is a button that uses a refresh icon. Hovering over the button displays the text "Refresh View" to the user. Currently, this button doesn't do anything.

  14. Modify the button element to add a click method called refresh. You may see an error message appear indicating refresh() doesn't exist. We need to create it.
    <button coButton color="primary" title="Refresh View" (click)="refresh()">
        <mpage-icon>refresh</mpage-icon>
    </button>
    
  15. Add the following code to the Prompts class in prompts.ts.
    protected refresh(): void {
        this.customService.load({
            name: '1trn_appt_by_res:group1',
            run: 'pre',
            id: 'tableData',
            parameters: {
                action: 'load-table',
                fromDate: this.customService.MPage.formatDate(this.datePrompt.fromDate, false),
                toDate: this.customService.MPage.formatDate(this.datePrompt.toDate, false),
                resourceCd: this.resourcePrompt
            }
        });
    }
    

    The code above will run a CCL script called 1trn_appt_by_res:group1 with a return id of tableData. We are passing a parameters object containing an action of 'load-table', fromDate and toDate in the format assigned in our CUSTOM_DATE_FORMATS definition of dateLabel (dd-mmm-yyyy), and our resourcePrompt array assigned as resourceCd.

    Notes
    • JavaScript Dates can be passed to CCL, however, timezone issues can sometimes occur. Converting dates to strings are more reliable when passed to CCL.
    • Fields passed to CCL from MPage Developer that have names ending in Id or Cd automatically have decimal places added to the end to prevent the CNVTJSONTOREC CCL function from converting numbers to integers if the value is too low.
  16. If you fill in your prompts and click the refresh button, you should be greeted with an error message. This is expected since your CCL script has not been written yet. Click the Ok button and open your MPage Debugger with CTRL + /.
  17. The process listed at the top will have three lines of text in the activity log. The top line indicates that the payload completed. The second line in red indicates the error message of the failed CCL script in the payload, while the third line represents the payload that was sent to CCL.

    Click the DEBUG button on the third line.

  18. You should see a new line of text appear indicating that a debug file has been created and the node it was created on. For multiple node domains (such as production), you will need to run the test script from the correct node.

  19. Our next section will be performed completely in DiscernVisualDeveloper and the CCL back-end. With the help of 1co5_mpage_test, we will be able to run and test our CCL script as we develop it.
<< Prev: 1. Getting Started
Next: 3. Custom Script - Part 1 >>
Copyright © 2026 Precision Healthcare Solutions