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

AGRPTINS.m

Go to the documentation of this file.
AGRPTINS ; IHS/SD/TPF - REPORT OF TOP 'N' INSURERS
 ;;7.1;PATIENT REGISTRATION;;AUG 25,2005
 ;
 ;RUN A REPORT TO LIST THE TOP INSURERS THAT HAVE OPEN ELIGBILITY
 ;AT A SPECIFIC POINT IN TIME.
 ;I.E. ASK FOR A SPECIFIC POINT IN TIME
 ;GO THROUGH THE PRIVATE ELIGIBILITY,MEDICAID,MEDICARE FILE AND
 ;FIND INSURERS THAT ARE ACTIVE. LET USER CHOOSE TO DISREGARD NON
 ;ACTIVE PATIENTS. ALLOW USER TO CHOOSE HOW MANY TOP INSURERS TO
 ;LIST
 ;
EN ;EP
 S ROUTNAME=$P($T(+1)," ")
 S:$G(AGLINE("EQ"))="" $P(AGLINE("EQ"),"=",81)=""
 D HDR
ASKFAC ;EP - ASK FOR A SPECIFIC FACILITY OR ALL
 K DIR,DTOUT,DUOUT,DIRUT,DIROUT,TARFAC
 S DIR("A")="Check for which Facility: All//"
 S DIR(0)="POA^9999999.06:EMZ"
 D ^DIR
 I $D(DTOUT)!($D(DUOUT))!($D(DIROUT)) D EXIT Q
 I X="" S TARFAC="ALL"
 E  S TARFAC=+Y
 K DIR
ASKDT ;EP - ASK FOR THE 'POINT IN TIME'
 W !!
 K DIR,DTOUT,DUOUT,DIRUT,DIROUT
 S DIR("A")="Date for the point in Time want eligibility for"
 S DIR(0)="DO"
 D ^DIR
 G:$D(DTOUT)!($D(DUOUT))!($D(DIRUT))!($D(DIROUT)) ASKFAC
 S TARDATE=Y
 K DIR
ASKACTPT ;EP - ASK WHETHER TO DISREGARD NON-ACTIVE PATIENTS
 K DIR,DTOUT,DUOUT,DIRUT,DIROUT
 S DIR("A")="Want to check if patient is active? "
 S DIR(0)="YOA"
 D ^DIR
 G:$D(DTOUT)!($D(DUOUT))!($D(DIRUT))!($D(DIROUT)) ASKDT
 S NONACT=+Y  ;IF TRUE THEN DO NOT COUNT NON-ACTIVE PATIENTS
 K DIR
ASKENTRY ;EP
 K DIR,DTOUT,DUOUT,DIRUT,DIROUT
 S DIR("A")="How many entries do you want in the list"
 S DIR("B")=20
 S DIR(0)="NO^5:100"
 D ^DIR
 G:$D(DTOUT)!($D(DUOUT))!($D(DIRUT))!($D(DIROUT)) ASKACTPT
 S MAXDISP=+Y
 K DIR
 D NOW^%DTC S Y=% D DD^%DT S REPTIME=Y
 D ASKDEV
 G:POP EN
 I $G(IO("Q")) D QUE Q
 U IO
 S PAGENO=0
 D RUN(TARDATE,NONACT)
 D ^%ZISC
 G EN
RUN(TARDATE,NONACT) ;EP
 ;IF REPTIME IS NULL THEN TASKMAN IS CALLING
 I $G(REPTIME)="" D NOW^%DTC S Y=% D DD^%DT S REPTIME=Y
 K ^XTMP(ROUTNAME,$J)
 D COMPILE(TARDATE,NONACT)
 F GLO="^AUPNMCD","^AUPNMCR","^AUPNRRE" D
 .D GENCOMPL(GLO,TARDATE,NONACT)
 I '$D(^XTMP(ROUTNAME,$J)) W !,"NO INSURANCE MEMBERS FOUND FOR ",$P($G(^DIC(4,TARFAC,0)),U)," FACILITES" H 3 G EN
 D SORTMAX("^XTMP("_ROUTNAME_",$J)")
 D PRINTMAX("^XTMP("_ROUTNAME_",$J,""MAXSORT"")")
 Q
ASKDEV ;EP
 S %ZIS="Q"
 D ^%ZIS
 Q
HDR ;EP
 X ^%ZOSF("UCI") S UCI=$P(Y,",")
 W @IOF
 D CENTER("PATIENT REGISTRATION")
 W !!
 D CENTER($P($G(^DIC(4,DUZ(2),0)),U))
 W !!
 D CENTER("TOP 20 INSURERS REPORT")
 W !!,$$CJ^XLFSTR("*** NOTE:  IF YOU EDIT A PATIENT AND SEE THEIR NAME IN REVERSE VIDEO ***",IOM)
 W !,$$CJ^XLFSTR("*** WITH '(RHI)' BLINKING NEXT TO IT, IT MEANS THEY HAVE RESTRICTED ***",IOM)
 W !,$$CJ^XLFSTR("*** HEALTH INFORMATION ***",IOM)
 Q
