maintenance: title: DOC_FUNC_Max_Temperature ;; mlmname: DOC_FUNC_Max_Temperature ;; arden: version 4.5;; version: 2.00;; institution: St.Clair Hospital;; author: Shivprasad Jadhav;; specialist: ;; date: 2015-04-27;; validation: testing;; library: purpose: ;; explanation: Change history 27.04.2015 DW CSR:33155- Created to show last 24 hours Max Temperature observations from Physician Progress Note. 14.08.2015 GOS Added document name [{{{SINGLE-QUOTE}}}B1. Newborn Vital Signs{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}1. Vital Signs - Critical Care{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}1.Vital Signs - Critical Care{{{SINGLE-QUOTE}}} ] ;; keywords: ;; knowledge: type: data-driven;; data: // Recieve arguments from the structured note (thisDocumentCommunication) := argument; local_session := cds_session.local; // Extract interesting parts of the object model (thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj; (thisParameters) := thisStructuredNoteDoc.ParametersList; (thisObservations) := thisStructuredNoteDoc.ChartedObservationsList; (this_currentObj) := thisdocumentCommunication.CurrentObservationObj; comm_obj := thisDocumentCommunication.primaryobj; // Create prototypes for the object types we{{{SINGLE-QUOTE}}}ll need to instantiate ObservationType := OBJECT [ObservationGUID, ClientDocumentGUID, ParameterGUID, DataType, ValueObj]; FreeTextValueType := OBJECT [Value]; // Get the client and visit GUIDs clientGuid := thisDocumentCommunication.ClientGUID; visitGuid := thisDocumentCommunication.ClientVisitGUID; chartGuid := thisDocumentCommunication.ChartGUID; standard_libs := mlm {{{SINGLE-QUOTE}}}std_include_libs{{{SINGLE-QUOTE}}}; include standard_libs; using "ObjectsPlusXA.SCM.Forms"; using namespace "ObjectsPlusXA.SunriseClinicalManager.Forms"; Infectious_Dis := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Grouping Disease"); selectedItems := (this_currentObj.ValueObj.ListItemsList WHERE this_currentObj.ValueObj.ListItemsList.IsSelected = true); currentObj_selectedItems := selectedItems.value ; //,Infectious Disease // OBSERVATION CHANGE if thisDocumentCommunication.EventType = "ChartObservation" then (obsNamesList, lastValuesList, highValuesList, lowValuesList) := read { " CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), name varchar(200), value decimal(5,2), timstmp datetime, sortseq int, timstmp2 varchar(30) ) " || " INSERT INTO #tmp_aaa (name,value,timstmp, sortseq) " || " select ocmi.Name, o.ValueText, od.RecordedDtm, " || " CASE WHEN Name = {{{SINGLE-QUOTE}}}farenheit{{{SINGLE-QUOTE}}} THEN 01 " || " ELSE 99 " || " END AS SortSeq " || " " || " from CV3ClientDocument cd with (nolock) " || " join CV3ClientDocDetail cdd with (nolock) ON (cdd.ClientDocumentGUID = cd.GUID AND cdd.ClientGUID = cd.clientguid and cdd.active = 1) " || " join CV3ObservationDocument od with (nolock)ON cdd.CLientDocumentGUID = od.OwnerGUID and od.active = 1 " || " join CV3Observation o with (nolock) ON o.GUID = od.ObservationGUID " || " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID " || " AND ocmi.Name in ({{{SINGLE-QUOTE}}}farenheit{{{SINGLE-QUOTE}}}) " || " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " " || " and cd.iscanceled = 0 " || " and cd.DocumentName IN ({{{SINGLE-QUOTE}}}1.Vital Signs - Basic{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}B1. Newborn Vital Signs{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}1. Vital Signs - Critical Care{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}1.Vital Signs - Critical Care{{{SINGLE-QUOTE}}}) " || " order by sortseq , cd.touchedwhen " || " " // || " update t1 set timstmp2 = t2.timstmp from #tmp_aaa t1 " // || " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq = t2.sortseq " || " delete from #tmp_aaa where Value is null Delete from #tmp_aaa Where Convert(datetime,timstmp) < dateadd(hour, -24,getdate()) " || " " || " select Top 1 name, value, timstmp, sortseq from #tmp_aaa Where Value= (Select Max(Value ) From #tmp_aaa ) order by timstmp desc, sortseq " || " drop table #tmp_aaa " }; // update #tmp_aaa Set #tmp_aaa.timstmp = Dateadd(hour, -4, Getdate()) header1 :="\n\n\b Vital Signs - Max Temperature in Past 24 Hours\b0\n\n"; formattedText1 := " "; thisdatefield := " "; yesterday := now-24 hours; indexList := 1 seqto count (obsNamesList); for i in indexList do obsName := (obsNamesList[i]); // Reformat the Time Stamp thisdatefield_unformatted := (highValuesList[i]); yy:= extract year thisdatefield_unformatted; mm := extract month thisdatefield_unformatted ; if mm < 10 then mm:= 0 || mm; endif; dd := extract day thisdatefield_unformatted ; if dd < 10 then dd:= 0 || dd; endif; hh := extract hour thisdatefield_unformatted ; if hh < 10 then hh:= 0 || hh; endif; mn := extract minute thisdatefield_unformatted ; if mn < 10 then mn:= 0 || mn; endif; thisdatefield_formatted := mm || "/" || dd || "/" || yy || " " || hh || ":" || mn; // Proceed if the data part of the first group and charted in the past 24 hours if obsName in ("farenheit" ) and thisdatefield_unformatted > yesterday then if thisdatefield = " " // first timestamp then thisdatefield := (highValuesList[i]); formattedText1 := thisdatefield_formatted; endif; if thisdatefield <> (highValuesList[i]) // new timestamp then formattedText1 := formattedText1 || "\n" || thisdatefield_formatted; thisdatefield := (highValuesList[i]); else formattedText1 := formattedText1 || " " ; endif; if obsName = "Farenheit" then formattedText1 := formattedText1 || "\b T:\b0 "; //elseif obsName = "SCH_vs_pulse ox source" then formattedText1 := formattedText1 || "/" ; //b O2 L/min:\b0 "; endif; formattedText1 := formattedText1 || " "; formattedText1 := formattedText1 || (lastValuesList[i]); endif; // Obsname amongst the Vital Signs observations enddo; // Gather the existing contents of the textbox theParameter := first of (thisparameters where thisparameters.Name = "SCH_MDPN_FT VS, I & O"); obs := FIRST OF (thisObservations WHERE thisObservations.parameterGUID = theParameter.parameterGUID); priorcontents := obs.ValueObj.Value; formattedTextAll:= priorcontents || header1 || formattedText1; endif; // for Passing the Value in Base MLm via Session Variable ===== If formattedText1 is Not Null Then abc:= Call (formattedText1 as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}).Replace with "T:" as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}, "" as {{{SINGLE-QUOTE}}}String{{{SINGLE-QUOTE}}}; Else abc:= formattedText1 ; Endif; local_session.ACS_FormatedText := Null ; local_session.ACS_FormatedText := " " || abc ; //End ========================================================= If formattedTextAll is not null then vitalSignsHL := first of (thisParameters where thisParameters.Name = "SCH_MDPN_FT VS, I & O"); newObservation := NEW ObservationType; newObservation.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; newObservation.ParameterGUID := vitalSignsHL.ParameterGUID; newObservation.DataType := "FreeTextValue"; newObservation.ValueObj := NEW FreeTextValueType; newObservation.ValueObj.Value := formattedTextAll; thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation); /*for current_item in currentObj_selectedItems do If current_item ="Infectious Disease" Then vitalSignsHL1 := first of (thisParameters where thisParameters.Name = "SCH_MDPN_Groupings"); newObservation1 := NEW ObservationType; newObservation1.ClientDocumentGUID:= thisStructuredNoteDoc.ClientDocumentGUID; newObservation1.ParameterGUID := vitalSignsHL1.ParameterGUID; newObservation1.DataType := "FreeTextValue"; newObservation1.ValueObj := NEW FreeTextValueType; newObservation1.ValueObj.Value := formattedTextAll; thisStructuredNoteDoc.ChartedObservationsList := (thisStructuredNoteDoc.ChartedObservationsList, newObservation1); Endif; enddo;*/ endif; ;; evoke: ;; logic: conclude true; ;; action: return thisDocumentCommunication; ;; Urgency: 50;; end: