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

AGGPTPVT.m

Go to the documentation of this file.
AGGPTPVT ;VNGT/HS/ALA-Private Insurance ; 15 Jul 2010  3:33 PM
 ;;1.0;PATIENT REGISTRATION GUI;;Nov 15, 2010
 ;
 ;
BLD(DATA,DFN,PIIEN,IINS) ; EP -- AGG BUILD PRIVATE INS
 ; Input Parameters
 ;   DFN   - Patient IEN
 ;   PIIEN - Record IEN
 ;   IINS  - Insurer IEN
 ;
 NEW UID,II,AGIEN,AGCN,AGDATA,FLD,TYPE,CODE,DEXEC,ARRAY,AN,DQTY,VAL,VALUE,HEADR,HDATA,FILE,FL,FD
 NEW VHD,J,K,LEN,LG,LN,ECHR,HDR,SECFILE,SECFLD,RET,VAL1,VAL2,IENS,SIENS,PHIEN,DEF,AGGPEC,AGGPINUM
 NEW AGGPIMBN
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGWDISP",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 DEF="Insurance Edit"
 S AGIEN=$O(^AGG(9009068.3,"B",DEF,""))
 I AGIEN=0 S BMXSEC="RPC Failed: Passed in window name "_DEF_" not found" Q
 ;
 S FILE=$P(^AGG(9009068.3,AGIEN,0),U,2),SECFILE=$P(^AGG(9009068.3,AGIEN,0),U,14)
 ;
 I $G(PIIEN)'="" S PHIEN=$P($G(^AUPNPRVT(DFN,11,PIIEN,0)),U,8)
 I $G(IINS)'="" S AGGIINS=IINS
 I $G(IINS)="" S AGGIINS=$P($G(^AUPNPRVT(DFN,11,PIIEN,0)),U,1)
 ;
 NEW DA,IENS
 I $G(PIIEN)'="" S DA(1)=DFN,DA=PIIEN,IENS=$$IENS^DILF(.DA)
 K DA
 I $G(PHIEN)'="" S DA=PHIEN,SIENS=$$IENS^DILF(.DA)
 ;
 S HEADR="",HDATA=""
 S AGCN=0
 F  S AGCN=$O(^AGG(9009068.3,AGIEN,10,AGCN)) Q:'AGCN  D
 . I $P(^AGG(9009068.3,AGIEN,10,AGCN,0),U,11)'="" Q
 . S AGDATA=$G(^AGG(9009068.3,AGIEN,10,AGCN,0))
 . S FLD=$P($G(^AGG(9009068.3,AGIEN,10,AGCN,3)),U,1),SECFLD=$P($G(^AGG(9009068.3,AGIEN,10,AGCN,3)),U,7)
 . S RET=$P($G(^AGG(9009068.3,AGIEN,10,AGCN,3)),U,2)
 . S TYPE=$P($G(^AGG(9009068.3,AGIEN,10,AGCN,1)),U,1)
 . S CODE=$P(AGDATA,U,7),HDR=$P(AGDATA,U,2)
 . S DEXEC=$G(^AGG(9009068.3,AGIEN,10,AGCN,8))
 . I TYPE="M" S VALUE=""
 . ;
 . I TYPE="T" D
 .. I DEXEC'="" D  Q
 ... S VAL=""
 ... I DEXEC'["DQTY" X DEXEC Q
 ... S DQTY="I" X DEXEC S VAL=VALUE_$C(28)
 ... S DQTY="E" X DEXEC S VALUE=VAL_VALUE
 .. I $G(IENS)="",$G(SIENS)="" S VALUE="" Q
 .. I FLD'="" S VALUE=$$GET1^DIQ(FILE,IENS,FLD,"I")_$C(28)_$$GET1^DIQ(FILE,IENS,FLD,"E") Q
 .. S VALUE=$$GET1^DIQ(SECFILE,SIENS,SECFLD,"I")_$C(28)_$$GET1^DIQ(SECFILE,SIENS,SECFLD,"E")
 . I (TYPE="C")!(TYPE="K") D
 .. I DEXEC'="" D  Q
 ... S VAL=""
 ... I DEXEC'["DQTY" X DEXEC Q
 ... S DQTY="I" X DEXEC S VAL=VALUE_$C(28)
 ... S DQTY="E" X DEXEC S VALUE=VAL_VALUE
 .. I $G(IENS)="",$G(SIENS)="" S VALUE="" Q
 .. I FLD'="" D  Q
 ... S VAL1=$$GET1^DIQ(FILE,IENS,FLD,"I") I VAL1="" Q
 ... S VAL2=$O(^AGG(9009068.3,AGIEN,10,AGCN,5,"C",VAL1,"")) I VAL2="" Q
 ... S VAL2=$P(^AGG(9009068.3,AGIEN,10,AGCN,5,VAL2,0),U,1)
 ... S VALUE=VAL1_$C(28)_VAL2
 .. S VAL1=$$GET1^DIQ(SECFILE,SIENS,SECFLD,"I") I VAL1="" Q
 .. S VAL2=$O(^AGG(9009068.3,AGIEN,10,AGCN,5,"C",VAL1,"")) I VAL2="" Q
 .. S VAL2=$P(^AGG(9009068.3,AGIEN,10,AGCN,5,VAL2,0),U,1)
 .. S VALUE=VAL1_$C(28)_VAL2
 . I TYPE="X"!(TYPE="N") D
 .. NEW TYPE
 .. I DEXEC'="" X DEXEC Q
 .. I FLD'="",FLD=.001 S VALUE=$G(PIIEN) Q
 .. I SECFLD'="",SECFLD=.001 S VALUE=$G(PHIEN) Q
 .. I $G(IENS)="",$G(SIENS)="" S VALUE="" Q
 .. I FLD'="",RET="I" D  Q
 ... S VALUE=$$GET1^DIQ(FILE,IENS,FLD,"I") Q
 ... S VALUE=$$GET1^DIQ(SECFILE,SIENS,SECFLD,"I")
 .. I $G(IENS)="",$G(SIENS)="" S VALUE="" Q
 .. I FLD'="" S VALUE=$$GET1^DIQ(FILE,IENS,FLD,"E") Q
 .. S VALUE=$$GET1^DIQ(SECFILE,SIENS,SECFLD,"E")
 . I TYPE="D" D
 .. I DEXEC'="" X DEXEC Q
 .. I $G(IENS)="",$G(SIENS)="" S VALUE="" Q
 .. I FLD'="" S VALUE=$$GET1^DIQ(FILE,IENS,FLD,"I"),VALUE=$$FMTE^AGGUL1(VALUE) Q
 .. S VALUE=$$GET1^DIQ(SECFILE,SIENS,SECFLD,"I"),VALUE=$$FMTE^AGGUL1(VALUE)
 . I TYPE="W" D
 .. NEW FL,FD
 .. K ARRAY S VALUE=""
 .. I DEXEC'="" X DEXEC
 .. I $G(IENS)="",$G(SIENS)="" S VALUE="" Q
 .. I DEXEC="" D
 ... I FLD'="" D GETS^DIQ(FILE,IENS,FLD,"E","ARRAY") Q
 ... D GETS^DIQ(SECFILE,SIENS,SECFLD,"E","ARRAY")
 .. S FL=$O(ARRAY("")) I FL="" Q
 .. S FD=$O(ARRAY(FL,IENS,"")) I FD="" Q  ;** look at this one **
 .. S AN=0,TXT=ARRAY(FL,IENS,FD,"E") I TXT="" Q
 .. K @TXT@("E")
 .. F  S AN=$O(@TXT@(AN)) Q:AN=""  S VALUE=VALUE_@TXT@(AN)_$C(10)
 . I HDR["AGGPINUM" S AGGPINUM=VALUE
 . I HDR["AGGPIMBN" S AGGPIMBN=VALUE,AGGPEC=$L(HEADR,"^")
 . I CODE="AGGPINUM",$G(AGGPIMBN)="" S $P(HDATA,U,AGGPEC)=AGGPINUM
 . S HEADR=HEADR_HDR_"^"
 . S HDATA=HDATA_$G(VALUE)_"^",VALUE=""
 S HEADR=$$TKO^AGGUL1(HEADR,"^"),HDATA=$$TKO^AGGUL1(HDATA,"^")
 S @DATA@(II)=HEADR_$C(30)
 I $$STRIP^XLFSTR(HDATA,$C(28)_"^")'="" S II=II+1,@DATA@(II)=HDATA_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 K AGGIINS,I,INS,IDATA,ST,STATUS,TYP
 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
 ;
INS(AGGIINS,PEC) ;EP
 NEW CTY,ST,ZIP
 I $G(AGGIINS)="" Q ""
 D GET^AGGINSUR(.IDATA,AGGIINS)
 I $G(PEC)="" D
 . S CTY=$P($G(@IDATA@(1)),U,4),ST=$P($G(@IDATA@(1)),U,5),ZIP=$P($G(@IDATA@(1)),U,6)
 . S VALUE=CTY_", "_ST_" "_ZIP
 I $G(PEC)'="" S VALUE=$P($G(@IDATA@(1)),U,PEC)
 K @IDATA
 Q VALUE