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

AGGPOLCY.m

Go to the documentation of this file.
AGGPOLCY ;VNGT/HS/ALA-Policy Members ; 28 Jun 2010  4:58 PM
 ;;1.0;PATIENT REGISTRATION GUI;;Nov 15, 2010
 ;
 ;
EN(DATA,INSN,POLH) ; EP -- AGG GET POLICY MEMBERS
 ; Input
 ;   INSN - Insurer IEN
 ;   POLH - Policy Holder IEN
 ;
 NEW UID,II,MM,IN
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGPOLCY",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^AGGWDISP D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S @DATA@(II)="I00010MBDFN^I00010AGGPIIEN^T00035AGGPLMNM^T00010AGGPMPCD^T00020AGGPINUM^T00006AGGPMHRN^T00050AGGPMREL^D00015AGGPHESD^"
 S @DATA@(II)=@DATA@(II)_"D00015AGGPHEED^I00010AGGPLIEN^I00010AGGPIINS^T00003PROC^T00040AGGPICOV^T00035AGGPIHLN^T00035AGGPMPCP^"
 S @DATA@(II)=@DATA@(II)_"T00007AGGPICCF^D00015AGGPICRD^T00020AGGPMNUM"_$C(30)
 S MM=""
 F  S MM=$O(^AUPNPRVT("C",POLH,MM)) Q:MM=""  D
 . S IN=""
 . F  S IN=$O(^AUPNPRVT("C",POLH,MM,IN)) Q:IN=""  D
 .. I $P(^AUPNPRVT(MM,11,IN,0),U,1)'=INSN Q
 .. NEW DA,IENS,REL,FROM,THRU,MEM,PC,MBNM,PCP,CCF,CCFD
 .. S DA(1)=MM,DA=IN,IENS=$$IENS^DILF(.DA)
 .. S REL=$$GET1^DIQ(9000006.11,IENS,.05,"I")
 .. S FROM=$$GET1^DIQ(9000006.11,IENS,.06,"I")
 .. S THRU=$$GET1^DIQ(9000006.11,IENS,.07,"I")
 .. S MEM=$$GET1^DIQ(9000006.11,IENS,.02,"E")
 .. S PC=$$GET1^DIQ(9000006.11,IENS,.12,"E")
 .. S MBNM=$$GET1^DIQ(9000006.11,IENS,21,"E") I MBNM="" S MBNM=$$GET1^DIQ(9000003.1,POLH_",",.04,"E")
 .. S PCP=$$GET1^DIQ(9000006.11,IENS,.14,"E")
 .. S CCF=$$GET1^DIQ(9000006.11,IENS,.15,"I")
 .. S CCFD=$$GET1^DIQ(9000006.11,IENS,.16,"I")
 .. S II=II+1,@DATA@(II)=MM_U_IN_U_$P(^DPT(MM,0),U,1)_U_PC_U_MEM_U_$$HRN^AGGUL1(MM)_U
 .. S @DATA@(II)=@DATA@(II)_REL_U_$$FMTE^AGGUL1(FROM)_U_$$FMTE^AGGUL1(THRU)_U_POLH_U_INSN_U_U_U_U_$G(PCP)_U_CCF_U_$$FMTE^AGGUL1(CCFD)_U_MBNM_$C(30)
 ;
