Files
St.Clair/MLMStripper/bin/Debug/STD/STD_FUNC_DOSAGE_TRIM_ADJUSTED.mlm

106 lines
4.0 KiB
Plaintext

maintenance:
title: Trim Excess Decimals from Numbers;;
mlmname: STD_FUNC_DOSAGE_TRIM_ADJUSTED;;
arden: version 2.5;;
version: 18.4;;
institution: Allscripts, Standard MLM;;
author: Allscripts Healthcare Solutions, Inc.;;
specialist: ;;
date: 2018-10-26;;
validation: testing;;
/* P r o p r i e t a r y N o t i c e */
/* Unpublished (c) 2013 - 2018 Allscripts Healthcare, LLC. and/or its affiliates. All Rights Reserved.
P r o p r i e t a r y N o t i c e: This software has been provided pursuant to a License Agreement, with
Allscripts Healthcare, LLC. and/or its affiliates, containing restrictions on its use. This software contains
valuable trade secrets and proprietary information of Allscripts Healthcare, LLC. and/or its affiliates and is
protected by trade secret and copyright law. This software may not be copied or distributed in any form or medium,
disclosed to any third parties, or used in any manner not provided for in said License Agreement except with prior
written authorization from Allscripts Healthcare, LLC. and/or its affiliates. Notice to U.S. Government Users:
This software is {{{SINGLE-QUOTE}}}Commercial Computer Software{{{SINGLE-QUOTE}}}.
All product names are the trademarks or registered trademarks of Allscripts Healthcare, LLC. and/or its affiliates.
*/
/* P r o p r i e t a r y N o t i c e */
library:
purpose: Applies conversion factor to the list of numbers, and if the conversion factor
is small and introduces extra significant digits, it shifts the template number to
add extra significant digits
;;
explanation: A list of numbers is rounded and trimmed to 1 decimal place more
than the template number with the most decimal places and conversion factor.
Example: the template number has 2 decimal places (e.g. 450.25),
then the list of numbers is rounded to 3 decimals (e.g. 20.333333, 50.7777777)
and becomes (20.333, 50.778).
The conversion factor is applied to the list of numbers.
If the conversion factor introduces extra significant digit, it adds the significant digits
to the template number.
Example: the template number has 2 decimal places (e.g. 450.25), and the conversion factor is 0.1
then the list of numbers is rounded to 3 decimals (e.g. 2.0333333, 5.07777777)
and becomes (2.0333, 5.0778).
;;
keywords: single dose; average daily dose; total daily dose; dosage range
;;
knowledge:
type: data-driven;;
data:
(template_numbers_list, // A list of numbers that a used as a template for trimming decimals (based on the one with the most decimals)
conversion_factor, // A number to convert the trim_numbers_list
trim_numbers_list // One or more numbers that need to be trimmed.
) := ARGUMENT;
// Set to true if logging is needed.
log_execution_info := false;
func_dosage_trim := MLM {{{SINGLE-QUOTE}}}STD_func_dosage_trim{{{SINGLE-QUOTE}}};
;;
evoke:
;;
logic:
if template_numbers_list is number
then
template_numbers_list := , template_numbers_list;
endif;
if all (template_numbers_list is number)
and conversion_factor is number
and all (trim_numbers_list is number)
then
divisor := 1;
// See how many factors of 10 we can find
// Every divisor of 10 shifts the number by one decimal place
// 0.1 => 1/0.1 = 10 => a factor of 10
// 0.05 => 1/0.05 = 20 => shifts the digits by a factor of 10
// 0.01 => 1/0.01 => 100 => shifts digits by a factor of 100
if (conversion_factor >0) and (conversion_factor < 1)
then
val := 1/conversion_factor;
while (val > 10)
do
divisor := divisor * 10;
val := val/10;
enddo;
endif;
// Adjust the significant digits of the template number based on the conversion factor
shifted_template_numbers_list := template_numbers_list / divisor;
converted_trim_numbers_list := trim_numbers_list * conversion_factor;
(rounded_trim_numbers_list) := call func_dosage_trim with (shifted_template_numbers_list, converted_trim_numbers_list);
endif; //if template_number is number
Conclude True;
;;
action:
Return rounded_trim_numbers_list;
;;
Urgency: 50;;
end: