AGEVINU ; cmi/flag/maw - AGEV Update Insurance Information ;
;;7.1;PATIENT REGISTRATION;;AUG 25,2005
;
MCD(AGEVPAT) ;EP - file medicaid data
S (AGEVMCDE,AGEVMCME)=""
I AGEVIID="" S AGEVERCD="NOMCDN" X AGEVERR Q
I AGEVPED="" S AGEVERCD="NOMCDED" X AGEVERR Q
S AGEVMCD=0
F S AGEVMCD=$O(^AUPNMCD("B",AGEVPAT,AGEVMCD)) Q:AGEVMCD="" D
. I $P(^AUPNMCD(AGEVMCD,0),U,3)=AGEVIID S AGEVMCDE=AGEVMCD Q
.Q
I AGEVMCDE="" D Q
. S DIC="^AUPNMCD(",DIC(0)="L",DLAYGO=9000005,X=AGEVPAT
. S DIC("DR")=".02////"_AGEVICN_";.03///"_AGEVIID_";.04///"_AGEVMST
. S DIC("DR")=DIC("DR")_";.05///"_AGEVNOI
. KILL DD,DO
. D FILE^DICN
. I Y<0 S AGEVERCD="NOMCD" X AGEVERR Q
. S AGEVMCDE=+Y
. S DIC="^AUPNMCD("_AGEVMCDE_",11,",DIC("P")=$P(^DD(9000004,1101,0),U,2)
. S DIC(0)="L",DA(1)=AGEVMCDE,X=AGEVPED,DIC("DR")=".02///"_AGEVPEXD
. S DIC("DR")=DIC("DR")_";.03///"_AGEVCT
. D ^DIC
. I Y<0 S AGEVERCD="NOMCDM" X AGEVERR Q
.Q
S AGEVMCM=0
F S AGEVMCM=$O(^AUPNMCD(AGEVMCDE,11,AGEVMCM)) Q:AGEVMCM="" D
. S AGEVDATA=$G(^AUPNMCD(AGEVMCDE,11,AGEVMCM,0))
. I AGEVMCM=AGEVPED,$P(AGEVDATA,U,3)=AGEVCT S AGEVMCME=AGEVMCM Q
.Q
Q:'$D(^AUPNMCR(AGEVMCDE,0))
I AGEVMCME="" D Q
. S DIC="^AUPNMCD("_AGEVMCDE_",11,",DIC("P")=$P(^DD(9000004,1101,0),U,2)
. S DIC(0)="L",DA(1)=AGEVMCDE,X=AGEVPED,DIC("DR")=".02///"_AGEVPEXD
. S DIC("DR")=DIC("DR")_";.03///"_AGEVCT
. D ^DIC
. I Y<0 S AGEVERCD="NOMCDM" X AGEVERR Q
.Q
S DIE="^AUPNMCD("_AGEVMCDE_",11,",DA(1)=AGEVMCDE,DA=AGEVMCME
S DR=".02///"_AGEVPEXD_";.03///"_AGEVCT
D ^DIE
I $D(Y) S AGEVERCD="NOUPMCDM" X AGEVERR Q
Q
;
MCR(AGEVPAT) ;EP - file medicare data
S AGEVMCRE=""
I AGEVIID="" S AGEVERCD="NOMCRN" X AGEVERR Q
I AGEVPED="" S AGEVERCD="NOMCRED" X AGEVERR Q
I '$D(^AUPNMCR(AGEVPAT,0)) D Q
. S DIC="^AUPNMCR(",DLAYGO=9000003,X=AGEVPAT,DINUM=X,DIC(0)="L"
. S DIC("DR")=".02////"_AGEVICN_";.03///"_AGEVIID_";.04///"_AGEVSUF
. KILL DD,DO
. D FILE^DICN
. K DINUM
. I Y<0 S AGEVERCD="NOMCR" X AGEVERR Q
. S DIC="^AUPNMCR("_AGEVPAT_",11,",DIC("P")=$P(^DD(9000003,1101,0),U,2)
. S DIC(0)="L",DA(1)=AGEVPAT,X=AGEVPED
. S DIC("DR")=".02///"_AGEVPEXD_";.03///"_AGEVCT
. D ^DIC
. I Y<0 S AGEVERCD="NOMCRM" X AGEVERR Q
.Q
S DIE="^AUPNMCR(",DA=AGEVPAT,DR=".03///"_AGEVIID_";.04///"_AGEVGN
S DR=DR_";2101///"_AGEVNOI
D ^DIE
I $D(Y) S AGEVERCD="NOUPMCR" X AGEVERR Q
S AGEVMCR=0
F S AGEVMCR=$O(^AUPNMCR(AGEVPAT,11,AGEVMCR)) Q:AGEVMCR="" D
. S AGEVDATA=$G(^AUPNMCR(AGEVPAT,11,AGEVMCR,0))
. I $P(AGEVDATA,U)=AGEVPED,$P(AGEVDATA,U,3)=AGEVCT S AGEVMCRE=AGEVMCR Q
.Q
Q:'$D(^AUPNMCR(AGEVPAT,0))
I AGEVMCRE="" D Q
. S DIC="^AUPNMCR("_AGEVPAT_",11,",DIC("P")=$P(^DD(9000003,1101,0),U,2)
. S DIC(0)="L",DA(1)=AGEVPAT,X=AGEVPED
. S DIC("DR")=".02///"_AGEVPEXD_";.03///"_AGEVCT
. D ^DIC
. I Y<0 S AGEVERCD="NOMCRM" X AGEVERR Q
.Q
S DIE="^AUPNMCR("_DFN_",11,",DA(1)=AGEVPAT,DA=AGEVMCRE
S DR=".02///"_AGEVPEXD
D ^DIE
I $D(Y) S AGEVERCD="NOUPMCRM" X AGEVERR Q
Q
;
PI(AGEVPAT) ;EP - file private insurance data
S AGEVPH=""
I AGEVICN="" S AGEVERCD="NOICN" X AGEVERR Q
Q:AGEVIID=""
S AGEVMA=0
F S AGEVMA=$O(^AUPN3PPH("D",AGEVIID,AGEVMA)) Q:AGEVMA="" D
. I $P(^AUPN3PPH(AGEVMA,0),U,3)=AGEVICNI S AGEVPH=AGEVMA Q
.Q
I AGEVPH="" D Q:$D(AGEVERCD)
. Q:AGEVNOI=""
. S DIC="^AUPN3PPH(",X=AGEVNOI,DLAYGO=9000003.1,DIC(0)="L"
. S DIC("DR")=".03////"_AGEVICN_";.04///"_AGEVIID
. S DIC("DR")=DIC("DR")_";.09///"_AGEVSTR
. S DIC("DR")=DIC("DR")_";.11///"_AGEVCTY_";.12///"_AGEVST
. S DIC("DR")=DIC("DR")_";.13///"_AGEVZP_";.17///"_AGEVPED
. S DIC("DR")=DIC("DR")_";.18///"_AGEVPEXD
. KILL DD,D0,DO
. D FILE^DICN
. I Y<0 S AGEVERCD="NO3PPH" X AGEVERR Q
. S AGEVPH=+Y
.Q
Q:AGEVNOI=""
I $D(^AUPNPRVT(AGEVPAT,0)) D UPI^AGEVINU Q
S DIC="^AUPNPRVT(",DLAYGO=9000006,DIC(0)="L",X=AGEVPAT,DINUM=X
KILL DD,DO
D FILE^DICN
KILL DINUM
I Y<0 S AGEVERCD="NOPIE" X AGEVERR Q
S DIC="^AUPNPRVT("_AGEVPAT_",11,"
S DIC("P")=$P(^DD(9000006,1101,0),U,2),DIC(0)="L",DA(1)=AGEVPAT
S X="`"_AGEVICN,DIC("DR")=".02///"_AGEVIID_";.04///"_AGEVNOI
S DIC("DR")=DIC("DR")_";.06///"_AGEVPED_";.07///"_AGEVPEXD
S DIC("DR")=DIC("DR")_";.08////"_AGEVPH
D ^DIC
I Y<0 S AGEVERCD="NOPIEM" X AGEVERR Q
Q
;
UPI ;EP -- update private insurance
S AGEVPIMM=""
S AGEVPIM=0
F S AGEVPIM=$O(^AUPNPRVT(AGEVPAT,11,AGEVPIM)) Q:AGEVPIM="" D
. S AGEVDATA=$G(^AUPNPRVT(AGEVPAT,11,AGEVPIM,0))
. I $P(AGEVDATA,U)=AGEVICNI,$P(AGEVDATA,U,6)=AGEVPED,$P(AGEVDATA,U,8)=AGEVPH S AGEVPIMM=AGEVPIM Q
.Q
I AGEVPIMM="" D Q
. S DIC="^AUPNPRVT("_AGEVPAT_",11,"
. S DIC("P")=$P(^DD(9000006,1101,0),U,2),DIC(0)="L",DA(1)=AGEVPAT
. S X="`"_AGEVICN,DIC("DR")=".02///"_AGEVIID_";.04///"_AGEVNOI
. S DIC("DR")=DIC("DR")_";.06///"_AGEVPED_";.07///"_AGEVPEXD
. S DIC("DR")=DIC("DR")_";.08///"_AGEVPH
. D ^DIC
. I Y<0 S AGEVERCD="NOPIEM" X AGEVERR Q
.Q
S DIE="^AUPNPRVT("_AGEVPAT_",11,"
S DIC("P")=$P(^DD(9000006,1101,0),U,2),DA=AGEVPIMM,DA(1)=AGEVPAT
S DR=".02///"_AGEVIID_";.04///"_AGEVNOI
S DR=DR_";.07///"_AGEVPEXD
D ^DIE
I $D(Y) S AGEVERCD="NOUPIEM" X AGEVERR Q
Q
;
EOJ ;-- kill variables
D EN^XBVK("AGEV") ;should I use this instead
K AGEVICN,AGEVGN,AGEVGNM,AGEVPED,AGEVPEXD,AGEVNOI,AGEVIDOB,AGEVSTR
K AGEVCTY,AGEVST,AGEVZP,AGEVISX,AGEVIID,AGEVIT,AGEVMCD,AGEVMCDE,AGEVMCM
K AGEVMCME,AGEVMCR,AGEVMCRE,AGEVMA,AGEVPH,AGEVICNI
Q
AGEVINU ; cmi/flag/maw - AGEV Update Insurance Information ;
+1 ;;7.1;PATIENT REGISTRATION;;AUG 25,2005
+2 ;
MCD(AGEVPAT) ;EP - file medicaid data
+1 SET (AGEVMCDE,AGEVMCME)=""
+2 IF AGEVIID=""
SET AGEVERCD="NOMCDN"
XECUTE AGEVERR
QUIT
+3 IF AGEVPED=""
SET AGEVERCD="NOMCDED"
XECUTE AGEVERR
QUIT
+4 SET AGEVMCD=0
+5 FOR
SET AGEVMCD=$ORDER(^AUPNMCD("B",AGEVPAT,AGEVMCD))
IF AGEVMCD=""
QUIT
Begin DoDot:1
+6 IF $PIECE(^AUPNMCD(AGEVMCD,0),U,3)=AGEVIID
SET AGEVMCDE=AGEVMCD
QUIT
+7 QUIT
End DoDot:1
+8 IF AGEVMCDE=""
Begin DoDot:1
+9 SET DIC="^AUPNMCD("
SET DIC(0)="L"
SET DLAYGO=9000005
SET X=AGEVPAT
+10 SET DIC("DR")=".02////"_AGEVICN_";.03///"_AGEVIID_";.04///"_AGEVMST
+11 SET DIC("DR")=DIC("DR")_";.05///"_AGEVNOI
+12 KILL DD,DO
+13 DO FILE^DICN
+14 IF Y<0
SET AGEVERCD="NOMCD"
XECUTE AGEVERR
QUIT
+15 SET AGEVMCDE=+Y
+16 SET DIC="^AUPNMCD("_AGEVMCDE_",11,"
SET DIC("P")=$PIECE(^DD(9000004,1101,0),U,2)
+17 SET DIC(0)="L"
SET DA(1)=AGEVMCDE
SET X=AGEVPED
SET DIC("DR")=".02///"_AGEVPEXD
+18 SET DIC("DR")=DIC("DR")_";.03///"_AGEVCT
+19 DO ^DIC
+20 IF Y<0
SET AGEVERCD="NOMCDM"
XECUTE AGEVERR
QUIT
+21 QUIT
End DoDot:1
QUIT
+22 SET AGEVMCM=0
+23 FOR
SET AGEVMCM=$ORDER(^AUPNMCD(AGEVMCDE,11,AGEVMCM))
IF AGEVMCM=""
QUIT
Begin DoDot:1
+24 SET AGEVDATA=$GET(^AUPNMCD(AGEVMCDE,11,AGEVMCM,0))
+25 IF AGEVMCM=AGEVPED
IF $PIECE(AGEVDATA,U,3)=AGEVCT
SET AGEVMCME=AGEVMCM
QUIT
+26 QUIT
End DoDot:1
+27 IF '$DATA(^AUPNMCR(AGEVMCDE,0))
QUIT
+28 IF AGEVMCME=""
Begin DoDot:1
+29 SET DIC="^AUPNMCD("_AGEVMCDE_",11,"
SET DIC("P")=$PIECE(^DD(9000004,1101,0),U,2)
+30 SET DIC(0)="L"
SET DA(1)=AGEVMCDE
SET X=AGEVPED
SET DIC("DR")=".02///"_AGEVPEXD
+31 SET DIC("DR")=DIC("DR")_";.03///"_AGEVCT
+32 DO ^DIC
+33 IF Y<0
SET AGEVERCD="NOMCDM"
XECUTE AGEVERR
QUIT
+34 QUIT
End DoDot:1
QUIT
+35 SET DIE="^AUPNMCD("_AGEVMCDE_",11,"
SET DA(1)=AGEVMCDE
SET DA=AGEVMCME
+36 SET DR=".02///"_AGEVPEXD_";.03///"_AGEVCT
+37 DO ^DIE
+38 IF $DATA(Y)
SET AGEVERCD="NOUPMCDM"
XECUTE AGEVERR
QUIT
+39 QUIT
+40 ;
MCR(AGEVPAT) ;EP - file medicare data
+1 SET AGEVMCRE=""
+2 IF AGEVIID=""
SET AGEVERCD="NOMCRN"
XECUTE AGEVERR
QUIT
+3 IF AGEVPED=""
SET AGEVERCD="NOMCRED"
XECUTE AGEVERR
QUIT
+4 IF '$DATA(^AUPNMCR(AGEVPAT,0))
Begin DoDot:1
+5 SET DIC="^AUPNMCR("
SET DLAYGO=9000003
SET X=AGEVPAT
SET DINUM=X
SET DIC(0)="L"
+6 SET DIC("DR")=".02////"_AGEVICN_";.03///"_AGEVIID_";.04///"_AGEVSUF
+7 KILL DD,DO
+8 DO FILE^DICN
+9 KILL DINUM
+10 IF Y<0
SET AGEVERCD="NOMCR"
XECUTE AGEVERR
QUIT
+11 SET DIC="^AUPNMCR("_AGEVPAT_",11,"
SET DIC("P")=$PIECE(^DD(9000003,1101,0),U,2)
+12 SET DIC(0)="L"
SET DA(1)=AGEVPAT
SET X=AGEVPED
+13 SET DIC("DR")=".02///"_AGEVPEXD_";.03///"_AGEVCT
+14 DO ^DIC
+15 IF Y<0
SET AGEVERCD="NOMCRM"
XECUTE AGEVERR
QUIT
+16 QUIT
End DoDot:1
QUIT
+17 SET DIE="^AUPNMCR("
SET DA=AGEVPAT
SET DR=".03///"_AGEVIID_";.04///"_AGEVGN
+18 SET DR=DR_";2101///"_AGEVNOI
+19 DO ^DIE
+20 IF $DATA(Y)
SET AGEVERCD="NOUPMCR"
XECUTE AGEVERR
QUIT
+21 SET AGEVMCR=0
+22 FOR
SET AGEVMCR=$ORDER(^AUPNMCR(AGEVPAT,11,AGEVMCR))
IF AGEVMCR=""
QUIT
Begin DoDot:1
+23 SET AGEVDATA=$GET(^AUPNMCR(AGEVPAT,11,AGEVMCR,0))
+24 IF $PIECE(AGEVDATA,U)=AGEVPED
IF $PIECE(AGEVDATA,U,3)=AGEVCT
SET AGEVMCRE=AGEVMCR
QUIT
+25 QUIT
End DoDot:1
+26 IF '$DATA(^AUPNMCR(AGEVPAT,0))
QUIT
+27 IF AGEVMCRE=""
Begin DoDot:1
+28 SET DIC="^AUPNMCR("_AGEVPAT_",11,"
SET DIC("P")=$PIECE(^DD(9000003,1101,0),U,2)
+29 SET DIC(0)="L"
SET DA(1)=AGEVPAT
SET X=AGEVPED
+30 SET DIC("DR")=".02///"_AGEVPEXD_";.03///"_AGEVCT
+31 DO ^DIC
+32 IF Y<0
SET AGEVERCD="NOMCRM"
XECUTE AGEVERR
QUIT
+33 QUIT
End DoDot:1
QUIT
+34 SET DIE="^AUPNMCR("_DFN_",11,"
SET DA(1)=AGEVPAT
SET DA=AGEVMCRE
+35 SET DR=".02///"_AGEVPEXD
+36 DO ^DIE
+37 IF $DATA(Y)
SET AGEVERCD="NOUPMCRM"
XECUTE AGEVERR
QUIT
+38 QUIT
+39 ;
PI(AGEVPAT) ;EP - file private insurance data
+1 SET AGEVPH=""
+2 IF AGEVICN=""
SET AGEVERCD="NOICN"
XECUTE AGEVERR
QUIT
+3 IF AGEVIID=""
QUIT
+4 SET AGEVMA=0
+5 FOR
SET AGEVMA=$ORDER(^AUPN3PPH("D",AGEVIID,AGEVMA))
IF AGEVMA=""
QUIT
Begin DoDot:1
+6 IF $PIECE(^AUPN3PPH(AGEVMA,0),U,3)=AGEVICNI
SET AGEVPH=AGEVMA
QUIT
+7 QUIT
End DoDot:1
+8 IF AGEVPH=""
Begin DoDot:1
+9 IF AGEVNOI=""
QUIT
+10 SET DIC="^AUPN3PPH("
SET X=AGEVNOI
SET DLAYGO=9000003.1
SET DIC(0)="L"
+11 SET DIC("DR")=".03////"_AGEVICN_";.04///"_AGEVIID
+12 SET DIC("DR")=DIC("DR")_";.09///"_AGEVSTR
+13 SET DIC("DR")=DIC("DR")_";.11///"_AGEVCTY_";.12///"_AGEVST
+14 SET DIC("DR")=DIC("DR")_";.13///"_AGEVZP_";.17///"_AGEVPED
+15 SET DIC("DR")=DIC("DR")_";.18///"_AGEVPEXD
+16 KILL DD,D0,DO
+17 DO FILE^DICN
+18 IF Y<0
SET AGEVERCD="NO3PPH"
XECUTE AGEVERR
QUIT
+19 SET AGEVPH=+Y
+20 QUIT
End DoDot:1
IF $DATA(AGEVERCD)
QUIT
+21 IF AGEVNOI=""
QUIT
+22 IF $DATA(^AUPNPRVT(AGEVPAT,0))
DO UPI^AGEVINU
QUIT
+23 SET DIC="^AUPNPRVT("
SET DLAYGO=9000006
SET DIC(0)="L"
SET X=AGEVPAT
SET DINUM=X
+24 KILL DD,DO
+25 DO FILE^DICN
+26 KILL DINUM
+27 IF Y<0
SET AGEVERCD="NOPIE"
XECUTE AGEVERR
QUIT
+28 SET DIC="^AUPNPRVT("_AGEVPAT_",11,"
+29 SET DIC("P")=$PIECE(^DD(9000006,1101,0),U,2)
SET DIC(0)="L"
SET DA(1)=AGEVPAT
+30 SET X="`"_AGEVICN
SET DIC("DR")=".02///"_AGEVIID_";.04///"_AGEVNOI
+31 SET DIC("DR")=DIC("DR")_";.06///"_AGEVPED_";.07///"_AGEVPEXD
+32 SET DIC("DR")=DIC("DR")_";.08////"_AGEVPH
+33 DO ^DIC
+34 IF Y<0
SET AGEVERCD="NOPIEM"
XECUTE AGEVERR
QUIT
+35 QUIT
+36 ;
UPI ;EP -- update private insurance
+1 SET AGEVPIMM=""
+2 SET AGEVPIM=0
+3 FOR
SET AGEVPIM=$ORDER(^AUPNPRVT(AGEVPAT,11,AGEVPIM))
IF AGEVPIM=""
QUIT
Begin DoDot:1
+4 SET AGEVDATA=$GET(^AUPNPRVT(AGEVPAT,11,AGEVPIM,0))
+5 IF $PIECE(AGEVDATA,U)=AGEVICNI
IF $PIECE(AGEVDATA,U,6)=AGEVPED
IF $PIECE(AGEVDATA,U,8)=AGEVPH
SET AGEVPIMM=AGEVPIM
QUIT
+6 QUIT
End DoDot:1
+7 IF AGEVPIMM=""
Begin DoDot:1
+8 SET DIC="^AUPNPRVT("_AGEVPAT_",11,"
+9 SET DIC("P")=$PIECE(^DD(9000006,1101,0),U,2)
SET DIC(0)="L"
SET DA(1)=AGEVPAT
+10 SET X="`"_AGEVICN
SET DIC("DR")=".02///"_AGEVIID_";.04///"_AGEVNOI
+11 SET DIC("DR")=DIC("DR")_";.06///"_AGEVPED_";.07///"_AGEVPEXD
+12 SET DIC("DR")=DIC("DR")_";.08///"_AGEVPH
+13 DO ^DIC
+14 IF Y<0
SET AGEVERCD="NOPIEM"
XECUTE AGEVERR
QUIT
+15 QUIT
End DoDot:1
QUIT
+16 SET DIE="^AUPNPRVT("_AGEVPAT_",11,"
+17 SET DIC("P")=$PIECE(^DD(9000006,1101,0),U,2)
SET DA=AGEVPIMM
SET DA(1)=AGEVPAT
+18 SET DR=".02///"_AGEVIID_";.04///"_AGEVNOI
+19 SET DR=DR_";.07///"_AGEVPEXD
+20 DO ^DIE
+21 IF $DATA(Y)
SET AGEVERCD="NOUPIEM"
XECUTE AGEVERR
QUIT
+22 QUIT
+23 ;
EOJ ;-- kill variables
+1 ;should I use this instead
DO EN^XBVK("AGEV")
+2 KILL AGEVICN,AGEVGN,AGEVGNM,AGEVPED,AGEVPEXD,AGEVNOI,AGEVIDOB,AGEVSTR
+3 KILL AGEVCTY,AGEVST,AGEVZP,AGEVISX,AGEVIID,AGEVIT,AGEVMCD,AGEVMCDE,AGEVMCM
+4 KILL AGEVMCME,AGEVMCR,AGEVMCRE,AGEVMA,AGEVPH,AGEVICNI
+5 QUIT