DONE ;
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
UPOL(DATA,MBDFN,AGGPIINS,AGGPLHIN,PROC,PARMS) ; EP - AGG UPDATE POLICY MEMBER
 ; Input
 ;   PROC      - 'A' to add, 'E' to edit, 'D' to delete
 ;   MBDFN     - Selected Member IEN
 ;   AGGPIINS  - Insurer IEN
 ;   AGGPLHIN  - Policy Holder IEN
 ;   PARMS     - Parameters
 NEW UID,II,AGIEN,AGGRIEN,LIST,BN,IENS,AGGPIIEN,ERROR,MBIEN
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGUPOL",UID))
 K @DATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^AGGPTUPD D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 S @DATA@(II)="I00010RESULT^T01024ERROR^I00010AGGPIIEN"_$C(30)
 ;
 S AGIEN=$O(^AGG(9009068.3,"B","Policy Members",""))
 I AGIEN="" D  Q
 . S II=II+1,@DATA@(II)="-1^"_"RPC Call Failed: "_DEF_" Definition does not exist."_$C(30)
 . S II=II+1,@DATA@(II)=$C(31)
 ;
 S FILE=$P(^AGG(9009068.3,AGIEN,0),U,2)
 ;
 I $G(AGGPIINS)="" S AGGPIINS=$$GET1^DIQ(9000003.1,AGGPLHIN_",",.03,"I")
 I $G(AGGPIIEN)="" D
 . S IN=""
 . F  S IN=$O(^AUPNPRVT("C",AGGPLHIN,MBDFN,IN))  Q:IN=""  D
 .. I $P(^AUPNPRVT(MBDFN,11,IN,0),U,1)'=AGGPIINS Q
 .. S AGGPIIEN=IN
 ;
 ;if deleting a Member
 I $G(PROC)="D" D  G DNE
 . NEW DA,IENS
 . I $G(AGGPIIEN)="" Q
 . S DA(1)=MBDFN,DA=AGGPIIEN,IENS=$$IENS^DILF(.DA)
 . S AGGUPD(FILE,IENS,.01)="@"
 . D FILE^DIE("","AGGUPD","ERROR")
 ;
 S PARMS=$G(PARMS,"")
 I PARMS="" D
 . S LIST="",BN=""
 . F  S BN=$O(PARMS(BN)) Q:BN=""  S LIST=LIST_PARMS(BN)
 . K PARMS
 . S PARMS=LIST
 . K LIST
 ; 
 I PARMS="" D  Q
 . S II=II+1,@DATA@(II)=1_$C(30)
 . S II=II+1,@DATA@(II)=$C(31)
 ;
 ; If selected member does not exist
 I $G(^AUPNPRVT(MBDFN,0))="" D
 . NEW DIC,X,DINUM
 . S DIC="^AUPNPRVT(",DLAYGO=9000006,DIC(0)="L",X=MBDFN,DINUM=X
 . K DO,DD D FILE^DICN
 ;
 NEW DIC,X,Y
 I $G(AGGPIIEN)="" D
 . I $G(^AUPNPRVT(MBDFN,11,0))="" S ^AUPNPRVT(MBDFN,11,0)="^9000006.11P^^"
 . S DIC="^AUPNPRVT("_MBDFN_",11,"
 . S DIC("P")=$P(^DD(9000006,1101,0),U,2),DIC(0)="L",DA(1)=MBDFN,X="`"_AGGPIINS
 . D ^DIC S AGGPIIEN=+Y
 ;
 S MBIEN=AGGPIIEN
 D PARS^AGGUPPVT
 S AGGPIIEN=MBIEN
 ;
 ;if editing a Policy Member
 S DA(1)=MBDFN,DA=AGGPIIEN,IENS=$$IENS^DILF(.DA)
 ;
 F BQ=1:1:$L(PARMS,$C(28)) D
 . S PDATA=$P(PARMS,$C(28),BQ) Q:PDATA=""
 . S NAME=$P(PDATA,"=",1)
 . S PFIEN=$O(^AGG(9009068.3,AGIEN,10,"AC",NAME,""))
 . I PFIEN="" Q
 . S FIELD=$P($G(^AGG(9009068.3,AGIEN,10,PFIEN,3)),U,1)
 . S SECFLD=$P($G(^AGG(9009068.3,AGIEN,10,PFIEN,3)),U,7)
 . S EXEC=$G(^AGG(9009068.3,AGIEN,10,PFIEN,7))
 . I EXEC'="" X EXEC Q
 . I FIELD="",SECFLD="" Q
 . I FIELD=".001"!(SECFLD=".001") Q
 . S PTYP=$P($G(^AGG(9009068.3,AGIEN,10,PFIEN,1)),U,1)
 . ;
 . I PTYP="C"!(PTYP="T")!(PTYP="K") D  Q
 .. I FIELD'="" D
 ... S DA(1)=MBDFN,DA=AGGPIIEN,IENS=$$IENS^DILF(.DA)
 ... S AGGDATAI(FILE,IENS,FIELD)=@NAME
 . I FIELD'="" D
 .. S DA(1)=MBDFN,DA=AGGPIIEN,IENS=$$IENS^DILF(.DA)
 .. I PTYP="D" S AGGDATAI(FILE,IENS,FIELD)=$$DATE^AGGUL1(@NAME) Q
 .. S AGGDATA(FILE,IENS,FIELD)=@NAME
 S AGGDATAI(FILE,IENS,.08)=$G(AGGPLHIN)
 ;
 I PROC="A" D
 . S AGGDATAI(FILE,IENS,.06)=$$GET1^DIQ(9000003.1,AGGPLHIN_",",.17,"I")
 . S AGGDATAI(FILE,IENS,.07)=$$GET1^DIQ(9000003.1,AGGPLHIN_",",.18,"I")
 . S AGGDATA(FILE,IENS,.02)=$$GET1^DIQ(9000003.1,AGGPLHIN_",",.04,"E")
 . S AGGDATA(FILE,IENS,21)=$$GET1^DIQ(9000003.1,AGGPLHIN_",",.04,"E")
 ;
 I $G(AGGPMREL)="" S AGGPMREL=$$GET1^DIQ(FILE,IENS,.05,"I")
 I $G(AGGPMREL)'="",$P(^AUTTRLSH(AGGPMREL,0),U,1)="SELF" D
 . S AGGDATAI(9000003.1,AGGPLHIN_",",.18)=AGGPHEED
 ;
 I $D(AGGDATA) D FILE^DIE("","AGGDATA","ERROR")
 I $D(AGGDATAI) D FILE^DIE("I","AGGDATAI","ERROR")
 ;
