313 lines
14 KiB
Plaintext
313 lines
14 KiB
Plaintext
maintenance:
|
|
|
|
title: Vital Signs - Highs and Lows;;
|
|
mlmname: DOC_FUNC_Last_24hrs_Urine;;
|
|
arden: version 4.5;;
|
|
version: 2.00;;
|
|
institution: St.Clair Hospital;;
|
|
author: Shivprasad Jadhav;;
|
|
specialist: Shivprasad Jadhav ;;
|
|
date: 2015-01-21;;
|
|
validation: testing;;
|
|
|
|
library:
|
|
purpose:
|
|
;;
|
|
explanation:
|
|
Change history
|
|
|
|
20.12.2014 DW CSR# 32476 Created to show last 24 hours Urine observations from Physician Progress Note.
|
|
;;
|
|
keywords:
|
|
;;
|
|
knowledge:
|
|
type: data-driven;;
|
|
data:
|
|
// Recieve arguments from the structured note
|
|
(thisDocumentCommunication) := argument;
|
|
|
|
|
|
// Extract interesting parts of the object model
|
|
(thisStructuredNoteDoc) := thisDocumentCommunication.DocumentConfigurationObj;
|
|
(thisParameters) := thisStructuredNoteDoc.ParametersList;
|
|
(thisObservations) := thisStructuredNoteDoc.ChartedObservationsList;
|
|
|
|
|
|
// 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";
|
|
|
|
|
|
|
|
|
|
// OBSERVATION CHANGE
|
|
|
|
|
|
|
|
|
|
if thisDocumentCommunication.EventType = "ChartObservation"
|
|
then
|
|
|
|
( lastValuesList, highValuesList ) := read
|
|
{
|
|
" CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), value varchar(500), timstmp datetime ) "
|
|
|| " INSERT INTO #tmp_aaa (value,timstmp) "
|
|
|| " select Sum(Convert(Integer, obsx.OutValue)) as Value , od.RecordedDtm "
|
|
|| " "
|
|
|| " 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 "
|
|
|| " Inner Join CV3ObservationXInfo AS obsx "
|
|
|| " ON (obsx.ObservationXInfoGUID = o.GUID AND obsx.ArcType = o.ArcType And obsx.BagVolumeUnit is Not Null ) "
|
|
|| " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID "
|
|
|| " AND ocmi.Name in ({{{SINGLE-QUOTE}}}SCH_io_Foley Catheter{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}io_output_condom_catheter{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCH_io_Straight Catheter{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}io_output_voided{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}io_output_nephrostomy{{{SINGLE-QUOTE}}} ,{{{SINGLE-QUOTE}}}SCH_io_Suprapubic Catheter{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCH_io_Urostomy{{{SINGLE-QUOTE}}} ) "
|
|
|| " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " "
|
|
|| " and cd.iscanceled = 0 "
|
|
|| " and cd.DocumentName IN ({{{SINGLE-QUOTE}}}2. Intake and Output{{{SINGLE-QUOTE}}}) "
|
|
|| " Group By od.RecordedDtm "
|
|
|| " Order By od.RecordedDtm Desc "
|
|
|| " "
|
|
// || " 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 timstmp2 is not null "
|
|
|| " "
|
|
|| " select value, timstmp from #tmp_aaa "
|
|
|| " drop table #tmp_aaa "
|
|
};
|
|
|
|
|
|
// update #tmp_aaa Set #tmp_aaa.timstmp = Dateadd(hour, -4, Getdate())
|
|
header1 :="\n\n\b Urine Output - Observations in Past 24 Hours -All Charted \b0\n\n";
|
|
formattedText1 := " ";
|
|
thisdatefield := " ";
|
|
yesterday := now-24 hours;
|
|
|
|
|
|
indexList := 1 seqto count (highValuesList);
|
|
|
|
for i in indexList do
|
|
|
|
|
|
|
|
// 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 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 = "SCH_io_Straight Catheter" then formattedText1 := formattedText1 || "\b Straight Cath:\b0 ";
|
|
elseif obsName = "SCH_io_Foley Catheter" then formattedText1 := formattedText1 || "\b Foley Cath:\b0 ";
|
|
elseif obsName = "io_output_condom_catheter" then formattedText1 := formattedText1 || "\b Condom Cath:\b0 ";
|
|
elseif obsName = "io_output_voided" then formattedText1 := formattedText1 || "\b Voided:\b0 ";
|
|
elseif obsName = "io_output_nephrostomy" then formattedText1 := formattedText1 || "\b Nephro:\b0 ";
|
|
/*elseif obsName = "Noninvasive Mean BP" then formattedText1 := formattedText1 || "\b Mean BP:\b0 ";
|
|
elseif obsName = "Noninvasive BP Source 1" then formattedText1 := formattedText1 || "/";
|
|
elseif obsName = "SCH_vs_pulse ox saturation" then formattedText1 := formattedText1 || "\b Pulse Ox:\b0 ";
|
|
elseif obsName = "SCH_vs_pulse ox source" then formattedText1 := formattedText1 || "/" ; //b O2 L/min:\b0 ";
|
|
endif; */
|
|
|
|
|
|
formattedText1 := formattedText1 || " ";
|
|
formattedText1 := formattedText1 || (lastValuesList[i]) || " ml";
|
|
|
|
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;
|
|
|
|
|
|
/* if thisDocumentCommunication.EventType = "ChartObservation"
|
|
then
|
|
|
|
(obsNamesList, lastValuesList, highValuesList, lowValuesList) := read
|
|
{
|
|
" CREATE TABLE #tmp_aaa ( ID int IDENTITY(1, 1), name varchar(200), value varchar(500), timstmp datetime, sortseq int, timstmp2 varchar(30) ) "
|
|
|| " INSERT INTO #tmp_aaa (name,value,timstmp, sortseq) "
|
|
|| " select ocmi.Name, Convert(Integer, obsx.OutValue) as Value, od.RecordedDtm, "
|
|
|| " CASE WHEN Name = {{{SINGLE-QUOTE}}}SCH_io_Straight Catheter{{{SINGLE-QUOTE}}} THEN 01 "
|
|
|| " WHEN Name = {{{SINGLE-QUOTE}}}SCH_io_Foley Catheter{{{SINGLE-QUOTE}}} THEN 02 "
|
|
|| " WHEN Name = {{{SINGLE-QUOTE}}}io_output_condom_catheter{{{SINGLE-QUOTE}}} THEN 03 "
|
|
|| " WHEN Name = {{{SINGLE-QUOTE}}}io_output_voided{{{SINGLE-QUOTE}}} THEN 04 "
|
|
|| " WHEN Name = {{{SINGLE-QUOTE}}}io_output_nephrostomy{{{SINGLE-QUOTE}}} THEN 05 "
|
|
|| " 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 "
|
|
|| " Inner Join CV3ObservationXInfo AS obsx "
|
|
|| " ON (obsx.ObservationXInfoGUID = o.GUID AND obsx.ArcType = o.ArcType And obsx.BagVolumeUnit is Not Null ) "
|
|
|| " join CV3ObsCatalogMasterItem ocmi with (nolock) on od.ObsMasterItemGUID = ocmi.GUID "
|
|
|| " AND ocmi.Name in ({{{SINGLE-QUOTE}}}SCH_io_Foley Catheter{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}io_output_condom_catheter{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCH_io_Straight Catheter{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}io_output_voided{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}io_output_nephrostomy{{{SINGLE-QUOTE}}} ) "
|
|
|| " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " "
|
|
|| " and cd.iscanceled = 0 "
|
|
|| " and cd.DocumentName IN ({{{SINGLE-QUOTE}}}2. Intake and Output{{{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 timstmp2 is not null "
|
|
|| " "
|
|
|| " select name, value, timstmp, sortseq 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 Urine Output - Observations in Past 24 Hours -All Charted \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 ("SCH_io_Foley Catheter","io_output_condom_catheter", "SCH_io_Straight Catheter", "io_output_voided" , "io_output_nephrostomy")
|
|
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 = "SCH_io_Straight Catheter" then formattedText1 := formattedText1 || "\b Straight Cath:\b0 ";
|
|
elseif obsName = "SCH_io_Foley Catheter" then formattedText1 := formattedText1 || "\b Foley Cath:\b0 ";
|
|
elseif obsName = "io_output_condom_catheter" then formattedText1 := formattedText1 || "\b Condom Cath:\b0 ";
|
|
elseif obsName = "io_output_voided" then formattedText1 := formattedText1 || "\b Voided:\b0 ";
|
|
elseif obsName = "io_output_nephrostomy" then formattedText1 := formattedText1 || "\b Nephro:\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; */
|
|
|
|
// Write to the Structured Note Text Box
|
|
|
|
|
|
|
|
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);
|
|
|
|
endif;
|
|
|
|
|
|
|
|
;;
|
|
evoke:
|
|
;;
|
|
logic: conclude true;
|
|
;;
|
|
action: return thisDocumentCommunication;
|
|
;;
|
|
Urgency: 50;;
|
|
end:
|