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

AGGUPPVT.m

Go to the documentation of this file.
AGGUPPVT ;VNGT/HS/ALA-Update Private Insurance ; 28 Jun 2010  12:11 PM
 ;;1.0;PATIENT REGISTRATION GUI;**1**;Nov 15, 2010
 ;
UPD(DATA,PROC,DFN,AGGPIIEN,AGGPLIEN,PARMS) ; EP - AGG UPDATE PRIVATE INSUR
 ; Input
 ;   PROC      - 'A' to add, 'E' to edit, 'D' to delete
 ;   DFN       - Patient IEN
 ;   AGGPIIEN  - Insurer IEN
 ;   AGGPLIEN  - Policy Holder IEN
 ;   PARMS     - Parameters
 NEW UID,II,AGIEN,ERROR,DEF,BN,LIST,FILE,SECFILE,BQ,AGGDATA,AGGDATAI,PHDATA
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGUPPVT",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^I00010AGGPLHIN"_$C(30)
 ;
 S DEF="Insurance Edit"
 ;
 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
 ;
 S AGIEN=$O(^AGG(9009068.3,"B",DEF,""))
 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),SECFILE=$P(^AGG(9009068.3,AGIEN,0),U,14)
 ;
 ;if deleting a Private Insurance
 I $G(PROC)="D" D  G DONE
 . S AGGUPD(FILE,IENS,.01)="@"
 . D FILE^DIE("","AGGUPD","ERROR")
 ;if adding a new Private Insurance
 I $G(^AUPNPRVT(DFN,0))="" D
 . NEW DIC,X,DINUM
 . S DIC="^AUPNPRVT(",DLAYGO=9000006,DIC(0)="L",X=DFN,DINUM=X
 . K DO,DD D FILE^DICN
 ;
 D PARS
 I $G(PROC)="A" D
 . NEW DIC,X,Y
 . I $G(AGGPIIEN)="" D
 .. I $G(^AUPNPRVT(DFN,11,0))="" S ^AUPNPRVT(DFN,11,0)="^9000006.11P^^"
 .. S DIC="^AUPNPRVT("_DFN_",11,"
 .. S DIC("P")=$P(^DD(9000006,1101,0),U,2),DIC(0)="L",DA(1)=DFN,X=AGGPIINS
 .. D FILE^DICN S AGGPIIEN=+Y
 . I $G(AGGPLIEN)="" D
 .. NEW SCREEN,N,QFL
 .. S SCREEN="I $P(^(0),U,3)=AGGPIINS",PHDATA=$NA(^TMP("DILIST",$J))
 .. D FIND^DIC(9000003.1,"",".01;.18","PX",AGGPIHLN,"","",SCREEN,"","","ERROR")
 .. S N=0,QFL=0
 .. F  S N=$O(@PHDATA@(N)) Q:'N  D  Q:QFL
 ... I $P(@PHDATA@(N,0),U,4)="" S AGGPLIEN=$P(@PHDATA@(N,0),U,1),QFL=1
 .. K @PHDATA
 .. I AGGPLIEN="" D
 ... NEW DIC,DLAYGO,X,Y
 ... S DIC="^AUPN3PPH(",X=AGGPIHLN,DLAYGO=9000003.1,DIC(0)="L"
 ... K DO,DD D FILE^DICN S AGGPLIEN=+Y
 .. NEW DA,IENS
 .. S DA(1)=DFN,DA=AGGPIIEN,IENS=$$IENS^DILF(.DA)
 .. S AGGDATAI(FILE,IENS,.08)=AGGPLIEN
 ;
 F BQ=1:1:$L(PARMS,$C(28)) D  Q:$G(BMXSEC)'=""
 . NEW DA,IENS,PDATA,NAME,PFIEN,FIELD,SECFLD,EXEC,PTYP
 . S PDATA=$P(PARMS,$C(28),BQ) Q:PDATA=""
 . S NAME=$P(PDATA,"=",1)
 . I NAME="AGGPTDFN",@NAME="" Q
 . S PFIEN=$O(^AGG(9009068.3,AGIEN,10,"AC",NAME,""))
 . I PFIEN="" S BMXSEC=NAME_" not a valid parameter for this update" 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)=DFN,DA=AGGPIIEN,IENS=$$IENS^DILF(.DA)
 ... S AGGDATAI(FILE,IENS,FIELD)=@NAME
 .. I SECFLD'="" D
 ... S DA=AGGPLIEN,IENS=$$IENS^DILF(.DA)
 ... S AGGDATAI(SECFILE,IENS,SECFLD)=@NAME
 . I FIELD'="" D
 .. S DA(1)=DFN,DA=AGGPIIEN,IENS=$$IENS^DILF(.DA)
 .. S AGGDATA(FILE,IENS,FIELD)=@NAME
 . I SECFLD'="" D
 .. S DA=AGGPLIEN,IENS=$$IENS^DILF(.DA)
 .. S AGGDATA(SECFILE,IENS,SECFLD)=@NAME
 ;
 I $D(AGGDATA) D FILE^DIE("","AGGDATA","ERROR")
 I $D(AGGDATAI) D FILE^DIE("I","AGGDATAI","ERROR")
 D UPOL
 ;
