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

AGGPTTRG.m

Go to the documentation of this file.
AGGPTTRG ;VNGT/HS/ALA-Patient Detail Triggers ; 27 May 2010  4:25 PM
 ;;1.0;PATIENT REGISTRATION GUI;;Nov 15, 2010
 ;
 ;
INIT(DATA,DFN) ;EP -- AGG PERSONAL DETAIL TRIGGER
 ; Input
 ;   DFN      - Patient IEN
 ;
 NEW UID,II,VALUE,SOURCE,IEN,HELP,TYPE,ABLE,NOSAVE,AGGPTSSV,DOBE,SSNV
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGTRPAT",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^AGGWTRIG D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 D HDR
 S @DATA@(II)=HDR_$C(30)
 ;
 S DOBE=$P($G(^AGFAC(DUZ(2),0)),U,13),SSNV=$P(^AUPNPAT(DFN,0),U,23)
 F SOURCE="AGGPTLNM","AGGPTFNM","AGGPTMNM","AGGPTSFX" S ABLE="N",VALUE="",TYPE="X",HELP="",CLEAR="",NOSAVE="N" D UP
 I $D(^XUSEC("AGZMGR",DUZ)) D
 . S SOURCE="AGGPTHRN",ABLE="Y",VALUE="",TYPE="X",HELP="",CLEAR="",NOSAVE="N" D UP
 . I SSNV'="","XV"[$P(^AUTTSSN(SSNV,0),U) D  Q
 .. S SOURCE="AGGPTDOB",ABLE="Y",VALUE="",TYPE="D",HELP="The NAME/SSN/DOB have been Verified by the SSA do not change the DOB unless you are certain that it is incorrect!" D UP
 . S SOURCE="AGGPTDOB",ABLE="Y",VALUE="",TYPE="X",HELP="",CLEAR="",NOSAVE="N" D UP
 I '$D(^XUSEC("AGZMGR",DUZ)) D
 . S SOURCE="AGGPTHRN",ABLE="N",VALUE="",TYPE="X",HELP="",CLEAR="",NOSAVE="N" D UP
 . I SSNV'="","XV"[$P(^AUTTSSN(SSNV,0),U) D  Q
 .. I DOBE="Y" S SOURCE="AGGPTDOB",ABLE="N",VALUE="",TYPE="D",HELP="DOB must be edited by a supervisor." D UP
 .. I DOBE="N" S SOURCE="AGGPTDOB",ABLE="Y",VALUE="",TYPE="D",HELP="The NAME/SSN/DOB have been Verified by the SSA do not change the DOB unless you are certain that it is incorrect!" D UP
 . I DOBE="Y" S SOURCE="AGGPTDOB",ABLE="N",VALUE="",TYPE="X",HELP="DOB must be edited by a supervisor.",CLEAR="",NOSAVE="N" D UP
 . I DOBE="N" S SOURCE="AGGPTDOB",ABLE="Y",VALUE="",TYPE="X",HELP="",CLEAR="",NOSAVE="N" D UP
 ;
 S AGGPTSSV=$$GET1^DIQ(9000001,DFN_",",.23,"E")
 S AGGNOSSN=$$GET1^DIQ(9000001,DFN_",",.24,"E")
 S AGGPTSSN=$$GET1^DIQ(2,DFN_",",.09,"E")
 S SSN=$$GET1^DIQ(2,DFN_",",.09,"E")
 ;
 I AGGPTSSN'="",AGGNOSSN="" D
 . S SOURCE="AGGNOSSN",ABLE="N",VALUE="",TYPE="X",HELP="",CLEAR="",NOSAVE="N" D UP
 . I AGGPTSSV="P"!(AGGPTSSV="") S SOURCE="AGGPTSSN",ABLE="Y",VALUE="",TYPE="X",HELP="",CLEAR="",NOSAVE="N" D UP
 . I AGGPTSSV'="P",AGGPTSSV'="" S SOURCE="AGGPTSSN",ABLE="N",VALUE="",TYPE="X",HELP="",CLEAR="",NOSAVE="Y" D UP
 I AGGPTSSN="",AGGNOSSN'="" D
 . S SOURCE="AGGNOSSN",ABLE="Y",VALUE="",TYPE="X",HELP="",CLEAR="",NOSAVE="N" D UP
 . S SOURCE="AGGPTSSN",ABLE="N",VALUE="",TYPE="X",HELP="",CLEAR="",NOSAVE="Y" D UP
 I AGGPTSSN="",AGGNOSSN="" D
 . S SOURCE="AGGNOSSN",ABLE="Y",VALUE="",TYPE="X",HELP="",CLEAR="",NOSAVE="N" D UP
 . S SOURCE="AGGPTSSN",ABLE="N",VALUE="",TYPE="X",HELP="",CLEAR="",NOSAVE="N" D UP
 ;
 S HRN=$$HRN^AGGUL1(DFN)
 I $E(HRN,1,1)="T",$D(^XUSEC("AGZMGR",DUZ)) S SOURCE="AGGPTHRN",ABLE="Y",VALUE="",TYPE="X",HELP="",CLEAR="",NOSAVE="N" 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 ;
 S II=II+1,@DATA@(II)=SOURCE_U_TYPE_U_VALUE_U_ABLE_U_NOSAVE_U_$G(CFLAG)_U_$G(CLEAR)_U_HELP_$C(30)
 Q
 ;
HDR ;
 S HDR="T00008SOURCE^T00001CODE_TYPE^T01024PARMS^T00001ABLE_FLAG^T00001NOSAVE^T00001CLEAR_FLAG^T00100CLEAR_FIELDS^T00200HELP_TEXT"
 Q
 ;
EMP(DATA,DFN,STATUS) ; EP -- AGG PAT EMPL STATUS TRIGGER
 NEW UID,II,VALUE,SOURCE,IEN,HELP,TYPE,ABLE,AGGEMSTS,PREVSTS,FLAG,AGGPTEPL
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGTREMP",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^AGGWTRIG D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 D HDR
 S @DATA@(II)=HDR_$C(30)
 S FLAG=0
 S PREVSTS=$$GET1^DIQ(9000001,DFN_",",.21,"I")
 I $G(STATUS)'="",$G(PREVSTS)'=STATUS S FLAG=1
 S AGGEMSTS=STATUS
 S AGGPTEPL=$$GET1^DIQ(9000001,DFN_",",.19,"I") D
 . I 'FLAG S CLEAR="" Q
 . I AGGEMSTS'=3&(AGGEMSTS'=5)&(AGGEMSTS'=9)&(PREVSTS'=3)&(PREVSTS'=5)&(PREVSTS'=9) S CLEAR="" Q
 . S CLEAR="AGGPTEPL"
 I PREVSTS="" S CLEAR="AGGPTEPL"
 I AGGEMSTS'=3&(AGGEMSTS'=5)&(AGGEMSTS'=9) S SOURCE="AGGPTEPL",ABLE="Y",VALUE=AGGPTEPL,TYPE="T",HELP="",NOSAVE="N" D UP
 E  S SOURCE="AGGPTEPL",ABLE="N",TYPE="T",HELP="",CLEAR="",NOSAVE="N" D
 . I AGGEMSTS=3 S VALUE=$O(^AUTNEMPL("B","UNEMPLOYED","")) D
 .. I VALUE="" S ABLE="Y" Q
 .. I VALUE'="" S VALUE=VALUE_$C(28)_"UNEMPLOYED"
 . I AGGEMSTS=5 S VALUE=$O(^AUTNEMPL("B","RETIRED","")) D
 .. I VALUE="" S ABLE="Y" Q
 .. I VALUE'="" S VALUE=VALUE_$C(28)_"RETIRED"
 . I AGGEMSTS=9 S VALUE=$O(^AUTNEMPL("B","UNKNOWN","")) D
 .. I VALUE="" S ABLE="Y" Q
 .. I VALUE'="" S VALUE=VALUE_$C(28)_"UNKNOWN"
 . D UP
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
SSN(DATA,SSN,NOSSN) ; EP -- AGG PAT SSN TRIGGER
 NEW UID,II,VALUE,SOURCE,IEN,HELP,TYPE,ABLE,AUPN,AUPIDS
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGTRSSN",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^AGGWTRIG D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 D HDR
 S @DATA@(II)=HDR_$C(30)
 ;
 I $G(SSN)="",$G(NOSSN)="" D
 . S SOURCE="AGGNOSSN",ABLE="Y",TYPE="T",HELP="",CLEAR="",NOSAVE="N",VALUE="" D UP
 . S SOURCE="AGGPTSSN",ABLE="Y",TYPE="X",HELP="",CLEAR="",NOSAVE="N",VALUE="" D UP
 I $G(SSN)'="",$G(NOSSN)="" D
 . S SOURCE="AGGNOSSN",ABLE="N",TYPE="T",HELP="",CLEAR="AGGNOSSN",NOSAVE="N",VALUE="" D UP
 I $G(SSN)="",$G(NOSSN)'="" D
 . S SOURCE="AGGNOSSN",ABLE="Y",TYPE="T",HELP="",CLEAR="",NOSAVE="N",VALUE="" D UP
 . S SOURCE="AGGPTSSN",ABLE="N",TYPE="X",HELP="",CLEAR="",NOSAVE="N",VALUE="" D UP
 S II=II+1,@DATA@(II)=$C(31)
 Q