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

BTPWETRG.m

Go to the documentation of this file.
BTPWETRG ;VNGT/HS/BEE-Event Triggers ; 20 Jan 2010  10:00 AM
 ;;1.0;CARE MANAGEMENT EVENT TRACKING;;Feb 07, 2011
 ;
EN(DATA,BTPWSTGE) ;EP -- BTPW EVENT TRIGGER
 NEW UID,II,SOURCE,TYPE,ABLE,HELP,VALUE,%
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BTPWETRG",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BTPWETRG D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S @DATA@(II)="T00008SOURCE^T00001CODE_TYPE^T01024PARMS^T00030PROP_VALUE^T00001ABLE_FLAG^T00200HELP_TEXT"_$C(30)
 I $E(BTPWSTGE,1)="O" S SOURCE="BTPWPCLR",TYPE="C",ABLE="N",HELP="",VALUE="" D UP
 I $E(BTPWSTGE,1)="C" S SOURCE="BTPWPCLR",TYPE="C",ABLE="Y",HELP="",VALUE="" 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_VALUE_U_ABLE_U_HELP_$C(30)
 Q
 ;
FND(DATA,CMIEN) ;EP -- BTPW FIND EVENT TRIG
 ;
 ; *Initial Trigger for Findings Dialog Box
 ;
 NEW UID,II,PRCN,FN,VALUE,SOURCE,TYPE,ABLE,HELP,IEN
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BTPWETRG",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BTPWETRG D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S @DATA@(II)="T00008SOURCE^T00001CODE_TYPE^T01024PARMS^T00001ABLE_FLAG^T00200HELP_TEXT"_$C(30)
 S PRCN=$P(^BTPWP(CMIEN,0),U,1)
 S FN=0,VALUE="",SOURCE="BTPWPFND",TYPE="T",ABLE="Y",HELP=""
 F  S FN=$O(^BTPW(90621,PRCN,6,FN)) Q:'FN  D
 . S IEN=$P(^BTPW(90621,PRCN,6,FN,0),U,1)
 . S VALUE=VALUE_IEN_$C(29)_$$GET1^DIQ(90620.9,IEN_",",.01,"E")_$C(28)
 S VALUE=$$TKO^BQIUL1(VALUE,$C(28)) D UP
 ;
 S SOURCE="CMIEN",VALUE=CMIEN,TYPE="N",ABLE="N",HELP="" D UP
 S SOURCE="BTPWFDTM",VALUE=$$FMTE^BQIUL1(DT),TYPE="D",ABLE="Y",HELP="" D UP
 D NOW^%DTC
 S SOURCE="BTPWLMDT",VALUE=$$FMTE^BQIUL1(%),TYPE="D",ABLE="N",HELP="" D UP
 S SOURCE="BTPWLMBY",VALUE=DUZ,TYPE="T",ABLE="N",HELP="" D UP
 ;
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
INFOL(DATA,CMIEN) ;EP -- BTPW FOL EVENT TRIG
 ;
 ; *Initial Trigger for Follow-up Dialog Box
 ;
 NEW UID,II,PRCN,CAT,FN,VALUE,SOURCE,TYPE,ABLE,HELP
 ;
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BTPWETRG",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BTPWETRG D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S @DATA@(II)="T00008SOURCE^T00001CODE_TYPE^T01024PARMS^T00001ABLE_FLAG^T00200HELP_TEXT"_$C(30)
 ;
 S PRCN=$P(^BTPWP(CMIEN,0),U,1)
 S CAT=$P(^BTPW(90621,PRCN,0),U,10)
 S FN=0,VALUE="",SOURCE="BTPWPFOL",TYPE="T",ABLE="Y",HELP=""
 F  S FN=$O(^BTPW(90621,"AD",CAT,FN)) Q:'FN  S VALUE=VALUE_FN_$C(29)_$P(^BTPW(90621,FN,0),U,1)_$C(28)
 S VALUE=$$TKO^BQIUL1(VALUE,$C(28)) D UP
 ;
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
FIN(DATA,CMIEN,BTPWPFND) ;EP -- BTPW EVENT FIND TRIG
 ;
 ; Called from the Finding field in the Finding Dialog Box
 ;
 NEW UID,II,BTPWPRC,SOURCE,TYPE,ABLE,HELP,IEN,VALUE
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BTPWETRG",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BTPWETRG D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S @DATA@(II)="T00008SOURCE^T00001CODE_TYPE^T01024PARMS^T00001ABLE_FLAG^T00200HELP_TEXT"_$C(30)
 S BTPWPRC=$P(^BTPWP(CMIEN,0),U,1)
 S IEN=$O(^BTPW(90621,BTPWPRC,6,"B",BTPWPFND,"")) Q:IEN=""
 S VALUE=$P(^BTPW(90621,BTPWPRC,6,IEN,0),U,2),VALUE=VALUE_$C(28)_$$STC^BQIUL2(90621.06,.02,VALUE)
 S SOURCE="BTPWFNTR",TYPE="C",ABLE="",HELP="" D UP
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
FNFL(DATA,BTPWFLUN,CMIEN,BTPWFIND) ;EP -- BTPW EVENT FIND FOL TRIG
 NEW UID,II,SOURCE,TYPE,ABLE,HELP,VALUE,BTPFNDTM,BTPWPFND,BTPWFNTR,BTPFNCOM,BTPFLND,BTPEDTM,BTPEDBY
 ;
 ; *Called by Follow-up Needed Field (in the worksheet)
 ;
 NEW UID,II,SOURCE,TYPE,ABLE,HELP,VALUE,PRCN,CAT,FN,BQ
 NEW FNDDT,BTPFNDTM,BTPWPFND,BTPWFNTR,BTPFNCOM,BTPFLND,BTPEDTM,BTPEDBY
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BTPWFNFL",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BTPWETRG D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S @DATA@(II)="T00008SOURCE^T00001CODE_TYPE^T01024PARMS^T00001ABLE_FLAG^T00200HELP_TEXT"_$C(30)
 ;
 ;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
 ;
 ;Calculate Follow-up Decision Due By 
 S SOURCE="BTPWFDUE",TYPE="D",ABLE="N",HELP="",VALUE=""
 I BTPWFLUN["N" S ABLE="N",VALUE=""
 I BTPWFLUN["Y" D
 . N IEN
 . S ABLE="Y"
 . S IEN=$O(^BTPW(90628,0)) Q:IEN=""
 . S VALUE=$$GET1^DIQ(90628,IEN_",",1.02,"E") D SYS^BTPWPUTL
 . S:FNDDT="" FNDDT=$$DATE^BQIUL1("T")
 . S VALUE=$$FMADD^XLFDT(FNDDT,VALUE) S:VALUE<$$DATE^BQIUL1("T") VALUE=$$DATE^BQIUL1("T")
 . S VALUE=$$FMTE^BQIUL1(VALUE)
 ; 
 D UP
 ;
 ;Enable/disable Follow-up Grid
 S SOURCE="BTPWFU",TYPE="M",ABLE="N",HELP="",VALUE=""
 I BTPWFLUN["Y" S ABLE="Y"
 D UP
 ;
 ;Populate Notification Due By
 I BTPWFLUN["N" D
 . N IEN,DUEDT
 . S SOURCE="BTPWNDUE",TYPE="D",HELP="",ABLE="Y",VALUE=""
 . S IEN=$O(^BTPW(90628,0)) Q:IEN=""
 . S VALUE=$$GET1^DIQ(90628,IEN_",",1.03,"E") D SYS^BTPWPUTL
 . S DUEDT=FNDDT
 . S:DUEDT="" DUEDT=$$DATE^BQIUL1("T")
 . S VALUE=$$FMADD^XLFDT(DUEDT,VALUE) S:VALUE<$$DATE^BQIUL1("T") VALUE=$$DATE^BQIUL1("T")
 . S VALUE=$$FMTE^BQIUL1(VALUE)
 . D UP
 ;
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
FOL(DATA,CMIEN,BTPFNDTM,BTPWFLUN,BTPWNDUE,BTPWFIND) ;EP -- BTPW EVENT FOL TRIGGER
 ;
 ; *Called by Finding Date field in Finding Dialog Box (after OK is entered)
 ;
 NEW UID,II,VALUE,BTPWFDUE,SOURCE,TYPE,ABLE,HELP
 NEW BTPFNDTM,BTPWPFND,BTPWFNTR,BTPFNCOM,BTPFLND,BTPEDTM,BTPEDBY,BQ,FNDDT,FOLND,BTPWFNER
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BTPWETRG",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BTPWETRG D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S @DATA@(II)="T00008SOURCE^T00001CODE_TYPE^T01024PARMS^T00001ABLE_FLAG^T00200HELP_TEXT"_$C(30)
 ;
 ;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,BTPWFNER)=""
 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)) I $P($G(BTPWFNER),$C(29),I)'="Y" S VAL=$$DATE^BQIUL1($P(BTPFNDTM,$C(29),I)) I VAL'="",(VAL<CVAL)!(CVAL="") S CVAL=VAL
 . S FNDDT=CVAL
 ;
 ;Get Followup Needed Values
 S FOLND=""
 I BTPFLND]"" D
 . N I,VAL,LAST
 . S LAST=$P(BTPFLND,$C(29),$L(BTPFLND,$C(29)))
 . I BTPWFLUN="N",LAST="N" S FOLND="N" Q  ;Use Existing Value if new value is NO
 . I BTPWFLUN="Y" S FOLND="Y" Q
 . F I=1:1:$L(BTPFLND,$C(29)) I $P($G(BTPWFNER),$C(29),I)'="Y" S VAL=$P(BTPFLND,$C(29),I) S:VAL]"" FOLND=VAL I FOLND="Y" Q
 ;
 ;Enable/disable Follow-up Needed
 S SOURCE="BTPWFLUN",TYPE="C",HELP="",ABLE="N",VALUE=""
 I FNDDT]"" S ABLE="Y",VALUE=FOLND
 D UP
 ;
 ;Calculate Follow-up Decision Due By 
 S SOURCE="BTPWFDUE",TYPE="D",ABLE="N",HELP="",VALUE=""
 I FOLND="N" S ABLE="N",VALUE=""
 I FOLND="Y" D
 . N IEN,DUEDT
 . S ABLE="Y"
 . S IEN=$O(^BTPW(90628,0)) Q:IEN=""
 . S VALUE=$$GET1^DIQ(90628,IEN_",",1.02,"E") D SYS^BTPWPUTL
 . S DUEDT=FNDDT
 . S:DUEDT="" DUEDT=$$DATE^BQIUL1("T")
 . S VALUE=$$FMADD^XLFDT(DUEDT,VALUE) S:VALUE<$$DATE^BQIUL1("T") VALUE=$$DATE^BQIUL1("T")
 . S VALUE=$$FMTE^BQIUL1(VALUE)
 D UP
 ;
 ;Enable/disable Follow-up Grid
 S SOURCE="BTPWFU",TYPE="M",ABLE="N",HELP="",VALUE=""
 I FOLND="Y" S ABLE="Y"
 D UP
 ;
 ;Enable/disable Notification Due By
 S SOURCE="BTPWNDUE",TYPE="D",HELP="",ABLE="N",VALUE=BTPWNDUE
 I FNDDT]"" D
 . S ABLE="Y"
 . I FOLND="N" D
 .. N IEN,DUEDT
 .. S IEN=$O(^BTPW(90628,0)) Q:IEN=""
 .. S VALUE=$$GET1^DIQ(90628,IEN_",",1.03,"E") D SYS^BTPWPUTL
 .. S DUEDT=FNDDT
 .. S:DUEDT="" DUEDT=$$DATE^BQIUL1("T")
 .. S VALUE=$$FMADD^XLFDT(DUEDT,VALUE) S:VALUE<$$DATE^BQIUL1("T") VALUE=$$DATE^BQIUL1("T")
 .. S VALUE=$$FMTE^BQIUL1(VALUE)
 D UP
 ;
 ;Enable/disable Notifications
 S SOURCE="BTPWNTY",TYPE="M",HELP="",ABLE="N",VALUE=""
 I FNDDT]"" S ABLE="Y"
 D UP
 ;
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
NOT(DATA,BTPFLDTM,BTPWFU) ; EP -- BTPW EVENT NOT TRIGGER
 NEW UID,II,VALUE,BTPWNDUE,SOURCE,TYPE,ABLE,HELP
 NEW BTPFLDTM,BTPWPFOL,BTPWPFLD,BTPEDBY,BTPEDTM,BTPWPFCM,FOLDT,BQ
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BTPWETRG",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BTPWETRG D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S @DATA@(II)="T00008SOURCE^T00001CODE_TYPE^T01024PARMS^T00001ABLE_FLAG^T00200HELP_TEXT"_$C(30)
 ;
 ;Re-Assemble parameter list if in an array
 S BTPWFU=$G(BTPWFU,"")
 I BTPWFU="" D
 . N LIST,BN
 . S LIST="",BN=""
 . F  S BN=$O(BTPWFU(BN)) Q:BN=""  S LIST=LIST_BTPWFU(BN)
 . K BTPWFU
 . S BTPWFU=LIST
 . K LIST
 ;
 ;Parse Parameters
 S (BTPFLDTM,BTPWPFOL,BTPWPFLD,BTPEDBY,BTPEDTM,BTPWPFCM)=""
 F BQ=1:1:$L(BTPWFU,$C(28)) D
 . N PDATA,NAME,VALUE,BP,BV
 . S PDATA=$P(BTPWFU,$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 follow-up creation date
 S FOLDT=""
 I BTPFLDTM]"" D
 . N I,VAL,CVAL
 . S CVAL="" F I=1:1:$L(BTPFLDTM,$C(29)) S VAL=$$DATE^BQIUL1($P(BTPFLDTM,$C(29),I)) I VAL'="",(VAL<CVAL)!(CVAL="") S CVAL=VAL
 . S FOLDT=CVAL
 ;
 ;Patient Notification Due Date
 S SOURCE="BTPWNDUE",TYPE="D",ABLE="N",HELP=""
 I FOLDT]"" D
 . S ABLE="Y"
 . N IEN,DUEDT
 . S IEN=$O(^BTPW(90628,0)) Q:IEN=""
 . S VALUE=$$GET1^DIQ(90628,IEN_",",1.03,"E") D SYS^BTPWPUTL
 . S DUEDT=FOLDT
 . S:DUEDT="" DUEDT=$$DATE^BQIUL1("T")
 . S VALUE=$$FMADD^XLFDT(DUEDT,VALUE) S:VALUE<$$DATE^BQIUL1("T") VALUE=$$DATE^BQIUL1("T")
 . S VALUE=$$FMTE^BQIUL1(VALUE)
 D UP
 ;
 ;Enable/disable Notifications
 S SOURCE="BTPWNTY",TYPE="M",HELP="",ABLE="N",VALUE=""
 I FOLDT]"" S ABLE="Y"
 D UP
 ;
 S II=II+1,@DATA@(II)=$C(31)
 Q