DONE ;
 S RESULT=1_U_U_AGGPIIEN_U_AGGPLIEN
 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)
 ;
 I $P(RESULT,U,1)=1 D
 . S AGGDATAI(9000001,DFN_",",.03)=DT,AGGDATAI(9000001,DFN_",",.12)=DUZ
 . D FILE^DIE("","AGGDATAI","ERROR")
 . D EDIT^AGGEXPRT(DFN)
 ;
 S NAME=""
 F  S NAME=$O(^AGG(9009068.3,AGIEN,10,"AC",NAME)) Q:NAME=""  K @NAME
 K PROC,DFN,AGGPIIEN,AGGPLIEN
 Q
 ;
PARS ;
 I $G(PARMS)="" Q
 F BQ=1:1:$L(PARMS,$C(28)) D  Q:$G(BMXSEC)'=""
 . S PDATA=$P(PARMS,$C(28),BQ) Q:PDATA=""
 . S NAME=$P(PDATA,"=",1),VALUE=$P(PDATA,"=",2,99)
 . S PFIEN=$O(^AGG(9009068.3,AGIEN,10,"AC",NAME,""))
 . I PFIEN="" S BMXSEC=NAME_" not a valid parameter for this update" Q
 . S PTYP=$P($G(^AGG(9009068.3,AGIEN,10,PFIEN,1)),U,1)
 . I PTYP="D" S VALUE=$$DATE^AGGUL1(VALUE)
 . I PTYP="C"!(PTYP="K") D
 .. I VALUE="" Q
 .. S CHIEN=$O(^AGG(9009068.3,AGIEN,10,PFIEN,5,"B",VALUE,"")) I CHIEN="" Q
 .. S VALUE=$P(^AGG(9009068.3,AGIEN,10,PFIEN,5,CHIEN,0),U,2)
 . I PTYP="W" D  Q
 .. F AGI=1:1  S AGJ=$P(VALUE,$C(10),AGI) Q:AGJ=""  D
 ... S AGWP(AGI,0)=$$CTRL^AGGUL1(AGJ)
 . S @NAME=VALUE
 Q
 ;
UPOL ; EP - Update Policy Members
 NEW IN,MBDFN
 S MBDFN=""
 F  S MBDFN=$O(^AUPNPRVT("C",AGGPLIEN,MBDFN)) Q:MBDFN=""  D
 . S IN=""
 . F  S IN=$O(^AUPNPRVT("C",AGGPLIEN,MBDFN,IN))  Q:IN=""  D
 .. I $P(^AUPNPRVT(MBDFN,11,IN,0),U,1)'=AGGPIINS Q
 .. NEW DA,IENS
 .. S DA(1)=MBDFN,DA=IN,IENS=$$IENS^DILF(.DA)
 .. I $$GET1^DIQ(9000006.11,IENS,.05,"E")="SELF" S AGGDATA(9000006.11,IENS,.06)=AGGPHESD,AGGDATA(9000006.11,IENS,.07)=AGGPHEED
 .. I $$GET1^DIQ(9000006.11,IENS,.06,"I")="" S AGGDATA(9000006.11,IENS,.06)=AGGPHESD
 .. I $$GET1^DIQ(9000006.11,IENS,.07,"I")="" S AGGDATA(9000006.11,IENS,.07)=AGGPHEED
 .. I $$GET1^DIQ(9000006.11,IENS,21,"E")="" S AGGDATA(9000006.11,IENS,21)=$$GET1^DIQ(9000003.1,AGGPLIEN_",",.04,"E")
 I $D(AGGDATA) D FILE^DIE("","AGGDATA","ERROR")
 K AGGPHESD,AGGPHEED
 Q