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

AGAPIS1.m

Go to the documentation of this file.
AGAPIS1 ;IHS/ASDS/TPF - THESE APIS CALLS ARE CALLED FROM AGAPIS AND ARE LIMITED TO THE ELIGIBILITY API   
 ;;7.1;PATIENT REGISTRATION;**2,4**;AUG 25,2005
 W !,"DO NOT CALL FROM ROOT!"
 Q
 ;
 ;GET RAILROAD RETIREMENT PART A & B
GETRRAB(CATPRIOR) ;EP - CALLED BY AGAPIS
 ;GET TOP LEVEL
 S TPRECPTR=$P(RECPTR,",")
 D GETS^DIQ(9000005,TPRECPTR,"*",AGGFLAG,"AGGDATA","AGGERR")
 Q:$D(AGGERR)
 M AGGINS=AGGDATA
 M CATPRIOR(CATEGORY,PRIORITY,INSPTR)=AGGINS
 ;GET JUST THE ONE SUB LEVEL
 S SBRECPTR=$P(RECPTR,",",3)_","_$P(RECPTR,",")_","
 D GETS^DIQ(9000005,SBRECPTR,"*",AGGFLAG,"AGGDATA","AGGERR")
 Q:$D(AGGERR)
 S AGGFILE=9000005.11
 D GETDATES(AGGFLAG,.AGGDATA,AGGFILE)
 I STDT="" S ENDDT="" Q
 ;I '$$ISACTIVE(STDT,ENDDT,AGGDOS) K AGGDATA,CATPRIOR(CATEGORY,PRIORITY,INSPTR,9000005,TPRECPTR) Q
 I '$$ISACTIVE(STDT,ENDDT,AGGDOS) K AGGDATA,CATPRIOR(CATEGORY,PRIORITY,INSPTR) Q  ;BAR*1.8*4 IM
 K STDT,ENDDT
 M AGGINS=AGGDATA
 M CATPRIOR(CATEGORY,PRIORITY,INSPTR)=AGGINS
 K AGGDATA,AGGERR,AGGINS
 Q
 ;GET MEDICARE PART A & B
GETMCRAB(CATPRIOR) ;EP - CALLED BY AGAPIS
 ;GET TOP LEVEL
 S TPRECPTR=$P(RECPTR,",")
 D GETS^DIQ(9000003,TPRECPTR,"*",AGGFLAG,"AGGDATA","AGGERR")
 Q:$D(AGGERR)
 M CATPRIOR(CATEGORY,PRIORITY,INSPTR)=AGGDATA
 ;GET JUST THE ONE SUB LEVEL
 S SBRECPTR=$P(RECPTR,",",3)_","_$P(RECPTR,",")_","
 K AGGDATA,AGGERR
 D GETS^DIQ(9000003.11,SBRECPTR,"*",AGGFLAG,"AGGDATA","AGGERR")
 Q:$D(AGGERR)
 S AGGFILE=9000003.11
 D GETDATES(AGGFLAG,.AGGDATA,AGGFILE)
 ;I '$$ISACTIVE(STDT,ENDDT,AGGDOS) K AGGDATA,CATPRIOR(CATEGORY,PRIORITY,INSPTR,9000003,TPRECPTR) Q
 I '$$ISACTIVE(STDT,ENDDT,AGGDOS) K AGGDATA,CATPRIOR(CATEGORY,PRIORITY,INSPTR) Q  ;BAR*1.8*4 IM
 K STDT,ENDDT
 M CATPRIOR(CATEGORY,PRIORITY,INSPTR)=AGGDATA
 K AGGDATA,AGGERR
 Q
 ;GET MEDICAID
