BTIUPG1 ; IHS/JM - PATIENT GOAL TIU OBJECT ROUTINE ;20-Mar-2013 15:09;DU
;;1.0;TEXT INTEGRATION UTILITIES;**1011**;NOV 04,2004;Build 13
GETGOALS(DFN,TARGET,STATUS,NOSTEPS,NONOTES,TYPES) ;
;
; Patient Goals TIU Object API
;
;Required Parameters:
;
; DFN Patient identifier
;
; TARGET Where the medication data will be stored
;
;Optional Parameters:
;
; STATUS String containing one or more flags of goal types to display.
; "A" - Show active goals
; "I" - Show inactive goals
; "D" - Show declined goals
; Defaults is to show all goals
;
; NOSTEPS 0 = Show Goal Steps (Default)
; 1 = Do Not Show Steps
;
; NONOTES 0 = Show Goal Notes (Default)
; 1 = Do Not Show Notes
;
; TYPES String for limiting output to specific patient goal types,
; as defined in File# 9001002.4 PATIENT GOAL TYPES. Multiple
; types must be delimited by a semicolon ";". Example input
; might be "PHYSICAL ACTIVITY;NUTRITION;DIABETES CURRICULUM",
; which would return all goals with any of these goal types.
; This parameter is case sensitive and must match the exact
; text found in File# 9001002.4 PATIENT GOAL TYPES.
; Default is to display all goal types.
;
N GOALS,LINEINDX,ACTIVE,INACTIVE,DECLINE,SHOWSTEP,SHOWNOTE,FILTER
N TEXT,MAXLEN,IDX,FLTRTXT,DASHES,GDATA,GFOUND,GSTATUS,GACTIVE
N GINACTIV,GDECLINE,PROCESS,GTYPES,GTYPECNT,FIDX,TEMP,TEXT2
N LISTIDX,ACTIVLST,INACTLST,DECLNLST,FIRST,SUBIDX,SUBDATA,SUBFIRST
N GIEN,STEPDATA,MULTILST,SHOWN,GSHOWN
K @TARGET
S LINEINDX=0,MAXLEN=73
D GETGOAL^BEHOPGAP(.GOALS,DFN)
I $D(@GOALS)=0 G NOGOALS
S $P(DASHES,"=",MAXLEN)="="
S SHOWSTEP='(+$G(NOSTEPS))
S SHOWNOTE='(+$G(NONOTES))
S STATUS=$G(STATUS)
S (ACTIVE,INACTIVE,DECLINE)=1
I $TR(STATUS,"AID","")'=STATUS D
. S ACTIVE=STATUS["A"
. S INACTIVE=STATUS["I"
. S DECLINE=STATUS["D"
;
; Display Report Criteria
;
S TEXT=""
I (ACTIVE&INACTIVE&DECLINE) S TEXT="All"
E D
. I ACTIVE S TEXT="Active"
. I INACTIVE D APPEND(.TEXT,"Inactive"," and")
. I DECLINE D APPEND(.TEXT,"Declined"," and")
D APPEND(.TEXT,"Patient Goals,")
I SHOWSTEP D APPEND(.TEXT,"including") I 1
E D APPEND(.TEXT,"excluding")
D APPEND(.TEXT,"steps")
I SHOWSTEP=SHOWNOTE D APPEND(.TEXT,"and") I 1
E D
. S TEXT=TEXT_","
. I SHOWNOTE D APPEND(.TEXT,"including") I 1
. E D APPEND(.TEXT,"excluding")
D APPEND(.TEXT,"notes.")
D ADD(TEXT)
;
; Display Filters
;
S FILTER=$G(TYPES)
I $L(FILTER)>0 D
. S TEXT=""
. F IDX=1:1 S FLTRTXT=$P(FILTER,";",IDX) Q:FLTRTXT="" D APPEND(.TEXT,FLTRTXT,",")
. S TEXT=": "_TEXT
. I FILTER[";" S TEXT="s"_TEXT
. S TEXT="Only showing goals of type"_TEXT_"."
. D ADD(TEXT)
;
; GETGOAL^BEHOPGAP and GETSTEP^BEHOPGAP return data in the same ^TMP global.
; To avoid overwriting data when processing steps, the original goal data
; is moved to a temporary "GOALS" node of the TARGET ^TMP global
;
I SHOWSTEP D
. M @TARGET@("GOALS")=@GOALS
. K @GOALS
. S GOALS=$NA(@TARGET@("GOALS"))
;
; Display Data
;
S MULTILST=((ACTIVE+INACTIVE+DECLINE)>1)
I 'MULTILST D ADD(DASHES)
S FILTER=";"_FILTER_";"
S ACTIVLST=1,INACTLST=2,DECLNLST=3
S (GFOUND,SHOWN)=0
;
; Call LSTGOALS up to 3 times in order to sort goals by status
;
F LISTIDX=1:1:3 D
. I (LISTIDX=ACTIVLST)&('ACTIVE) Q
. I (LISTIDX=INACTLST)&('INACTIVE) Q
. I (LISTIDX=DECLNLST)&('DECLINE) Q
. D LSTGOALS
G SUMMARY
;
LSTGOALS ;
I MULTILST D ; If more than one status, display a sub-header
. D ADD("")
. S TEXT=$S(LISTIDX=ACTIVLST:"Active",LISTIDX=INACTLST:"Inactive",LISTIDX=DECLNLST:"Declined",1:"")
. D APPEND(.TEXT,"Patient Goals")
. D ADD(TEXT) D ADD(DASHES)
;
; Loop through the goal data
;
S IDX=0,FIRST=1,GSHOWN=0
N CNT S CNT=0
F S IDX=$O(@GOALS@(IDX)) Q:IDX="" D
. S GDATA=$G(@GOALS@(IDX,0))
. ;
. ; Determine if goal should be displayed
. ;
. S GSTATUS=$P($P(GDATA,U,10),";")
. I GSTATUS="D" Q ; Ignore deleted goals
. S GFOUND=1
. S (GACTIVE,GINACTIV)=0
. S GDECLINE=($P(GDATA,U,2)'="GOAL SET")
. I 'GDECLINE D
.. S GACTIVE=(GSTATUS="A")!(GSTATUS="MA")
.. S GINACTIV=(GSTATUS="S")!(GSTATUS="ME")
. S PROCESS=0
. I (LISTIDX=ACTIVLST)&(ACTIVE&GACTIVE) S PROCESS=1
. I (LISTIDX=INACTLST)&(INACTIVE&GINACTIV) S PROCESS=1
. I (LISTIDX=DECLNLST)&(DECLINE&GDECLINE) S PROCESS=1
. I 'PROCESS Q
. S GTYPES=$G(@GOALS@(IDX,10))
. I FILTER'=";;" D
.. S PROCESS=0
.. F FIDX=1:1 S TEMP=$P(GTYPES,U,FIDX) Q:(PROCESS!(TEMP="")) D
... S TEMP=";"_TEMP_";"
... I FILTER[TEMP S PROCESS=1
. I 'PROCESS Q
. ;
. ; Display Goal - column format not used because text fields
. ; can be up to 120 characters long
. ;
. I FIRST S FIRST=0
. E D ADD("")
. S (SHOWN,GSHOWN)=1
. S CNT=CNT+1
. S TEXT="Goal "_CNT_") "_$G(@GOALS@(IDX,11))
. ;S TEXT="Goal "_$P(GDATA,U,11)_") "_$G(@GOALS@(IDX,11))
. D ADD(TEXT)
. ;
. ; Display Goal Types
. ;
. S TEXT2="",TEXT=" Goal Type",GTYPECNT=0
. F FIDX=1:1 S TEMP=$P(GTYPES,U,FIDX) Q:TEMP="" S TEXT2=TEXT2_TEMP_", ",GTYPECNT=GTYPECNT+1
. S TEXT2=$E(TEXT2,1,$L(TEXT2)-2) ; Strip last comma
. I GTYPECNT>1 S TEXT=TEXT_"s"
. S TEXT=TEXT_": "_TEXT2
. D ADD(TEXT)
. ;
. ; Display Goal start/followup dates, status and reason
. ;
. S TEXT=" Start: "_$$DATESTR($P(GDATA,U,8))
. I 'GDECLINE D APPEND(.TEXT," Follow Up: "_$$DATESTR($P(GDATA,U,9)))
. D APPEND(.TEXT," Status: "_$S(GDECLINE:"Declined",1:$$STSTEXT(GSTATUS)))
. D ADD(TEXT)
. D ADD(" Reason: "_$G(@GOALS@(IDX,12)))
. ;
. ; Show Notes
. ;
. I SHOWNOTE,($D(@GOALS@(IDX,13))>9) D
.. S SUBIDX=0,SUBFIRST=1
.. F S SUBIDX=$O(@GOALS@(IDX,13,SUBIDX)) Q:SUBIDX="" D
... I SUBFIRST S SUBFIRST=0 S TEXT=" Notes: "
... E S TEXT=" " ; Additional notes line up with start of first note
... S SUBDATA=$G(@GOALS@(IDX,13,SUBIDX))
... S TEXT=TEXT_$$DATESTR($P(SUBDATA,U,2))_" "_$P(SUBDATA,U,3)
... D ADD(TEXT)
. ;
. ; Show Steps, but only for active goals - same design as GUI Component
. ;
. N CNT
. I SHOWSTEP&(LISTIDX=ACTIVLST) D
.. S GIEN=$P(GDATA,U),SUBIDX=0,SUBFIRST=1
.. D GETSTEP^BEHOPGAP(.STEPDATA,GIEN)
.. S CNT=0
.. F S SUBIDX=$O(@STEPDATA@(SUBIDX)) Q:SUBIDX="" D
... S SUBDATA=$G(@STEPDATA@(SUBIDX,0))
... S CNT=CNT+1
... I SUBFIRST S SUBFIRST=0 S TEXT=" Step "
... E S TEXT=" "
... S TEXT=TEXT_CNT_") Start: "_$$DATESTR($P(SUBDATA,U,8))_" "
... ;S TEXT=TEXT_$P(SUBDATA,U,4)_") Start: "_$$DATESTR($P(SUBDATA,U,8))_" "
... D APPEND(.TEXT,"Follow Up: "_$$DATESTR($P(SUBDATA,U,9)))
... D APPEND(.TEXT," Status: "_$$STSTEXT($P($P(SUBDATA,U,12),";")))
... D ADD(TEXT)
... ; Line up step text with above line
... S TEXT=" "_$E(" ",1,$L($P(SUBDATA,U,4)))_$G(@STEPDATA@(SUBIDX,1))
... D ADD(TEXT)
I 'GSHOWN D ADD("None Found.")
Q
;
SUMMARY ;
;
; Display goal count
;
I 'GFOUND G NOGOALS ; Happens when only deleted goals are found
I 'SHOWN D ADD("No Patient Goals found that match the above criteria.")
G DONE
;
NOGOALS ;
K @TARGET
D ADD("No patient goal information found.")
G DONE
;
DONE ;
D ADD("")
K @TARGET@("GOALS")
Q "~@"_$NA(@TARGET)
;
APPEND(VALUE,TXT,MIDDLE) ;
I $L(VALUE)>0 D
. I $L($G(MIDDLE))>0 S VALUE=VALUE_MIDDLE
. S VALUE=VALUE_" "
S VALUE=VALUE_TXT
Q
;
ADD(TXT) ; Saves TXT in TARGET
N TXT2,SUBCOUNT,SUBLINE
I $L(TXT)>MAXLEN D I 1
. S TXT2=$$WRAP^TIULS(TXT,MAXLEN)
. F SUBCOUNT=1:1 S SUBLINE=$P(TXT2,"|",SUBCOUNT) Q:SUBLINE="" D ADD2(SUBLINE)
E D ADD2(TXT)
Q
;
ADD2(TXT) ;
S LINEINDX=LINEINDX+1
S @TARGET@(LINEINDX,0)=TXT
Q
;
DATESTR(DATE) ; returns Fileman date converted to MM/DD/YY format
Q $S(+DATE>0:$E(DATE,4,5)_"/"_$E(DATE,6,7)_"/"_($E(DATE,1,3)+1700),1:"")
;
STSTEXT(CODE) ;
Q $S(CODE="A":"Active",CODE="MA":"Maintained",CODE="S":"Stopped",CODE="ME":"Met",1:"")
BTIUPG1 ; IHS/JM - PATIENT GOAL TIU OBJECT ROUTINE ;20-Mar-2013 15:09;DU
+1 ;;1.0;TEXT INTEGRATION UTILITIES;**1011**;NOV 04,2004;Build 13
GETGOALS(DFN,TARGET,STATUS,NOSTEPS,NONOTES,TYPES) ;
+1 ;
+2 ; Patient Goals TIU Object API
+3 ;
+4 ;Required Parameters:
+5 ;
+6 ; DFN Patient identifier
+7 ;
+8 ; TARGET Where the medication data will be stored
+9 ;
+10 ;Optional Parameters:
+11 ;
+12 ; STATUS String containing one or more flags of goal types to display.
+13 ; "A" - Show active goals
+14 ; "I" - Show inactive goals
+15 ; "D" - Show declined goals
+16 ; Defaults is to show all goals
+17 ;
+18 ; NOSTEPS 0 = Show Goal Steps (Default)
+19 ; 1 = Do Not Show Steps
+20 ;
+21 ; NONOTES 0 = Show Goal Notes (Default)
+22 ; 1 = Do Not Show Notes
+23 ;
+24 ; TYPES String for limiting output to specific patient goal types,
+25 ; as defined in File# 9001002.4 PATIENT GOAL TYPES. Multiple
+26 ; types must be delimited by a semicolon ";". Example input
+27 ; might be "PHYSICAL ACTIVITY;NUTRITION;DIABETES CURRICULUM",
+28 ; which would return all goals with any of these goal types.
+29 ; This parameter is case sensitive and must match the exact
+30 ; text found in File# 9001002.4 PATIENT GOAL TYPES.
+31 ; Default is to display all goal types.
+32 ;
+33 NEW GOALS,LINEINDX,ACTIVE,INACTIVE,DECLINE,SHOWSTEP,SHOWNOTE,FILTER
+34 NEW TEXT,MAXLEN,IDX,FLTRTXT,DASHES,GDATA,GFOUND,GSTATUS,GACTIVE
+35 NEW GINACTIV,GDECLINE,PROCESS,GTYPES,GTYPECNT,FIDX,TEMP,TEXT2
+36 NEW LISTIDX,ACTIVLST,INACTLST,DECLNLST,FIRST,SUBIDX,SUBDATA,SUBFIRST
+37 NEW GIEN,STEPDATA,MULTILST,SHOWN,GSHOWN
+38 KILL @TARGET
+39 SET LINEINDX=0
SET MAXLEN=73
+40 DO GETGOAL^BEHOPGAP(.GOALS,DFN)
+41 IF $DATA(@GOALS)=0
GOTO NOGOALS
+42 SET $PIECE(DASHES,"=",MAXLEN)="="
+43 SET SHOWSTEP='(+$GET(NOSTEPS))
+44 SET SHOWNOTE='(+$GET(NONOTES))
+45 SET STATUS=$GET(STATUS)
+46 SET (ACTIVE,INACTIVE,DECLINE)=1
+47 IF $TRANSLATE(STATUS,"AID","")'=STATUS
Begin DoDot:1
+48 SET ACTIVE=STATUS["A"
+49 SET INACTIVE=STATUS["I"
+50 SET DECLINE=STATUS["D"
End DoDot:1
+51 ;
+52 ; Display Report Criteria
+53 ;
+54 SET TEXT=""
+55 IF (ACTIVE&INACTIVE&DECLINE)
SET TEXT="All"
+56 IF '$TEST
Begin DoDot:1
+57 IF ACTIVE
SET TEXT="Active"
+58 IF INACTIVE
DO APPEND(.TEXT,"Inactive"," and")
+59 IF DECLINE
DO APPEND(.TEXT,"Declined"," and")
End DoDot:1
+60 DO APPEND(.TEXT,"Patient Goals,")
+61 IF SHOWSTEP
DO APPEND(.TEXT,"including")
IF 1
+62 IF '$TEST
DO APPEND(.TEXT,"excluding")
+63 DO APPEND(.TEXT,"steps")
+64 IF SHOWSTEP=SHOWNOTE
DO APPEND(.TEXT,"and")
IF 1
+65 IF '$TEST
Begin DoDot:1
+66 SET TEXT=TEXT_","
+67 IF SHOWNOTE
DO APPEND(.TEXT,"including")
IF 1
+68 IF '$TEST
DO APPEND(.TEXT,"excluding")
End DoDot:1
+69 DO APPEND(.TEXT,"notes.")
+70 DO ADD(TEXT)
+71 ;
+72 ; Display Filters
+73 ;
+74 SET FILTER=$GET(TYPES)
+75 IF $LENGTH(FILTER)>0
Begin DoDot:1
+76 SET TEXT=""
+77 FOR IDX=1:1
SET FLTRTXT=$PIECE(FILTER,";",IDX)
IF FLTRTXT=""
QUIT
DO APPEND(.TEXT,FLTRTXT,",")
+78 SET TEXT=": "_TEXT
+79 IF FILTER[";"
SET TEXT="s"_TEXT
+80 SET TEXT="Only showing goals of type"_TEXT_"."
+81 DO ADD(TEXT)
End DoDot:1
+82 ;
+83 ; GETGOAL^BEHOPGAP and GETSTEP^BEHOPGAP return data in the same ^TMP global.
+84 ; To avoid overwriting data when processing steps, the original goal data
+85 ; is moved to a temporary "GOALS" node of the TARGET ^TMP global
+86 ;
+87 IF SHOWSTEP
Begin DoDot:1
+88 MERGE @TARGET@("GOALS")=@GOALS
+89 KILL @GOALS
+90 SET GOALS=$NAME(@TARGET@("GOALS"))
End DoDot:1
+91 ;
+92 ; Display Data
+93 ;
+94 SET MULTILST=((ACTIVE+INACTIVE+DECLINE)>1)
+95 IF 'MULTILST
DO ADD(DASHES)
+96 SET FILTER=";"_FILTER_";"
+97 SET ACTIVLST=1
SET INACTLST=2
SET DECLNLST=3
+98 SET (GFOUND,SHOWN)=0
+99 ;
+100 ; Call LSTGOALS up to 3 times in order to sort goals by status
+101 ;
+102 FOR LISTIDX=1:1:3
Begin DoDot:1
+103 IF (LISTIDX=ACTIVLST)&('ACTIVE)
QUIT
+104 IF (LISTIDX=INACTLST)&('INACTIVE)
QUIT
+105 IF (LISTIDX=DECLNLST)&('DECLINE)
QUIT
+106 DO LSTGOALS
End DoDot:1
+107 GOTO SUMMARY
+108 ;
LSTGOALS ;
+1 ; If more than one status, display a sub-header
IF MULTILST
Begin DoDot:1
+2 DO ADD("")
+3 SET TEXT=$SELECT(LISTIDX=ACTIVLST:"Active",LISTIDX=INACTLST:"Inactive",LISTIDX=DECLNLST:"Declined",1:"")
+4 DO APPEND(.TEXT,"Patient Goals")
+5 DO ADD(TEXT)
DO ADD(DASHES)
End DoDot:1
+6 ;
+7 ; Loop through the goal data
+8 ;
+9 SET IDX=0
SET FIRST=1
SET GSHOWN=0
+10 NEW CNT
SET CNT=0
+11 FOR
SET IDX=$ORDER(@GOALS@(IDX))
IF IDX=""
QUIT
Begin DoDot:1
+12 SET GDATA=$GET(@GOALS@(IDX,0))
+13 ;
+14 ; Determine if goal should be displayed
+15 ;
+16 SET GSTATUS=$PIECE($PIECE(GDATA,U,10),";")
+17 ; Ignore deleted goals
IF GSTATUS="D"
QUIT
+18 SET GFOUND=1
+19 SET (GACTIVE,GINACTIV)=0
+20 SET GDECLINE=($PIECE(GDATA,U,2)'="GOAL SET")
+21 IF 'GDECLINE
Begin DoDot:2
+22 SET GACTIVE=(GSTATUS="A")!(GSTATUS="MA")
+23 SET GINACTIV=(GSTATUS="S")!(GSTATUS="ME")
End DoDot:2
+24 SET PROCESS=0
+25 IF (LISTIDX=ACTIVLST)&(ACTIVE&GACTIVE)
SET PROCESS=1
+26 IF (LISTIDX=INACTLST)&(INACTIVE&GINACTIV)
SET PROCESS=1
+27 IF (LISTIDX=DECLNLST)&(DECLINE&GDECLINE)
SET PROCESS=1
+28 IF 'PROCESS
QUIT
+29 SET GTYPES=$GET(@GOALS@(IDX,10))
+30 IF FILTER'=";;"
Begin DoDot:2
+31 SET PROCESS=0
+32 FOR FIDX=1:1
SET TEMP=$PIECE(GTYPES,U,FIDX)
IF (PROCESS!(TEMP=""))
QUIT
Begin DoDot:3
+33 SET TEMP=";"_TEMP_";"
+34 IF FILTER[TEMP
SET PROCESS=1
End DoDot:3
End DoDot:2
+35 IF 'PROCESS
QUIT
+36 ;
+37 ; Display Goal - column format not used because text fields
+38 ; can be up to 120 characters long
+39 ;
+40 IF FIRST
SET FIRST=0
+41 IF '$TEST
DO ADD("")
+42 SET (SHOWN,GSHOWN)=1
+43 SET CNT=CNT+1
+44 SET TEXT="Goal "_CNT_") "_$GET(@GOALS@(IDX,11))
+45 ;S TEXT="Goal "_$P(GDATA,U,11)_") "_$G(@GOALS@(IDX,11))
+46 DO ADD(TEXT)
+47 ;
+48 ; Display Goal Types
+49 ;
+50 SET TEXT2=""
SET TEXT=" Goal Type"
SET GTYPECNT=0
+51 FOR FIDX=1:1
SET TEMP=$PIECE(GTYPES,U,FIDX)
IF TEMP=""
QUIT
SET TEXT2=TEXT2_TEMP_", "
SET GTYPECNT=GTYPECNT+1
+52 ; Strip last comma
SET TEXT2=$EXTRACT(TEXT2,1,$LENGTH(TEXT2)-2)
+53 IF GTYPECNT>1
SET TEXT=TEXT_"s"
+54 SET TEXT=TEXT_": "_TEXT2
+55 DO ADD(TEXT)
+56 ;
+57 ; Display Goal start/followup dates, status and reason
+58 ;
+59 SET TEXT=" Start: "_$$DATESTR($PIECE(GDATA,U,8))
+60 IF 'GDECLINE
DO APPEND(.TEXT," Follow Up: "_$$DATESTR($PIECE(GDATA,U,9)))
+61 DO APPEND(.TEXT," Status: "_$SELECT(GDECLINE:"Declined",1:$$STSTEXT(GSTATUS)))
+62 DO ADD(TEXT)
+63 DO ADD(" Reason: "_$GET(@GOALS@(IDX,12)))
+64 ;
+65 ; Show Notes
+66 ;
+67 IF SHOWNOTE
IF ($DATA(@GOALS@(IDX,13))>9)
Begin DoDot:2
+68 SET SUBIDX=0
SET SUBFIRST=1
+69 FOR
SET SUBIDX=$ORDER(@GOALS@(IDX,13,SUBIDX))
IF SUBIDX=""
QUIT
Begin DoDot:3
+70 IF SUBFIRST
SET SUBFIRST=0
SET TEXT=" Notes: "
+71 ; Additional notes line up with start of first note
IF '$TEST
SET TEXT=" "
+72 SET SUBDATA=$GET(@GOALS@(IDX,13,SUBIDX))
+73 SET TEXT=TEXT_$$DATESTR($PIECE(SUBDATA,U,2))_" "_$PIECE(SUBDATA,U,3)
+74 DO ADD(TEXT)
End DoDot:3
End DoDot:2
+75 ;
+76 ; Show Steps, but only for active goals - same design as GUI Component
+77 ;
+78 NEW CNT
+79 IF SHOWSTEP&(LISTIDX=ACTIVLST)
Begin DoDot:2
+80 SET GIEN=$PIECE(GDATA,U)
SET SUBIDX=0
SET SUBFIRST=1
+81 DO GETSTEP^BEHOPGAP(.STEPDATA,GIEN)
+82 SET CNT=0
+83 FOR
SET SUBIDX=$ORDER(@STEPDATA@(SUBIDX))
IF SUBIDX=""
QUIT
Begin DoDot:3
+84 SET SUBDATA=$GET(@STEPDATA@(SUBIDX,0))
+85 SET CNT=CNT+1
+86 IF SUBFIRST
SET SUBFIRST=0
SET TEXT=" Step "
+87 IF '$TEST
SET TEXT=" "
+88 SET TEXT=TEXT_CNT_") Start: "_$$DATESTR($PIECE(SUBDATA,U,8))_" "
+89 ;S TEXT=TEXT_$P(SUBDATA,U,4)_") Start: "_$$DATESTR($P(SUBDATA,U,8))_" "
+90 DO APPEND(.TEXT,"Follow Up: "_$$DATESTR($PIECE(SUBDATA,U,9)))
+91 DO APPEND(.TEXT," Status: "_$$STSTEXT($PIECE($PIECE(SUBDATA,U,12),";")))
+92 DO ADD(TEXT)
+93 ; Line up step text with above line
+94 SET TEXT=" "_$EXTRACT(" ",1,$LENGTH($PIECE(SUBDATA,U,4)))_$GET(@STEPDATA@(SUBIDX,1))
+95 DO ADD(TEXT)
End DoDot:3
End DoDot:2
End DoDot:1
+96 IF 'GSHOWN
DO ADD("None Found.")
+97 QUIT
+98 ;
SUMMARY ;
+1 ;
+2 ; Display goal count
+3 ;
+4 ; Happens when only deleted goals are found
IF 'GFOUND
GOTO NOGOALS
+5 IF 'SHOWN
DO ADD("No Patient Goals found that match the above criteria.")
+6 GOTO DONE
+7 ;
NOGOALS ;
+1 KILL @TARGET
+2 DO ADD("No patient goal information found.")
+3 GOTO DONE
+4 ;
DONE ;
+1 DO ADD("")
+2 KILL @TARGET@("GOALS")
+3 QUIT "~@"_$NAME(@TARGET)
+4 ;
APPEND(VALUE,TXT,MIDDLE) ;
+1 IF $LENGTH(VALUE)>0
Begin DoDot:1
+2 IF $LENGTH($GET(MIDDLE))>0
SET VALUE=VALUE_MIDDLE
+3 SET VALUE=VALUE_" "
End DoDot:1
+4 SET VALUE=VALUE_TXT
+5 QUIT
+6 ;
ADD(TXT) ; Saves TXT in TARGET
+1 NEW TXT2,SUBCOUNT,SUBLINE
+2 IF $LENGTH(TXT)>MAXLEN
Begin DoDot:1
+3 SET TXT2=$$WRAP^TIULS(TXT,MAXLEN)
+4 FOR SUBCOUNT=1:1
SET SUBLINE=$PIECE(TXT2,"|",SUBCOUNT)
IF SUBLINE=""
QUIT
DO ADD2(SUBLINE)
End DoDot:1
IF 1
+5 IF '$TEST
DO ADD2(TXT)
+6 QUIT
+7 ;
ADD2(TXT) ;
+1 SET LINEINDX=LINEINDX+1
+2 SET @TARGET@(LINEINDX,0)=TXT
+3 QUIT
+4 ;
DATESTR(DATE) ; returns Fileman date converted to MM/DD/YY format
+1 QUIT $SELECT(+DATE>0:$EXTRACT(DATE,4,5)_"/"_$EXTRACT(DATE,6,7)_"/"_($EXTRACT(DATE,1,3)+1700),1:"")
+2 ;
STSTEXT(CODE) ;
+1 QUIT $SELECT(CODE="A":"Active",CODE="MA":"Maintained",CODE="S":"Stopped",CODE="ME":"Met",1:"")