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

BARRTBSL.m

Go to the documentation of this file.
BARRTBSL ; IHS/SD/TPF - TREASURY DEPOSIT/BATCH STATISTICAL LISTING RPT ;08/20/2008
 ;;1.8;IHS ACCOUNTS RECEIVABLE;**6,19**;OCT 26, 2005
 ;
 ; SDD V1.8 PATCH 6 ITEM 4.1.4
 ;
 ;IHS/SD/AR BAR 1.8, PATCH 19 04/20/2010
 ; IHS/SD/PKD BAR 1.8*19 7/30/10 - Routine too long per SAC - create addt'l routine BARRTBS1
 ; 
ASKTYPE ;EP - ASK WHETHER WANT BATCH OR TRANXN RANGE
 D ^XBFMK
 W !!
 K DIR
 S DIR(0)="SA^1:BATCH;2:TRANSACTION"
 S DIR("A")="Enter date type (Batch/Transaction): "
 D ^DIR
 W !!
 Q:$D(DIRUT)!$D(DTOUT)!$D(DUOUT)!$D(DIROUT)
 Q:X=""!(X[U)
 N DATETYPE
 S DATETYPE=Y
 I Y=1  D ASKBFROM
 I Y=2  D ASKTFROM
 Q:$D(DIRUT)!$D(DTOUT)!$D(DUOUT)!$D(DIROUT)
 Q:X=""!(X[U)
 G ASKSORT
ASKTFROM ;EP - ASK FROM TRANSACTION DATE
 N ALLOW,SORTTYP
 K %DT
 S %DT="AET"
 S %DT("A")="Enter beginning POSTING TRANSACTION date: "
 W !
 D ^%DT
 Q:X=""!(X[U)
 I Y<0 W !,"INVALID DATE. TRY AGAIN!" H 2 G ASKTFROM
 S BARFROM=Y
ASKTTO ;EP - ASK TO TRANSACTION DATE
 K %DT
 S %DT="AET"
 S %DT("A")="Enter ending POSTING TRANSACTION date: "
 W !
 D ^%DT
 Q:X=""!(X[U)
 I Y<0 W !,"INVALID DATE. TRY AGAIN!" H 2 G ASKTTO
 S BARTO=Y
 I BARTO<BARFROM W !!,"END DATE MUST BE GREATER THAN BEGINING DATE" H 2 G ASKTFROM
 Q
ASKBFROM ;EP - ASK FROM BATCH DATE
 N ALLOW,SORTTYP
 K %DT
 S %DT="AET"
 S %DT("A")="Enter beginning batch open date: "
 W !
 D ^%DT
 Q:X=""!(X[U)
 I Y<0 W !,"INVALID DATE. TRY AGAIN!" H 2 G ASKBFROM
 S BARFROM=Y
ASKBTO ;EP - ASK TO BATCH DATE
 K %DT
 S %DT="AET"
 S %DT("A")="Enter ending batch open date: "
 W !
 D ^%DT
 Q:X=""!(X[U)
 I Y<0 W !,"INVALID DATE. TRY AGAIN!" H 2 G ASKBTO
 S BARTO=Y
 I BARTO<BARFROM W !!,"END DATE MUST BE GREATER THAN BEGINING DATE" H 2 G ASKBFROM
 Q
 ;IHS/SD/AR BAR 1.8, PATCH 19 04/20/2010
 ;
ASKSORT ;EP - ASK USER TO SORT BY
 K DIR
 ;IHS/SD/AR BAR 1.8, PATCH 19 04/20/2010
 ;S DIR(0)="SO^1:ALLOWANCE CATEGORY;2:TDN/IPAC NUMBER"
 ;S DIR("A")="Sort Report by:"
 S DIR(0)="SO^1:ALLOWANCE CATEGORY;2:TDN/IPAC NUMBER;3:BOTH ALLOWANCE CATEGORY AND TDN/IPAC NUMBER SORTED BY ALLOWANCE CATEGORY;4:BOTH TDN/IPAC NUMBER AND ALLOWANCE CATEGORY SORTED BY TDN/IPAC THEN BY ALLOWANCE CATEGORY, SUBTOTAL BY TDN/IPAC"
 S DIR("A")="Sort Report by:"
 S DIR("L",1)="Select one of the following:"
 S DIR("L",2)=""
 S DIR("L",3)="  1		ALLOWANCE CATEGORY"
 S DIR("L",4)="  2		TDN/IPAC NUMBER"
 ;IHS/SD/AR BAR 1.8, PATCH 19 04/20/2010
 S DIR("L",5)="  3		BOTH ALLOWANCE CATEGORY AND TDN/IPAC NUMBER"
 S DIR("L",6)="			SORTED BY ALLOWANCE CATEGORY THEN BY TDN/IPAC, SUBTOTAL"
 S DIR("L",7)="			BY ALLOWANCE CATEGORY"
 S DIR("L",8)="  4		BOTH TDN/IPAC NUMBER AND ALLOWANCE CATEGORY"
 S DIR("L",9)="			SORTED BY TDN/IPAC THEN BY ALLOWANCE CATEGORY, SUBTOTAL BY TDN/IPAC"
 S DIR("B")=1
 D ^DIR
 G:$D(DTOUT)!$D(DIROUT)!$D(DUOUT)!(Y="") ASKTYPE
 ;
 N BARSORT
 S BARSORT=X
 I (X=1)!(X=3)!(X=4)  D ASKALLOW(.ALLOW)  ;GET LIST OF ALLOWANCES TO PULL
 ;
ASKDEV ;EP - ASK DEVICE 
 S %ZIS="AQ"
 W !
 D ^%ZIS
 ;IHS/SD/AR PATCH 19 06/03/2010
 ;G:POP ASKFROM
 ;I $D(IO("Q")) D QUE G ASKFROM
 G:POP ASKTYPE
 I $D(IO("Q")) D QUE G ASKTYPE
 U IO
 ;IHS/SD/AR PATCH 18 04/20/2010
 ;D SORT
 D:(DATETYPE=1) SORT
 D:(DATETYPE=2) TRANSORT
 ;D:DATETYPE=1 BATSET  ;THESE CREATE THE BILLS GLOBAL
 ;D:DATETYPE=2 TRANSET
 ;D:BARSORT=3 ALLOW SORT NO ITEMS
 ;D:BARSORT=4 TDN SORT NO ITEMS
 I '$D(^XTMP("BARRTBSL",$J)) D  G ASKTYPE
 .W !!,"THERE IS NO DATA TO PRINT"
 .K DIR
 .S DIR(0)="E"
 .D ^DIR
 ;
 D:(BARSORT=1)!(BARSORT=2) PRINT
 D:(BARSORT>2) PRINTNI^BARRTBS1
 ;D PRINT
 D ^%ZISC
 D HOME^%ZIS
 ;IHS/SD/AR PATCH 19 06/03/2010
 ;G ASKFROM
 G ASKTYPE
 Q
 ;
SORTQ ;EP - ENTRY FROM TASK MAN
 D SORT
 I '$D(^XTMP("BARRTBSL",$J)) D  Q
 .D TOPHDR
 .W !!,"THERE IS NO DATA TO PRINT"
 D PRINT
 Q
 ;
QUE ; EP - QUE THE BARRTBSL REPORT
 S ZTRTN="SORTQ^BARRTBSL"
 S ZTDESC="BATCH STATISTICAL REPORT (TBSL)"
 S ZTSAVE("BARTO")=""
 S ZTSAVE("BARFROM")=""
 S ZTSAVE("ALLOW")=""
 D ^%ZTLOAD
 I $D(ZTSK)[0 W !!?5,"Report Cancelled!"
 E  W !!?5,"Report task #: ",$G(ZTSK)
 D HOME^%ZIS
 Q
 ;
ASKALLOW(ALLOW) ;EP - ASK LIST OF ALLOWANCES TO PULL
 N DONE,LIST
 ;GET LIST OF ALLOWANCE CATEGORIES
 S LIST=$P($G(^DD(90051.02,7,0)),U,3)_"ALL:ALL CATEGORIES"
 K DIR
 S DIR(0)="SO^"_LIST
 S DIR("A")="Include Which Allowance Categories"
 S DIR("B")="ALL"
 S DONE=0
 F  D  Q:DONE
 .I $O(ALLOW("")) W !!,"You have chosen the following:"
 .S A=""
 .F  S A=$O(ALLOW(A)) Q:A=""  D
 ..W !?30,A
 .D ^DIR
 .I Y'="ALL" K DIR("B")
 .I $D(DTOUT)!$D(DIROUT)!$D(DUOUT)!(Y="") S DONE=1 Q
 .S ALLOW(Y)=""
 .I Y="ALL" K ALLOW S ALLOW="ALL",DONE=1
 I '$D(ALLOW) S ALLOW="ALL"
 Q
 ;
TOPHDR ;EP - TOP HEADER
 D TOPHDR^BARRTBS1
 Q
 ;
ITEMHDR ;EP - ITEM HEADER
 ;W !,"BATCH DATE"
 ;IHS/SD/AR PATCH 19 06/04/2010
 D ITEMHDR^BARRTBS1
 Q
 ;
DATACHEK D DATACHEK^BARRTBS1  ; moved code to shorten routine
 Q
 ;
PRINT D PRINT^BARRTBS1
 Q
 ;
 ;IHS/SD/AR PATCH 19 06/03/2010
TRANSORT ;
 ;SORT BY ALLOWANCE CAT, THEN TDN, SUBT TDN, SUBT ALLOW
 N DATETIME,BARCOLDA,BARITMDA,ALLOWCAT,COLLIDDA,COLLIDNM,BATCHNM,COLIENS,NOW,SORTSUB2
 N ITEMIENS,ITMTDN,ITEMTOT,ITMPSTOT,ITMUNALL,ITMREFUN,ITMPSBAL,SORTSUB,END,BATSTAT
 K ^XTMP("BARRTBSL",$J)
 S DATETIME=BARFROM-.01
 S END=BARTO_".999999"
 S BATCHNM=""
 ;F  S DATETIME=$O(^BARCOL(DUZ(2),"C",DATETIME)) Q:'DATETIME!(DATETIME>END)  D
 F  S DATETIME=$O(^BARTR(DUZ(2),"B",DATETIME)) Q:'DATETIME!(DATETIME>END)  D
 .S BATCHNM=$$GET1^DIQ(90050.03,DATETIME,14)  ;A/R COLLECTION BATCH NAME
 .Q:BATCHNM=""
 .S BARCOLDA=""
 .F  S BARCOLDA=$O(^BARCOL(DUZ(2),"B",BATCHNM,BARCOLDA)) Q:'BARCOLDA  D
 ..S COLIENS=BARCOLDA_","
 ..;S BATCHNM=$P($$GET1^DIQ(90051.01,COLIENS,.01,"E"),"-",2,999)_"-"  ;A/R COLLECTION BATCH NAME
 ..;S BATCHNM=$$GET1^DIQ(90051.01,COLIENS,.01,"E")  ;A/R COLLECTION BATCH NAME
 ..S COLLIDDA=$$GET1^DIQ(90051.01,COLIENS,2,"I")  ;A/R COLLECTION POINT PTR
 ..S COLLIDNA=$$GET1^DIQ(90051.01,COLIENS,2,"E")  ;A/R COLLECTION POINT NAME
 ..S ALLOWCAT=$$GET1^DIQ(90051.02,COLLIDDA_",",7,"I")  ;ALLOWANCE CATEGORY
 ..S:ALLOWCAT="" ALLOWCAT="NULL"                       ;'MCR' FOR Medicare;
 ..;                                                   ;'MCD' FOR Medicaid;
 ..;                                                   ;'PVT' FOR Private Insurance;
 ..;                                                   ;'OTH' FOR Other;
 ..S BATSTAT=$$GET1^DIQ(90051.01,COLIENS,3,"I")  ;BATCH STATUS 
 ..;
 ..I $D(ALLOW)=10,('$D(ALLOW(ALLOWCAT))) Q  ;SCREEN OUT UNCHOSEN ALLOWANCE CATEGORIES
 ..S BATCHTDN=$$GET1^DIQ(90051.01,COLIENS,28,"E")  ;BATCH LEVEL 'TREASURY DEPOSIT NUMBER/IPAC
 ..S:BATCHTDN="" BATCHTDN="NULL"
 ..;IHS/SD/AR PATCH 19 06/04/2010
 ..S BATDNDT=$$GET1^DIQ(90051.01,COLIENS,30)  ;BATCH LEVEL TDN DATE
 ..S:BATDNDT="" BATDNDT="NULL"
 ..;IHS/SD/AR PATCH 19 06/04/2010
 ..S BARITMDA=0
 ..F  S BARITMDA=$O(^BARCOL(DUZ(2),BARCOLDA,1,BARITMDA)) Q:'BARITMDA  D
 ...S ITEMIENS=BARITMDA_","_BARCOLDA_","
 ...S BARSTAT=$$GET1^DIQ(90051.1101,ITEMIENS,17,"I")  ;ITEM STATUS 'C' = CANCELLED, 'R' ROLLED OVER
 ...Q:BARSTAT="R"!(BARSTAT="C")
 ...S ITMTDN=$$GET1^DIQ(90051.1101,ITEMIENS,20,"E")  ;ITEM LEVEL 'TREASURY DEPOSIT NUMBER/IPAC
 ...S:ITMTDN="" ITMTDN="NULL"
 ...S ITEMTOT=$$GET1^DIQ(90051.1101,ITEMIENS,102.5,"E")  ;CREDIT-DEBIT
 ...S ITMPSTOT=$$GET1^DIQ(90051.1101,ITEMIENS,18,"E")  ;ITEM POSTING TOTAL
 ...S ITMUNTRU=$$GET1^DIQ(90051.1101,ITEMIENS,105,"E")  ;TRUE ITEM UN-ALLOCATED
 ...S ITMUNTOT=$$GET1^DIQ(90051.1101,ITEMIENS,105.5,"E")  ;ITEM TOTAL UN-ALLOCATED
 ...S ITMREFUN=$$GET1^DIQ(90051.1101,ITEMIENS,106,"E")  ;ITEM REFUNDED
 ...S ITMTOTTR=$$GET1^DIQ(90051.1101,ITEMIENS,22,"E")  ;ITEM TOTAL TRANSFER
 ...S ITMPSBAL=$$GET1^DIQ(90051.1101,ITEMIENS,19,"E")  ;ITEM POSTING BALANCE
 ...;IHS/SD/AR PATCH 19 06/06/10
 ...;I $D(ALLOW) S SORTSUB=ALLOWCAT,SORTTYP="ALLOW"
 ...;E  S SORTSUB=$S(BATCHTDN'="NULL":BATCHTDN,1:ITMTDN),SORTTYP="TDN"
 ...I (BARSORT=1)!(BARSORT=3) S SORTSUB=ALLOWCAT,SORTTYP="ALLOW",SORTSUB2=BATCHTDN
 ...E  S SORTSUB=$S(BATCHTDN'="NULL":BATCHTDN,1:ITMTDN),SORTTYP="TDN",SORTSUB2=ALLOWCAT
 ...;IHS/SD/AR PATCH 19 06/04/2010
 ...;S ^XTMP("BARRTBSL",$J,SORTSUB,BATCHNM,BARITMDA)=COLLIDNA_U_$S(BATCHTDN'="NULL":BATCHTDN_"~",1:ITMTDN)_U_ITEMTOT_U_ITMPSTOT_U_ITMUNTRU_U_ITMUNTOT_U_ITMREFUN_U_ITMTOTTR_U_ITMPSBAL_U_BATSTAT Q
 ...I (BARSORT<3)  D
 ....S ^XTMP("BARRTBSL",$J,SORTSUB,BATCHNM,BARITMDA)=COLLIDNA_U_$S(BATCHTDN'="NULL":BATCHTDN_"~",1:ITMTDN)_U_ITEMTOT_U_ITMPSTOT_U_ITMUNTRU_U_ITMUNTOT_U_ITMREFUN_U_ITMTOTTR_U_ITMPSBAL_U_BATSTAT_U_BATDNDT Q
 ...I (BARSORT>2)  D
 ....S ^XTMP("BARRTBSL",$J,SORTSUB,SORTSUB2,BATDNDT,BATCHNM,BARITMDA)=COLLIDNA_U_$S(BATCHTDN'="NULL":BATCHTDN_"~",1:ITMTDN)_U_ITEMTOT_U_ITMPSTOT_U_ITMUNTRU_U_ITMUNTOT_U_ITMREFUN_U_ITMTOTTR_U_ITMPSBAL_U_BATSTAT Q
 Q
 ;
SORT ;EP- SORT FO TBSL REPORT
 N DATETIME,BARCOLDA,BARITMDA,ALLOWCAT,COLLIDDA,COLLIDNM,BATCHNM,COLIENS,NOW,SORTSUB2
 N ITEMIENS,ITMTDN,ITEMTOT,ITMPSTOT,ITMUNALL,ITMREFUN,ITMPSBAL,SORTSUB,END,BATSTAT
 K ^XTMP("BARRTBSL",$J)
 S DATETIME=BARFROM-.01
 S END=BARTO_".999999"
 F  S DATETIME=$O(^BARCOL(DUZ(2),"C",DATETIME)) Q:'DATETIME!(DATETIME>END)  D
 .S BARCOLDA=""
 .F  S BARCOLDA=$O(^BARCOL(DUZ(2),"C",DATETIME,BARCOLDA)) Q:'BARCOLDA  D
 ..S COLIENS=BARCOLDA_","
 ..;S BATCHNM=$P($$GET1^DIQ(90051.01,COLIENS,.01,"E"),"-",2,999)_"-"  ;A/R COLLECTION BATCH NAME
 ..S BATCHNM=$$GET1^DIQ(90051.01,COLIENS,.01,"E")  ;A/R COLLECTION BATCH NAME
 ..S COLLIDDA=$$GET1^DIQ(90051.01,COLIENS,2,"I")  ;A/R COLLECTION POINT PTR
 ..S COLLIDNA=$$GET1^DIQ(90051.01,COLIENS,2,"E")  ;A/R COLLECTION POINT NAME
 ..S ALLOWCAT=$$GET1^DIQ(90051.02,COLLIDDA_",",7,"I")  ;ALLOWANCE CATEGORY
 ..S:ALLOWCAT="" ALLOWCAT="NULL"                       ;'MCR' FOR Medicare;
 ..;                                                   ;'MCD' FOR Medicaid;
 ..;                                                   ;'PVT' FOR Private Insurance;
 ..;                                                   ;'OTH' FOR Other;
 ..S BATSTAT=$$GET1^DIQ(90051.01,COLIENS,3,"I")  ;BATCH STATUS 
 ..;
 ..I $D(ALLOW)=10,('$D(ALLOW(ALLOWCAT))) Q  ;SCREEN OUT UNCHOSEN ALLOWANCE CATEGORIES
 ..S BATCHTDN=$$GET1^DIQ(90051.01,COLIENS,28,"E")  ;BATCH LEVEL 'TREASURY DEPOSIT NUMBER/IPAC
 ..S:BATCHTDN="" BATCHTDN="NULL"
 ..;IHS/SD/AR PATCH 19 06/04/2010
 ..S BATDNDT=$$GET1^DIQ(90051.01,COLIENS,30)  ;BATCH LEVEL TDN DATE
 ..S:BATDNDT="" BATDNDT="NULL"
 ..;IHS/SD/AR PATCH 19 06/04/2010
 ..S BARITMDA=0
 ..F  S BARITMDA=$O(^BARCOL(DUZ(2),BARCOLDA,1,BARITMDA)) Q:'BARITMDA  D
 ...S ITEMIENS=BARITMDA_","_BARCOLDA_","
 ...S BARSTAT=$$GET1^DIQ(90051.1101,ITEMIENS,17,"I")  ;ITEM STATUS 'C' = CANCELLED, 'R' ROLLED OVER
 ...Q:BARSTAT="R"!(BARSTAT="C")
 ...S ITMTDN=$$GET1^DIQ(90051.1101,ITEMIENS,20,"E")  ;ITEM LEVEL 'TREASURY DEPOSIT NUMBER/IPAC
 ...S:ITMTDN="" ITMTDN="NULL"
 ...S ITEMTOT=$$GET1^DIQ(90051.1101,ITEMIENS,102.5,"E")  ;CREDIT-DEBIT
 ...S ITMPSTOT=$$GET1^DIQ(90051.1101,ITEMIENS,18,"E")  ;ITEM POSTING TOTAL
 ...S ITMUNTRU=$$GET1^DIQ(90051.1101,ITEMIENS,105,"E")  ;TRUE ITEM UN-ALLOCATED
 ...S ITMUNTOT=$$GET1^DIQ(90051.1101,ITEMIENS,105.5,"E")  ;ITEM TOTAL UN-ALLOCATED
 ...S ITMREFUN=$$GET1^DIQ(90051.1101,ITEMIENS,106,"E")  ;ITEM REFUNDED
 ...S ITMTOTTR=$$GET1^DIQ(90051.1101,ITEMIENS,22,"E")  ;ITEM TOTAL TRANSFER
 ...S ITMPSBAL=$$GET1^DIQ(90051.1101,ITEMIENS,19,"E")  ;ITEM POSTING BALANCE
 ...;IHS/SD/AR PATCH 19 06/06/10
 ...;I $D(ALLOW) S SORTSUB=ALLOWCAT,SORTTYP="ALLOW"
 ...;E  S SORTSUB=$S(BATCHTDN'="NULL":BATCHTDN,1:ITMTDN),SORTTYP="TDN"
 ...I (BARSORT=1)!(BARSORT=3) S SORTSUB=ALLOWCAT,SORTTYP="ALLOW",SORTSUB2=BATCHTDN
 ...E  S SORTSUB=$S(BATCHTDN'="NULL":BATCHTDN,1:ITMTDN),SORTTYP="TDN",SORTSUB2=ALLOWCAT
 ...;IHS/SD/AR PATCH 19 06/04/2010
 ...;S ^XTMP("BARRTBSL",$J,SORTSUB,BATCHNM,BARITMDA)=COLLIDNA_U_$S(BATCHTDN'="NULL":BATCHTDN_"~",1:ITMTDN)_U_ITEMTOT_U_ITMPSTOT_U_ITMUNTRU_U_ITMUNTOT_U_ITMREFUN_U_ITMTOTTR_U_ITMPSBAL_U_BATSTAT Q
 ...I (BARSORT<3)  D
 ....S ^XTMP("BARRTBSL",$J,SORTSUB,BATCHNM,BARITMDA)=COLLIDNA_U_$S(BATCHTDN'="NULL":BATCHTDN_"~",1:ITMTDN)_U_ITEMTOT_U_ITMPSTOT_U_ITMUNTRU_U_ITMUNTOT_U_ITMREFUN_U_ITMTOTTR_U_ITMPSBAL_U_BATSTAT_U_BATDNDT Q
 ...I (BARSORT>2)  D
 ....S ^XTMP("BARRTBSL",$J,SORTSUB,SORTSUB2,BATDNDT,BATCHNM,BARITMDA)=COLLIDNA_U_$S(BATCHTDN'="NULL":BATCHTDN_"~",1:ITMTDN)_U_ITEMTOT_U_ITMPSTOT_U_ITMUNTRU_U_ITMUNTOT_U_ITMREFUN_U_ITMTOTTR_U_ITMPSBAL_U_BATSTAT Q
 Q
 ;