CodeValueService
The CodeValueService is used to retrieve reference Cerner Code Value data.
Import
The CodeValueService should be imported and initialized in the component source that is responsible for displaying data from the service. Alternatively, if you have your required payload information available, you can initialize the loading of your data in the app.component.ts source.
V4+ import { CodeValueService } from '@clinicaloffice/clinical-office-mpage-core'; < V3 import { CodeValueService } from '@clinicaloffice/clinical-office-mpage';
Initialization
Once you have imported the CodeValueService, you need to inject it into your component and assign it to a variable. This is done through the constructor of your component (or the app.component.ts file).
export class myComponent implements OnInit { constructor(public codeValueService: CodeValueService) {} }
Initialization can be performed one of three ways.
-
In the ngOnInit() method of your app.component.ts or component file through a payload tag and direct
call to the mPageService executeCCL method.
ngOnInit() { this.mpage.executeCCL({ payload: { codeValue: [ {cs: codeSet, value: codeValue, filter: 'filterString', alias: 'aliasType', outboundAlias: 'outboundAliasType'} ] } }); }
-
Immediately load a code value or code set by calling the CodeValueService load method from the ngOnInit() method
of your app.component.ts or component file.
ngOnInit() { this.codeValueService.load(codeSet); }
-
Load a group of code values and code sets with the loadLater and loadNow methods in CodeValueService.
ngOnInit() { 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 }
Methods
get(value: number): ICodeValue
Returns a codeValue object for a specific code value if you have loaded the code value with the load/loadLater
methods. See the RESULTS tab for a list of valid codeValue fields.
HTML Example showing how to display a code value alias
Patient Gender: {{ codeValueService.get(personService.get().sexCd).alias }}
getCodeSet(cs: number): ICodeValue[]
Returns an array of codeValue objects containing all of the loaded code values for a code set. This is
very useful for drop-downs of code values you may want to display on your MPage.
HTML Example listing all of the available patient types
<ol *ngFor="let cv of codeValueService.getCodeSet(71)"> <li>{{ cv.display }}</li> </ol>
isLoaded(codeSet:number): boolean
Returns a boolean true or false indicating if the code set has been loaded.
load(cs: number,
value: number = 0,
alias: string = "",
outboundAlias: string = "",
filter: string = "",
reloadValues: boolean = false): void
Loads 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(cs: number,
value: 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(message: string): void
Outputs the content of the message parameter to the activity log component.
Public Variables
The CodeValueService exposes the following variable that can be useful in the development of your MPages.
- codeValues:iCodeValue[] - Array containing all loaded code values.
Payload
The following payload options represent all available payload values for the CodeValueService service.
{ payload: { codeValue: [ {cs: codeSet, value: codeValue, filter: 'filterString', alias: 'aliasType', outboundAlias: 'outboundAliasType'} ] }
Interfaces
ICodeValue
export interface ICodeValue { codeValue: number; codeSet: number; cdfMeaning: string; display: string; displayKey: string; description: string; definition: string; alias: string; outbound: string; }