GETMCD(CATPRIOR) ;EP - CALLED BY AGAPIS
 ;GET TOP LEVEL FIELDS
 S TPRECPTR=$P(RECPTR,",")
 D GETS^DIQ(9000004,TPRECPTR,"*",AGGFLAG,"AGGDATA","AGGERR")
 M CATPRIOR(CATEGORY,PRIORITY,INSPTR)=AGGDATA
 ;GET JUST THE ONE SUB LEVEL
 S SBRECPTR=$P(RECPTR,",",3)_","_$P(RECPTR,",")_","
 D GETS^DIQ(9000004.11,SBRECPTR,"*",AGGFLAG,"AGGDATA","AGGERR")  ;MEDICAID
 Q:$D(AGGERR)
 S AGGFILE=9000004.11
 D GETDATES(AGGFLAG,.AGGDATA,AGGFILE)
 ;I STDT=""!('$$ISACTIVE(STDT,ENDDT,AGGDOS)) K AGGDATA,CATPRIOR(CATEGORY,PRIORITY,INSPTR,9000004,TPRECPTR) Q
 I STDT=""!('$$ISACTIVE(STDT,ENDDT,AGGDOS)) K AGGDATA,CATPRIOR(CATEGORY,PRIORITY,INSPTR) Q  ;BAR*1.8*4 IM
 K STDT,ENDDT
 M CATPRIOR(CATEGORY,PRIORITY,INSPTR)=AGGDATA
 K AGGDATA,AGGERR
 Q
 ;GET RAILROAD RETIREMENT PART D
GETRRD(CATPRIOR) ;EP - CALLED BY AGAPIS
 ;GET JUST THE ONE SUB LEVEL
 S SBRECPTR=$P(RECPTR,",",3)_","_$P(RECPTR,",")_","
 D GETS^DIQ(9000005.11,SBRECPTR,"*",AGGFLAG,"AGGDATA","AGGERR")
 Q:$D(AGGERR)
 S AGGFILE=9000005.11
 D GETDATES(AGGFLAG,.AGGDATA,AGGFILE)
 ;I '$$ISACTIVE(STDT,ENDDT,AGGDOS) K AGGDATA,CATPRIOR(CATEGORY,PRIORITY,INSPTR,9000005,TPRECPTR) Q
 I '$$ISACTIVE(STDT,ENDDT,AGGDOS) K AGGDATA,CATPRIOR(CATEGORY,PRIORITY,INSPTR) Q  ;BAR*1.8*4 IM
 K STDT,ENDDT
 M AGGINS=AGGDATA
 M CATPRIOR(CATEGORY,PRIORITY,INSPTR)=AGGINS
 K AGGINS,AGGDATA,AGGERR
 Q
 ;GET MEDICARE PART D
GETMCRD(CATPRIOR) ;EP - CALLED BY AGAPIS
 ;GET JUST THE ONE SUB LEVEL
 S SBRECPTR=$P(RECPTR,",",3)_","_$P(RECPTR,",")_","
 K AGGDATA,AGGERR
 D GETS^DIQ(9000003.11,SBRECPTR,"*",AGGFLAG,"AGGDATA","AGGERR")
 Q:$D(AGGERR)
 S AGGFILE=9000003.11
 D GETDATES(AGGFLAG,.AGGDATA,AGGFILE)
 ;I '$$ISACTIVE(STDT,ENDDT,AGGDOS) K AGGDATA,CATPRIOR(CATEGORY,PRIORITY,INSPTR,9000003,TPRECPTR) Q
 I '$$ISACTIVE(STDT,ENDDT,AGGDOS) K AGGDATA,CATPRIOR(CATEGORY,PRIORITY,INSPTR) Q  ;BAR*1.8*4 IM
 K STDT,ENDDT
 M CATPRIOR(CATEGORY,PRIORITY,INSPTR)=AGGDATA
 K AGGDATA,AGGERR
 Q
 ;GET GUARANTOR
GETGUAR(CATPRIOR) ;EP - CALLED BY AGAPIS
 ;GET TOP LEVEL FIELDS
 S TPRECPTR=$P(RECPTR,",")
 D GETS^DIQ(9000043,TPRECPTR,"*",AGGFLAG,"AGGDATA","AGGERR")
 Q:$D(AGGERR)
 M CATPRIOR(CATEGORY,PRIORITY,INSPTR)=AGGDATA
 ;GET JUST THE ONE SUB LEVEL
 S SBRECPTR=$P(RECPTR,",",3)_","_$P(RECPTR,",")_","
 D GETS^DIQ(9000043.0101,SBRECPTR,"*",AGGFLAG,"AGGDATA","AGGERR")  ;MEDICAID
 Q:$D(AGGERR)
 S AGGFILE=9000043.0101
 D GETDATES(AGGFLAG,.AGGDATA,AGGFILE)
 ;I STDT=""!('$$ISACTIVE(STDT,ENDDT,AGGDOS)) K AGGDATA,CATPRIOR(CATEGORY,PRIORITY,INSPTR,9000043.0101,TPRECPTR) Q
 I STDT=""!('$$ISACTIVE(STDT,ENDDT,AGGDOS)) K AGGDATA,CATPRIOR(CATEGORY,PRIORITY,INSPTR) Q  ;BAR*1.8*4 IM
 K STDT,ENDDT
 M CATPRIOR(CATEGORY,PRIORITY,INSPTR)=AGGDATA
 K AGGDATA,AGGERR
 Q
GETTPL(CATPRIOR) ;EP - CALLED BY AGAPIS
 ;GET JUST THE ONE SUB LEVEL
 S SBRECPTR=$P(RECPTR,",",3)_","_$P(RECPTR,",")_","
 D GETS^DIQ(9000041.0101,SBRECPTR,"*",AGGFLAG,"AGGDATA","AGGERR")
 Q:$D(AGGERR)
 S AGGFILE=9000041.0101
 D GETDATES(AGGFLAG,.AGGDATA,AGGFILE)
 ;I '$$ISACTIVE(STDT,ENDDT,AGGDOS) K AGGDATA,CATPRIOR(CATEGORY,PRIORITY,INSPTR,9000041.0101,TPRECPTR) Q
 I '$$ISACTIVE(STDT,ENDDT,AGGDOS) K AGGDATA,CATPRIOR(CATEGORY,PRIORITY,INSPTR) Q  ;BAR*1.8*4 IM
 K STDT,ENDDT
 M AGGINS=AGGDATA
 M CATPRIOR(CATEGORY,PRIORITY,INSPTR)=AGGINS
 K AGGINS,AGGDATA,AGGERR
 Q
WCOMP(CATPRIOR) ;EP - CALLED BY AGAPIS
 ;GET JUST THE ONE SUB LEVEL
 S SBRECPTR=$P(RECPTR,",",2)_","_$P(RECPTR,",")_","
 D GETS^DIQ(9000042.11,SBRECPTR,"*",AGGFLAG,"AGGDATA","AGGERR")
 Q:$D(AGGERR)
 S AGGFILE=9000042.11
 D GETDATES(AGGFLAG,.AGGDATA,AGGFILE)
 ;I '$$ISACTIVE(STDT,ENDDT,AGGDOS) K AGGDATA,CATPRIOR(CATEGORY,PRIORITY,INSPTR,9000042.11,TPRECPTR) Q
 I '$$ISACTIVE(STDT,ENDDT,AGGDOS) K AGGDATA,CATPRIOR(CATEGORY,PRIORITY,INSPTR) Q  ;BAR*1.8*4 IM
 K STDT,ENDDT
 M AGGINS=AGGDATA
 M CATPRIOR(CATEGORY,PRIORITY,INSPTR)=AGGINS
 K AGGERR,AGGDATA,AGGERR
 Q
GETPRVT(CATPRIOR) ;EP - CALLED BY AGAPIS
 ;GET JUST THE ONE SUB LEVEL
 S SBRECPTR=$P(RECPTR,",",3)_","_$P(RECPTR,",")_","
 K AGGDATA,AGGERR
 D GETS^DIQ(9000006.11,SBRECPTR,"*",AGGFLAG,"AGGDATA","AGGERR")
 Q:$D(AGGERR)
 S AGGFILE=9000006.11
 D GETDATES(AGGFLAG,.AGGDATA,AGGFILE)
 ;I '$$ISACTIVE(STDT,ENDDT,AGGDOS) K AGGDATA,CATPRIOR(CATEGORY,PRIORITY,INSPTR,9000006.11,TPRECPTR) Q
 I '$$ISACTIVE(STDT,ENDDT,AGGDOS) K AGGDATA,CATPRIOR(CATEGORY,PRIORITY,INSPTR) Q  ;BAR*1.8*4 IM
 K STDT,ENDDT
 M CATPRIOR(CATEGORY,PRIORITY,INSPTR)=AGGDATA
 ;NOW LETS GET THE POLICY HOLDER ENTRY
 K AGGPOLH,AGGERR
 D GETS^DIQ(9000006.11,SBRECPTR,.08,"I","AGGPOLH","AGGERR")
 Q:$D(AGGERR)
 S POLHPTR=$G(AGGPOLH(9000006.11,SBRECPTR,.08,"I"))
 Q:POLHPTR=""
 K AGGPOLH,AGGERR
 D GETS^DIQ(9000003.1,POLHPTR,"*",AGGFLAG,"AGGPOLH","AGGERR")
 Q:$D(AGGERR)
 M CATPRIOR(CATEGORY,PRIORITY,INSPTR)=AGGPOLH
 K AGGPOLH,AGGDATA,AGGERR
 Q
 ;TAKE EXTERNAL DATE AND MAKE INTERNAL
INT(DATE) ;
 K %DT
 S X=DATE D ^%DT
 K %DT
 Q Y
ISACTIVE(EFFDT,ENDDT,DOS) ;EP - DETERMINE WHETHER THE POLICY IS ACTIVE AS OF DOS
 N OPENEND
 I EFFDT="",(ENDDT="") Q 0  ;NO DATES CONSIDERED INACTIVE
 S ENDDT=ENDDT  ;TRUE IF END DATE IS AT COB OF END DATE - ANSWER FROM
 S OPENEND=ENDDT=""
 I OPENEND I DOS=EFFDT!(DOS>EFFDT) Q 1
 I DOS=EFFDT!(DOS=ENDDT) Q 1
 I DOS>EFFDT&(DOS<ENDDT) Q 1
 Q 0
GETDATES(AGGFLAG,AGGDATA,AGGFILE) ;
 I AGGFLAG="R" D
 .S STDT=$G(AGGDATA(AGGFILE,SBRECPTR,$S(AGGFILE=9000043.0101!(AGGFILE=9000042.11)!(AGGFILE=9000041.0101):"EFFECTIVE DATE",1:"ELIG. DATE")))
 .S ENDDT=$G(AGGDATA(AGGFILE,SBRECPTR,$S(AGGFILE=9000043.0101!(AGGFILE=9000042.11)!(AGGFILE=9000041.0101):"ENDING DATE",1:"ELIG. END DATE")))
 .S STDT=$$INT(STDT)
 .Q:ENDDT=""
 .S ENDDT=$$INT(ENDDT)
 I AGGFLAG="E" D
 .S STDT=$G(AGGDATA(AGGFILE,SBRECPTR,$S(AGGFILE=9000042.11:.13,AGGFILE=9000041.0101:.04,AGGFILE=9000006.11:.06,1:.01),"E"))
 .S ENDDT=$G(AGGDATA(AGGFILE,SBRECPTR,$S(AGGFILE=9000042.11:.14,AGGFILE=9000041.0101:.05,AGGFILE=9000006.11:.07,1:.02),"E"))
 .S STDT=$$INT(STDT)
 .Q:ENDDT=""
 .S ENDDT=$$INT(ENDDT)
 I AGGFLAG="I" D
 .S STDT=$G(AGGDATA(AGGFILE,SBRECPTR,$S(AGGFILE=9000042.11:.13,AGGFILE=9000041.0101:.04,AGGFILE=9000006.11:.06,1:.01),"I"))
 .S ENDDT=$G(AGGDATA(AGGFILE,SBRECPTR,$S(AGGFILE=9000042.11:.14,AGGFILE=9000041.0101:.05,AGGFILE=9000006.11:.07,1:.02),"I"))
 .S STDT=$$INT(STDT)
 .Q:ENDDT=""
 .S ENDDT=$$INT(ENDDT)
 I AGGFLAG["E"&(AGGFLAG["I")&(AGGFLAG'["R") D
 .S STDT=$G(AGGDATA(AGGFILE,SBRECPTR,$S(AGGFILE=9000042.11:.13,AGGFILE=9000041.0101:.04,AGGFILE=9000006.11:.06,1:.01),"I"))
 .S ENDDT=$G(AGGDATA(AGGFILE,SBRECPTR,$S(AGGFILE=9000042.11:.14,AGGFILE=9000041.0101:.05,AGGFILE=9000006.11:.07,1:.02),"I"))
 I AGGFLAG["R"&(AGGFLAG["E")&(AGGFLAG'["I") D
 .S STDT=$G(AGGDATA(AGGFILE,SBRECPTR,$S(AGGFILE=9000043.0101!(AGGFILE=9000042.11)!(AGGFILE=9000041.0101):"EFFECTIVE DATE",1:"ELIG. DATE"),"E"))
 .S ENDDT=$G(AGGDATA(AGGFILE,SBRECPTR,$S(AGGFILE=9000043.0101!(AGGFILE=9000042.11)!(AGGFILE=9000041.0101):"ENDING DATE",1:"ELIG. END DATE"),"E"))
 .S STDT=$$INT(STDT)
 .Q:ENDDT=""
 .S ENDDT=$$INT(ENDDT)
 I AGGFLAG["R"&(AGGFLAG["I")&(AGGFLAG'["E") D
 .S STDT=$G(AGGDATA(AGGFILE,SBRECPTR,$S(AGGFILE=9000043.0101!(AGGFILE=9000042.11)!(AGGFILE=9000041.0101):"EFFECTIVE DATE",1:"ELIG. DATE"),"I"))
 .S ENDDT=$G(AGGDATA(AGGFILE,SBRECPTR,$S(AGGFILE=9000043.0101!(AGGFILE=9000042.11)!(AGGFILE=9000041.0101):"ENDING DATE",1:"ELIG. END DATE"),"I"))
 I AGGFLAG["R"&(AGGFLAG["E")&(AGGFLAG["I") D
 .S STDT=$G(AGGDATA(AGGFILE,SBRECPTR,$S(AGGFILE=9000043.0101!(AGGFILE=9000042.11)!(AGGFILE=9000041.0101):"EFFECTIVE DATE",1:"ELIG. DATE"),"I"))
 .S ENDDT=$G(AGGDATA(AGGFILE,SBRECPTR,$S(AGGFILE=9000043.0101!(AGGFILE=9000042.11)!(AGGFILE=9000041.0101):"ENDING DATE",1:"ELIG. END DATE"),"I"))
 Q