CENTER(X) ;
 S CENTER=IOM/2
 W ?CENTER-($L(X)/2),X
 Q
COMPILE(TARDATE,NONACT,MAXDISP) ;EP - GO THROUGH THE PRVT ELG FILE AND
 ;FIND ALL PATIENTS WITH ACTIVE POLICIES
 N PDFN,INS
 S ELIGCNT=0
 S PDFN=0
 F  S PDFN=$O(^AUPNPRVT(PDFN)) Q:'PDFN  D
 .Q:'$D(^AUPNPAT(PDFN,0))              ;BAD NODE
 .I TARFAC'="ALL" Q:'$D(^AUPNPAT(PDFN,41,TARFAC,0))    ;SKIP FACILITIES NOT PICKED AT 'ASKFAC' PROMPT
 .S STATDT=$P($G(^AUPNPAT(PDFN,41,TARFAC,0)),U,3)  ;INACTIVATED/DELETED FIELD
 .I NONACT I TARDATE=STATDT!(TARDATE>STATDT),(STATDT'="") Q  ;IF THEY WANT TO DISREGARD NOACTIVE PATIENTS AND THE PATIENT IS CONSIDERED INACTIVE THEN QUIT
 .S INS=0
 .F  S INS=$O(^AUPNPRVT(PDFN,11,INS)) Q:'INS  D
 ..S ELIGDT=$P($G(^AUPNPRVT(PDFN,11,INS,0)),U,6)
 ..S EXPDT=$P($G(^AUPNPRVT(PDFN,11,INS,0)),U,7)
 ..S COVTYP=$P($G(^AUPNPRVT(PDFN,11,INS,0)),U,3) S:COVTYP'="" COVTYP=$P($G(^AUTTPIC(COVTYP,0)),U) S:COVTYP="" COVTYP="UNDEF"
 ..I $$ISACTIVE(ELIGDT,EXPDT,TARDATE) D
 ...S INSPTR=$P($G(^AUPNPRVT(PDFN,11,INS,0)),U) S:INSPTR="" INSPTR="UNDEF"
 ...S ELIGCNT=ELIGCNT+1
 ...S ^XTMP(ROUTNAME,$J,INSPTR,COVTYP)=$G(^XTMP(ROUTNAME,$J,INSPTR,COVTYP))+1
 Q
GENCOMPL(GLO,TARDATE,NONACT) ;EP - LETS DO THE OTHER INSURERS. PASS
 ;GLOBAL ROOT
 N PDFN,ELIGDT,EXPDT,ELIGCNT
 S PDFN=0,ELIGCNT=0
 F  S PDFN=$O(@GLO@(PDFN)) Q:PDFN=""!('PDFN)  D
 .Q:'$D(@GLO@(PDFN,11))  ;NO ELIGIBILITY DATES
 .Q:'$D(^AUPNPAT(PDFN,0))              ;NOT EVEN REGISTERED
 .I TARFAC'="ALL" Q:'$D(^AUPNPAT(PDFN,41,TARFAC,0))    ;SKIP FACILITIES NOT PICKED AT 'ASKFAC' PROMPT
 .S STATDT=$P($G(^AUPNPAT(PDFN,41,DUZ(2),0)),U,3)  ;INACTIVATED/DELETED FIELD
 .S DTREC=0
 .F  S DTREC=$O(@GLO@(PDFN,11,DTREC)) Q:'DTREC  D
 ..S ELIGDT=$P($G(@GLO@(PDFN,11,DTREC,0)),U)
 ..S EXPDT=$P($G(@GLO@(PDFN,11,DTREC,0)),U,2)
 ..S COVTYP=$P($G(@GLO@(PDFN,11,DTREC,0)),U,3) S:COVTYP="" COVTYP="UNDEF"
 ..I $$ISACTIVE(ELIGDT,EXPDT,TARDATE) D
 ...S INSPTR=$P($G(@GLO@(PDFN,0)),U,2) S:INSPTR="" INSPTR="UNDEF"
 ...S ELIGCNT=ELIGCNT+1
 ...S ^XTMP(ROUTNAME,$J,INSPTR,COVTYP)=$G(^XTMP(ROUTNAME,$J,INSPTR,COVTYP))+1
 Q
ISACTIVE(EFFDT,ENDDT,TARDATE) ;
 NEW OPENEND
 I EFFDT="",(ENDDT="") Q 0
 S ENDDT=ENDDT  ;TRUE IF ENDING DATE IS AT COB OF ENDING DATE - ANSWER FROM ADRIAN IS IT IS
 ;               IN FORCE FOR ALL OF TODAY
 S OPENEND=ENDDT=""
 I OPENEND I TARDATE=EFFDT!(TARDATE>EFFDT) Q 1
 I TARDATE=EFFDT!(TARDATE=ENDDT) Q 1
 I TARDATE>EFFDT&(TARDATE<ENDDT) Q 1
 Q 0
SORTMAX(GLO) ;EP - GO THROUGH TEMP GLOBAL AND RE-SORT BY MAX
 N INSPTR,COVTYP
 S INSPTR=""
 F  S INSPTR=$O(^XTMP(ROUTNAME,$J,INSPTR)) Q:INSPTR=""!(INSPTR="ZMAXSORT")  D
 .S COVTYP=""
 .F  S COVTYP=$O(^XTMP(ROUTNAME,$J,INSPTR,COVTYP)) Q:COVTYP=""  D
 ..S MAX=$G(^XTMP(ROUTNAME,$J,INSPTR,COVTYP))
 ..S ^XTMP(ROUTNAME,$J,"ZMAXSORT",MAX,INSPTR,COVTYP)=""
 Q
PRINTMAX(GLO) ;EP - PRINT THE MAX COUNTS OUT
 D MAINHDR
 U IO
 N MAX,LINE,ESCAPE
 S ESCAPE=0,LINE=0
 S MAX=""
 F RANK=1:1 S MAX=$O(^XTMP(ROUTNAME,$J,"ZMAXSORT",MAX),-1) Q:MAX=""!(ESCAPE)  D
 .S INSPTR=""
 .F  S INSPTR=$O(^XTMP(ROUTNAME,$J,"ZMAXSORT",MAX,INSPTR)) Q:INSPTR=""!(ESCAPE)  D
 ..S COVTYP=""
 ..F ITEM=1:1 S COVTYP=$O(^XTMP(ROUTNAME,$J,"ZMAXSORT",MAX,INSPTR,COVTYP)) Q:COVTYP=""!(ESCAPE)  D
 ...W:ITEM'=1 !
 ...S LINE=LINE+1
 ...S ESCAPE=LINE>MAXDISP
 ...I ESCAPE,(IOST[("C-")) W ! K DIR S DIR(0)="E" D ^DIR Q
 ...I ESCAPE,(IOST'[("C-")) Q
 ...W !?2,$E($P($G(^AUTNINS(INSPTR,0)),U),1,23)
 ...W ?31,$S(COVTYP="UNDEF":"",1:COVTYP)
 ...W ?62,MAX
 ...;NOTE: HEADER IS 10 LINES
 ...I $Y>(IOSL-10),(IOST[("C-")) W ! K DIR S DIR(0)="E" D ^DIR S ESCAPE=X=U D:'ESCAPE MAINHDR Q
 ...I $Y>(IOSL-10) D MAINHDR
 Q
MAINHDR ;EP
 S PAGENO=PAGENO+1
 W @IOF
 W !,$P($G(^VA(200,DUZ,0)),U)
 D CENTER($P($G(^DIC(4,DUZ(2),0)),U))
 W ?73,"Page ",PAGENO
 W !
 D CENTER("TOP '"_MAXDISP_"' INSURER'S REPORT")
 W !
 D CENTER("as of "_REPTIME)
 W !!
 I NONACT D CENTER("REPORT CONTAINS ACTIVE PATIENTS ONLY")
 W !!
 W !?2,"INSURER",?26,"COVERAGE TYPE",?61,"COUNT"
 W !,$G(AGLINE("EQ"))
 Q
EXIT ;EP - CLEANUP VARS
 K CENTER,COVTYP,DIR,DTREC,EFFDT,ELIGCNT,ELIGDT,ENDDT,ESCAPE,EXPDT,GLO,TARFAC,AGLINE,TARDATE,NONACT,PAGENO,ROUTNAME
 Q
QUE ;EP
 K IO("Q")
 S ZTRTN="RUN^AGRPTINS(TARDATE,NONACT)",ZTDESC="REPORT OF TOP "_MAXDISP_" INSURERS"
 S ZTSAVE("ROUTNAME")=""
 S ZTSAVE("AGLINE")=""
 S ZTSAVE("TARFAC")=""
 S ZTSAVE("TARDATE")=""
 S ZTSAVE("NONACT")=""
 S ZTSAVE("MAXDISP")=""
 S ZTSAVE("PAGENO")=0
 D ^%ZTLOAD W:$D(ZTSK) !,"REQUEST QUEUED AS TASK # "_ZTSK_" !",!
 Q