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

IBUCMM1.m

Go to the documentation of this file.
  1. IBUCMM1 ;WOIFO/AAT-IBUC VISIT SUMMARY/DETAIL REPORT;30-JUL-02
  1. ;;2.0;INTEGRATED BILLING;**663,671**;21-MAR-94;Build 13
  1. ;; Per VHA Directive 6402, this routine should not be modified
  1. Q
  1. ;
  1. ; Prints report to the current device
  1. ;
  1. ; Input:
  1. ; IBBDT - Beginning date
  1. ; IBEDT - Ending date
  1. ; Output:
  1. ; IBQUIT = 1, if user entered "^" (Devices starting with "C-" only)
  1. REPORT ;
  1. ;
  1. ;Clear the temp global in case the process didn't finish the last time it ran.
  1. K ^TMP($J,"IBUCMMNM")
  1. ;
  1. ;Gather the data into the Temp global
  1. D GETDATA(IBBDT,IBEDT)
  1. ;
  1. ;Print the report
  1. D PRSUM
  1. ;
  1. ;Clean up and exit
  1. K ^TMP($J,"IBUCMM") ; Kill the temporary global node
  1. K ^TMP($J,"IBUCMMNM") ; Kill the temporary global node
  1. S:$D(ZTQUEUED) ZTREQ="@" ; for Taskman
  1. Q
  1. ;
  1. GETDATA(IBBDT,IBEDT) ;Gather the data for the report
  1. ;
  1. N IBNEW,IBLP,IBIEN,IBDATA,IBDFN,IBSITE,IBSTAT,IBYR,IBMN,IBCSITE,IBCTX
  1. ;
  1. ;Get the current site's ID, and then re-initializing IBSITE for future use.
  1. D SITE^IBAUTL S IBCSITE=IBSITE,IBSITE=""
  1. ; Initialize loop to start date
  1. S IBLP=0 ;initial starting value
  1. S:+$G(IBBDT)>0 IBLP=+$G(IBBDT)-1 ; use beginning date if defined
  1. ;Loop through the "VD" index to gather
  1. F S IBLP=$O(^IBUC(351.82,"VD",IBLP)) Q:'IBLP Q:IBLP>IBEDT D
  1. . S IBIEN=0
  1. . F S IBIEN=$O(^IBUC(351.82,"VD",IBLP,IBIEN)) Q:'IBIEN D
  1. . . ;
  1. . . S IBNEW=0
  1. . . S IBDATA=$G(^IBUC(351.82,IBIEN,0)),IBYR=$E(IBLP,1,3)+1700,IBMN=$E(IBLP,1,5)
  1. . . I (IBCA="C"),($P(IBDATA,U,2)'=IBCSITE) Q
  1. . . S IBDFN=$P(IBDATA,U),IBSITE=$P(IBDATA,U,2),IBSTAT=$P(IBDATA,U,4),IBCTX=IBSTAT+1
  1. . . S IBNM=$$GET1^DIQ(2,IBDFN_",",.01,"E")
  1. . . Q:IBNM=""
  1. . . ;# visits by a patient in a given month (for the total and the code)
  1. . . S:'$D(^TMP($J,"IBUCMM",IBYR,IBMN,IBNM,IBDFN)) IBNEW=1
  1. . . S $P(^TMP($J,"IBUCMM",IBYR,IBMN,IBNM,IBDFN),U)=+$P($G(^TMP($J,"IBUCMM",IBYR,IBMN,IBNM,IBDFN)),U)+1
  1. . . S $P(^TMP($J,"IBUCMM",IBYR,IBMN,IBNM,IBDFN),U,IBCTX)=+$P($G(^TMP($J,"IBUCMM",IBYR,IBMN,IBNM,IBDFN)),U,IBCTX)+1
  1. . . ;# visits in a given month
  1. . . S $P(^TMP($J,"IBUCMM",IBYR,IBMN),U)=+$P($G(^TMP($J,"IBUCMM",IBYR,IBMN)),U)+1
  1. . . S $P(^TMP($J,"IBUCMM",IBYR,IBMN),U,IBCTX)=+$P($G(^TMP($J,"IBUCMM",IBYR,IBMN)),U,IBCTX)+1
  1. . . S:IBNEW $P(^TMP($J,"IBUCMM",IBYR,IBMN),U,6)=+$P($G(^TMP($J,"IBUCMM",IBYR,IBMN)),U,6)+1
  1. . . ;# visits in a given year
  1. . . S $P(^TMP($J,"IBUCMM",IBYR),U)=+$P($G(^TMP($J,"IBUCMM",IBYR)),U)+1
  1. . . S $P(^TMP($J,"IBUCMM",IBYR),U,IBCTX)=+$P($G(^TMP($J,"IBUCMM",IBYR)),U,IBCTX)+1
  1. . . I '$D(^TMP($J,"IBUCMMNM",IBDFN)) D
  1. . . . S ^TMP($J,"IBUCMMNM",IBDFN)=""
  1. . . . S ^TMP($J,"IBUCMMNM")=$G(^TMP($J,"IBUCMMNM"))+1
  1. Q
  1. ;
  1. PRSUM ; Print report from the temp. global
  1. N IBLINE,IBPAG,IBTOT,IBD,IBTY,IBDA,IBY,IBCHG,IBSAV,IBSEQ,IBMON,X,X2,X3,Y,%,IBYR
  1. N IBTOT,IBTOTF,IBTOTC,IBTOTN,IBTOTV
  1. D NOW^%DTC S IBDTH=$$FMTE^XLFDT($E(%,1,12))
  1. S IBLINE="",$P(IBLINE,"=",IOM+1)="",(IBPAG,IBTOT,IBTOTC,IBTOTF,IBTOTN,IBTOTV,IBQUIT,IBCHG)=0
  1. D:'IBEXCEL HDR
  1. D:IBEXCEL EXHDR
  1. I '$D(^TMP($J,"IBUCMM")) W !!,"No Urgent Care Visits found within the specified period" D PAUSE(1) Q
  1. ; - first, print detail lines
  1. F IBMON=$E(IBBDT,1,5):1:$E(IBEDT,1,5) D Q:IBQUIT
  1. . D:'IBEXCEL CHKSTOP Q:IBQUIT
  1. . S IBYR=$E(IBMON,1,3)+1700
  1. . S IBY=$G(^TMP($J,"IBUCMM",IBYR,IBMON))
  1. . ;
  1. . Q:$G(IBY)=""
  1. . ;If EXCEL Output, display with ^ delim
  1. . I IBEXCEL D
  1. . . W !,$$MON($E(IBMON,4,5))_" "_(1700+$E(IBMON,1,3)),U,+$P(IBY,U,1),U,+$P(IBY,U,2),U,+$P(IBY,U,3),U,+$P(IBY,U,4),U,+$P(IBY,U,5),U,+$P(IBY,U,6)
  1. . ;
  1. . ; Otherwise print in screen format
  1. . I 'IBEXCEL D
  1. . . W !,$$MON($E(IBMON,4,5)),?10,1700+$E(IBMON,1,3)
  1. . . W ?34,$J(+$P(IBY,U,1),5) ;# visits
  1. . . W ?43,$J(+$P(IBY,U,2),5) ;# free visits
  1. . . W ?52,$J(+$P(IBY,U,3),5) ;# charged Visits
  1. . . W ?62,$J(+$P(IBY,U,4),5) ;# not counted Visits
  1. . . W ?72,$J(+$P(IBY,U,5),5) ;# visit only Visits
  1. . . W ?83,$J(+$P(IBY,U,6),5) ;# # Unique Patients
  1. . S IBTOT=IBTOT+$P(IBY,U,1),IBTOTF=IBTOTF+$P(IBY,U,2),IBTOTC=IBTOTC+$P(IBY,U,3),IBTOTN=IBTOTN+$P(IBY,U,4),IBTOTV=IBTOTV+$P(IBY,U,5)
  1. . I IBSD="D" D PRDET(IBYR,IBMON)
  1. Q:IBQUIT
  1. D TOTALS
  1. ;
  1. ;Write Unique Patient Definition
  1. W !!,"*The total unique patient number only counts a patient once for the period",!,"of the report."
  1. D PAUSE(1)
  1. Q
  1. ;
  1. PRDET(IBYR,IBMON) ; Print the details of the summary
  1. ;
  1. N IBDFN,IBNM
  1. S IBNM=""
  1. F S IBNM=$O(^TMP($J,"IBUCMM",IBYR,IBMON,IBNM)) Q:IBNM="" D
  1. . S IBDFN=0
  1. . F S IBDFN=$O(^TMP($J,"IBUCMM",IBYR,IBMON,IBNM,IBDFN)) Q:'IBDFN D
  1. . .D CHKSTOP Q:IBQUIT
  1. . .S IBDATA=$G(^TMP($J,"IBUCMM",IBYR,IBMON,IBNM,IBDFN))
  1. . . ;
  1. . . ;Excel Format
  1. . . I IBEXCEL D Q
  1. . . . W !,$$GET1^DIQ(2,IBDFN_",",.01,"E"),U,+$P(IBDATA,U,1),U,+$P(IBDATA,U,2),U,+$P(IBDATA,U,3),U,+$P(IBDATA,U,4),U,+$P(IBDATA,U,5)
  1. . . ;
  1. . . ;Screen format
  1. . . W !?3,$$GET1^DIQ(2,IBDFN_",",.01,"E")
  1. . . W ?34,$J(+$P(IBDATA,U,1),5)
  1. . . W ?43,$J(+$P(IBDATA,U,2),5) ;# free visits
  1. . . W ?52,$J(+$P(IBDATA,U,3),5) ;# charged Visits
  1. . . W ?62,$J(+$P(IBDATA,U,4),5) ;# Removed Visits
  1. . . W ?72,$J(+$P(IBDATA,U,5),5) ;# Visit On Visits
  1. Q
  1. TOTALS ; Print the totals.
  1. N IBI,X
  1. ;
  1. ;MS Excel format
  1. I IBEXCEL D Q
  1. . W !,"REPORT TOTALS",U,IBTOT,U,IBTOTF,U,IBTOTC,U,IBTOTN,U,IBTOTV,U,$G(^TMP($J,"IBUCMMNM"))
  1. ;
  1. ; screen format
  1. W ! F IBI=1:1:88 W "-"
  1. W !,"REPORT TOTALS",?34,$J(IBTOT,5),?43,$J(IBTOTF,5),?52,$J(IBTOTC,5),?62,$J(IBTOTN,5),?72,$J(IBTOTV,5),?82,$J($G(^TMP($J,"IBUCMMNM")),6)
  1. Q
  1. ;
  1. ;Number format
  1. FORMAT(IBNUM,IBDIG,IBFRM) ; Comma format the number
  1. N X,X1,X3
  1. S X=IBNUM,X3=IBDIG
  1. D COMMA^%DTC
  1. Q X
  1. ;
  1. CHKSTOP I $Y>(IOSL-5) D PAUSE(0) Q:IBQUIT D HDR
  1. Q
  1. ;
  1. HDR ; Print header.
  1. N IBI,IBHDR,IBH,IBH1,IBFACNM,IBH2
  1. I $E(IOST,1,2)["C-"!(IBPAG) W @IOF,*13
  1. S IBHDR=$S(IBSD="S":"SUMMARY",1:"DETAIL")
  1. S IBH="URGENT CARE VISIT TRACKING "_IBHDR_" REPORT"
  1. S IBPAG=IBPAG+1 W ?(122-$L(IBH)\2),IBH
  1. S IBH1="FOR ALL SITES"
  1. I IBCA="C" D
  1. . S IBFACNM=$$GET1^DIQ(4,IBFAC_",",.01,"E")
  1. . S IBH1="FOR "_IBFACNM
  1. W !,?(122-$L(IBH1)\2),IBH1
  1. S IBH2="From "_$$DAT(IBBDT)_" through "_$$DAT(IBEDT)
  1. W !,?(122-$L(IBH2)\2),IBH2
  1. W ?IOM-36,IBDTH,?IOM-9,"Page: ",IBPAG
  1. W !!,?33,"TOTAL",?60,"REMOVED",?71,"VISITS",?80,"UNIQUE"
  1. W !," MONTH",?10,"YEAR",?33,"VISITS",?44,"FREE",?51,"BILLED",?60,"VISITS",?71,"ONLY",?80,"PATIENTS"
  1. W ! F IBI=1:1:88 W "-"
  1. Q
  1. ;
  1. EXHDR ; Print Excel version of the header.
  1. W !,"MONTH/YEAR",U,"TOTAL VISITS",U,"FREE",U,"BILLED",U,"REMOVED VISITS",U,"VISITS ONLY",U,"UNIQUE PATIENTS"
  1. Q
  1. ;
  1. STAT() ; Display bill number or status
  1. N IBSTAT S IBSTAT=$G(^IBE(350.21,+$P(IBZ,U,5),0))
  1. Q $S($P(IBSTAT,U,6):$$HLD(+$P(IBZ,U,5)),$P(IBZ,U,5)=99:"Converted",$P(IBZ,U,11)]"":$P($P(IBZ,U,11),"-",2),$P(IBSTAT,U,5):"Cancelled",1:"Pending")
  1. ;
  1. HLD(STAT) ; Return an 'on hold' status string
  1. Q "Hold "_$S(STAT=20:"Rate",STAT=21:"Rev",1:"Ins")
  1. ;
  1. PAUSE(IBEND) ;
  1. Q:$E(IOST,1,2)'["C-"
  1. N IBJ,DIR,DIRUT,DTOUT,DUOUT,DIROUT,Y
  1. W !! ;F IBJ=$Y:1:(IOSL-4) W !
  1. S DIR(0)="E"
  1. I $G(IBEND) S DIR("A")="End of the report. Enter RETURN to continue or '^' to exit"
  1. D ^DIR K DIR I $G(DUOUT) S IBQUIT=1 W @IOF Q
  1. I $G(IBEND) W @IOF
  1. Q
  1. ;
  1. DAT(IBDT) ; Convert FM date to (mm/dd/yy) format.
  1. Q $$FMTE^XLFDT(IBDT,"2MZ")
  1. ;
  1. MON(IBMON) I (IBMON<1)!(IBMON>12) Q ""
  1. Q $P("JANUARY FEBRUARY MARCH APRIL MAY JUNE JULY AUGUST SEPTEMBER OCTOBER NOVEMBER DECEMBER"," ",IBMON)
  1. ;