BPSTASDB ;AITC/PD - ECME TAS BPSTL Utility; 12/16/2019
 ;;1.0;E CLAIMS MGMT ENGINE;**27**;JUN 2004;Build 15
 ;;Per VA Directive 6402, this routine should not be modified.
 ;
 Q
 ;
 ; RPC to reset or add entries to the queue used for
 ; transmitting claims to TAS. Queue = ^BPSTL("C")
 ; Database: BPS LOG OF TRANSACTIONS (#9002313.57)
 ;    Field: MCCF EDI TAS PROGRESS (#20)
 ; 
 ; Inputs: FLAG (Required)
 ;            1 = Reset Existing Entries to 1
 ;            2 = Add New Entries
 ;         DATE (optional)
 ;            Date to be used if input parameter FLAG = 2 (ADD)
 ;            Starting date for adding new entries to the queue
 ;
EN(RESULT,ARGS) ; RPC Entry Point
 ;
 N BPSDATE,BPSFLAG,COUNT
 K RESULT
 ;
 S BPSFLAG=$G(ARGS("FLAG"))
 I BPSFLAG="" S COUNT=-1 G RESULT
 I (BPSFLAG'=1)&(BPSFLAG'=2) S COUNT=-3 G RESULT
 S BPSDATE=$G(ARGS("DATE"))
 I BPSFLAG=2,$G(BPSDATE)="" S COUNT=-1 G RESULT
 ;
 S COUNT=0
 I BPSFLAG=1 D RESET
 I BPSFLAG=2 D ADD(BPSDATE)
 ;
RESULT ; setup JSON result
 ; Result will return variable COUNT
 ; COUNT = # of records reset or added
 ; COUNT = -1 indicates an input parameter was missing
 ; COUNT = -2 indicates the date passed in for ADD was invalid
 ; COUNT = -3 indicates input FLAG was not 1 or 2
 S RESULT(1)="[{"_"""updates"""_":"_COUNT_"}]"
 ;
 Q
 ;
RESET ; Reset existing entries in ^BPSTL("C") to 1
 ; Only entries that currently have a defined value for field #20
 ; will be reset.  Value will be reset to 1 (READY TO SEND (OPEN))
 ;
 N BPS57,BPSINDX
 ;
 S BPSINDX=1
 F  S BPSINDX=$O(^BPSTL("C",BPSINDX)) Q:'BPSINDX  D
 . S BPS57=0
 . F  S BPS57=$O(^BPSTL("C",BPSINDX,BPS57)) Q:'BPS57  D
 . . N BPSA,BPSFN,BPSREC
 . . S BPSFN=9002313.57
 . . S BPSREC=BPS57_","
 . . S BPSA(BPSFN,BPSREC,20)=1
 . . D FILE^DIE("","BPSA","")
 . . S COUNT=COUNT+1
 Q
 ;
ADD(BPSDATE) ; Add new entries to ^BPSTL("C")
 ; Using the AH index and the date passed in, add entries
 ; to the queue that are not already in the queue. Set
 ; the value to 1.
 ;
 N BPS57
 ;
 S BPSDATE=$$DATE(BPSDATE)
 I BPSDATE=-1 S COUNT=-2 Q
 ;
 F  S BPSDATE=$O(^BPSTL("AH",BPSDATE)) Q:'BPSDATE  D
 . S BPS57=0
 . F  S BPS57=$O(^BPSTL("AH",BPSDATE,BPS57)) Q:'BPS57  D
 . . ; Don't include entries with Field #20 already set
 . . I $$GET1^DIQ(9002313.57,BPS57,20)'="" Q
 . . ; Don't include non-billable transactions
 . . I $$GET1^DIQ(9002313.57,BPS57,19,"I")'="N" D
 . . . N BPSA,BPSFN,BPSREC
 . . . S BPSFN=9002313.57
 . . . S BPSREC=BPS57_","
 . . . S BPSA(BPSFN,BPSREC,20)=1
 . . . D FILE^DIE("","BPSA","")
 . . . S COUNT=COUNT+1
 Q
 ;
DATE(X) ; Convert Date to FileMan format
 ;
 N %DT,Y
 D ^%DT
 Q Y
 ;
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HBPSTASDB   2707     printed  Sep 23, 2025@19:29:41                                                                                                                                                                                                    Page 2
BPSTASDB  ;AITC/PD - ECME TAS BPSTL Utility; 12/16/2019
 +1       ;;1.0;E CLAIMS MGMT ENGINE;**27**;JUN 2004;Build 15
 +2       ;;Per VA Directive 6402, this routine should not be modified.
 +3       ;
 +4        QUIT 
 +5       ;
 +6       ; RPC to reset or add entries to the queue used for
 +7       ; transmitting claims to TAS. Queue = ^BPSTL("C")
 +8       ; Database: BPS LOG OF TRANSACTIONS (#9002313.57)
 +9       ;    Field: MCCF EDI TAS PROGRESS (#20)
 +10      ; 
 +11      ; Inputs: FLAG (Required)
 +12      ;            1 = Reset Existing Entries to 1
 +13      ;            2 = Add New Entries
 +14      ;         DATE (optional)
 +15      ;            Date to be used if input parameter FLAG = 2 (ADD)
 +16      ;            Starting date for adding new entries to the queue
 +17      ;
EN(RESULT,ARGS) ; RPC Entry Point
 +1       ;
 +2        NEW BPSDATE,BPSFLAG,COUNT
 +3        KILL RESULT
 +4       ;
 +5        SET BPSFLAG=$GET(ARGS("FLAG"))
 +6        IF BPSFLAG=""
               SET COUNT=-1
               GOTO RESULT
 +7        IF (BPSFLAG'=1)&(BPSFLAG'=2)
               SET COUNT=-3
               GOTO RESULT
 +8        SET BPSDATE=$GET(ARGS("DATE"))
 +9        IF BPSFLAG=2
               IF $GET(BPSDATE)=""
                   SET COUNT=-1
                   GOTO RESULT
 +10      ;
 +11       SET COUNT=0
 +12       IF BPSFLAG=1
               DO RESET
 +13       IF BPSFLAG=2
               DO ADD(BPSDATE)
 +14      ;
RESULT    ; setup JSON result
 +1       ; Result will return variable COUNT
 +2       ; COUNT = # of records reset or added
 +3       ; COUNT = -1 indicates an input parameter was missing
 +4       ; COUNT = -2 indicates the date passed in for ADD was invalid
 +5       ; COUNT = -3 indicates input FLAG was not 1 or 2
 +6        SET RESULT(1)="[{"_"""updates"""_":"_COUNT_"}]"
 +7       ;
 +8        QUIT 
 +9       ;
RESET     ; Reset existing entries in ^BPSTL("C") to 1
 +1       ; Only entries that currently have a defined value for field #20
 +2       ; will be reset.  Value will be reset to 1 (READY TO SEND (OPEN))
 +3       ;
 +4        NEW BPS57,BPSINDX
 +5       ;
 +6        SET BPSINDX=1
 +7        FOR 
               SET BPSINDX=$ORDER(^BPSTL("C",BPSINDX))
               if 'BPSINDX
                   QUIT 
               Begin DoDot:1
 +8                SET BPS57=0
 +9                FOR 
                       SET BPS57=$ORDER(^BPSTL("C",BPSINDX,BPS57))
                       if 'BPS57
                           QUIT 
                       Begin DoDot:2
 +10                       NEW BPSA,BPSFN,BPSREC
 +11                       SET BPSFN=9002313.57
 +12                       SET BPSREC=BPS57_","
 +13                       SET BPSA(BPSFN,BPSREC,20)=1
 +14                       DO FILE^DIE("","BPSA","")
 +15                       SET COUNT=COUNT+1
                       End DoDot:2
               End DoDot:1
 +16       QUIT 
 +17      ;
ADD(BPSDATE) ; Add new entries to ^BPSTL("C")
 +1       ; Using the AH index and the date passed in, add entries
 +2       ; to the queue that are not already in the queue. Set
 +3       ; the value to 1.
 +4       ;
 +5        NEW BPS57
 +6       ;
 +7        SET BPSDATE=$$DATE(BPSDATE)
 +8        IF BPSDATE=-1
               SET COUNT=-2
               QUIT 
 +9       ;
 +10       FOR 
               SET BPSDATE=$ORDER(^BPSTL("AH",BPSDATE))
               if 'BPSDATE
                   QUIT 
               Begin DoDot:1
 +11               SET BPS57=0
 +12               FOR 
                       SET BPS57=$ORDER(^BPSTL("AH",BPSDATE,BPS57))
                       if 'BPS57
                           QUIT 
                       Begin DoDot:2
 +13      ; Don't include entries with Field #20 already set
 +14                       IF $$GET1^DIQ(9002313.57,BPS57,20)'=""
                               QUIT 
 +15      ; Don't include non-billable transactions
 +16                       IF $$GET1^DIQ(9002313.57,BPS57,19,"I")'="N"
                               Begin DoDot:3
 +17                               NEW BPSA,BPSFN,BPSREC
 +18                               SET BPSFN=9002313.57
 +19                               SET BPSREC=BPS57_","
 +20                               SET BPSA(BPSFN,BPSREC,20)=1
 +21                               DO FILE^DIE("","BPSA","")
 +22                               SET COUNT=COUNT+1
                               End DoDot:3
                       End DoDot:2
               End DoDot:1
 +23       QUIT 
 +24      ;
DATE(X)   ; Convert Date to FileMan format
 +1       ;
 +2        NEW %DT,Y
 +3        DO ^%DT
 +4        QUIT Y
 +5       ;