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

AGGFMTRG.m

Go to the documentation of this file.
AGGFMTRG ;VNGT/HS/ALA-Family, Contact Triggers ; 26 May 2010  11:06 AM
 ;;1.0;PATIENT REGISTRATION GUI;;Nov 15, 2010
 ;
 ;
EC(DATA,DFN) ; EP -- AGG EMER CONTACT TRIGGER
 ; Input
 ;   DFN      - Patient IEN
 ;
 NEW UID,II,VALUE,SOURCE,IEN,HELP,TYPE,ABLE,AGGECREL
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGTREC",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)
 ; Other Relationship is disabled, if relationship is not OTHER
 S AGGECREL=$$GET1^DIQ(9000001,DFN_",",3102,"E")
 I AGGECREL'="OTHER" S SOURCE="AGGECORL",VALUE="",ABLE="N",TYPE="X",CLEAR="",HELP="" D UP
 I AGGECREL="OTHER" D
 . S VALUE=$$GET1^DIQ(2,DFN_",",.332,"E")
 . S SOURCE="AGGECORL",ABLE="Y",TYPE="X",CLEAR="",HELP="Enter the 'other' relationship" D UP
 ;
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
ECREL(DATA,AGGECREL) ; EP -- AGG EC RELATION TRIGGER
 ; Input
 ;   AGGECREL - Emergency Contact Relationship
 ;
 NEW UID,II,VALUE,SOURCE,IEN,HELP,TYPE,ABLE,ECREL
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGTRECRL",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)
 ; Other Relationship is disabled, if relationship is not OTHER
 I AGGECREL?.N S ECREL=$P(^AUTTRLSH(AGGECREL,0),U,1)
 I ECREL'="OTHER" S SOURCE="AGGECORL",VALUE="",ABLE="N",TYPE="X",CLEAR="",HELP="" D UP
 I ECREL="OTHER" D
 . S SOURCE="AGGECORL",ABLE="Y",TYPE="X",CLEAR="",HELP="Enter the 'other' relationship",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 ;
 S II=II+1,@DATA@(II)=SOURCE_U_TYPE_U_VALUE_U_ABLE_U_$G(CLEAR)_U_HELP_$C(30)
 Q
 ;
HDR ;
 S HDR="T00008SOURCE^T00001CODE_TYPE^T01024PARMS^T00001ABLE_FLAG^T00100CLEAR_FIELDS^T00200HELP_TEXT"
 Q
 ;
NK(DATA,DFN) ; EP -- AGG NEXT OF KIN TRIGGER
 ; Input
 ;   DFN      - Patient IEN
 ;
 NEW UID,II,VALUE,SOURCE,IEN,HELP,TYPE,ABLE,AGGNKREL
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGTRNK",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)
 ; Other Relationship is disabled, if relationship is not OTHER
 S AGGNKREL=$$GET1^DIQ(9000001,DFN_",",2802,"E")
 I AGGNKREL'="OTHER" S SOURCE="AGGNKORL",VALUE="",ABLE="N",TYPE="X",CLEAR="",HELP="" D UP
 I AGGNKREL="OTHER" D
 . S VALUE=$$GET1^DIQ(2,DFN_",",.212,"E")
 . S SOURCE="AGGNKORL",ABLE="Y",TYPE="X",CLEAR="",HELP="Enter the 'other' relationship" D UP
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
NKREL(DATA,AGGNKREL) ; EP -- AGG NK RELATION TRIGGER
 ; Input
 ;   AGGNKREL - Next of Kin Relationship
 ;
 NEW UID,II,VALUE,SOURCE,IEN,HELP,TYPE,ABLE,NKREL
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGTRNKRL",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)
 ; Other Relationship is disabled, if relationship is not OTHER
 I AGGNKREL?.N S NKREL=$P(^AUTTRLSH(AGGNKREL,0),U,1)
 I NKREL'="OTHER" S SOURCE="AGGNKORL",VALUE="",ABLE="N",TYPE="X",CLEAR="",HELP="" D UP
 I NKREL="OTHER" D
 . S SOURCE="AGGNKORL",ABLE="Y",TYPE="X",CLEAR="",HELP="Enter the 'other' relationship",VALUE="" D UP
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
INIT(DATA,DFN) ; EP -- AGG FAMILY INITIAL TRIGGER
 NEW UID,II,VALUE,SOURCE,IEN,HELP,TYPE,ABLE,NKREL
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGTRFMY",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 DOB=$P(^DPT(DFN,0),U,3)
 S X=$E(X1,1,3)-$E(X2,1,3)-($E(X1,4,7)<$E(X2,4,7))
 I X<18 D
 . S SOURCE="AGGFTNME",ABLE="Y",TYPE="X",CLEAR="",HELP="",VALUE="" D UP
 . S SOURCE="AGGMTNME",ABLE="Y",TYPE="X",CLEAR="",HELP="",VALUE="" D UP
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
FTH(DATA,AGGFTNME) ; EP -- AGG FATHER NAME TRIGGER
 NEW UID,II,VALUE,SOURCE,IEN,HELP,TYPE,ABLE
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGFNMTR",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(AGGFTNME)="" D
 . S SOURCE="AGGFTEMN",ABLE="Y",TYPE="T",CLEAR="AGGFTEMN",HELP="",VALUE="" D UP
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
MTH(DATA,AGGMTNME) ; EP -- AGG MOTHER NAME TRIGGER
 NEW UID,II,VALUE,SOURCE,IEN,HELP,TYPE,ABLE
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGMNMTR",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(AGGMTNME)="" D
 . S SOURCE="AGGMTEMN",ABLE="Y",TYPE="T",CLEAR="AGGMTEMN",HELP="",VALUE="" D UP
 S II=II+1,@DATA@(II)=$C(31)
 Q