Phone Service
Overview
The phone service will retrieve phone number information from Cerner for any type of address object including patients, providers and organizations.
To use this service, you must import the service, assign it to an object, execute a data collection operation (either with the load method on this or any other MPage Developer service, or with the MPage Service executeCCL method). Finally, you need to do something with the data you have retrieved.
Import
import {Component, inject, OnInit, ...etc...} from '@angular/core';
import {PhoneService} from '@clinicaloffice/mpage-developer';
Object Assignment
Using the Angular inject command, assign the PhoneService to a new object. It is recommended that you scope your object as "protected" to allow access from your component HTML.
@Component({...
...})
export class YourComponent implements OnInit {
protected phoneService = inject(PhoneService);
....remaining code...
Data Collection
The examples below demonstrate data collection methods you can use.
// Load the phone information for the current patient in context using the default payload of "APO_PHONE"
this.phoneService.load();
// Load the address and phone information for personId=3245, encntrId=1234
this.phoneService.load("APO_ALL", [{personId: 3245, encntrId=1234}]);
// Load the phone information for organization=456
this.phoneService.load("APO_PHONE", undefined, [{organizationId: 456}]);
// Use the MPage Service to load multiple payload items for the current patient
this.MPageService.executeCCL({
payload: {
patientSource: [{personId: 0, encntrId: 0}],
address: true,
phone: true,
person: {
aliases: true,
patient: true,
personReltn: true
}
});
Payload Options
The phone service only offers an option to skip generating JSON output. If not skipping the JSON generation, call the phone property as true (e.g. { phone: true }). Skipping the JSON output will prevent the output of the service from being included in the data returned to your MPage. This functionality is useful if you are creating a custom CCL script after everything else has run where you want to summarize specific information.
{
phone: {
skipJSON: true
}
}
Default Payload Tags that Reference the Phone Service
| APO_PHONE | {
phone: true
}
|
| APO_ALL | {
address: true,
phone: true
}
|
| APO_ORG | {
clearPatientSource: true,
organization: {
aliases: true
},
address: true,
phone: true
}
|
Using Callbacks
Both the service load method and MPageService executeCCL methods offer a callback parameter as the final parameter. You can use this callback or another option of your choosing to work with the data returned from Cerner.
this.MPageService.executeCCL({
payload: {
...
}
}, () => { ...do something here... }
Accessing from HTML
The phones() or get() methods in the Phone Service can be accessed directly from HTML. The phones() method will return all loaded phone information where the get() method returns a specific phone. Care should be taken to ensure you filter the correct phones when using the phones() method.
<h1>Home Phone</h1>
@let home = phoneService.get('HOME');
{{ home?.phoneFormatted }}
Methods / Usable Objects
get(phoneType: string, parentEntityId: number = this.MPage.personId, parentEntityType: string = 'PERSON'): IPhone | undefinedReturns an IPhone object containing Cerner phone information for either a person or organization or an empty phone if the phone has not yet been loaded.
Valid values for phoneType can be found in code set 43, and you can either use the cdf_meaning or display value. parentEntityId represents a personId or organizationId with a default value being the current patient. parentEntityType can either have a value of "PERSON" or "ORGANIZATION". The default is "PERSON".
length(): numberReturns a count containing the number of phone values loaded in memory.
load(payload: any = 'APO_PHONE', patientSource: IPatientSource[] | undefined = [{personId: 0, encntrId: 0}], orgSource: IOrgSource[] | undefined = undefined, callback: any = undefined ): voidLoads phone information for either a patientSource or orgSource. The payload can be any valid payload string or default payload (see payload tab).
If the sourceType is set to "patientSource", the dataSource array must be in the valid PatientSource format of [{"personId": value, "encntrId": value}] where value represents a personId/encntrId pair. Passing the value of 0 for both personId/encntrId in a chart MPage will result in the current encounter being used.
If sourceType is set to "orgSource", the dataSource array must be in the format of [{"organizationId": value}] where value represents a valid Cerner ORGANIZATION_ID.
phones(): IPhone[]Returns and array of all loaded IPhone values.
putLog(text: string, type: string = 'info', processId: number = -1, statusText: string = ''): voidWrites a line of text to the MPage Developer log. Valid values for type include 'info', 'error', 'payload', and 'debug'. You should only use the values 'info' or 'error' as 'payload' and 'debug' are reserved for system use. The processId and statusText values can safely be ignored.
values(): IterableIterator<IPhone>Returns an iterable iterator representation of all loaded phone values.
typeList Filtering
You can limit the amount of data collected in CCL by optionally adding a typeList object to your payload. For example, if you only wanted to load "HOME" phone for patients, and you never plan on using the other types, add a typeList entry for code set 43 to your payload. Simply include the codeSet value, type or typeCd where type represents a cdf_meaning or display_key value and typeCd represents the actual code value you want to filter by.
{
payload: {
patientSource [{personId: 0, encntrId: 0}],
phone: true,
typeList: [{codeSet: 43, type: 'HOME', typeCd: 0}]
}
}
Interfaces
IOrgSource {
organizationId: number;
}
IPhone {
parentEntityId: number;
parentEntityName: string;
phoneId: number;
phoneType: string;
phoneTypeMeaning: string;
phoneTypeSeq: number;
activeInd: number;
begEffectiveDtTm: Date;
endEffectiveDtTm: Date;
phoneNumber: string;
phoneFormatted: string;
extension: string;
phoneTypeCd: number;
}