Address Service
Overview
The address service will retrieve address 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 {AddressService} from '@clinicaloffice/mpage-developer';
Object Assignment
Using the Angular inject command, assign the AddressService to a new object. It is recommended that you scope your object as "protected" to allow access to your component HTML.
@Component({...
...})
export class YourComponent implements OnInit {
protected addressService = inject(AllergyService);
....remaining code...
Data Collection
The examples below demonstrate data collection methods you can use.
// Load the address information for the current patient in context using the default payload of "APO_ADDR"
this.addressService.load();
// Load the address and phone information for personId=3245, encntrId=1234
this.addressService.load("APO_ALL", [{personId: 3245, encntrId=1234}]);
// Load the address information for organization=456
this.addressService.load("APO_ADDR", 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 address service only offers an option to skip generating JSON output. If not skipping the JSON generation, call the address property as true (e.g. { address: 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.
{
address: {
skipJSON: true
}
}
Default Payload Tags that Reference the Address Service
| APO_ADDR | {
address: 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 addresses() or get() methods in the Address Service can be accessed directly from HTML. The addresses() method will return all loaded address information where the get() method returns a specific address. Care should be taken to ensure you filter the correct addresses when using the addresses() method.
<h1>Home Address State & City</h1>
@let home = addressService.get('HOME');
{{ home?.state }} {{ home?.city }}
Methods / Usable Objects
addresses(): IAddress[]Returns and array of all loaded IAddress values.
get(addressType: string, parentEntityId: number = this.MPage.personId, parentEntityType: string = 'PERSON'): IAddress | undefinedReturns an IAddress object containing Cerner address information for either a person or organization .
Valid values for addressType can be found in code set 212, 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 address values loaded in memory.
load(payload: any = 'APO_ADDR', patientSource: IPatientSource[] | undefined = [{personId: 0, encntrId: 0}], orgSource: IOrgSource[] | undefined = undefined, callback: any = undefined ): voidLoads Address 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.
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<IAddress>Returns an iterable iterator representation of all loaded address 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" address for patients, and you never plan on using the other types, add a typeList entry for code set 212 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}],
address: true,
typeList: [{codeSet: 212, type: 'HOME', typeCd: 0}]
}
}
Interfaces
IAddress {
parentEntityId: number;
parentEntityName: string;
addressId: number;
addressType: string;
addressTypeMeaning: string;
addressTypeSeq: number;
activeInd: number;
begEffectiveDtTm: Date;
endEffectiveDtTm: Date;
streetAddr: string;
streetAddr2: string;
streetAddr3: string;
streetAddr4: string;
city: string;
state: string;
zipCode: string;
county: string;
country: string;
addressTypeCd: number;
stateCd: number;
countyCd: number;
countryCd: number;
}
IOrgSource {
organizationId: number;
}