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

BPSOSIZ.m

Go to the documentation of this file.
  1. BPSOSIZ ;BHAM ISC/FCS/DRS/DLF - Filing BPS Transaction ;06/01/2004
  1. ;;1.0;E CLAIMS MGMT ENGINE;**1,5,7,8,10,20**;JUN 2004;Build 27
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. Q
  1. ;
  1. ; EN - Create and/or update BPS Transaction
  1. ; Input
  1. ; IEN59 - BPS Transaction number
  1. ; MOREDATA - Array of data created by BPSNCPD*
  1. ; BP77 - BPS REQUEST file ien
  1. ; BPSNB - (optional) Flag to indicate if this is a non-billable entry being added
  1. EN(IEN59,MOREDATA,BP77,BPSNB) ;EP - BPSOSRB
  1. ; Initialize variables
  1. N EXISTS,ERROR,X
  1. S ERROR=0,BPSNB=+$G(BPSNB)
  1. I BPSNB S BP77="" ; for non-billable entries, we skip BPS requests processing
  1. ;
  1. D LOG^BPSOSL(IEN59,$T(+0)_"-Building Transaction")
  1. I BPSNB D LOG^BPSOSL(IEN59,$T(+0)_"-Start of Building Transaction for Non-Billable Entry")
  1. ;
  1. ; Lock the transaction
  1. I '$$LOCK59(IEN59) D ERROR(BP77,IEN59,"Could not lock the BPS Transaction") Q
  1. ;
  1. ; Make sure that the record is not already IN PROGRESS
  1. S X=+$$STATUS59^BPSOSRX(IEN59)
  1. I X'=0,X'=31,X'=99 D ERROR(BP77,IEN59,"STATUS is "_X) Q
  1. ;
  1. ; Check if the BPS Transaction exists
  1. S EXISTS=$$EXIST59(IEN59)
  1. ;
  1. ; If the record exists, delete all but the essential fields
  1. I EXISTS D CLEAR59(IEN59)
  1. ;
  1. ; If the record does not exist, create new record and validate the IEN
  1. I 'EXISTS S X=$$NEW59(IEN59) I X'=IEN59 D ERROR(BP77,IEN59,"NEW59 returned "_X) Q
  1. ;
  1. ; Update the fields. If error is returned, log to the BPS Transaction, which
  1. ; we know exists at this point
  1. S ERROR=$$INIT^BPSOSIY(IEN59,BP77,BPSNB) ;MOREDATA is passed in background, BPSNB added with patch 20
  1. I ERROR D Q
  1. . D ERROR^BPSOSU($T(+0),IEN59,ERROR,"BPS Transaction not updated")
  1. . I BPSNB D LOG^BPSOSL(IEN59,$T(+0)_"-Error BPS Transaction not updated for Non-Billable Entry- ERROR="_ERROR_".")
  1. . D UNLOCK59(IEN59)
  1. . Q
  1. ;
  1. ; Validate the transaction
  1. I 'BPSNB D ONE59^BPSOSQA(IEN59) ; don't perform this for Non-Billable entries ('BPSNB)
  1. ;
  1. ; Unlock the transaction
  1. D UNLOCK59(IEN59)
  1. Q
  1. ;
  1. ; LOCK59 - Lock Transaction
  1. LOCK59(IEN59) ;
  1. D LOG^BPSOSL(IEN59,$T(+0)_"-Lock BPS Transaction")
  1. L +^BPST(IEN59):5
  1. Q $T
  1. ;
  1. ; UNLOCK59 - Unlock record
  1. UNLOCK59(IEN59) ;
  1. D LOG^BPSOSL(IEN59,$T(+0)_"-Unlock BPS Transaction")
  1. L -^BPST(IEN59)
  1. Q
  1. ;
  1. ; EXISTS - See if the BPS Transaction already exists
  1. EXIST59(IEN59) ;
  1. N X
  1. S X=$$FIND1^DIC(9002313.59,,"QX","`"_IEN59)
  1. Q $S(X>0:X,X=0:0)
  1. ;
  1. ; NEW59 - Create a new BPS Transaction record
  1. ; IEN59 - BPS TRANSACTION ien
  1. NEW59(IEN59) ;
  1. ; Initialize variables
  1. N FDA,IEN,MSG,FN,BPSTIME,BPCOB
  1. ;
  1. ; The .01 node and IEN should be the transaction number
  1. S FN=9002313.59
  1. S (IEN(1),FDA(FN,"+1,",.01))=IEN59
  1. ;
  1. ; Create the new BPS Transaction record
  1. D UPDATE^DIE("","FDA","IEN","MSG")
  1. I $D(MSG) Q 0
  1. Q IEN(1)
  1. ;
  1. ; CLEAR59 - If it exists, clear out the old values
  1. CLEAR59(IEN59) ;
  1. ; Deletes all values except for fields:
  1. ; Entry # (.01)
  1. ; Resubmit after reversal (1.12)
  1. ; Result Text (202)
  1. ; Comments (111 multiple)
  1. ; If reverse/resubmit, then also do not clear fields:
  1. ; Status (1)
  1. ; Submit Date/Time (6)
  1. ; Last Update (7)
  1. ; Start Date (15)
  1. ;
  1. ; Initialize variables
  1. N FN,FDA,MSG,FIELD,SKIP,ENTRY
  1. S FN=9002313.59
  1. ;
  1. ; Set up fields that we do not want to delete
  1. S SKIP(1.12)="",SKIP(202)=""
  1. I $G(MOREDATA("REVERSE THEN RESUBMIT"))=1 S SKIP(1)="",SKIP(6)="",SKIP(7)="",SKIP(15)=""
  1. ;
  1. ; Start with field .01 so it will not be deleted
  1. ; Place 'non-skip' fields in FDA to be deleted
  1. S FIELD=.01
  1. F S FIELD=$O(^DD(FN,FIELD)) Q:'FIELD I '$D(SKIP(FIELD)) S FDA(FN,IEN59_",",FIELD)=""
  1. ;
  1. ; Delete Insurance multiple
  1. S FN=9002313.59902,ENTRY=0
  1. F S ENTRY=$O(^BPST(IEN59,10,ENTRY)) Q:ENTRY="B"!(ENTRY="") D
  1. . S FDA(FN,ENTRY_","_IEN59_",",.01)=""
  1. ;
  1. ; Delete DUR multiple
  1. S FN=9002313.5913,ENTRY=0
  1. F S ENTRY=$O(^BPST(IEN59,13,ENTRY)) Q:+ENTRY=0 D
  1. . S FDA(FN,ENTRY_","_IEN59_",",.01)=""
  1. ;
  1. ; Delete COB OTHER PAYERS multiple
  1. S FN=9002313.5914,ENTRY=0
  1. F S ENTRY=$O(^BPST(IEN59,14,ENTRY)) Q:'ENTRY D
  1. . S FDA(FN,ENTRY_","_IEN59_",",.01)=""
  1. ;
  1. ; Fileman call to do the delete
  1. D FILE^DIE("","FDA","MSG")
  1. ;
  1. ; Update Result Text File with 'PREVIOUSLY['
  1. D PREVISLY(IEN59) ; for result text field 202
  1. Q
  1. ;
  1. ; PREVISLY - Add semicolon in between the result text
  1. PREVISLY(IEN59) ;EP - BPSOSRB, BPSOSU
  1. N X
  1. S X=$$GET1^DIQ(9002313.59,IEN59,202)
  1. I X="" Q
  1. S X=$E(";"_X,1,200)
  1. N FN,FDA,MSG
  1. S FDA(9002313.59,IEN59_",",202)=X
  1. D FILE^DIE("","FDA","MSG")
  1. Q
  1. ;
  1. ; ERROR - Log an error to the log
  1. ERROR(BP77,IEN59,ERROR) ;
  1. D LOG^BPSOSL(IEN59,$T(+0)_"-Calling BPSOSRB to handle error")
  1. I $G(BPSNB) D LOG^BPSOSL(IEN59,$T(+0)_"-Error with Non-Billable Entry: "_ERROR)
  1. D ERROR^BPSOSRB(BP77,IEN59,ERROR)
  1. D UNLOCK59(IEN59)
  1. Q