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

Data Retrieval

Angular applications are built by creating components and services. Components are building blocks that contain both HTML and TypeScript code where services are strictly TypeScript. Components should be built to handle the presentation logic of your MPage where services are responsible for handling the sharing of data between your components.

Everything that happens in your MPage starts in the app component. The app component is located in a folder called app inside the src folder of your project. The two files you are most concerned with will be app.html and app.ts. The app.routes.ts file can be safely ignored as routing cannot be used in Cerner workflow components. The app.config.ts file is critical to your project, however it will not require any modifications for this tutorial. You are encouraged to examine app.config.ts to get a better understanding of the CUSTOM_DATE_FORMATS constant and how services are provided.

Steps

  1. Return to your Visual Studio Code session and launch a new terminal window. Left-click the content area of the new terminal and press the enter key. This will reveal your project path. If it does not, use the command line cd command to get to the correct path.
  2. From the new command line, create a new service and call it services/common. This is done with the Angular CLI by typing in:
    ng g s services/common
    or
    ng generate service services/common
    Once completed, you will have a new sub-folder in your src folder called services that contains a file called common.ts.
  3. Any component (or other service) that will make use of our new common service needs to have the common service injected into it. Open app.ts. Add the following line to the imports section of your app.ts file.
    import { Common } from './services/common';
  4. Workflow components have been developed as stand-alone components with their own DOM tree. For your service to work inside your workflow component, you must add it to the providers array.
    providers: [MPageService, AddressService, AllergyService, CodeValueService, ConfigService, CustomService,
      DiagnosisService, Dialog, EncounterService, OrganizationService, PersonService, PhoneService,
      ProblemService, PrsnlService, ReferenceService, Common]
  5. To use functionality in your service, you must inject it into any component that directly accesses it. Do this by assigning it to a new object called common.
    export class App implements OnInit {
      public activatedRoute = inject(ActivatedRoute);
      public MPage = inject(MPageService);
      public common = inject(Common);

    When complete, your app.ts file should appear as in the screenshot shown below.

  6. Open your common.ts file and add a new boolean WritableSignal called ready. You will need to import signal and WritableSignal into your service.
    public ready: WritableSignal<boolean> = signal(false);
  7. You can test your service by adding a reference to it in your app.html file. Remove everything except the <mpage-log-component> line and add the following code at the top of the file.
    {{ common.ready() }}
    Return to your browser where you should see the word false appear on screen.
  8. Return to your common service file and import the inject and MPageService.
    import { inject, Injectable, signal, WritableSignal } from '@angular/core';
    import { MPageService } from '@clinicaloffice/mpage-developer';
  9. Inject the MPageService into a new object variable called MPage.
    export class Common {
    public ready: WritableSignal = signal(false);
    public MPage = inject(MPageService);
    
  10. Our patient information component is going to extensively use data from PersonService, EncounterService, PrsnlService, AddressService, and PhoneService. We could use the load methods of each of these services to collect the data in separate calls, however, in this application it is more efficient and easier to manage our data collection in a single call.

    Create a new public method in your custom service and call it initialLoad().

    In this service, we are going to make a call to the executeCCL method found in the MPage service with a payload that calls each of our data services. The code below does collect more information than we will use in this project, but it will be there for when you want to expand the information you want to provide your users.

    At the end of the executeCCL method call, we have a callback function that simply assigns the value of true to our ready signal.

    // Perform Initial Data Load
    public initialLoad(): void {
    
        this.MPage.executeCCL({
            payload: {
                patientSource: [this.MPage.emptyPatientSource],
                person: {
                    aliases: true,
                    names: true,
                    personInfo: true,
                    prsnlReltn: true,
                    personReltn: true,
                    personPlanReltn: true,
                    personCodeReltn: true,
                    patient: true,
                    orgReltn: true,
                    loadExtendedPersons: true
                },
                encounter: {
                    prsnlReltn: true,
                    personReltn: true,
                    encounterInfo: true,
                    loadExtendedPersons: true
                },
                prsnl: {
                    aliases: true,
                    loadExtendedPersons: true
                },
                address: true,
                phone: true
            }
        }, -1, (() => {
            this.ready.set(true);
        }));
    }
    
  11. To make use of our new method, return to your app.ts file and add the following line of code immediately after your MPage.setMaxInstances call.
    this.common.initialLoad();
  12. Return to your browser. After the page refreshes, you will see the "false" value display as "true" once all data has been loaded. Open the debugger with the CTRL + / keys.

    If this is the first chart level MPage you have developed in MPage Developer, you will not have a test patient assigned. With the debugger open, you will see the text "No Visit Selected" in the top right corner. Click this to launch the visit search window to assign a test patient.

  13. Search for a patient you would like to test with. Once your selection is complete, the debugger will show the new assignment and a message that the page will refresh in 5 seconds. Once the refresh has completed, you will be ready to view your data services.
  14. Once your page has been refreshed, open the debugger with the CTRL + / keys and click the Data Services tab.

    You will see numbers assigned to the data services which have qualifying data. In my example, I have information for the Address, Encounter, Person, Prsnl, and Phone services.

    You can click on the names of any service to expand the view. From there, click on a record to see a JSON representation of that record on the right hand side of the screen.

    Our data collection is now complete.

<< Prev: 1. Getting Started
Next: 3. Tabbed Menu >>
Copyright © 2026 Precision Healthcare Solutions