Files
St.Clair/MLMStripper/bin/Debug/DOC/DOC_FUNC_NEWBORN_VS_24HRS.mlm

524 lines
30 KiB
Plaintext

maintenance:
title: Vital Signs - Highs and Lows;;
mlmname: DOC_FUNC_NewBorn_VS_24hrs;;
arden: version 4.5;;
version: 2.00;;
institution: St.Clair Hospital;;
author: Vikaskumar Yadav;;
specialist: ;;
date: 2015-06-16;;
validation: testing;;
library:
purpose:
;;
explanation:
Change history
06-16-2015 - VY Created MLM to pull the data of all the vital signs charted on the patient in last 24 hours from the "B1. Newborn Vital Signs " flowsheet.
10.26.2015 SJ
01.03.2017 DW HD# 2469756 - Upgrade SCM to version 16.3 uncovered an issue with missing ounces
;;
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
(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, o.ValueText, od.RecordedDtm, "
|| " CASE WHEN Name = {{{SINGLE-QUOTE}}}Supine Systolic BP{{{SINGLE-QUOTE}}} THEN 01 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}Supine Diastolic BP{{{SINGLE-QUOTE}}} THEN 02 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}Sitting Systolic BP{{{SINGLE-QUOTE}}} THEN 03 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}Sitting Diastolic BP{{{SINGLE-QUOTE}}} THEN 04 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}Standing Systolic BP{{{SINGLE-QUOTE}}} THEN 05 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}Standing Diastolic BP{{{SINGLE-QUOTE}}} THEN 06 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}sch_orthostatic heart rate - supine{{{SINGLE-QUOTE}}} THEN 07 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}sch_orthostatic heart rate - sitting{{{SINGLE-QUOTE}}} THEN 08 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}sch_orthostatic heart rate - standing{{{SINGLE-QUOTE}}} THEN 09 "
|| " 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}}}Supine Systolic BP{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Supine Diastolic BP{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Sitting Systolic BP{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Sitting Diastolic BP{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Standing Systolic BP{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Standing Diastolic BP{{{SINGLE-QUOTE}}}, "
|| " {{{SINGLE-QUOTE}}}sch_orthostatic heart rate - supine{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}sch_orthostatic heart rate - sitting{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}sch_orthostatic heart rate - standing{{{SINGLE-QUOTE}}} ) "
|| " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " "
|| " and cd.iscanceled = 0 "
|| " and cd.DocumentName IN ({{{SINGLE-QUOTE}}}B1. Newborn Vital Signs{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Newborn Patient Profile{{{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 "
};
header1 :="\n\n\b Orthostatic Vital Signs in Past 24 Hours - Last Charted \b0\n\n";
formattedText1 := " ";
thisdatefield := " ";
yesterday := now-24 hours;
indexList := 1 seqto count (obsNamesList);
for i in indexList do
obsName := last (first i from obsNamesList);
// Reformat the Time Stamp
thisdatefield_unformatted := last (first i from highValuesList);
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 ("Supine Systolic BP" , "Supine Diastolic BP" , "Sitting Systolic BP" , "Sitting Diastolic BP" , "Standing Systolic BP" , "Standing Diastolic BP","sch_orthostatic heart rate - supine",
"sch_orthostatic heart rate - sitting","sch_orthostatic heart rate - standing" )
and
thisdatefield_unformatted > yesterday
then
if thisdatefield = " " // first timestamp
then
thisdatefield := last (first i from highValuesList);
formattedText1 := thisdatefield_formatted;
endif;
if thisdatefield <> last (first i from highValuesList) // new timestamp
then
formattedText1 := formattedText1 || "\n" || thisdatefield_formatted;
thisdatefield := last (first i from highValuesList);
else
formattedText1 := formattedText1 || " " ;
endif;
if obsName = "Supine Systolic BP" then formattedText1 := formattedText1 || "\b Supine BP:\b0 ";
elseif obsName = "Supine Diastolic BP" then formattedText1 := formattedText1 || "/";
elseif obsName = "Sitting Systolic BP" then formattedText1 := formattedText1 || "\b Sitting BP:\b0 ";
elseif obsName = "Sitting Diastolic BP" then formattedText1 := formattedText1 || "/";
elseif obsName = "Standing Systolic BP" then formattedText1 := formattedText1 || "\b Standing BP:\b0 ";
elseif obsName = "Standing Diastolic BP" then formattedText1 := formattedText1 || "/";
elseif obsName = "sch_orthostatic heart rate - supine" then formattedText1 := formattedText1 || "\b Ortho HR Supine:\b0 ";
elseif obsName = "sch_orthostatic heart rate - sitting" then formattedText1 := formattedText1 || "\b Ortho HR Sitting:\b0 ";
elseif obsName = "sch_orthostatic heart rate - standing" then formattedText1 := formattedText1 || "\b Ortho HR Standing:\b0 ";
endif;
formattedText1 := formattedText1 || " ";
formattedText1 := formattedText1 || last (first i from lastValuesList);
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;
// DOCUMENT OPEN
if thisdocumentCommunication.EventType = "DocumentOpening"
then
// Query the database for the vitals info
(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, o.ValueText, od.RecordedDtm, "
|| " CASE WHEN Name = {{{SINGLE-QUOTE}}}Farenheit{{{SINGLE-QUOTE}}} THEN 01 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}Heart Rate{{{SINGLE-QUOTE}}} THEN 02 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}Resp Rate{{{SINGLE-QUOTE}}} THEN 03 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}Noninvasive Systolic BP{{{SINGLE-QUOTE}}} THEN 04 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}Noninvasive Diastolic BP{{{SINGLE-QUOTE}}} THEN 05 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}Arterial Systolic BP - Radial{{{SINGLE-QUOTE}}} THEN 06 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}Arterial Diastolic BP - Radial{{{SINGLE-QUOTE}}} THEN 07 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}Arterial Systolic BP - Second Line{{{SINGLE-QUOTE}}} THEN 08 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}Arterial Diastolic - Second Line{{{SINGLE-QUOTE}}} THEN 09 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}SCH_vs_pulse ox saturation{{{SINGLE-QUOTE}}} THEN 10 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}L/min{{{SINGLE-QUOTE}}} THEN 11 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}Height in cm{{{SINGLE-QUOTE}}} THEN 20 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}Height in ft{{{SINGLE-QUOTE}}} THEN 21 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}Height remainder in inches{{{SINGLE-QUOTE}}} THEN 22 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby a wt gm ob NU{{{SINGLE-QUOTE}}} THEN 23 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby b wt gm ob NU{{{SINGLE-QUOTE}}} THEN 24 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby a wt lb ob NU{{{SINGLE-QUOTE}}} THEN 25 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby a wt oz ob NU{{{SINGLE-QUOTE}}} THEN 26 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby b wt lb ob NU{{{SINGLE-QUOTE}}} THEN 27 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}AS deliv baby b wt oz ob NU{{{SINGLE-QUOTE}}} THEN 28 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}SCH_Newborn Weight - grams{{{SINGLE-QUOTE}}} THEN 29 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}SCH_Newborn Weight - lbs{{{SINGLE-QUOTE}}} THEN 40 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}SCH_Newborn Weight - oz{{{SINGLE-QUOTE}}} THEN 41 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}Weight - lbs{{{SINGLE-QUOTE}}} THEN 42 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}Weight - kg{{{SINGLE-QUOTE}}} THEN 43 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}SCH_vs_Occipital-Frontal Head{{{SINGLE-QUOTE}}} THEN 44 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}SCH_io_newborn_diaper count - Stool{{{SINGLE-QUOTE}}}THEN 45 "
|| " WHEN Name = {{{SINGLE-QUOTE}}}SCH_io_newborn_diaper count - Urine{{{SINGLE-QUOTE}}}THEN 46 "
|| " 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}}},{{{SINGLE-QUOTE}}}Heart Rate{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Resp Rate{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_vs_pulse ox saturation{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}L/min{{{SINGLE-QUOTE}}}, "
|| " {{{SINGLE-QUOTE}}}Noninvasive Diastolic BP{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Noninvasive Systolic BP{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Arterial Systolic BP - Radial{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Arterial Diastolic BP - Radial{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Arterial Systolic BP - Second Line{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}Arterial Diastolic - Second Line{{{SINGLE-QUOTE}}}, "
|| " {{{SINGLE-QUOTE}}}AS deliv baby a wt gm ob NU{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}AS deliv baby b wt gm ob NU{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}AS deliv baby a wt lb ob NU{{{SINGLE-QUOTE}}} , "
|| " {{{SINGLE-QUOTE}}}AS deliv baby b wt lb ob NU{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}AS deliv baby a wt oz ob NU{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}AS deliv baby b wt oz ob NU{{{SINGLE-QUOTE}}} , "
|| " {{{SINGLE-QUOTE}}}SCH_Newborn Weight - grams{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_Newborn Weight - lbs{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_Newborn Weight - oz{{{SINGLE-QUOTE}}}, "
|| " {{{SINGLE-QUOTE}}}Weight - lbs{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Weight - kg{{{SINGLE-QUOTE}}}, "
|| " {{{SINGLE-QUOTE}}}Height in ft{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Height remainder in inches{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}Height in cm{{{SINGLE-QUOTE}}}, {{{SINGLE-QUOTE}}}SCH_vs_Occipital-Frontal Head{{{SINGLE-QUOTE}}}, "
|| " {{{SINGLE-QUOTE}}}Current Weight{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}SCH_io_newborn_diaper count - Stool{{{SINGLE-QUOTE}}} , {{{SINGLE-QUOTE}}}SCH_io_newborn_diaper count - Urine{{{SINGLE-QUOTE}}} "
|| " ) "
|| " where cd.chartguid = " || ChartGuid || " and cd.clientguid = " || ClientGuid || " and cd.clientvisitguid = " || VisitGuid || " "
|| " and cd.iscanceled = 0 "
|| " and cd.DocumentName IN ({{{SINGLE-QUOTE}}}B1. Newborn Vital Signs{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}Newborn Patient Profile{{{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 "
|| " update t2 set timstmp2 = {{{SINGLE-QUOTE}}}first weight{{{SINGLE-QUOTE}}}, name = {{{SINGLE-QUOTE}}}First Adult Weight - kg{{{SINGLE-QUOTE}}} from #tmp_aaa t1 "
|| " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq <> t2.sortseq and t2.name = {{{SINGLE-QUOTE}}}SCH_Newborn Weight - grams{{{SINGLE-QUOTE}}} " //{{{SINGLE-QUOTE}}}Weight - kg{{{SINGLE-QUOTE}}}
|| " update t2 set timstmp2 = {{{SINGLE-QUOTE}}}first weight lbs{{{SINGLE-QUOTE}}}, name = {{{SINGLE-QUOTE}}}First Adult Weight - lbs{{{SINGLE-QUOTE}}} from #tmp_aaa t1 "
|| " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq <> t2.sortseq and t2.name = {{{SINGLE-QUOTE}}}SCH_Newborn Weight - lbs{{{SINGLE-QUOTE}}} " //{{{SINGLE-QUOTE}}}Weight - lbs{{{SINGLE-QUOTE}}}
|| " update t2 set timstmp2 = {{{SINGLE-QUOTE}}}first weight oz{{{SINGLE-QUOTE}}}, name = {{{SINGLE-QUOTE}}}First Adult Weight - oz{{{SINGLE-QUOTE}}} from #tmp_aaa t1 "
|| " inner join #tmp_aaa t2 on t2.id = t1.id +1 and t1.sortseq <> t2.sortseq and t2.name = {{{SINGLE-QUOTE}}}SCH_Newborn Weight - oz{{{SINGLE-QUOTE}}} " //{{{SINGLE-QUOTE}}}Weight - oz{{{SINGLE-QUOTE}}}
|| " delete from #tmp_aaa where timstmp2 is not null and timstmp2 not in ({{{SINGLE-QUOTE}}}first weight{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}first weight lbs{{{SINGLE-QUOTE}}},{{{SINGLE-QUOTE}}}first weight oz{{{SINGLE-QUOTE}}}) "
|| " "
|| " select name, value, timstmp, sortseq from #tmp_aaa order by timstmp desc, sortseq "
|| " drop table #tmp_aaa "
};
//break;
// Process the First Group Data Elements (past 24 hours)
header1 :="\b Vital Signs in Past 24 Hours - Last Charted \b0\n\n";
formattedText1:= " ";
thisdatefield := " ";
yesterday:= now-24 hours;
indexList := 1 seqto count (obsNamesList);
for i in indexList do
obsName := last (first i from obsNamesList);
// Reformat the Time Stamp
thisdatefield_unformatted := last (first i from highValuesList);
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
//break;
if obsName in ("farenheit","Heart Rate","Resp Rate","SCH_vs_pulse ox saturation","L/min",
"Noninvasive Diastolic BP","Noninvasive Systolic BP","Arterial Systolic BP - Radial","Arterial Diastolic BP - Radial",
"Arterial Systolic BP - Second Line","Arterial Diastolic - Second Line" )
and
thisdatefield_unformatted > yesterday
then
if thisdatefield = " " // first timestamp
then
thisdatefield := last (first i from highValuesList);
formattedText1 := thisdatefield_formatted;
endif;
if thisdatefield <> last (first i from highValuesList) // new timestamp
then
formattedText1 := formattedText1 || "\n" || thisdatefield_formatted;
thisdatefield := last (first i from highValuesList);
else
formattedText1 := formattedText1 || " " ;
endif;
if obsName = "Heart Rate" then formattedText1 := formattedText1 || "\b HR:\b0 ";
elseif obsName = "Farenheit" then formattedText1 := formattedText1 || "\b T:\b0 ";
elseif obsName = "Noninvasive Systolic BP" then formattedText1 := formattedText1 || "\b BP:\b0 ";
elseif obsName = "Noninvasive Diastolic BP" then formattedText1 := formattedText1 || "/";
elseif obsName = "Arterial Systolic BP - Radial" then formattedText1 := formattedText1 || "\b ART BP:\b0 ";
elseif obsName = "Arterial Diastolic BP - Radial" then formattedText1 := formattedText1 || "/";
elseif obsName = "Arterial Systolic BP - Second Line" then formattedText1 := formattedText1 || "\b ART BP Second:\b0 ";
elseif obsName = "Arterial Diastolic - Second Line" then formattedText1 := formattedText1 || "/";
elseif obsName = "Resp Rate" then formattedText1 := formattedText1 || "\b R:\b0 ";
elseif obsName = "SCH_vs_pulse ox saturation" then formattedText1 := formattedText1 || "\b Pulse Ox:\b0 ";
elseif obsName = "L/min" then formattedText1 := formattedText1 || "\b O2 L/min:\b0 ";
endif;
formattedText1 := formattedText1 || " ";
formattedText1 := formattedText1 || last (first i from lastValuesList);
endif; // Obsname amongst the Vital Signs observations
enddo;
formattedText1 := header1 || formattedText1;
// Process the Second Group Data Elements (Start of Chart)
header2 :="\n\n \b Additional Information - Last Charted \b0 \n\n";
formattedText2:= " ";
thisdatefield := " ";
//break;
indexList := 1 seqto count (obsNamesList);
for i in indexList do
obsName := last (first i from obsNamesList);
// Reformat the Time Stamp
thisdatefield_unformatted := last (first i from highValuesList);
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 second group
//break;
if obsName in (
"AS deliv baby a wt gm ob NU" , "AS deliv baby b wt gm ob NU" , "AS deliv baby a wt lb ob NU" , "AS deliv baby b wt lb ob NU" , "AS deliv baby a wt oz ob NU" , "AS deliv baby b wt oz ob NU" ,
"SCH_Newborn Weight - grams","SCH_Newborn Weight - lbs","SCH_Newborn Weight - oz", "Weight - lbs","Weight - kg","First Adult Weight - kg","Height in ft" , "Height remainder in inches" , "Height in cm",
"SCH_vs_Occipital-Frontal Head", "Current Weight","SCH_io_newborn_diaper count - Stool" , "SCH_io_newborn_diaper count - Urine","First Adult Weight - lbs","First Adult Weight - oz"
)
then
if thisdatefield = " " // first timestamp
then
thisdatefield := last (first i from highValuesList);
formattedText2 := thisdatefield_formatted;
endif;
if thisdatefield <> last (first i from highValuesList) // new timestamp
then
formattedText2 := formattedText2 || "\n" || thisdatefield_formatted;
thisdatefield := last (first i from highValuesList);
else
formattedText2 := formattedText2 || " " ;
endif;
if obsName = "SCH_io_newborn_diaper count - Stool" then formattedText2 := formattedText2 || "\b Stool Diaper:\b0 ";
elseif obsName = "SCH_io_newborn_diaper count - Urine" then formattedText2 := formattedText2 || "\b Urine Diaper:\b0 ";
elseif obsName = "SCH_vs_Occipital-Frontal Head" then formattedText2 := formattedText2 || "\b H.C./cm:\b0 ";
elseif obsName = "Height in cm" then formattedText2 := formattedText2 || "\b Ht/cm:\b0 ";
elseif obsName = "Height in ft" then formattedText2 := formattedText2 || "\b Ht/ft:\b0 ";
elseif obsName = "Height remainder in inches" then formattedText2 := formattedText2 || "-";
elseif obsName = "SCH_Newborn Weight - grams" then formattedText2 := formattedText2 || "\b Wt/gm:\b0 ";
curwt:= last (first i from lastValuesList);
lastwt := last (first i from lastValuesList);
//delwt:= last (last i from lastValuesList); //vikas
elseif obsName = "SCH_Newborn Weight - lbs" then formattedText2 := formattedText2 || "\b Wt/lb:\b0 ";
//curwt:= last (first i from lastValuesList);
//lastwt := last (first i from lastValuesList);
elseif obsName = "SCH_Newborn Weight - oz" then formattedText2 := formattedText2 || "-";
elseif obsName = "AS deliv baby a wt gm ob NU" then formattedText2 := formattedText2 || "\b Deliv Wt/gm:\b0 "; delwt:= last (first i from lastValuesList);
elseif obsName = "AS deliv baby b wt gm ob NU" then formattedText2 := formattedText2 || "\b Deliv Wt/gm:\b0 "; delwt:= last (first i from lastValuesList);
elseif obsName = "AS deliv baby a wt lb ob NU" then formattedText2 := formattedText2 || "\b Deliv Wt/lb:\b0 ";
elseif obsName = "AS deliv baby a wt oz ob NU" then formattedText2 := formattedText2 || "-";
elseif obsName = "AS deliv baby b wt lb ob NU" then formattedText2 := formattedText2 || "\b Deliv Wt/lb:\b0 ";
elseif obsName = "AS deliv baby b wt oz ob NU" then formattedText2 := formattedText2 || "-";
elseif obsName = "Weight - lbs" then formattedText2 := formattedText2 || "\b Wt/lb:\b0 ";
elseif obsName = "Weight - kg" then formattedText2 := formattedText2 || "\b Wt/kg:\b0 "; lastwt := last (first i from lastValuesList);
elseif obsName = "First Adult Weight - kg" then formattedText2 := formattedText2 || "\b First Wt/gm:\b0 "; firstwt:= last (first i from lastValuesList);
elseif obsName = "First Adult Weight - lbs" then formattedText2 := formattedText2 || "\b First Wt/lb:\b0 "; //firstwtlbs:= last (first i from lastValuesList);
elseif obsName = "First Adult Weight - oz" then formattedText2 := formattedText2 || "-";
//break;
endif;
formattedText2 := formattedText2 || " ";
formattedText2 := formattedText2 || last (first i from lastValuesList);
endif; // Obsname amongst the Additional Information observations
enddo;
// Calculate the weight change
//break;
If exist delwt // Baby since birth weight
then
/*wtlabel := "Wt change since birth: \b0 ";
wtscale := " gm ";
wtchange := ((curwt as number) - (delwt as number)) formatted with " %.2f %";
wtchangepcnt := (((curwt as number) - (delwt as number))/(delwt as number) * 100) formatted with " %.2f %%"; */
wtlabel := "Wt change since birth: \b0 ";
wtscale := " gm ";
wtscalelbs := " lbs ";
//wtchange := (((curwt as number) - (delwt as number))/1000) formatted with " %.2f %";
wtchange := ((curwt as number) - (delwt as number)) formatted with " %.2f %";
wtchangepcnt := (((curwt as number) - (delwt as number))/(delwt as number) * 100) formatted with " %.2f %%";
Calc := (wtchange as number) * ("0.00220462" As number); //("2.20462" as number) ;// * ("1000" as number ) ;
If Calc Is Not Null Then
WtChangeLbs := Read first{" Select Format( " || Calc || " , {{{SINGLE-QUOTE}}}00.00{{{SINGLE-QUOTE}}}) " } ; // Added By Shivprasad for CSR:33428 on 19 June 2015
Endif;
else // Adult since first weighing
Void:= Null;
/*wtlabel := "Wt change since first weighing: \b0 ";
wtscale := " kg ";
wtchange := ((lastwt as number) - (firstwt as number)) formatted with " %.2f %";
wtchangepcnt := (((lastwt as number) - (firstwt as number)) /(firstwt as number) * 100) formatted with " %.2f %%";*/
/* wtlabel := "Wt change since first weighing: \b0 ";
wtscale := " kg ";
wtscalelbs := " lbs "; // Added By Shivprasad for CSR:33428 on 19 June 2015
wtchange := (((lastwt as number) - (firstwt as number))/1000) formatted with " %.2f %";
wtchangepcnt := (((lastwt as number) - (firstwt as number)) /(firstwt as number)) formatted with " %.2f %%"; // /(firstwt as number) * 100) formatted with " %.2f %%";
WtChangeLbs := (wtchange as number) * ("2.20462" as number) ; */ //Hide By Shivprasad On 11 Sept 2015
//break;
endif;
// break;
If wtchange is not null
then
//wtchange := " \n\n\b " || wtlabel || wtchange || wtscale || wtchangepcnt ;
wtchange := " \n\n\b " || wtlabel || WtChangeLbs || wtscalelbs || wtchange || wtscale || wtchangepcnt ;
else
wtchange := " ";
endif;
formattedText2 := header2 || formattedText2 || wtchange;
formattedTextAll:= formattedText1 || formattedText2;
endif; // Document Open
// 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: