Initial Checking with all 820 MLMs
This commit is contained in:
394
MLMStripper/bin/Debug/STD/STD_FUNC_DOSAGE_XML_PARAMS.mlm
Normal file
394
MLMStripper/bin/Debug/STD/STD_FUNC_DOSAGE_XML_PARAMS.mlm
Normal file
@@ -0,0 +1,394 @@
|
||||
maintenance:
|
||||
|
||||
title: Generate XML parameters to get dose range data;;
|
||||
mlmname: STD_Func_Dosage_XML_Params;;
|
||||
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: Generate XML input parameters for getting dose range data from
|
||||
item-catalog or multum.
|
||||
;;
|
||||
explanation: This MLM assists the STD_Dosage MLM with dose-range checking.
|
||||
It formats the input XML for the SCMGetItemCatDosageRangePr and
|
||||
SCMMultumGrouperDosageRangePR.
|
||||
;;
|
||||
keywords: dosage range, multum, item catalog, order, prescription
|
||||
;;
|
||||
knowledge:
|
||||
type: data-driven;;
|
||||
data:
|
||||
// Set to true if logging is needed.
|
||||
log_execution_info := false;
|
||||
|
||||
(
|
||||
// Common medication data
|
||||
drc_grouper_id,
|
||||
multum_dnum,
|
||||
multum_mmdc,
|
||||
order_med_route,
|
||||
order_med_route_id,
|
||||
is_generic_route,
|
||||
order_med_significant_date,
|
||||
order_med_units,
|
||||
order_med_uom_id,
|
||||
multum_freq_id,
|
||||
med_order_type,
|
||||
is_order,
|
||||
// Patient data
|
||||
patient_birthday_info_on_order,
|
||||
has_valid_birthdate,
|
||||
wt_kg,
|
||||
BSA_number_rounded,
|
||||
intl_patient_gender,
|
||||
// Item Catalog only
|
||||
for_item_catalog,
|
||||
catalog_item_obj,
|
||||
// Multum only
|
||||
has_liver_disease_bit,
|
||||
dialysis_type_str,
|
||||
serum_creatinine,
|
||||
// Flags and constants
|
||||
alert_if_missing_flags,
|
||||
patient_info,
|
||||
core_uom_const
|
||||
):= ARGUMENT;
|
||||
|
||||
Name_Value_Object := OBJECT [name, val];
|
||||
|
||||
// XML parameter
|
||||
indent := " ";
|
||||
indent1 := indent;
|
||||
indent2 := indent || indent;
|
||||
newline := "\n";
|
||||
|
||||
// Set the medication parameters
|
||||
med_info_list := (
|
||||
(new Name_Value_Object with "GrouperID", drc_grouper_id),
|
||||
(new Name_Value_Object with "DNum", multum_dnum),
|
||||
(new Name_Value_Object with "MMDC", multum_mmdc),
|
||||
(new Name_Value_Object with "UOMID", order_med_uom_id),
|
||||
(new Name_Value_Object with "RouteID", order_med_route_id),
|
||||
(new Name_Value_Object with "FrequencyID", multum_freq_id)
|
||||
);
|
||||
|
||||
if for_item_catalog and exists catalog_item_obj then
|
||||
|
||||
catalog_med_info_list := (
|
||||
(new Name_Value_Object with "CatalogMasterItemGUID", catalog_item_obj.GUID),
|
||||
(new Name_Value_Object with "UOM", order_med_units),
|
||||
(new Name_Value_Object with "Route", order_med_route)
|
||||
);
|
||||
med_info_list := med_info_list, catalog_med_info_list;
|
||||
endif;
|
||||
|
||||
med_params_xml :=
|
||||
indent1 ||"<Medication " || newline;
|
||||
for med_item in med_info_list
|
||||
do
|
||||
if exists med_item.val
|
||||
then
|
||||
med_params_xml := med_params_xml ||
|
||||
indent2 || med_item.name || "={{{SINGLE-QUOTE}}}" || XMLEX(med_item.val) || "{{{SINGLE-QUOTE}}}" || newline;
|
||||
endif;
|
||||
enddo;
|
||||
med_params_xml := med_params_xml ||
|
||||
indent1 ||"/>" || newline;
|
||||
|
||||
// Patient Info
|
||||
age_params_xml := "";
|
||||
if has_valid_birthdate
|
||||
then
|
||||
age_unit_list := (
|
||||
(new Name_Value_Object with core_uom_const.day_string, patient_birthday_info_on_order.age_day_value),
|
||||
(new Name_Value_Object with core_uom_const.week_string, patient_birthday_info_on_order.age_week_value),
|
||||
(new Name_Value_Object with core_uom_const.month_string, patient_birthday_info_on_order.age_month_value),
|
||||
(new Name_Value_Object with core_uom_const.year_string, patient_birthday_info_on_order.age_year_value),
|
||||
(new Name_Value_Object with core_uom_const.hour_string, patient_birthday_info_on_order.age_hour_value)
|
||||
);
|
||||
|
||||
//[New born birth-time missing]: when new born < 4 days is missing birth time and >= 1 day, add AgeMin value to it
|
||||
age_unit_min_list := ();
|
||||
if patient_birthday_info_on_order.is_estimated_birthday = true and patient_birthday_info_on_order.age_day_value >= 1.0
|
||||
then
|
||||
age_unit_min_list := (
|
||||
(new Name_Value_Object with core_uom_const.day_string, patient_birthday_info_on_order.age_day_min_value),
|
||||
(new Name_Value_Object with core_uom_const.week_string, patient_birthday_info_on_order.age_week_min_value),
|
||||
(new Name_Value_Object with core_uom_const.month_string, patient_birthday_info_on_order.age_month_min_value),
|
||||
(new Name_Value_Object with core_uom_const.year_string, patient_birthday_info_on_order.age_year_min_value),
|
||||
(new Name_Value_Object with core_uom_const.hour_string, patient_birthday_info_on_order.age_hour_min_value)
|
||||
);
|
||||
endif;
|
||||
|
||||
for unit_item_index in (1 seqto count age_unit_list)
|
||||
do
|
||||
// age_unit_list and the age_unit_min_list are in the same unit sequence
|
||||
// day, week, month, year, hour
|
||||
unit_item := age_unit_list[unit_item_index];
|
||||
unit_min_item := age_unit_min_list[unit_item_index];
|
||||
|
||||
age_params_xml := age_params_xml ||
|
||||
indent2 || "<Item type={{{SINGLE-QUOTE}}}Age{{{SINGLE-QUOTE}}} "
|
||||
|| "unit={{{SINGLE-QUOTE}}}" || XMLEX(unit_item.name) || "{{{SINGLE-QUOTE}}} "
|
||||
|| "val={{{SINGLE-QUOTE}}}" || XMLEX(unit_item.val formatted with "%.16f") || "{{{SINGLE-QUOTE}}} ";
|
||||
|
||||
if exists unit_min_item
|
||||
then
|
||||
//[New born birth-time missing]: item will be lik:
|
||||
// <Item type={{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}Age{{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}} unit={{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}day{{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}} val={{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}2.4270833333333335{{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}} min_val={{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}}1.4277777777777778{{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}} />
|
||||
age_params_xml := age_params_xml || "min_val={{{SINGLE-QUOTE}}}" || XMLEX(unit_min_item.val formatted with "%.16f") || "{{{SINGLE-QUOTE}}} ";
|
||||
endif;
|
||||
age_params_xml := age_params_xml || "/>" || newline;
|
||||
|
||||
enddo;
|
||||
|
||||
endif;
|
||||
|
||||
bsa_params_xml := "";
|
||||
if BSA_number_rounded is number and BSA_number_rounded > 0
|
||||
then
|
||||
bsa_params_xml :=
|
||||
indent2 || "<Item type={{{SINGLE-QUOTE}}}BSA{{{SINGLE-QUOTE}}} unit={{{SINGLE-QUOTE}}}M2{{{SINGLE-QUOTE}}} val={{{SINGLE-QUOTE}}}" || XMLEX(BSA_number_rounded) || "{{{SINGLE-QUOTE}}} />" || newline;
|
||||
endif;
|
||||
|
||||
weight_params_xml := "";
|
||||
if wt_kg is number and wt_kg > 0
|
||||
then
|
||||
// Convert patient weight to grams
|
||||
wt_gm:= wt_kg * 1000;
|
||||
|
||||
weight_lb_value := wt_gm/453.6; // pound
|
||||
weight_ounce_value := wt_gm/28.35; // ounce
|
||||
|
||||
wt_unit_list:= (
|
||||
(new Name_Value_Object with core_uom_const.gm_string, wt_gm),
|
||||
(new Name_Value_Object with core_uom_const.ounce_string, weight_ounce_value),
|
||||
(new Name_Value_Object with core_uom_const.lb_string, weight_lb_value),
|
||||
(new Name_Value_Object with core_uom_const.kg_string, wt_kg)
|
||||
);
|
||||
|
||||
for unit_item in wt_unit_list
|
||||
do
|
||||
weight_params_xml := weight_params_xml ||
|
||||
indent2 || "<Item type={{{SINGLE-QUOTE}}}Weight{{{SINGLE-QUOTE}}} "
|
||||
|| "unit={{{SINGLE-QUOTE}}}" || XMLEX(unit_item.name) || "{{{SINGLE-QUOTE}}} "
|
||||
|| "val={{{SINGLE-QUOTE}}}" || XMLEX(unit_item.val) || "{{{SINGLE-QUOTE}}} "
|
||||
|| "/>" || newline;
|
||||
enddo;
|
||||
endif;
|
||||
|
||||
gender_params_xml := "";
|
||||
if exists intl_patient_gender
|
||||
then
|
||||
gender_params_xml :=
|
||||
indent1 || "<Gender val={{{SINGLE-QUOTE}}}" || XMLEX(intl_patient_gender) || "{{{SINGLE-QUOTE}}}/>" || newline;
|
||||
endif;
|
||||
|
||||
//[New born birth-time missing]: add MissingBabyBirthTime
|
||||
birth_time_missing_xml := "";
|
||||
if patient_birthday_info_on_order.is_estimated_birthday = true
|
||||
then
|
||||
if patient_birthday_info_on_order.age_day_value >= 1.0
|
||||
then
|
||||
missing_baby_birthTime_value := 1;
|
||||
else
|
||||
missing_baby_birthTime_value := 2;
|
||||
endif;
|
||||
|
||||
birth_time_missing_xml :=
|
||||
indent1 || "<MissingBabyBirthTime val={{{SINGLE-QUOTE}}}" || XMLEX(missing_baby_birthTime_value) || "{{{SINGLE-QUOTE}}}/>" || newline;
|
||||
endif;
|
||||
|
||||
liver_params_xml := "";
|
||||
dialysis_params_xml := "";
|
||||
creatinine_params_xml := "";
|
||||
|
||||
if not for_item_catalog
|
||||
then
|
||||
if exists has_liver_disease_bit
|
||||
then
|
||||
liver_params_xml :=
|
||||
indent2 || "<LiverDisease val={{{SINGLE-QUOTE}}}" || XMLEX(has_liver_disease_bit) || "{{{SINGLE-QUOTE}}}/>" || newline;
|
||||
endif;
|
||||
|
||||
if exists dialysis_type_str
|
||||
then
|
||||
dialysis_params_xml :=
|
||||
indent2 || "<DialysisType val={{{SINGLE-QUOTE}}}" || XMLEX(dialysis_type_str) || "{{{SINGLE-QUOTE}}}/>" || newline;
|
||||
endif;
|
||||
|
||||
if exists serum_creatinine
|
||||
then
|
||||
creatinine_params_xml :=
|
||||
indent2 || "<SerumCreatinine val={{{SINGLE-QUOTE}}}" || XMLEX(serum_creatinine) || "{{{SINGLE-QUOTE}}}/>" || newline;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
patient_params_xml :=
|
||||
indent1 ||"<Patient>" || newline ||
|
||||
age_params_xml ||
|
||||
bsa_params_xml ||
|
||||
weight_params_xml ||
|
||||
gender_params_xml ||
|
||||
birth_time_missing_xml ||
|
||||
liver_params_xml ||
|
||||
dialysis_params_xml ||
|
||||
creatinine_params_xml ||
|
||||
indent1 ||"</Patient>" || newline;
|
||||
|
||||
get_dosage_for_missing_weight :=
|
||||
( alert_if_missing_flags.patient_weight
|
||||
and ( patient_info.Weight.is_missing or patient_info.Weight.not_current )
|
||||
);
|
||||
|
||||
get_dosage_for_missing_BSA := get_dosage_for_missing_weight
|
||||
or
|
||||
( alert_if_missing_flags.patient_height
|
||||
and ( patient_info.Height.is_missing or patient_info.Height.not_current )
|
||||
);
|
||||
|
||||
is_gender_missing := Patient_info.Gender.is_missing or intl_patient_gender in ("U", "O");
|
||||
|
||||
get_dosage_for_missing_gender :=
|
||||
( ( alert_if_missing_flags.patient_gender and is_gender_missing )
|
||||
or ( alert_if_missing_flags.unmapped_gender and Patient_info.Gender.is_unmapped )
|
||||
);
|
||||
|
||||
if (is_order)
|
||||
then
|
||||
missing_route := order_med_route is null;
|
||||
missing_uom := order_med_units is null;
|
||||
else
|
||||
missing_route := order_med_route is null AND order_med_route_id is null;
|
||||
missing_uom := order_med_units is null AND order_med_uom_id is null;
|
||||
endif;
|
||||
|
||||
|
||||
if (for_item_catalog)
|
||||
then
|
||||
// For item catalog, there is no "unmapped" concept
|
||||
unmapped_route := false;
|
||||
unmapped_uom := false;
|
||||
else
|
||||
unmapped_route := (not missing_route) and order_med_route_id is null;
|
||||
unmapped_uom := (not missing_uom) and order_med_uom_id is null;
|
||||
endif;
|
||||
|
||||
get_dosage_for_missing_route :=
|
||||
( ( alert_if_missing_flags.route and missing_route )
|
||||
or ( alert_if_missing_flags.unmapped_route and unmapped_route)
|
||||
);
|
||||
|
||||
get_dosage_for_missing_uom :=
|
||||
( ( alert_if_missing_flags.uom and missing_uom)
|
||||
or ( alert_if_missing_flags.unmapped_uom and unmapped_uom )
|
||||
);
|
||||
|
||||
get_dosage_for_missing_grouper :=
|
||||
( alert_if_missing_flags.cannot_check_DNUM_Rx_to_Multum
|
||||
and drc_grouper_id is null
|
||||
and not is_order
|
||||
and not for_item_catalog
|
||||
);
|
||||
|
||||
// - Return other routes if the current route is unrecognized route
|
||||
// and the cannot check unrecognized route flag is on
|
||||
// - Return other routes if the current route is not an unrecognized route
|
||||
// and the inapplicable route flag is on
|
||||
get_dosage_for_route_match_not_found :=
|
||||
( alert_if_missing_flags.cannot_check_generic_route
|
||||
and is_generic_route
|
||||
)
|
||||
OR
|
||||
( alert_if_missing_flags.inapplicable_route
|
||||
and not is_generic_route
|
||||
and not for_item_catalog
|
||||
);
|
||||
|
||||
|
||||
get_dosage_for_uom_conversion := alert_if_missing_flags.uom_conversion;
|
||||
|
||||
if for_item_catalog and not is_order
|
||||
then
|
||||
get_dosage_for_ic_dnum := alert_if_missing_flags.cannot_check_Rx_to_IC;
|
||||
endif;
|
||||
|
||||
if not for_item_catalog and is_order
|
||||
then
|
||||
get_dosage_for_any_freq := (med_order_type = "Complex Order");
|
||||
endif;
|
||||
|
||||
if for_item_catalog
|
||||
then
|
||||
get_dosage_for_missing_age := alert_if_missing_flags.patient_age and (not has_valid_birthdate);
|
||||
endif;
|
||||
|
||||
missing_data_flags_list := (
|
||||
(new Name_Value_Object with "ReturnDataForMissingWeight", get_dosage_for_missing_weight),
|
||||
(new Name_Value_Object with "ReturnDataForMissingBSA", get_dosage_for_missing_BSA),
|
||||
(new Name_Value_Object with "ReturnDataForMissingGender", get_dosage_for_missing_gender),
|
||||
(new Name_Value_Object with "ReturnDataForMissingGrouperBasedOnDnum", get_dosage_for_missing_grouper),
|
||||
(new Name_Value_Object with "ReturnDataForMissingRoute", get_dosage_for_missing_route),
|
||||
(new Name_Value_Object with "ReturnDataForRouteMatchNotFound", get_dosage_for_route_match_not_found),
|
||||
(new Name_Value_Object with "ReturnDataForMissingUOM", get_dosage_for_missing_uom),
|
||||
(new Name_Value_Object with "ReturnDataForUomConversionIssue", get_dosage_for_uom_conversion),
|
||||
(new Name_Value_Object with "ReturnDataByDnumWhenNoMatchFound", get_dosage_for_ic_dnum),
|
||||
(new Name_Value_Object with "ReturnDailyDoseForAnyFreq", get_dosage_for_any_freq),
|
||||
(new Name_Value_Object with "ReturnDataForMissingAge", get_dosage_for_missing_age)
|
||||
);
|
||||
|
||||
missing_data_flag_name_val_xml := "";
|
||||
for unit_item in missing_data_flags_list
|
||||
do
|
||||
if unit_item.val then bit_val := 1; else bit_val := 0; endif;
|
||||
missing_data_flag_name_val_xml := missing_data_flag_name_val_xml ||
|
||||
indent2 || unit_item.name || "={{{SINGLE-QUOTE}}}" || XMLEX(bit_val) || "{{{SINGLE-QUOTE}}}" || newline;
|
||||
enddo;
|
||||
|
||||
missing_data_flags_xml :=
|
||||
indent1 || "<MissingData " || newline ||
|
||||
missing_data_flag_name_val_xml || newline ||
|
||||
indent1 || "/>" || newline;
|
||||
|
||||
input_param_xml := "\n<ROOT>\n" ||
|
||||
med_params_xml ||
|
||||
patient_params_xml ||
|
||||
missing_data_flags_xml ||
|
||||
"</ROOT>" || newline;
|
||||
|
||||
debug_str_input_param_xml := SQL(input_param_xml);
|
||||
;;
|
||||
priority: 50
|
||||
;;
|
||||
evoke:
|
||||
;;
|
||||
logic:
|
||||
|
||||
/* Always conclude true to return variables to calling MLM */
|
||||
CONCLUDE TRUE;
|
||||
;;
|
||||
action:
|
||||
return (input_param_xml, missing_route, unmapped_route, missing_uom, unmapped_uom, uom_conversion_issue);
|
||||
;;
|
||||
Urgency: 50;;
|
||||
end:
|
||||
Reference in New Issue
Block a user