DNE ;
 S RESULT=1_U_U_AGGPIIEN
 I $D(ERROR) S RESULT="-1"_U_$G(ERROR("DIERR",1,"TEXT",1))_U
 S II=II+1,@DATA@(II)=RESULT_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 ;
 ; Set last date updated and updated by
 I $P(RESULT,U,1)=1 D
 . S AGGDATAI(9000001,MBDFN_",",.03)=DT,AGGDATAI(9000001,MBDFN_",",.12)=DUZ
 . D FILE^DIE("I","AGGDATAI","ERROR")
 . D EDIT^AGGEXPRT(MBDFN)
 ;
 S NAME=""
 F  S NAME=$O(^AGG(9009068.3,AGIEN,10,"AC",NAME)) Q:NAME=""  K @NAME
 K AGGDATA,AGGDATAI,ERROR,AGGPMREL
 Q
 ;
INIT(DATA,TRANSTYP,AGGPLIEN) ;EP -- AGG POLICY MEMBER TRIGGER
 NEW UID,II,HDR,SOURCE,VALUE,TYPE,ABLE,CLEAR,HELP,VISIBLE
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGPMTRG",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 SOURCE="AGGPMREL",VALUE="",TYPE="T",ABLE="Y",CLEAR="",HELP="",VISIBLE=$S(TRANSTYP="A":"",1:"N"),REQ=$S(VISIBLE="":"R",1:"") D UP
 S SOURCE="AGGPMREL",VALUE="",TYPE="T",ABLE="Y",CLEAR="",HELP="",VISIBLE="",REQ="R" D UP
 S SOURCE="AGGPMPCD",VALUE="",TYPE="X",ABLE="Y",CLEAR="",HELP="",REQ="",VISIBLE="" D UP
 S SOURCE="AGGPICCF",VALUE="",TYPE="C",ABLE="Y",CLEAR="",HELP="",REQ="",VISIBLE="" D UP
 S SOURCE="AGGPICRD",VALUE="",TYPE="D",ABLE="Y",CLEAR="",HELP="",REQ="",VISIBLE="" D UP
 S SOURCE="AGGPMNUM",TYPE="X",ABLE="Y",CLEAR="",HELP="",REQ="",VISIBLE="" D  D UP
 . S VALUE=$$GET1^DIQ(9000003.1,AGGPLIEN_",",.04,"E")
 ;S SOURCE="AGGPHESD",TYPE="D",ABLE="Y",CLEAR="",HELP="",REQ=$S(TRANSTYP="A":"O",1:"R"),VISIBLE=$S(TRANSTYP="A":"N",1:"") D  D UP
 S SOURCE="AGGPHESD",TYPE="D",ABLE=$S(TRANSTYP="A":"N",1:"Y"),CLEAR="",HELP="",REQ=$S(TRANSTYP="A":"O",1:"R"),VISIBLE="" D  D UP
 . S VALUE=""
 . I TRANSTYP="A" S VALUE=$$FMTE^AGGUL1($$GET1^DIQ(9000003.1,AGGPLIEN_",",.17,"I"))
 ;S SOURCE="AGGPHEED",TYPE="D",ABLE="Y",CLEAR="",HELP="",REQ="",VISIBLE=$S(TRANSTYP="A":"N",1:"") D  D UP
 S SOURCE="AGGPHEED",TYPE="D",ABLE=$S(TRANSTYP="A":"N",1:"Y"),CLEAR="",HELP="",REQ="",VISIBLE="" D  D UP
 . S VALUE=""
 . I TRANSTYP="A" S VALUE=$$FMTE^AGGUL1($$GET1^DIQ(9000003.1,AGGPLIEN_",",.18,"I"))
 S SOURCE="AGGPMPCP",VALUE="",TYPE="X",ABLE="Y",CLEAR="",HELP="",REQ="",VISIBLE="" D UP
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
HDR ;
 S HDR="T00008SOURCE^T00001CODE_TYPE^T01024PARMS^T00001ABLE_FLAG^T00100CLEAR_FIELDS^T00200HELP_TEXT^T00001REQ_OPT^T00001VISIBLE"
 Q
 ;
