181 lines
6.5 KiB
Plaintext
181 lines
6.5 KiB
Plaintext
maintenance:
|
|
|
|
title: Calculate the Frequency Multiplier for Average Daily;;
|
|
mlmname: SYS_CALC_FREQMULT_AVERAGE;;
|
|
arden: version 2.5;;
|
|
version: 18.4;;
|
|
institution: Allscripts, System 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: Calculates a Frequency Mutiplier for a Frequency such as BID, Q18H, etc.
|
|
This AVERAGE DAILY multiplier is for the average number of times something can occur in a day.
|
|
;;
|
|
explanation: Using the Frequency dictionary and the Units of Measure
|
|
dictionary, an AVERAGE DAILY frequency multiplier is calculated
|
|
based on seconds, minutes, hours, days, weeks, months, or years.
|
|
The Frequency Multiplier can be used to calculate an Average
|
|
Daily Dose from a Single-Dose. For example, BID returns 2 as
|
|
a multiplier, and Q18H returns 1.333333 as a multiplier
|
|
|
|
;;
|
|
keywords: Frequency Multiplier; Average Daily
|
|
;;
|
|
knowledge:
|
|
type: data-driven;;
|
|
data:
|
|
|
|
/* Pass in a frequency as a string */
|
|
(order_med_frequency,
|
|
from_time,
|
|
from_uom):= argument;
|
|
|
|
/* The facility must map its Dictionary Codes to the Core UOM in the */
|
|
/* Units of Measure Dictionary. The MLM converts the facility-defined units of measure */
|
|
/* to the system-defined values in the Unit of Measure Dictionary called CoreUOM. */
|
|
|
|
day_string:= "day";
|
|
hour_string:= "hr";
|
|
minute_string:= "min";
|
|
month_string:= "month";
|
|
ounce_string:= "oz";
|
|
second_string:= "s";
|
|
week_string:= "week";
|
|
year_string:= "year";
|
|
|
|
if order_med_frequency = "<Variable Interval>"
|
|
then
|
|
frequency_type := 3;
|
|
time_from_value := from_time as number;
|
|
(time_core_uom) := read last
|
|
{"SELECT CoreUOM "
|
|
|| " FROM CV3UnitOfMeasure"
|
|
|| " WHERE Code = " || SQL (from_uom)
|
|
|| " AND Active = 1 " };
|
|
|
|
else
|
|
/* Gets the Frequency information from the Enterprise data */
|
|
/* Only gets the Active Frequencies and Active Units of Measures */
|
|
(frequency_code,
|
|
frequency_type,
|
|
time_from_value,
|
|
time_to_value,
|
|
time_uom,
|
|
time_core_uom):= read last
|
|
{"SELECT f.Code, f.DefinitionType, f.TimeFromValue, f.TimeToValue,"
|
|
|| " f.TimeUom, u.CoreUOM "
|
|
|| " FROM CV3Frequency AS f JOIN CV3UnitOfMeasure AS u"
|
|
|| " ON f.TimeUom = u.Code "
|
|
|| " WHERE f.Code = " || SQL (order_med_frequency)
|
|
|| " AND f.Active = 1 "
|
|
|| " AND u.Active = 1 " };
|
|
|
|
|
|
/* Handle frequency templates <qxh> and <qxm> by parsing the frequency string */
|
|
/* If changes are made to this code, also change them in SYS_CALC_FREQMULT_DAILY */
|
|
/* This is a temporary workaround for frequency templates */
|
|
If NOT Exist frequency_type
|
|
then
|
|
/* Declare C functions to parse the frequency string */
|
|
func_get_token := interface {char* msvcrt:strtok(char*, char*)};
|
|
func_get_str := interface {char* msvcrt:strstr(char*, char*)};
|
|
|
|
/* Declare characters used for delimiting the string */
|
|
/* Delimiters are Case Sensitive */
|
|
q_delim:= "Q";
|
|
h_delim:= "H";
|
|
m_delim:= "M";
|
|
|
|
/* Determine if the letter in at the back of the string is H or M */
|
|
get_H:= call func_get_str with (order_med_frequency, h_delim);
|
|
get_M:= call func_get_str with (order_med_frequency, m_delim);
|
|
|
|
/* Remove the front Q, so xH or xM is left */
|
|
trim_Q:= call func_get_token with (order_med_frequency, q_delim);
|
|
|
|
/* Set the time_core_uom */
|
|
/* Remove the H or the M, leaving a string representation of a number */
|
|
if exist get_H
|
|
then
|
|
time_core_uom := hour_string;
|
|
freq_num_str := call func_get_token with (trim_Q, h_delim);
|
|
elseif exist get_M
|
|
then time_core_uom := minute_string;
|
|
freq_num_str := call func_get_token with (trim_Q, m_delim);
|
|
endif; /* if exist get_H */
|
|
|
|
/* Convert string to number */
|
|
time_from_value := freq_num_str as number;
|
|
endif; /* If NOT Exist frequency_type */
|
|
|
|
endif /* if order_med_frequency = "<Variable Interaval>" */
|
|
|
|
;;
|
|
evoke:
|
|
;;
|
|
logic:
|
|
|
|
if time_core_uom = day_string then
|
|
if frequency_type = 1 /* y times per day */
|
|
then conversion_factor_ave:= time_from_value;
|
|
else conversion_factor_ave:= 1/ time_from_value ;
|
|
endif;
|
|
elseif time_core_uom = hour_string then
|
|
if frequency_type = 1 /* y times per hour */
|
|
then conversion_factor_ave:= 24 * time_from_value;
|
|
else conversion_factor_ave:= 24/ time_from_value;
|
|
endif;
|
|
elseif time_core_uom = minute_string then
|
|
if frequency_type = 1 /* y times per minute*/
|
|
then conversion_factor_ave:= 24*60* time_from_value;
|
|
else conversion_factor_ave:= 24*60/ time_from_value;
|
|
endif;
|
|
elseif time_core_uom = second_string then
|
|
if frequency_type = 1 /* y times per second */
|
|
then conversion_factor_ave:= 24*60*60* time_from_value;
|
|
else conversion_factor_ave:= 24*60*60/time_from_value;
|
|
endif;
|
|
elseif time_core_uom = week_string then
|
|
if frequency_type = 1 /* y times per week */
|
|
then conversion_factor_ave:= time_from_value / 7;
|
|
else conversion_factor_ave:= 1/(7 * time_from_value);
|
|
endif;
|
|
elseif time_core_uom = month_string then
|
|
if frequency_type = 1 /* y times per month */
|
|
then conversion_factor_ave:= time_from_value /(365/12);
|
|
else conversion_factor_ave:= (1/((365/12)* time_from_value));
|
|
endif;
|
|
elseif time_core_uom = year_string then
|
|
if frequency_type = 1 /* y times per year */
|
|
then conversion_factor_ave:= time_from_value/365;
|
|
else conversion_factor_ave:= 1/(365 * time_from_value);
|
|
endif;
|
|
endif; /* if time_core_uom */
|
|
|
|
|
|
|
|
Conclude true;
|
|
;;
|
|
action:
|
|
return conversion_factor_ave;
|
|
;;
|
|
end:
|