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

AGGPTPVI.m

Go to the documentation of this file.
AGGPTPVI ;VNGT/HS/ALA-Private Insurance ; 26 Apr 2010  5:18 PM
 ;;1.0;PATIENT REGISTRATION GUI;;Nov 15, 2010
 ;
INIT(DATA,AGGPLIEN) ;EP -- AGG INSUR INITIAL TRIG
 NEW UID,II,HDR,SOURCE,VALUE,TYPE,ABLE,CLEAR,HELP
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGPINIT",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(AGGPLIEN)="" S SOURCE="DFNWARN",VALUE="",TYPE="X",ABLE="N",CLEAR="",HELP="" D UP
 I $G(AGGPLIEN)'="" D
 . I $P($G(^AUPN3PPH(AGGPLIEN,0)),U,2)="" S SOURCE="DFNWARN",VALUE="",TYPE="X",ABLE="Y",CLEAR="",HELP="" D UP Q
 . S SOURCE="DFNWARN",VALUE="",TYPE="X",ABLE="N",CLEAR="",HELP="" D UP
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
EN(DATA,AGGPIHLN) ;EP -- AGG POLICY HOLDER TRIGGER
 NEW UID,II,HDR,SOURCE,VALUE,TYPE,ABLE,CLEAR,HELP
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGPHPOL",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="AGGPIHLN",VALUE=AGGPIHLN,TYPE="X",ABLE="Y",CLEAR="AGGPIHSX;AGGPIHDB;AGGPIHDB;AGGPIEMP;AGGPIHAD;AGGPIHCY;AGGPIHST;AGGPIHZP;AGGPIHPH",HELP="" D UP
 I $G(AGGPIHLN)'="" D
 . I AGGPIHLN'?.N Q
 . S SOURCE="AGGPIHLN",VALUE=$P(^AUPN3PPH(AGGPIHLN,0),U,1),TYPE="X",ABLE="Y",CLEAR="AGGPIHSX;AGGPIHDB;AGGPIHDB;AGGPIEMP;AGGPIHAD;AGGPIHCY;AGGPIHST;AGGPIHZP;AGGPIHPH",HELP="" D UP
 . S SOURCE="AGGPTDFN",VALUE=$P(^AUPN3PPH(AGGPIHLN,0),U,2),TYPE="N",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPIHSX",VALUE=$P(^AUPN3PPH(AGGPIHLN,0),U,8),TYPE="C",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPIHDB",VALUE=$P(^AUPN3PPH(AGGPIHLN,0),U,19),TYPE="D",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPIHDB",VALUE=$P(^AUPN3PPH(AGGPIHLN,0),U,15),TYPE="C",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPIEMP",VALUE=$P(^AUPN3PPH(AGGPIHLN,0),U,16),TYPE="T",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPIHAD",VALUE=$P(^AUPN3PPH(AGGPIHLN,0),U,9),TYPE="X",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPIHCY",VALUE=$P(^AUPN3PPH(AGGPIHLN,0),U,11),TYPE="X",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPIHST",VALUE=$P(^AUPN3PPH(AGGPIHLN,0),U,12),TYPE="T",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPIHZP",VALUE=$P(^AUPN3PPH(AGGPIHLN,0),U,13),TYPE="X",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPIHPH",VALUE=$P(^AUPN3PPH(AGGPIHLN,0),U,14),TYPE="X",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPHESD",VALUE=$$FMTE^AGGUL1($P(^AUPN3PPH(AGGPIHLN,0),U,17)),TYPE="D",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPHEED",VALUE=$$FMTE^AGGUL1($P(^AUPN3PPH(AGGPIHLN,0),U,18)),TYPE="D",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPINUM",VALUE=$P(^AUPN3PPH(AGGPIHLN,0),U,4),TYPE="X",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPIHDB",VALUE=$$FMTE^AGGUL1($P(^AUPN3PPH(AGGPIHLN,0),U,19)),TYPE="D",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPIEMP",VALUE=$P(^AUPN3PPH(AGGPIHLN,0),U,16),TYPE="T",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPIEMS",VALUE=$P(^AUPN3PPH(AGGPIHLN,0),U,15),TYPE="C",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPIGRP",VALUE=$P(^AUPN3PPH(AGGPIHLN,0),U,6) I VALUE'="" S VALUE=VALUE_$C(28)_$P($G(^AUTNEGRP(VALUE,0)),U,1)
 . S TYPE="T",ABLE="Y",CLEAR="",HELP="" D UP
 . S VALUE="",GROUP=$P(^AUPN3PPH(AGGPIHLN,0),U,6) I GROUP'="" S VALUE=$P($G(^AUTNEGRP(GROUP,0)),U,2)
 . S SOURCE="AGGPIGRN",TYPE="X",ABLE="Y",CLEAR="",HELP="" D UP
 ;
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
SAM(DATA,DFN) ; EP -- AGG POLICY HOLDER SAME TRIG
 NEW UID,II,HDR,SOURCE,VALUE,TYPE,ABLE,CLEAR,HELP,CFLAG
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGPHSAME",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="AGGPTDFN",VALUE=DFN,TYPE="N",ABLE="Y",CLEAR="AGGPIHSX;AGGPIHDB;AGGPIHDB;AGGPIEMP;AGGPIHAD;AGGPIHCY;AGGPIHST;AGGPIHZP;AGGPIHPH",HELP="" D UP
 S SOURCE="AGGPIHLN",VALUE=$P(^DPT(DFN,0),U,1),TYPE="X",ABLE="Y",CFLAG="",CLEAR="",HELP="" D UP
 S SOURCE="AGGPIREL",VALUE=$O(^AUTTRLSH("B","SELF","")),TYPE="T",ABLE="N",CFLAG="N",CLEAR="",HELP="" D UP
 S SOURCE="AGGPIHSX",VALUE=$P(^DPT(DFN,0),U,2),TYPE="C",ABLE="Y",CFLAG="",CLEAR="",HELP="" D UP
 S SOURCE="AGGPIHDB",VALUE=$$FMTE^AGGUL1($P(^DPT(DFN,0),U,3)),TYPE="D",ABLE="Y",CFLAG="",CLEAR="",HELP="" D UP
 S SOURCE="AGGPIEMS",VALUE=$$GET1^DIQ(9000001,DFN_",",.21,"I"),TYPE="C",ABLE="Y",CFLAG="",CLEAR="",HELP="" D UP
 S SOURCE="AGGPIEMP",VALUE=$$GET1^DIQ(9000001,DFN_",",.19,"I"),TYPE="T",ABLE="Y",CFLAG="",CLEAR="",HELP="" D UP
 S SOURCE="AGGPIHAD",VALUE=$$GET1^DIQ(2,DFN_",",.111,"E"),TYPE="X",ABLE="Y",CFLAG="",CLEAR="",HELP="" D UP
 S SOURCE="AGGPIHCY",VALUE=$$GET1^DIQ(2,DFN_",",.114,"E"),TYPE="X",ABLE="Y",CFLAG="",CLEAR="",HELP="" D UP
 S SOURCE="AGGPIHST",VALUE=$$GET1^DIQ(2,DFN_",",.115,"I"),TYPE="T",ABLE="Y",CFLAG="",CLEAR="",HELP="" D UP
 S SOURCE="AGGPIHZP",VALUE=$S($$GET1^DIQ(2,DFN_",",.1112,"E")'="":$$GET1^DIQ(2,DFN_",",.1112,"E"),1:$$GET1^DIQ(2,DFN_",",.116,"E")),TYPE="X",ABLE="Y",CFLAG="",CLEAR="",HELP="" D UP
 S SOURCE="AGGPIHPH",VALUE=$$GET1^DIQ(2,DFN_",",.131,"E"),TYPE="X",ABLE="Y",CFLAG="",CLEAR="",HELP="" D UP
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
PTN(DATA,AGGPTDFN) ; EP -- AGG POLICY HOLDER PAT TRIG
 NEW UID,II,HDR,SOURCE,VALUE,TYPE,ABLE,CLEAR,HELP
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGPHPAT",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(AGGPTDFN)'="" D
 . S SOURCE="AGGPIHLN",VALUE=$P(^DPT(AGGPTDFN,0),U,1),TYPE="X",ABLE="Y",CLEAR="AGGPIHSX;AGGPIHDB;AGGPIHDB;AGGPIEMP;AGGPIHAD;AGGPIHCY;AGGPIHST;AGGPIHZP;AGGPIHPH",HELP="" D UP
 . S SOURCE="AGGPIHSX",VALUE=$P(^DPT(AGGPTDFN,0),U,2),TYPE="C",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPIHDB",VALUE=$$FMTE^AGGUL1($P(^DPT(AGGPTDFN,0),U,3)),TYPE="D",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPIEMS",VALUE=$$GET1^DIQ(9000001,AGGPTDFN_",",.21,"I"),TYPE="C",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPIEMP",VALUE=$$GET1^DIQ(9000001,AGGPTDFN_",",.19,"I"),TYPE="T",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPIHAD",VALUE=$$GET1^DIQ(2,AGGPTDFN_",",.111,"E"),TYPE="X",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPIHCY",VALUE=$$GET1^DIQ(2,AGGPTDFN_",",.114,"E"),TYPE="X",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPIHST",VALUE=$$GET1^DIQ(2,AGGPTDFN_",",.115,"I"),TYPE="T",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPIHZP",VALUE=$S($$GET1^DIQ(2,AGGPTDFN_",",.1112,"E")'="":$$GET1^DIQ(2,AGGPTDFN_",",.1112,"E"),1:$$GET1^DIQ(2,AGGPTDFN_",",.116,"E")),TYPE="X",ABLE="Y",CLEAR="",HELP="" D UP
 . S SOURCE="AGGPIHPH",VALUE=$$GET1^DIQ(2,AGGPTDFN_",",.131,"E"),TYPE="X",ABLE="Y",CLEAR="",HELP="" D UP
 ;
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
HDR ;
 S HDR="T00008SOURCE^T00001CODE_TYPE^T01024PARMS^T00001ABLE_FLAG^T00001CLEAR_FLAG^T00100CLEAR_FIELDS^T00200HELP_TEXT"
 Q
 ;
UP ;
 S II=II+1,@DATA@(II)=SOURCE_U_TYPE_U_VALUE_U_ABLE_U_$G(CFLAG)_U_$G(CLEAR)_U_HELP_$C(30)
 Q
 ;
POL(LDATA,VALUE,INSRUR) ;EP -- AGG POLICY HOLDER LOOKUP
 ; Lookup policy holder by name (VALUE) and selected insurer (INSRUR)
 NEW UID,II,AGN,PIEN,EXP
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S LDATA=$NA(^TMP("AGGPOLH",UID)) K @LDATA
 S SCREEN="I $P(^(0),U,3)="_INSRUR,FNBR=9000003.1
 D LKP^AGGWTBLK(.LDATA,FNBR,VALUE,SCREEN)
 S LG=$L(@LDATA@(0)),ECHR=$E(@LDATA@(0),LG,LG) I $C(ECHR)'=30 S @LDATA@(0)=@LDATA@(0)_$C(30)
 S AGN=0
 F  S AGN=$O(@LDATA@(AGN)) Q:'AGN  D
 . S PIEN=$P(@LDATA@(AGN),U,1)
 . S EXP=$P($G(^AUPN3PPH(PIEN,0)),U,18) I EXP="" Q
 . I EXP>DT Q
 . K @LDATA@(AGN)
 Q
 ;
PAT(LDATA,VALUE) ;EP -- AGG POLICY HOLDER PATIENT
 NEW UID,II
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S LDATA=$NA(^TMP("AGGPOLHP",UID)) K @LDATA
 D FND^AGGPTLKP(.LDATA,VALUE,"N","")
 S $P(@LDATA@(0),U,1)="I00010AGGPTDFN",$P(@LDATA@(0),U,2)="T00035AGGPIHLN"
 Q
 ;
INS(DATA,VALUE) ; EP -- AGG LOOKUP INSURANCE
 NEW UID,II,X,DDATA,FNBR,LPC
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGINSLK",UID))
 K @DATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^AGGPTPVI D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S FNBR=9999999.18,VALUE=$G(VALUE,"")
 ;
 NEW FILE,FIELD,INDEX,FLAGS,NUMB,JJ,IEN,TEXT,DESC,AGTYPE,WINDOW
 NEW MAP,HDR,MII,NFLD,TYPE,ERROR,XTLKUT,SCREEN
 S FILE=FNBR,NUMB="*",INDEX=""
 S SCREEN="I $P($G(^(1)),U,7)'=0"
 S FIELD="FID;.02;.03",INDEX="B",FLAGS="P"
 ;
 D FIND^DIC(FILE,"",FIELD,FLAGS,VALUE,"",INDEX,SCREEN,"","","ERROR")
 ;
 I $D(ERROR)>0 S BMXSEC="RPC Call Failed: "_$G(ERROR("DIERR",1,"TEXT",1)) Q
 ;
 S DDATA=$NA(^TMP("DILIST",UID))
 S MAP=$G(@DDATA@(0,"MAP"))
 I MAP'="" D
 . S HDR=""
 . F MII=1:1:$L(MAP,"^") D
 .. I $P(MAP,"^",MII)="IEN" S HDR=HDR_"T00015IEN^" Q
 .. I $P(MAP,"^",MII)[".01" D CHK(.01) S HDR=HDR_TYPE_"^" Q
 .. S NFLD=$P(MAP,"^",MII)
 .. I NFLD["FID(" S NFLD=$P($P(NFLD,"FID(",2),")",1) D CHK(NFLD) S HDR=HDR_TYPE_"^" Q
 .. D CHK(NFLD) S HDR=HDR_TYPE_"^"
 . S HDR=HDR_"T00025TYPE_OF_INSURER^T00040HIDE_WINDOW"
 . S HDR=$$TKO^AGGUL1(HDR,"^"),HDR=$TR(HDR," ","_")
 . S @DATA@(II)=HDR_$C(30)
 ;
 S JJ=0
 F  S JJ=$O(@DDATA@(JJ)) Q:'JJ  D
 . I MAP'="" D
 .. NEW IEN,TEXT,DESC,QFL
 .. S IEN=$P(@DDATA@(JJ,0),U,1),QFL=0
 .. S TEXT=$P(@DDATA@(JJ,0),U,2)
 .. I TEXT?.N D
 ... S DESC=$$GET1^DIQ(FNBR,IEN,.01,"E")
 ... S $P(@DDATA@(JJ,0),U,2)=DESC
 .. S AGTYPE=$$GET1^DIQ(FNBR,$P(@DDATA@(JJ,0),U,1)_",",.21,"I")
 .. S WINDOW=""
 .. I AGTYPE="MD" S WINDOW="Medicare"
 .. I AGTYPE="R",TEXT'="RAILROAD RETIREMENT" S WINDOW="Medicare"
 .. I AGTYPE="R",TEXT="RAILROAD RETIREMENT" S WINDOW="Railroad"
 .. I AGTYPE="D"!(AGTYPE="K") S WINDOW="Medicaid"
 .. I AGTYPE="W" S WINDOW="Workers Comp"
 .. I AGTYPE="T" S WINDOW="Private Insurance"
 .. I AGTYPE="G" S WINDOW="Guarantor"
 .. I WINDOW="" S WINDOW="Private Insurance"
 .. S LPC=$L(@DDATA@(JJ,0),"^")+1,$P(@DDATA@(JJ,0),U,LPC)=AGTYPE_U_WINDOW
 .. S II=II+1,@DATA@(II)=@DDATA@(JJ,0)_$C(30)
 ;
 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
 ;
CHK(BFLD) ;EP - Check for definition of a field
 NEW DLEN
 D FIELD^DID(FNBR,BFLD,"","TYPE","BQX")
 D FIELD^DID(FNBR,BFLD,"","FIELD LENGTH","BQX")
 D FIELD^DID(FNBR,BFLD,"","LABEL","BQX")
 S TYPE=$S(BQX("TYPE")["DATE":"D",1:"T")
 S DLEN=BQX("FIELD LENGTH")+5
 S TYPE=TYPE_$E("00000",$L(DLEN)+1,5)_DLEN_BQX("LABEL")
 K BQX
 Q
 ;
COV(DATA,AGGPIINS) ;EP - AGG INSUR COV TRIGGER
 NEW UID,II,HDR,SOURCE,VALUE,TYPE,ABLE,CLEAR,HELP
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("AGGINSCV",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="AGGPICOV",VALUE="",TYPE="T",ABLE="Y",CLEAR="",HELP=""
 I $O(^AUTTPIC("C",AGGPIINS,""))="" S HELP="No coverage types found for this Insurer" D UP
 I $O(^AUTTPIC("C",AGGPIINS,""))'="" D
 . S IEN="",VALUE=""
 . F  S IEN=$O(^AUTTPIC("C",AGGPIINS,IEN)) Q:IEN=""  D
 .. S VALUE=VALUE_IEN_$C(29)_$P(^AUTTPIC(IEN,0),U,1)_$C(28)
 . D UP
 S II=II+1,@DATA@(II)=$C(31)
 Q