UP ;
 S II=II+1,@DATA@(II)=SOURCE_U_TYPE_U_VALUE_U_ABLE_U_$G(CLEAR)_U_HELP_U_$G(REQ)_U_$G(VISIBLE)_$C(30)
 Q
 ;
MBTR(DATA,MBDFN) ;EP -- AGG MEMBER TRIGGER
 NEW UID,II,HDR,SOURCE,VALUE,TYPE,ABLE,CLEAR,HELP
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGMBTRG",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 SOURCE="MBDFN",VALUE=MBDFN,TYPE="N",ABLE="Y",CLEAR="AGGPLMNM;AGGPMHRN",HELP="",REQ="",VISIBLE="" D UP
 S SOURCE="AGGPLMNM",VALUE=$P(^DPT(MBDFN,0),U,1),TYPE="X",ABLE="Y",CLEAR="",HELP="",REQ="",VISIBLE="" D UP
 S SOURCE="AGGPMHRN",VALUE=$$HRN^AGGUL1(MBDFN),TYPE="X",ABLE="Y",CLEAR="",HELP="",REQ="",VISIBLE="" D UP
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
DATE(DATA,AGGPLIEN) ;EP -- AGG HOLDER DATES
 NEW UID,II,HDR
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGPHDATE",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^AGGWTRIG D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S HDR="D00015AGGPHESD^D00015AGGPHEED"
 S @DATA@(II)=HDR_$C(30)
 S AGGPHESD=$$FMTE^AGGUL1($$GET1^DIQ(9000003.1,AGGPLIEN_",",.17,"I"))
 S AGGPHEED=$$FMTE^AGGUL1($$GET1^DIQ(9000003.1,AGGPLIEN_",",.18,"I"))
 S II=II+1,@DATA@(II)=AGGPHESD_U_AGGPHEED_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 Q