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

BPSRPC03.m

Go to the documentation of this file.
  1. BPSRPC03 ;AITC/PD - ECME TAS RPC - Write Back;02/08/2019
  1. ;;1.0;E CLAIMS MGMT ENGINE;**27,34**;JUN 2004;Build 11
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. Q
  1. ;
  1. PUT(RESULT,ARGS) ; RPC: BPS TAS CLAIM WRITE BACK
  1. ; Update BPSTL entry successfully written to TAS
  1. ;
  1. ; Required Input: BPS57 - IEN for BPS LOG OF TRANSACTIONS FILE (#9002313.57)
  1. ; BPS57 = ARGS("IEN")
  1. ;
  1. ; Once a transaction has successfully be written to the TAS database,
  1. ; the record id is returned to VistA to update the MCCF EDI TAS PROGRESS
  1. ; field in BPS LOG OF TRANSACTIONS file.
  1. ;
  1. ; MCCF EDI TAS PROGRESS Values:
  1. ; '1' FOR READY TO SEND
  1. ; '2' FOR SENT
  1. ; '3' FOR WRITTEN
  1. ;
  1. N BPS57,BPSFLAG,BPSPC,BPSRES,BPSVALUE
  1. K RESULT
  1. ;
  1. ; BPSRES indicates if the Write Back is successful or not.
  1. ; 0=Unsuccessful 1=Successful
  1. S BPSRES=0
  1. S BPS57=ARGS("IEN")
  1. ;
  1. ; If no Txn IEN was passed in or a Txn IEN that doesn't
  1. ; exist in the ^BPSTL file, exit RPC with the RESULT
  1. ; JSON indicating Unsuccessful
  1. I BPS57="" G RESULT
  1. I '$D(^BPSTL(BPS57)) G RESULT
  1. ;
  1. ; --------------------------------------------------------
  1. ;
  1. ; Initialize fields
  1. ;
  1. ; CLAIM - Field 3 - Pointer to BPS CLAIMS FILE #9002313.02
  1. S BPSPC=$$GET1^DIQ(9002313.57,BPS57,3,"I")
  1. ;
  1. ; MCCF EDI TAS PROGRESS - Field 20
  1. S BPSFLAG=$$GET1^DIQ(9002313.57,BPS57,20,"I")
  1. ;
  1. ; --------------------------------------------------------
  1. ;
  1. ; The only Txn IENs that should be receiving a write back
  1. ; are ones that previously had the MCCF EDI TAS PROGRESS
  1. ; flag set with the value 2, meaning "SENT".
  1. I BPSFLAG'=2 G RESULT
  1. ;
  1. ; --------------------------------------------------------
  1. ;
  1. ; Update MCCF EDI TAS PROGRESS flag to 3, indicating the record
  1. ; was successfully transmitted to TAS.
  1. ;
  1. N BPSA,BPSFN,BPSREC
  1. S BPSFN=9002313.57
  1. S BPSREC=BPS57_","
  1. S BPSA(BPSFN,BPSREC,20)=3
  1. D FILE^DIE("","BPSA","")
  1. ;
  1. S BPSRES=1
  1. ;
  1. RESULT ; setup JSON result
  1. ;
  1. S RESULT(1)="[{"_"""ien"""_":"_BPS57_","_"""status"""_":"_BPSRES_"}]"
  1. ;
  1. ; On rare occasions, the MCCF EDI TAS PROGRESS index gets an extra entry.
  1. ; e.g.:
  1. ; ^BPSTL("C",1,IEN)=""
  1. ; ^BPSTL("C",3,IEN)=""
  1. ;
  1. ; When this happens, TAS attempts to transmit the transaction over and over.
  1. ; The following code checks if the IEN is in the 3 index and also in the 1 or 2 index.
  1. ; If so, the MCCF EDI TAS PROGRESS field is reset to 1. This forces the
  1. ; transaction to be succesfully transmitted, allowing the index issue to be resolved.
  1. ;
  1. I $D(^BPSTL("C",3,BPS57))&(($D(^BPSTL("C",1,BPS57))!($D(^BPSTL("C",2,BPS57))))) D
  1. . N BPSA,BPSFN,BPSREC
  1. . S BPSFN=9002313.57
  1. . S BPSREC=BPS57_","
  1. . S BPSA(BPSFN,BPSREC,20)=1
  1. . D FILE^DIE("","BPSA","")
  1. ;
  1. Q
  1. ;
  1. ; ========================================================
  1. ;
  1. CLOSE(BPS02) ; Entry point when a claim is closed
  1. ;
  1. ; Changes to BPS Claims File (9002313.02) field 901 (CLOSED)
  1. ; will trigger this code to execute. This code will loop
  1. ; through associated BPS LOG OF TRANSACTIONS entries and
  1. ; update field 20 (MCCF EDI TAS PROGRESS). Field 20 only
  1. ; needs to be updated if the transaction was previously
  1. ; successfully transmitted to TAS. This is indicated by
  1. ; a value of 3.
  1. ;
  1. I BPS02="" Q
  1. ;
  1. ; Get IEN for associated BPS TRANSACTION file (#9002313.59)
  1. S BPS59=$$GET1^DIQ(9002313.02,BPS02,.08,"I")
  1. I BPS59="" Q
  1. ;
  1. ; Loop through BPS LOG OF TRANSACTIONS file (#9002313.57)
  1. ; using the IEN from #9002313.59.
  1. S BPS57=0
  1. F S BPS57=$O(^BPSTL("B",BPS59,BPS57)) Q:'BPS57 D
  1. . S BPSFLAG=$$GET1^DIQ(9002313.57,BPS57,20,"I")
  1. . ;
  1. . ; QUIT if MCCF EDI TAS PROGRESS field does not exist
  1. . I BPSFLAG="" Q
  1. . ;
  1. . ; QUIT if MCCF EDI TAS PROGRESS field is not 3.
  1. . I BPSFLAG'=3 Q
  1. . ;
  1. . ; Setting field 20 to 1 will place the IEN back in the
  1. . ; queue to be transmitted to TAS again.
  1. . N BPSA,BPSFN,BPSREC
  1. . S BPSFN=9002313.57
  1. . S BPSREC=BPS57_","
  1. . S BPSA(BPSFN,BPSREC,20)=1
  1. . D FILE^DIE("","BPSA","")
  1. ;
  1. Q