Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: BTPWBTTR

BTPWBTTR.m

Go to the documentation of this file.
BTPWBTTR ;VNGT/HS/ALA-Batch Event Trigger ; 21 Oct 2009  1:36 PM
 ;;1.1;CARE MANAGEMENT EVENT TRACKING;**2**;Apr 01, 2015;Build 17
 ;
 ;
INIT(DATA,BTPWPRC) ;EP -- BTPW BATCH EVENT INITIAL
 NEW UID,II,VALUE,SOURCE,IEN,TYPE,IIEN,BTPWPFND,BTPWFNTR,FNDING,ABLE,FNDING
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BTPWBTTR",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BTPWBTTR D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S @DATA@(II)="T00008SOURCE^T00001CODE_TYPE^T00001ABLE_FLAG^T01024PARMS"_$C(30)
 S IEN="",VALUE=""
 S IEN=$O(^BTPW(90628,1,2,"B",BTPWPRC,IEN))
 I IEN="" S BMXSEC="RPC Failed: This procedure is not on file for batch events" Q
 ; For findings, get default from Site parameters
 S SOURCE="BTPWPFND",TYPE="T",ABLE="Y" D
 . S (FNDING,VALUE)=$P($G(^BTPW(90628,1,2,IEN,1)),U,1)
 . I $P(^BTPW(90621,BTPWPRC,0),U,1)="PAP SMEAR",VALUE]"" S VALUE=VALUE_$C(28)_$P($G(^BTPW(90620.9,VALUE,0)),U) ;Include name with Paps
 . I $P(^BTPW(90621,BTPWPRC,0),U,1)="PAP SMEAR" S ABLE="Y"
 . S @SOURCE=VALUE D UP
 . ;S VALUE=FNDING_$C(29)_$P(^BTPW(90620.9,FNDING,0),U,1) D UP
 . ; for findings interpretation, get default from findings
 S SOURCE="BTPWFNTR",TYPE="C",ABLE="Y" D
 . NEW IIEN
 . S IIEN=$O(^BTPW(90621,BTPWPRC,6,"B",FNDING,"")) I IIEN="" Q
 . S VAL=$P(^BTPW(90621,BTPWPRC,6,IIEN,0),U,2)
 . S VALUE=VAL_$C(29)_$$STC^BQIUL2(90621.06,.02,VAL)
 . S @SOURCE=VALUE
 . D UP
 ; For followup event, same as selected event
 S SOURCE="BTPWPFOL",TYPE="T",ABLE="Y" D
 . ;S VALUE=BTPWPRC_$C(29)_$P(^BTPW(90621,BTPWPRC,0),U,1) D UP
 . S VALUE=$P(^BTPW(90621,BTPWPRC,0),U,1) D UP
 ; For Followup Due By Date, get from Site parameters
 S SOURCE="BTPWPFLD",TYPE="C" D
 . S VALUE=$P(^BTPW(90628,1,2,IEN,0),U,2)
 . S VALUE=VALUE
 . ;_$C(29)_$S(VALUE="24M":"2 years",VALUE="36M":"3 years",1:"1 year")
 . D UP
 ; For close reason, Event Complete = 1
 ;S SOURCE="BTPWPCLR",TYPE="C",VALUE=1_$C(29)_$$STC^BQIUL2(90620,1.04,1) D UP
 S SOURCE="BTPWPCLR",TYPE="C",VALUE=$$STC^BQIUL2(90620,1.04,1) D UP
 ; For State, it is CLOSED
 ;S SOURCE="BTPWSTGE",TYPE="C",VALUE="C"_$C(29)_"CLOSED" D UP
 S SOURCE="BTPWSTGE",TYPE="C",VALUE="CLOSED" D UP
 S SOURCE="BTPWPNOT",TYPE="T",VALUE=$P(^BTPW(90628,1,2,IEN,0),U,5) D UP
 ; For Status, it is TRACKED
 ;S SOURCE="BTPWSTAT",TYPE="C",VALUE="T"_$C(29)_"TRACKED" D UP
 S SOURCE="BTPWSTAT",TYPE="C",VALUE="TRACKED" D UP
 ;
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
ERR ;
 D ^%ZTER
 NEW Y,ERRDTM
 S Y=$$NOW^XLFDT() X ^DD("DD") S ERRDTM=Y
 S BMXSEC="Recording that an error occurred at "_ERRDTM
 I $D(II),$D(DATA) S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
UP ; Update
 S II=II+1,@DATA@(II)=SOURCE_U_TYPE_U_$G(ABLE)_U_VALUE_$C(30)
 Q
 ;
NOT(DATA,BTPWPNOT) ; EP - BTPW TRIGGER NOTIFICATION
 NEW UID,II,VALUE,SOURCE,HELP,ABLE,REQ,CLEAR,TYPE,ABR,CLFLAG
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BTPWBTTR",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BTPWBTTR D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 D HDR
 ;
 S ABR=$P(^BTPW(90622,BTPWPNOT,0),U,3)
 I ABR="L"!(ABR="T") D
 . S SOURCE="BTPWTDOC",VALUE="",HELP="",ABLE="Y",REQ="R",CLEAR="",CLFLAG="",TYPE="T" D REC
 . S SOURCE="BTPWTTMP",VALUE="",HELP="",ABLE="Y",REQ="R",CLEAR="",CLFLAG="",TYPE="T" D REC
 . S SOURCE="BTPWSIGN",VALUE="",HELP="",ABLE="Y",REQ="R",CLEAR="",CLFLAG="",TYPE="P" D REC
 . S SOURCE="BTPWLNK",VALUE="",HELP="",ABLE="Y",REQ="R",CLEAR="",CLFLAG="",TYPE="X" D REC
 E  D
 . S SOURCE="BTPWTDOC",VALUE="",HELP="",ABLE="N",REQ="R",CLEAR="BTPWTDOC",CLFLAG="",TYPE="T" D REC
 . S SOURCE="BTPWTTMP",VALUE="",HELP="",ABLE="N",REQ="R",CLEAR="BTPWTTMP",CLFLAG="",TYPE="T" D REC
 . S SOURCE="BTPWSIGN",VALUE="",HELP="",ABLE="N",REQ="R",CLEAR="BTPWSIGN",CLFLAG="",TYPE="P" D REC
 . S SOURCE="BTPWLNK",VALUE="",HELP="",ABLE="N",REQ="R",CLEAR="BTPWLNK",CLFLAG="",TYPE="X" D REC
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
STATE(DATA,BTPWSTGE,BTPWRDUE,BTPWFDUE,BTPWNDUE,BTPWFLUN,BTPWFIND) ; EP - BTPW TRIGGER STATE
 NEW UID,II,VALUE,SOURCE,HELP,ABLE,REQ,CLEAR,TYPE
 NEW BTPFNDTM,BTPWPFND,BTPWFNTR,BTPFNCOM,BTPFLND,BTPEDTM,BTPEDBY,FNDDT
 ;
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BTPWBTTR",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BTPWBTTR D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 ;Re-Assemble parameter list if in an array
 S BTPWFIND=$G(BTPWFIND,"")
 I BTPWFIND="" D
 . N LIST,BN
 . S LIST="",BN=""
 . F  S BN=$O(BTPWFIND(BN)) Q:BN=""  S LIST=LIST_BTPWFIND(BN)
 . K BTPWFIND
 . S BTPWFIND=LIST
 . K LIST
 ;
 ;Parse Parameters
 S (BTPFNDTM,BTPWPFND,BTPWFNTR,BTPFNCOM,BTPFLND,BTPEDTM,BTPEDBY)=""
 F BQ=1:1:$L(BTPWFIND,$C(28)) D
 . N PDATA,NAME,VALUE,BP,BV
 . S PDATA=$P(BTPWFIND,$C(28),BQ) Q:PDATA=""
 . S NAME=$P(PDATA,"=",1) I NAME=""!(NAME="CMIEN")!(NAME="EVIEN") Q
 . S VALUE=$P(PDATA,"=",2,99) Q:VALUE=""
 . F BP=1:1:$L(VALUE,$C(29)) S BV=$P(VALUE,$C(29),BP),@NAME=$G(@NAME)_$S(BP=1:"",1:$C(29))_BV
 ;
 ;Get earliest finding date
 S FNDDT=""
 I BTPFNDTM]"" D
 . N I,VAL,CVAL
 . S CVAL="" F I=1:1:$L(BTPFNDTM,$C(29)) S VAL=$$DATE^BQIUL1($P(BTPFNDTM,$C(29),I)) I VAL'="",(VAL<CVAL)!(CVAL="") S CVAL=VAL
 . S FNDDT=CVAL
 ;
 S BTPWRDUE=$$FMTE^BQIUL1($$DATE^BQIUL1(BTPWRDUE))
 S BTPWFDUE=$$FMTE^BQIUL1($$DATE^BQIUL1(BTPWFDUE))
 S BTPWNDUE=$$FMTE^BQIUL1($$DATE^BQIUL1(BTPWNDUE))
 ;
 D HDR
 I BTPWSTGE="O" D
 . S SOURCE="BTPCLREA",VALUE="",HELP="",ABLE="N",REQ="",CLEAR="BTPCLREA",CLFLAG="",TYPE="C" D REC
 . S SOURCE="BTPOTCOM",VALUE="",HELP="",ABLE="Y",REQ="",CLEAR="BTPOTCOM",CLFLAG="",TYPE="X" D REC
 . ;
 . ;Enable/disable Follow-up Needed
 . I FNDDT]"" S SOURCE="BTPWFLUN",VALUE=BTPWFLUN,HELP="",ABLE="Y",REQ="",CLEAR="",CLFLAG="",TYPE="C" D REC
 . ;
 . ;Enable Follow-up Decision Due By
 . I BTPWFLUN="Y" S SOURCE="BTPWFDUE",VALUE=BTPWFDUE,HELP="",ABLE="Y",REQ="",CLEAR="",CLFLAG="",TYPE="D" D REC
 . ;
 . ;Enable Findings Due By
 . S SOURCE="BTPWRDUE",VALUE=BTPWRDUE,HELP="",ABLE="Y",REQ="",CLEAR="",CLFLAG="",TYPE="D" D REC
 . ;
 . ;Enable Findings Grid
 . S SOURCE="BTPWFIND",VALUE="",HELP="",ABLE="Y",REQ="",CLEAR="",CLFLAG="",TYPE="M" D REC
 . ;
 . ;Enable Follow-up Grid
 . I BTPWFLUN="Y" S SOURCE="BTPWFU",VALUE="",HELP="",ABLE="Y",REQ="",CLEAR="",CLFLAG="",TYPE="M" D REC
 . ;
 . ;Enable Notifications Due By
 . I FNDDT]"" S SOURCE="BTPWNDUE",VALUE=BTPWNDUE,HELP="",ABLE="Y",REQ="",CLEAR="",CLFLAG="",TYPE="D" D REC
 . ;
 . ;Enable Notifications Grid
 . I FNDDT]"" S SOURCE="BTPWNTY",VALUE="",HELP="",ABLE="Y",REQ="",CLEAR="",CLFLAG="",TYPE="M" D REC
 . ;
 ;
 I BTPWSTGE="C" D
 . S SOURCE="BTPCLREA",VALUE="",HELP="",ABLE="Y",REQ="R",CLEAR="",CLFLAG="",TYPE="T" D REC
 . S SOURCE="BTPOTCOM",VALUE="",HELP="",ABLE="Y",REQ="",CLEAR="",CLFLAG="",TYPE="X" D REC
 . S SOURCE="BTPWFIND",VALUE="",HELP="",ABLE="N",REQ="",CLEAR="",CLFLAG="",TYPE="M" D REC
 . S SOURCE="BTPWFU",VALUE="",HELP="",ABLE="N",REQ="",CLEAR="",CLFLAG="",TYPE="M" D REC
 . S SOURCE="BTPWNTY",VALUE="",HELP="",ABLE="N",REQ="",CLEAR="",CLFLAG="",TYPE="M" D REC
 . S SOURCE="BTPWRDUE",VALUE=BTPWRDUE,HELP="",ABLE="N",REQ="",CLEAR="",CLFLAG="N",TYPE="D" D REC
 . S SOURCE="BTPWFDUE",VALUE=BTPWFDUE,HELP="",ABLE="N",REQ="",CLEAR="",CLFLAG="N",TYPE="D" D REC
 . S SOURCE="BTPWNDUE",VALUE=BTPWNDUE,HELP="",ABLE="N",REQ="",CLEAR="",CLFLAG="N",TYPE="D" D REC
 . S SOURCE="BTPWFLUN",VALUE=BTPWFLUN,HELP="",ABLE="N",REQ="",CLEAR="",CLFLAG="N",TYPE="C" D REC
 ;
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
HDR ; Header
 S @DATA@(II)="T00008SOURCE^T00001CODE_TYPE^T01024PARMS^T00030PROP_VALUE^T00001ABLE_FLAG^T00001REQ_OPT^T00200HELP_TEXT^T01024CLEAR_FIELDS^T00001CLEAR_FLAG"_$C(30)
 Q
 ;
REC ; Record
 S II=II+1,@DATA@(II)=$G(SOURCE)_U_$G(TYPE)_U_$G(VALUE)_U_U_$G(ABLE)_U_$G(REQ)_U_$G(HELP)_U_$G(CLEAR)_U_$G(CLFLAG)_$C(30)
 Q