maintenance: title: FORM_Post_Uterine_OS;; mlmname: FORM_Post_Uterine_OS;; arden: version 2.5;; version: 6.10;; institution: St. Clair Hospital ;; author: Shivprasad Jadhav;; specialist: Shivprasad Jadhav, Allscripts;; date: 2015-03-30;; validation: testing;; library: purpose: Change History ============================================ 30-03-2015 CSR-32728 : Created ;; explanation: Change Date Format of Stop After ;; keywords: ;; citations: ;; knowledge: type: data-driven;; data: ( this_communication, // Communication object this_form, // Form object client_info_obj //Arden ClientInfo object ) := argument; field_list:= this_form.Fields; /* freqOccNum := sort Data freqOccNum; RequestedDateOccNum := sort data RequestedDateOccNum; RequestedTimeOccNum := sort data RequestedTimeOccNum; FrequencyCode_Toradol := first of (field_list where field_list.DataItemName = "FrequencyCode" and field_List.Control_MultiFieldOccNum = freqOccNum[1]); StartDate_Toradol := first of (field_list where field_list.DataItemName = "RequestedDate" and field_List.Control_MultiFieldOccNum = RequestedDateOccNum[1]); StartTime_Toradol := first of (field_list where field_list.DataItemName = "RequestedTime" and field_List.Control_MultiFieldOccNum = RequestedTimeOccNum[1]); StartDate_IBU := first of (field_list where field_list.DataItemName = "RequestedDate" and field_List.Control_MultiFieldOccNum = RequestedDateOccNum[2]); StartTime_IBU := first of (field_list where field_list.DataItemName = "RequestedTime" and field_List.Control_MultiFieldOccNum = RequestedTimeOccNum[2]); FreqCodeValue_Toradol := FrequencyCode_Toradol.value.FrequencySummary; StDateValue_Toradol := StartDate_Toradol.value; StTimeValue_Tordol := StartTime_Toradol.value; StTimeValue_IBU := StartTime_IBU.value; */ //Retrieve relevant form fields //Prm_StopAfter := last of (field_list where field_list.DataItemName = "StopAfter"); GD_Serum_Creatinine := last of ( field_list WHERE field_list.DataItemName = "MultiOrderGrid" and field_list.Control_MultiFieldOccNum = 74 ); GD_Serum_Creatinine_Val := GD_Serum_Creatinine.Value ; Ketorolac_Inj := GD_Serum_Creatinine_Val[1] ; Ketorolac_Tab := GD_Serum_Creatinine_Val[2] ; Prm_RequestedDate := first of (field_list where field_list.DataItemName = "RequestedDate" And field_list.Control_MultiFieldOccNum =1); Prm_RequestedTime := first of (field_list where field_list.DataItemName = "RequestedTime" And field_list.Control_MultiFieldOccNum =1); Prm_StopAfter := first of (field_list where field_list.DataItemName = "StopAfter" And field_list.Control_MultiFieldOccNum = 1); Prm_FrequencyCode := first of (field_list where field_list.DataItemName = "FrequencyCode" And field_list.Control_MultiFieldOccNum = 1); StartDate_IBU := first of (field_list where field_list.DataItemName = "RequestedDate" and field_List.Control_MultiFieldOccNum = 2); StartTime_IBU := first of (field_list where field_list.DataItemName = "RequestedTime" and field_List.Control_MultiFieldOccNum = 2); RequeStedDate_Val := Prm_RequestedDate.Value ; RequestedTime_Val := Prm_RequestedTime.Value.ReqTimeValue ; RequestedTime_Code := Prm_RequestedTime.Value.ReqTimeCode ; StopAfter_Number := Prm_StopAfter.Value.NUMBER ; StopAfter_Option := Prm_StopAfter.Value.Option ; Frequency_val := Prm_FrequencyCode.Value.FrequencySummary ; StTimeValue_IBU := StartTime_IBU.value; // If User Select Any keterolac row then This value are get Pre-populated If ( Prm_RequestedTime.Value.ReqTimeCode is null And Prm_StopAfter.Value.Option is null ) Then //and Prm_StopAfter.Value.Option = "" Then If Ketorolac_Inj.IsSelected = True //or Ketorolac_Tab.IsSelected =True Then Prm_RequestedTime.Value.ReqTimeCode := "Scheduled/Start Time" ; Prm_StopAfter.Value.Option := "Hours" ; EndIf; Endif; If ( Ketorolac_Inj.IsSelected = False And Ketorolac_Tab.IsSelected = False ) Then Prm_RequestedTime.Value.ReqTimeCode := "" ; Prm_StopAfter.Value.Option := "" ; Endif; If Ketorolac_Inj.IsSelected = True And Ketorolac_Tab.IsSelected =True Then THR := Extract Hour NOW; TMN := Extract Minute NOW; if THR < 10 then THR := "0" || THR; endif; if TMN < 10 then TMN := "0" || TMN; endif; PlusLocation := FIND "+" IN STRING RequeStedDate_Val ; TLocation := FIND "T" IN STRING RequeStedDate_Val ; If TLocation = 1 and PlusLocation = 0 then RequeStedDate_Val := (now as time); RequeStedDate_Val.ReqTimeCode := "Scheduled/Start Time"; RequeStedDate_Val.ReqTimeValue := THR || ":" || TMN; endif; If PlusLocation > 0 then PlusDays := SUBSTRING 1 CHARACTERS STARTING AT LENGTH OF RequeStedDate_Val FROM RequeStedDate_Val ; RequeStedDate_Val := (now as time) + (PlusDays as number) day; Prm_RequestedTime.ReqTimeCode := "Scheduled/Start Time"; Prm_RequestedTime.ReqTimeValue := THR || ":" || TMN; endif; //RequestedTime_Code := RequestedTime_Val.ReqTimeCode; SchHour_Val := substring 2 characters from RequestedTime_Val as number; SchMin_Val := substring 2 characters starting at 4 from RequestedTime_Val; if (RequestedTime_Code = "Scheduled/Start Time") then HR := SchHour_Val; MN := SchMin_Val; else HR := Extract Hour NOW; MN := Extract Minute Now; endif; if HR < 10 then HR := "0" || HR; endif; if MN < 10 then MN := "0" || MN; endif; HR_seconds := (60 * (HR as number)) * 60; MN_Seconds := (MN as number) * 60; Calc_starttime := ((RequeStedDate_Val + (HR_seconds seconds)) + (MN_Seconds seconds)); Freq_length := length of Frequency_val as number; freq_endposition := freq_length; begin_freq := substring 1 characters from Frequency_val as string; end_freq := substring 1 characters starting at freq_endposition from Frequency_val as string; if begin_freq = "Q" then Freqnum := Freq_length - 2; Schnum := substring Freqnum characters starting at 2 from Frequency_val; endif; schnum := schnum as number; If StopAfter_Option In ("Times","Doses","Units") Then StopAfter_Option:= "Times"; Endif; If StopAfter_Option ="Times" Then if (end_freq = "M") then //calc_schnum_seconds := (((86400 / (60 * schnum)) - 1) * (60 * schnum)); //take the minutes times 60 to get the seconds, divide that calc_schnum_seconds := schnum * 60 ; elseif (end_freq = "H") then //calc_schnum_seconds := ((((24 / schnum)-1) * schnum) * 60) * 60; calc_schnum_seconds := schnum * 60 * 60 ; endif; sched_time := read { "select ScheduledTime from CV3FixedScheduleDefinition fs " || " inner join CV3CodedFreqTranslation ft on fs.ParentGUID = ft.GUID " || " where ft.FrequencyCode = " || sql(Frequency_val) || " and ft.FrequencyClass = {{{SINGLE-QUOTE}}}{{{SINGLE-QUOTE}}} "}; sched_time := sort data sched_time; sched_starttime := ""; sched_endtime := ""; if (count(sched_time) = 0) or (RequestedTime_Code = "Scheduled/Start Time") then calc_startDTTM_IBU := (Calc_starttime + (calc_schnum_seconds * StopAfter_Number ) seconds ) + 21600 seconds; else tmp_starthhmn := HR || MN; for s in (1 seqto count(sched_time)) do if ((sched_time[s] as number) > (tmp_starthhmn as number)) and sched_starttime = "" then sched_starttime := sched_time[s]; endif; if ((sched_time[s] as number) < (tmp_starthhmn as number)) then sched_endtime := sched_time[s]; endif; enddo; If (count(sched_time) = 1) And sched_endtime = "" Then sched_endtime := sched_time[1] ; Endif; If sched_endtime =0 Then sched_endtime:="0000" ; Endif; length_sched_endtime := length (sched_endtime as string); // Problem In This Statement when user select Q24H, Q48H Frequency sched_minPOS := ((length_sched_endtime as number) - 2) as number; calc_schMIN := (substring 2 characters starting at (sched_minPOS + 1) from (sched_endtime as string)) as number; calc_schHR := (substring (sched_minPOS as number) characters from (sched_endtime as string)) as number; calc_schMIN_Seconds := calc_schMIN * 60; calc_schHR_Seconds := (calc_schHR * 60) * 60; //calc_startDTTM_IBU := (((RequeStedDate_Val + 86400 seconds) + calc_schMIN_Seconds seconds) + calc_schHR_seconds seconds) + 21600 seconds; calc_startDTTM_IBU := (Calc_starttime + ( calc_schnum_seconds * StopAfter_Number ) seconds ) + 21600 seconds + calc_schMIN_Seconds seconds + calc_schHR_seconds seconds ; endif; Else If StopAfter_Number Is Not Null And StopAfter_Option is Not Null Then If StopAfter_Option In ("Times","Doses","Units") Then StopAfter_Option:= "Times"; Endif; If StopAfter_Option ="Days" Then MultiPly := 86400 ;// seconds ; Elseif StopAfter_Option ="Hours" Then MultiPly := 3600 ;// seconds; ElseIf StopAfter_Option ="Minutes" Then MultiPly := 60 ;//seconds; //ElseIf StopAfter_Option ="Times" Then MultiPly := calc_schnum_seconds ;// seconds; Endif; Endif; Total_Additional_Sec := (StopAfter_Number as Number ) * (MultiPly as Number) ; calc_startDTTM_IBU := Calc_starttime + Total_Additional_Sec Seconds + 6 Hours ; EndIf; // for Adding Stop After Time to existing Time /* If StopAfter_Number Is Not Null And StopAfter_Option is Not Null Then If StopAfter_Option In ("Times","Doses","Units") Then StopAfter_Option:= "Times"; Endif; If StopAfter_Option ="Days" Then MultiPly := 86400 ;// seconds ; Elseif StopAfter_Option ="Hours" Then MultiPly := 3600 ;// seconds; ElseIf StopAfter_Option ="Minutes" Then MultiPly := 60 ;//seconds; ElseIf StopAfter_Option ="Times" Then MultiPly := calc_schnum_seconds ;// seconds; Endif; Endif; Total_Additional_Sec := (StopAfter_Number as Number ) * (MultiPly as Number) ; calc_startDTTM_IBU := calc_startDTTM_IBU + Total_Additional_Sec Seconds + 6 Hours ; // Adding 6 Hr for Next order of Ketorolac abc := calc_startDTTM_IBU ; calc_startDTTM_IBU := calc_startDTTM_IBU + 6 Hours ; */ format_hr := extract hour calc_startDTTM_IBU; if format_hr < 10 then format_hr := "0" || format_hr; endif; format_min := extract minute calc_startDTTM_IBU; if format_min < 10 then format_min := "0" || format_min; endif; IBU_date_extract := (extract month calc_startDTTM_IBU) || "-" || (extract day calc_startDTTM_IBU) || "-" || (extract year calc_startDTTM_IBU); IBU_time_extract := format_hr || ":" || format_min; If Ketorolac_Inj.IsSelected = True And Ketorolac_Tab.IsSelected =True Then StTimeValue_IBU.ReqTimeCode := "Scheduled/Start Time"; StTimeValue_IBU.ReqTimeValue := IBU_time_extract; StartDate_IBU.Value := calc_startDTTM_IBU; Endif ; Endif; ;; priority: 50 ;; evoke: ;; logic: conclude true; ;; action: return this_communication, this_form; ;; Urgency: 50;; end: