Code Handler

There are 2 new functions in the maracis.code_handler package for SMHS 5.3.1 you should be aware of. Both functions call equivalent functions in corp.code_handler.

Description
Obtains the parent code id value for the specified code id.

Syntax
maracis.code_handler.f_getparentcodeid ( p_code_id )

Arguments

 * p_code_id : The primary key of the local code for which you want the parent code id

Return values
Returns the parent code id for p_code_id if it succeeds and null if the local code cannot be found. If p_code_id is null, f_GetParentCodeID returns null.

Usage
Use f_GetParentCodeID to obtain the parent code id for a given local code. The result can be passed as a parameter to other functions or procedures requiring a code id.

Examples
This statement selects the parent code id for a local code with a code id of 100:

SELECT maracis.code_handler.f_getparentcodeid(100) FROM dual;

This statement selects the parent code ids for the local code values in column accommodation_status in table patient_indicators:

SELECT maracis.code_handler.f_getparentcodeid(a.accommodation_status) FROM patient_indicators a;

Description
Obtains the national code value for the specified code id or its ancestor if the national code is null.

Syntax
maracis.code_handler.f_getnationalcodeex ( p_code_id, {{p_national_code_pos},{p_exclude_root}} )

Arguments

 * p_code_id : The primary key of the local code for which you want the national code
 * p_national_code_pos : Number indicating which national code to obtain. Values are:
 * 1 : returns the value in column national_code (default)
 * 2 : returns the value in column national_code_2
 * 3 : returns the value in column national_code_3
 * p_exclude_root : Number indicating whether to exclude getting the national code from the root local code. The default value is 0 (false).

Return values
Returns the national code value if it succeeds and null if the local code cannot be found. If p_code_id is null, f_GetNationalCodeEx returns null.

Usage
Use f_GetNationalCodeEx to get the national code for local codes that may not have a national code value itself but can take its value from one of its ancestor codes.

f_GetNationalCodeEx differs from f_GetNationalCode in that if the national code value for the specified local code is null, then it searches for the first non-null national code value from the code’s ancestors, up to the root code.

For this code tree, note that for the local code COFFEE, which has no national code value, the national code for its ancestor BEVERAGE, is returned instead.

Examples
This statement selects the 1st national code values for the local codes in incident_type, including the root codes:

SELECT maracis.code_handler.f_getnationalcodeex(a.incident_type) incident_class FROM incident_type a;

This statement selects the national code values for local codes of SOURCE_OF_REFERRAL, where the root code’s national codes are excluded:

SELECT c.code_id ,c.code ,c.description ,maracis.code_handler.f_getnationalcodeex(c.code_id, 1, 1) national_code ,maracis.code_handler.f_getnationalcodeex(c.code_id, 2, 1) national_code_2 ,maracis.code_handler.f_getnationalcodeex(c.code_id, 3, 1) national_code_3 ,'SOURCE_OF_REFERRAL' root_code FROM maracis.code c START WITH c.code = 'SOURCE_OF_REFERRAL' CONNECT BY c.parent_code_id = PRIOR c.code_id;