144 lines
5.7 KiB
Plaintext
144 lines
5.7 KiB
Plaintext
maintenance:
|
|
|
|
title: SCH_Func_Create_Med_Order;;
|
|
mlmname: SCH_Func_Create_Med_Order;;
|
|
arden: version 2.5;;
|
|
version: 16.30;;
|
|
institution: ;;
|
|
author: Teresa Spicuzza;;
|
|
specialist: ;;
|
|
date: 2017-11-13;;
|
|
validation: testing;;
|
|
|
|
library:
|
|
purpose: Create an Order using the information passed from the calling MLM.
|
|
;;
|
|
explanation: Called MLM that builds orders for a patient.
|
|
|
|
Change history
|
|
|
|
11.10.2017 TMS CSR# 35723 Created
|
|
|
|
|
|
;;
|
|
keywords: Called MLM, Generic, Create Order
|
|
;;
|
|
knowledge:
|
|
type: data-driven;;
|
|
data:
|
|
|
|
standard_libs := MLM {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}};
|
|
include standard_libs;
|
|
error_occurred := false;
|
|
|
|
(visitGuid,UserGuid,ClientGUID,SessionType,OrderSource,ItemName,ItemModifier,OrderType,CareProviderGuid,OrderFrequency) := ARGUMENT;
|
|
|
|
send_alert := "DoNotSend";
|
|
alert_dest := destination { Alert: warning, "Order Create", high, chart, "Order Create", 15042, send_alert, "No Override Allowed" };
|
|
|
|
user_IDType := "Edstan Number (physician)";
|
|
RequestingSource := OrderSource;
|
|
order_Creation_Reason := "Protocol Order";
|
|
|
|
If SessionType = "Hold"
|
|
then SessionReason := "Hold Orders";
|
|
Else SessionReason := ""; // Session type is Standard
|
|
endif;
|
|
|
|
|
|
|
|
// Create Objects
|
|
|
|
try
|
|
|
|
client_visit_obj := call {{{SINGLE-QUOTE}}}ClientVisit{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((visitGuid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}}) ;
|
|
user_IDCode := read last {"SELECT IDCode FROM CV3CAREPROVIDERID " || " where ProviderGUID = " || CareProviderGuid
|
|
|| " and ProviderIDTypeCode = {{{SINGLE-QUOTE}}}Edstan Number (physician){{{SINGLE-QUOTE}}}"};
|
|
RequestingCareProvider_obj := call {{{SINGLE-QUOTE}}}CareProvider{{{SINGLE-QUOTE}}}.FindById with ( user_IDType, (user_IDCode as STRING) );
|
|
location_guid := read last {"SELECT CurrentLocationGUID FROM CV3ClientVisit where ClientGUID = " || ClientGUID};
|
|
location_obj := call {{{SINGLE-QUOTE}}}Location{{{SINGLE-QUOTE}}}.FindByPrimaryKey with ((location_guid as number) as {{{SINGLE-QUOTE}}}Int64{{{SINGLE-QUOTE}}});
|
|
|
|
|
|
endtry;
|
|
|
|
catch Exception ex
|
|
error_occurred := true;
|
|
error_message := "{{+R}}Retrieve client:{{-R}}\n" || ex.Message || "\n\n";
|
|
if ex.InnerException is not null net_object then error_message := error_message || "Inner Exception: " || ex.InnerException.Message || "\n\n"; endif;
|
|
if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif;
|
|
if ( RequestingCareProvider_obj is NOT NULL ) then void:= call RequestingCareProvider_obj.Dispose; RequestingCareProvider_obj:= null; endif;
|
|
if ( location_obj is NOT NULL ) then void:= call location_obj.Dispose; location_obj := null; endif;
|
|
endcatch;
|
|
|
|
try
|
|
|
|
Catalog_Item_Name := ItemName;
|
|
Catalog_Item_Modifier := ItemModifier;
|
|
Catalog_Item_Version := "";
|
|
Medication_catalog_item := call {{{SINGLE-QUOTE}}}OrderCatalogMasterItem{{{SINGLE-QUOTE}}}.FindByName with Catalog_Item_Name;
|
|
|
|
PreFilled_MedicationOrder_obj := call {{{SINGLE-QUOTE}}}MedicationOrder{{{SINGLE-QUOTE}}}.CreateMedicationOrder
|
|
with
|
|
client_visit_obj, // ClientVisit ObjectsPlus object
|
|
Medication_catalog_item, // OrderCatalogMasterItem ObjectsPlus object
|
|
Catalog_Item_Modifier, // string ItemNameModifier
|
|
Catalog_Item_Version, // string ItemNameModifierVersion
|
|
order_Creation_Reason, // string CreateReason
|
|
RequestingCareProvider_obj , // RequestedBy ObjectsPlus object
|
|
RequestingSource, // string RequestedBySource (must be in dictionary)
|
|
SessionType, // string SessionType
|
|
SessionReason, // string SessionReason
|
|
location_obj, // Location ReleaseLocGrpID
|
|
"Always" as {{{SINGLE-QUOTE}}}AvailabilityOverride{{{SINGLE-QUOTE}}}; // AvailabilityOverride eAvailabilityOverride
|
|
|
|
if (exists OrderFrequency) then
|
|
|
|
frequencyCode_obj := new net_object {{{SINGLE-QUOTE}}}Frequency{{{SINGLE-QUOTE}}};
|
|
frequencyCode_obj.code := OrderFrequency;
|
|
PreFilled_MedicationOrder_obj.frequency := frequencyCode_obj;
|
|
Endif;
|
|
|
|
if ( Medication_catalog_item is NOT NULL ) then
|
|
void := call PreFilled_MedicationOrder_obj.Save;
|
|
void := call PreFilled_MedicationOrder_obj.Dispose;
|
|
void:= call Medication_catalog_item.Dispose;
|
|
Medication_catalog_item:= null;
|
|
endif;
|
|
|
|
endtry;
|
|
|
|
catch Exception ex
|
|
|
|
error_occurred := true;
|
|
error_message := "{{+R}}New prefilled medication order:{{-R}}\n" || ex.Message || "\n\n";
|
|
|
|
if ( Medication_catalog_item is NOT NULL ) then void:= call Medication_catalog_item.Dispose; Medication_catalog_item:= null; endif;
|
|
if ( PreFilled_MedicationOrder_obj is NOT NULL ) then void:= call PreFilled_MedicationOrder_obj.Dispose; PreFilled_MedicationOrder_obj:= null; endif;
|
|
|
|
Prefilled_MedicationOrder_dest := null;
|
|
endcatch;
|
|
|
|
if ( client_visit_obj is NOT NULL ) then void:= call client_visit_obj.Dispose; client_visit_obj:= null; endif;
|
|
if ( RequestingCareProvider_obj is NOT NULL ) then void:= call RequestingCareProvider_obj.Dispose; RequestingCareProvider_obj:= null; endif;
|
|
if ( location_obj is NOT NULL ) then void:= call location_obj.Dispose; location_obj:= null; endif;
|
|
|
|
;;
|
|
evoke:
|
|
;;
|
|
logic:
|
|
Conclude true ;
|
|
;;
|
|
action:
|
|
|
|
if error_occurred then
|
|
write "An error has occured in the MLM {{+B}}SCH_Func_Create_Order{{-B}} " || "Please notify your System Administrators that an error message has occurred " ||
|
|
"message: \n" at alert_dest;
|
|
write messageText at alert_dest;
|
|
endif;
|
|
|
|
return error_occurred;
|
|
|
|
;;
|
|
Urgency: 50;;
|
|
end:
|