Code Value Service
Overview
The code value service is used to retrieve reference Cerner Code Value data.
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 {CodeValueService} from '@clinicaloffice/mpage-developer';
Object Assignment
Using the Angular inject command, assign the CodeValueService 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 codeValueService = inject(CodeValueService);
....remaining code...
Data Collection
The examples below demonstrate data collection methods you can use.
// Load a code set by code set number
this.codeValueService.load(codeSet);
// Use the MPage Service to load code value payload items
this.MPageService.executeCCL({
payload: {
codeValue: [
{cs: codeSet, value: codeValue, filter: 'filterString', alias: 'aliasType', outboundAlias: 'outboundAliasType'}
]
}
});
// Load a group of code values and code sets with the loadLater and loadNow methods in CodeValueService.
this.codeValueService.loadLater(71); // Queue loading code set 71
this.codeValueService.loadLater(220, 0, '', '', 'CV.CDF_MEANING="NURSE_UNIT"'); // Queue loading nurse units only from code set 220
this.codeValueService.loadNow(); // Load all queued code sets
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... }
Methods / Usable Objects
codeValues(): ICodeValue[]Returns and array of all loaded ICodeValue values.
get(codeValue: number): ICodeValueReturns a specific code value if loaded or an empty code value record if not yet loaded.
has(codeSet: number): booleanReturns a true or false if a code set has been loaded into memory.
length(): numberReturns a count containing the number of code values loaded in memory.
load( codeSet: number, codeValue: number = 0, alias: string = '', outboundAlias: string = '', filter: string = '', reloadValues: boolean = false, callback: any = undefined ): voidLoads code set or code value data immediately. Passing a valid code set value to the cs parameter is required unless you are loading a single specific code value with the value parameter. If a value other than 0 is passed to the value parameter the cs parameter is ignored.
If you have already loaded any values from a specific code set, and you execute the load method for the same code set, your request will be ignored unless you set the reloadValues parameter to true. Any code values that exist in memory that are loaded on a new load will have their values replaced by the newly loaded data.
The alias and outboundAlias parameters are used to load a specific code value alias and/or code value outbound alias value for each specified code value or code set. To implement, simply value the field with the DISPLAY_KEY value of the contributor source for the alias type. For example, if you had a code value alias for PREMIER, you would simply pass "PREMIER" as the parameter value for alias.
The filter parameter allows you the ability to filter any of the fields in the code value table. When the CCL is run that collects the code values, the table is aliased as CV, so you must prefix any fields you use with "CV.". You are permitted to use any CCL SQL syntax you wish (e.g. CV.DISPLAY_KEY = 'HEART*').
Examples
// Loads all code values in code set 71 this.codeValueService.load(71); // Loads nurse units in code set 220 this.codeValueService.load(220, 0, '', '', 'CV.CDF_MEANING="NURSE_UNIT"'); // Tries to load ambulatory units only from code set 220 but will fail as we already // loaded data from code set 220 this.codeValueService.load(220, 0, '', '', 'CV.CDF_MEANING="AMBULATORY"'); // Loads ambulatory units from code set 220 and passes reloadValues parameter to allow loading. // The previously loaded nurse units remain in memory. this.codeValueService.load(220, 0, '', '', 'CV.CDF_MEANING="AMBULATORY"', true); // Loads a specific code value (The number used is fake and for demonstration only) this.codeValueService.load(0, 453343); // Loads all code values in code set 19 along with code value aliases for PREMIER this.codeValueService.load(19, 0, 'PREMIER');loadLater( codeSet: number, codeValue: number = 0, alias: string = '', outboundAlias: string = '', filter: string = ''): void
The loadLater method functions in a similar method to the load function. With the exception of the reloadValues parameter (which is not present in the loadLater method), all of the parameters are identical to the load method. The loadLater method will function the same as the load method with the reloadValues parameter set to true.
The purpose of loadLater is to allow you the ability to queue up a larger request to CCL of code values to aid in performance. For example, if you issued 10 calls to the load function and have 4 instances available in your MPage, your MPage queue may be tied up for longer than you would like loading code values. By queuing up code value requests with the loadLater method, you can send a single request containing all 10 of your code value calls.
Once you have queued all of your code value loads, simply execute the CCL with the loadNow method.
Example (Results in same data being loaded as example for load method above except that a single call is made to CCL instead of 5).
this.codeValueService.loadLater(71); this.codeValueService.loadLater(220, 0, '', '', 'CV.CDF_MEANING="NURSE_UNIT"'); this.codeValueService.loadLater(220, 0, '', '', 'CV.CDF_MEANING="AMBULATORY"'); this.codeValueService.loadLater(0, 453343); this.codeValueService.loadLater(19, 0, 'PREMIER'); this.codeValueService.loadNow();loadNow(): void
If code value requests have been made with the loadLater method, the loadNow method simply executes the CCL.
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<ICodeSet>Returns an iterable iterator representation of all loaded code values.
Interfaces
ICodeValue {
codeValue: number;
codeSet: number;
cdfMeaning: string;
display: string;
displayKey: string;
description: string;
definition: string;
alias: string;
outbound: string;
}
ICodeSet {
codeSet: number;
count: number;
}