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 - Add a Table

In this next section, we will add a table component to our MPage and wire it up with the data we have just collected.

While we are working with the table, we are also going to clean up a few potential issues users will encounter.

  1. While running your MPage, click the Refresh button without any resources chosen. You will be greeted with a CCL error as the expand method used in our CCL does not account for an empty array being passed in. This is easily resolved in our MPage.
  2. In your prompts.ts file, add the following method.
    // Determine if all required prompts completed
    protected requirementsNotMet(): boolean {
        return this.resourcePrompt.length === 0;
    }
  3. Update prompts.html to include the required parameters on the two inputs and the disabled property on the button.
    <div class="prompts flex flex-gap flex-center-items">
        <mpage-date-range-picker [(ngModel)]="datePrompt" [rangeTypes]="rangeTypes" label="Appointment Date(s)" [required]="true" />
        <mpage-select [(ngModel)]="resourcePrompt" [codeSet]="14231" label="Resource(s)" [multiple]="true" class="co-w30" [required]="true" />
        <button coButton color="primary" title="Refresh View" (click)="refresh()" [disabled]="requirementsNotMet()">
            <mpage-icon>refresh</mpage-icon>
        </button>
    </div>
    Our button is now disabled until at least one resource is entered. We didn't bother checking the date value as it is impossible to delete the value.
  4. We are going to use an Angular Signal output variable in our prompts component, which will notify our main app component that data has been loaded and that the table should be refreshed. Add output to your import statement from @angular/core in the prompts.ts file.
    import { ChangeDetectionStrategy, Component, inject, output } from '@angular/core';
  5. In your Prompts class definition, add a public boolean output variable called dataReady
    export class Prompts {
      protected customService = inject(CustomService);
    
      public dataReady = output<boolean>();
    
      protected rangeTypes: ISelectValue[] = [{ key: 'between', value: 'Between' }];
      protected datePrompt: IDateRange = { range: 'between', fromDate: new Date(), toDate: new Date() };
      protected resourcePrompt: number[] = [];  
  6. Modify your customService.load method to include a callback function that emits the value true once data has been loaded.
      // Refresh the table data
      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
          }
        }, undefined, () => {
          this.dataReady.emit(true);
        });
      }
  7. Return to the app.ts file add an imports for signal and WritableSignal from @angular/core and the RemainingScreenSpaceDirective from @clinicaloffice/mpage-developer.
    import { ChangeDetectionStrategy, Component, inject, OnInit, signal, WritableSignal } from '@angular/core';
    import { CUSTOM_DATE_FORMATS } from './app.config';
    import { MPageService, MpageLogComponent, AddressService, AllergyService, CodeValueService, ConfigService, CustomService, DiagnosisService, EncounterService, Dialog, OrganizationService, PersonService, PhoneService, ProblemService, ReferenceService, PrsnlService, MpageTableComponent, RemainingScreenSpaceDirective } from '@clinicaloffice/mpage-developer';
    import { Prompts } from "./components/prompts/prompts";
  8. Add RemainingScreenSpaceDirective to the imports array in your @Component decorator.
    @Component({
      selector: 'app-root',
      imports: [MpageLogComponent, Prompts, MpageTableComponent, RemainingScreenSpaceDirective],
      templateUrl: './app.html',
      standalone: true,
      changeDetection: ChangeDetectionStrategy.OnPush,
      providers: [MPageService, AddressService, AllergyService, CodeValueService, ConfigService, CustomService,
        DiagnosisService, EncounterService, Dialog, OrganizationService, PersonService, PhoneService,
        ProblemService, PrsnlService, ReferenceService]
    })
  9. Add a new protected WritableSignal array called tableData to your App component.
    protected tableData: WritableSignal<any[]> = signal([]);
  10. The final step in app.ts is to add a new method called loadTable. When executed, this method will assign the values from the custom service data to the new signal called tableData.
    // Populate the tableData signal with the values from custom service
    protected loadTable() {
        if (this.customService.has('tableData')) {
            this.tableData.set(this.customService.get('tableData').data);
        }
    }
    
  11. Open app.html and replace the content with the following:
    <app-prompts (dataReady)="loadTable()" />
    
    <div coRemainingScreenSpace>
        <mpage-table [data]="tableData()" [params]="{showToolbar: true}" />
    </div>
    
    <mpage-log-component />

    The major differences to the code are:

    • The (dataReady) emitter has been assigned on the app-prompts element. When triggered in the prompts component, this emitter will execute the loadTable() method we just created.
    • A new <div> element has been created and the coRemainingScreenSpace directive has been applied. This directive will size the <div> element to match the exact height remaining in your browser. It is responsive, meaning any change in screen size will result in the container size being updated.
    • The <mpage-table /> component has been added with the data property pointing to our new tableData signal. Any changes to the signal variable will result in the table being refreshed. We have also allowed the toolbar to be shown to give users the ability to customize the output.
  12. View your MPage and fill in some prompt values. You should see the table rendered.
<< Prev: 3. Custom Script - Part 1
Next: 5. Click to View Details >>
Copyright © 2026 Precision Healthcare Solutions