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

IBCFP.m

Go to the documentation of this file.
  1. IBCFP ;ALB/ARH - PRINT AUTHORIZED BILLS IN ORDER ; 6-DEC-94
  1. ;;Version 2.0 ; INTEGRATED BILLING ;; 21-MAR-94
  1. ;;Per VHA Directive 10-93-142, this routine should not be modified.
  1. ;
  1. ;
  1. S IBPAR1=$G(^IBE(350.9,1,1))
  1. S IBFT=$G(^IBE(353,+$P(IBPAR1,U,26),0)) I $P(IBFT,U,2)="" W !,"Default printer in billing not defined for the "_$P(IBFT,U,1)_", none will print!",!
  1. I +$P(IBPAR1,U,22),$P($G(^IBE(353,+$$FNT^IBCU3("HCFA 1500"),0)),U,2)="" W !,"Default printer in billing not defined for the HCFA 1500, none will print!",!
  1. I '$D(^DGCR(399,"AST")) W !,"There are no Authorized but not Printed bills to print!" G END
  1. ;
  1. S IBS="",IBZ="Z:ZIP;I:INSURANCE COMPANY NAME;P:PATIENT NAME;"
  1. ORDER S DIR("?")="This option prints all bills with a Status of Authorized in the order requested. The printed bills may be sorted by: Zip Code, Insurance Company Name, and Patient name."
  1. 1 S DIR("A")="First Sort Bills By",DIR(0)="SOB^"_IBZ D ^DIR I $D(DIRUT) G END
  1. S IBS=IBS_$S(Y="Z":1,Y="I":2,Y="P":3,1:0) S IBX=$P($P(IBZ,Y_":",2),";",1)
  1. ;
  1. S DIR("?",1)="Enter the field that the bills should be sorted on within "_IBX_". Press return if the order already entered is sufficient.",DIR("?",2)=""
  1. 2 S DIR("A")="Then Sort Bills By",DIR(0)="SOB^"_IBZ D ^DIR I Y'="",$D(DIRUT) G END
  1. S IBS=IBS_$S(Y="Z":1,Y="I":2,Y="P":3,1:0) G:Y="" BEG S IBY=$P($P(IBZ,Y_":",2),";",1)
  1. ;
  1. S DIR("?",1)="Enter the field that the bills should be sorted on within "_IBX_" and "_IBY_". Press return if the order already entered is sufficient."
  1. 3 S DIR("A")="Then Sort Bills By",DIR(0)="SOB^"_IBZ D ^DIR K DIR I Y'="",$D(DIRUT) G END
  1. S IBS=IBS_$S(Y="Z":1,Y="I":2,Y="P":3,1:0)
  1. ;
  1. BEG S DIR("A")="Begin printing bills",DIR("?")="Enter 'Y'es to begin printing of all authorized bills."
  1. W ! S DIR(0)="YBO",DIR("??")="^D DISP^IBCF" D ^DIR K DIR I 'Y W "... bills not printed!" G END
  1. ;
  1. S ZTRTN="QTASK^IBCFP",ZTDESC="BATCH PRINT AUTHORIZED THIRD PARTY BILLS",ZTIO="",ZTSAVE("IBS")="" D ^%ZTLOAD
  1. I $D(ZTSK) W !," ... queued"
  1. ;
  1. END K DIR,IBX,IBY,IBZ,IBS,IBPAR1,IBFT,Y,X,DIRUT ; end of interactive part
  1. Q
  1. ;
  1. QTASK ; first part, sorts authorized bills in to order requested by bill form type then queues off one job for each form type to print the bills
  1. ;
  1. SORT ;sort authorized bills by form type and requested sort order (notice that bill addendums only print for HCFA 1500's)
  1. S (IBQ,IBIFN)=0 F S IBIFN=$O(^DGCR(399,"AST",3,IBIFN)) Q:'IBIFN!IBQ D I $$STOP S IBQ=1 Q
  1. . S IBFT=$$FT^IBCU3(IBIFN)
  1. . S IBX=$G(^DGCR(399,IBIFN,0)),IBPAT=$P($G(^DPT(+$P(IBX,U,2),0)),U,1) Q:$P(IBX,U,13)'=3
  1. . S IBX=$G(^DGCR(399,IBIFN,"M")),IBZIP=$P(IBX,U,9),IBINS=$P($G(^DIC(36,+IBX,0)),U,1)
  1. . S IBX=IBZIP_U_IBINS_U_IBPAT,IBS1=$P(IBX,U,$E(IBS,1))_" ",IBS2=$P(IBX,U,$E(IBS,2))_" ",IBS3=$P(IBX,U,$E(IBS,3))_" "
  1. . S ^TMP("IBCFP"_IBFT,$J,IBS1,IBS2,IBS3,IBIFN)="" Q:$$FTN^IBCU3(IBFT)'["HCFA 1500"
  1. . S IBFT=$$FNT^IBCU3("BILL ADDENDUM") I +IBFT S ^TMP("IBCFP"_IBFT,$J,IBS1,IBS2,IBS3,IBIFN)=""
  1. K IBIFN,IBFT,IBX,IBY,IBPAT,IBZIP,IBINS,IBS1,IBS2,IBS3,IBS
  1. ;
  1. QUEUE ; starts a queued job for each form type that an authorized bill was found for
  1. ; first checks that a device has been defined for the form type
  1. I 'IBQ S IBX="IBCFP" F S IBX=$O(^TMP(IBX)) Q:(IBX'?1"IBCFP"1N) Q:($O(^TMP(IBX,0))'=$J) S IBFT=$E(IBX,6) D
  1. . S ZTIO=$P($G(^IBE(353,+IBFT,0)),U,2) Q:ZTIO="" S IBFTP=IBX,IBJ=$J
  1. . S ZTDTH=$H,ZTSAVE("IBFTP")="",ZTSAVE("IBFT")="",ZTSAVE("IBJ")="",ZTSAVE("^TMP(IBFTP,IBJ,")=""
  1. . S ZTDESC="BATCH PRINTING "_$$FTN^IBCU3(+IBFT),ZTRTN="QBILL^IBCFP" D ^%ZTLOAD
  1. K IBX,IBY,IBFTP,IBJ ; end of first queued part
  1. Q
  1. ;
  1. ;
  1. QBILL ; second queued part, this will print all authorized bills for a specific form type
  1. ; pass in IBFTP="IBCFP"_(form type) and "^TMP(IBFTP,$J)" sorted array of bills
  1. S (IBQ,IBS1)=0 F S IBS1=$O(^TMP(IBFTP,IBJ,IBS1)) Q:IBS1=""!IBQ D
  1. . S IBS2=0 F S IBS2=$O(^TMP(IBFTP,IBJ,IBS1,IBS2)) Q:IBS2=""!IBQ D
  1. .. S IBS3=0 F S IBS3=$O(^TMP(IBFTP,IBJ,IBS1,IBS2,IBS3)) Q:IBS3=""!IBQ D
  1. ... S IBBN=0 F S IBBN=$O(^TMP(IBFTP,IBJ,IBS1,IBS2,IBS3,IBBN)) Q:IBBN="" D I $$STOP S IBQ=1 Q
  1. .... D ROUT(IBFT,1,IBBN)
  1. K ^TMP(IBFTP,IBJ),IBJ,IBFT,IBFTP,IBL,IBIFN,IBBN,IBPNT,IBQ ; end of last queued part
  1. Q
  1. ;
  1. ROUT(IBFT,IBPNT,IBIFN) ; sub procedure so can protect variables with new
  1. N IBBN,IBS1,IBS2,IBS3,IBQ,IBFTP,IBJ
  1. I IBFT=1 S DFN=$P($G(^DGCR(399,+IBIFN,0)),U,2) D ENP^IBCF1 W @IOF G RE
  1. I IBFT=2 D EN^IBCF2 W @IOF G RE
  1. I $$FTN^IBCU3(+IBFT)="UB-92" D EN^IBCF3 W @IOF G RE
  1. I $$FTN^IBCU3(+IBFT)="BILL ADDENDUM" I +$$BILLAD^IBCF4(IBIFN) D EN^IBCF4 W @IOF G RE
  1. RE Q
  1. ;
  1. DATE(X) Q $E(X,4,5)_"/"_$E(X,6,7)_"/"_$E(X,2,3)
  1. ;
  1. STOP() ;determine if user has requested the queued report to stop
  1. I $D(ZTQUEUED),$$S^%ZTLOAD S ZTSTOP=1 K ZTREQ I +$G(IBPGN) W !,"***TASK STOPPED BY USER***"
  1. Q +$G(ZTSTOP)