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

FBXIP154.m

Go to the documentation of this file.
  1. FBXIP154 ;WOIFO/SAB - PATCH INSTALL ROUTINE ;12/2/2014
  1. ;;3.5;FEE BASIS;**154**;JAN 30, 1995;Build 12
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. ; ICRs
  1. ; #2050 MSG^DIALOG
  1. ; #2052 $$GET1^DID
  1. ; #2053 FILE^DIE, UPDATE^DIE
  1. ; #2056 $$GET1^DIQ
  1. ; #2343 $$ACTIVE^XUSER()
  1. ; #10103 $$FMADD^XLFDT
  1. ; #10141 BMES^XPDUTL, MES^XPDUTL, $$NEWCP^XPDUTL
  1. ;
  1. PS ; post-install entry point
  1. ; create KIDS checkpoints with call backs
  1. N FBX,Y
  1. F FBX="USRAUD","AUTHP" D
  1. . S Y=$$NEWCP^XPDUTL(FBX,FBX_"^FBXIP154")
  1. . I 'Y D BMES^XPDUTL("ERROR Creating "_FBX_" Checkpoint.")
  1. Q
  1. ;
  1. USRAUD ; populate user audit
  1. N DA,DIERR,FBC,FBCE,FBDT,FBFILE,FBIENS,FBTXT,FBUSR,FBY
  1. D BMES^XPDUTL(" Creating User Audit entries. This may take some time.")
  1. ;
  1. ; populate user audit in file 162.2
  1. D MES^XPDUTL(" processing file 162.2...")
  1. S (FBC,FBCE)=0
  1. S FBFILE=162.292
  1. S FBTXT(1)="Added by FB*3.5*154 based on legal determination."
  1. S FBTXT(2)="Added by FB*3.5*154 based on medical determination."
  1. S FBTXT(3)="Added by FB*3.5*154 based on user entering & install date."
  1. ; loop thru file 162.2
  1. S DA=0 F S DA=$O(^FBAA(162.2,DA)) Q:'DA D
  1. . ; skip if user audit already populated
  1. . Q:$O(^FBAA(162.2,DA,"LOG1",0))
  1. . ;
  1. . S FBIENS=DA_","
  1. . S FBY=$G(^FBAA(162.2,DA,0))
  1. . ;
  1. . S FBDT=$P(FBY,U,10) ; DATE OF LEGAL DETERMINATION
  1. . S FBUSR=$P(FBY,U,11) ; USER ENTERING LEGAL DETERM.
  1. . I FBDT,FBUSR D ADDUA(FBFILE,FBIENS,FBDT,FBUSR,FBTXT(1))
  1. . ;
  1. . S FBDT=$P(FBY,U,13) ; DATE OF MEDICAL DETERMINATION
  1. . S FBUSR=$P(FBY,U,14) ; USER ENTERING MEDICAL DETERM.
  1. . I FBDT,FBUSR D ADDUA(FBFILE,FBIENS,FBDT,FBUSR,FBTXT(2))
  1. . ;
  1. . S FBDT=DT ; current (install) date
  1. . S FBUSR=$P(FBY,U,8) ; USER ENTERING NOTIFICATION
  1. . I FBDT,FBUSR D ADDUA(FBFILE,FBIENS,FBDT,FBUSR,FBTXT(3))
  1. D SHOWCNT
  1. ;
  1. ; populate user audit in file 162.4
  1. D MES^XPDUTL(" processing file 162.4...")
  1. S (FBC,FBCE)=0
  1. S FBFILE=162.492
  1. S FBTXT="Added by FB*3.5*154 based on user entering & date of issue."
  1. ; loop thru file 162.4
  1. S DA=0 F S DA=$O(^FB7078(DA)) Q:'DA D
  1. . ; skip if user audit already populated
  1. . Q:$O(^FB7078(DA,"LOG1",0))
  1. . ;
  1. . S FBIENS=DA_","
  1. . S FBY=$G(^FB7078(DA,0))
  1. . ;
  1. . S FBDT=$P(FBY,U,10) ; DATE OF ISSUE
  1. . S FBUSR=$P(FBY,U,8) ; USER ENTERING
  1. . I FBDT,FBUSR D ADDUA(FBFILE,FBIENS,FBDT,FBUSR,FBTXT)
  1. D SHOWCNT
  1. ;
  1. ; populate user audit in file 162.7
  1. D MES^XPDUTL(" processing file 162.7...")
  1. S (FBC,FBCE)=0
  1. S FBFILE=162.792
  1. S FBTXT="Added by FB*3.5*154 based on entered/last edited."
  1. ; loop thru file 162.7
  1. S DA=0 F S DA=$O(^FB583(DA)) Q:'DA D
  1. . ; skip if user audit already populated
  1. . Q:$O(^FB583(DA,"LOG1",0))
  1. . ;
  1. . S FBIENS=DA_","
  1. . S FBY=$G(^FB583(DA,0))
  1. . ;
  1. . S FBDT=$P(FBY,U,18) ; DATE ENTERED/LAST EDITED
  1. . S FBUSR=$P(FBY,U,17) ; ENTERED/LAST EDITED BY
  1. . I FBDT,FBUSR D ADDUA(FBFILE,FBIENS,FBDT,FBUSR,FBTXT)
  1. D SHOWCNT
  1. ;
  1. ; populate user audit in sub-file 161.01
  1. D MES^XPDUTL(" processing sub-file 161.01...")
  1. S (FBC,FBCE)=0
  1. S FBFILE=161.192
  1. S FBTXT="Added by FB*3.5*154 based on clerk & install date."
  1. ; loop thru file 161
  1. S DA(1)=0 F S DA(1)=$O(^FBAAA(DA(1))) Q:'DA(1) D
  1. . ; loop thru sub-file 161.01
  1. . S DA=0 F S DA=$O(^FBAAA(DA(1),1,DA)) Q:'DA D
  1. . . N FBX
  1. . . ; skip if user audit already populated
  1. . . Q:$O(^FBAAA(DA(1),1,DA,"LOG1",0))
  1. . . ;
  1. . . S FBIENS=DA_","_DA(1)_","
  1. . . ;
  1. . . S FBDT=DT ; current (install) date
  1. . . S FBUSR=$P($G(^FBAAA(DA(1),1,DA,100)),U) ; CLERK
  1. . . S FBX=$P($G(^FBAAA(DA(1),1,DA,0)),U,9) ; ASSOCIATED 7078/583
  1. . . ;
  1. . . ; skip if 7078 and clerk already in file 162.4 user audit
  1. . . I FBUSR,FBX[";FB7078(",$O(^FB7078(+FBX,"LOG1","AU",FBUSR,0)) Q
  1. . . ;
  1. . . ; skip if U/C and clerk already in file 162.7 user audit
  1. . . I FBUSR,FBX[";FB583(",$O(^FB583(+FBX,"LOG1","AU",FBUSR,0)) Q
  1. . . ;
  1. . . I FBDT,FBUSR D ADDUA(FBFILE,FBIENS,FBDT,FBUSR,FBTXT)
  1. D SHOWCNT
  1. ;
  1. D MES^XPDUTL(" Done creating user audit entries.")
  1. Q
  1. ;
  1. ADDUA(FBFILE,FBIENS,FBDT,FBUSR,FBTXT) ; add user audit record
  1. Q:FBDT'?7N ; invalid date
  1. Q:$$ACTIVE^XUSER(FBUSR)="" ; no user record found
  1. N FBFDA
  1. S FBIENS="+1,"_FBIENS
  1. S FBFDA(FBFILE,FBIENS,.01)=FBDT ; DATE/TIME EDITED
  1. S FBFDA(FBFILE,FBIENS,1)=FBUSR ; EDITED BY
  1. S FBFDA(FBFILE,FBIENS,2)=FBTXT ; COMMENTS
  1. D UPDATE^DIE("","FBFDA")
  1. I $G(DIERR)="" S FBC=FBC+1
  1. E D
  1. . S FBCE=FBCE+1
  1. . D MES^XPDUTL(" "_"Error creating record with IENS "_FBIENS)
  1. Q
  1. ;
  1. SHOWCNT ; show counts for file
  1. D MES^XPDUTL(" "_FBC_" user audit entries were created.")
  1. D:FBCE MES^XPDUTL(" "_FBCE_" user audit entries not created due to error.")
  1. Q
  1. ;
  1. AUTHP ; populate authorization pointer data
  1. N DA,DIERR,FBA,FBAUTHP,FBFE,FBIENS,FBP,FBT,FBX,FBYA,FBYD,FBYP
  1. D MES^XPDUTL("Populating new AUTHORIZATION POINTER field. This may take some time...")
  1. ;
  1. ; init counters
  1. S FBT("TLN")=0 ; total line items
  1. S FBT("TLN","SKIP")=0 ; lines skipped because new field was populated
  1. S FBT("TLN","PROC")=0 ; lines processed
  1. S FBT("NOP")=0 ; processed lines without old authorization pointer
  1. S FBT("NOP","7078C")=0 ; populated based on 7078/583 match
  1. S FBT("NOP","7078U")=0 ; not populated, no 7078/583 match found
  1. S FBT("NOP","POVC")=0 ; populated based on POV match
  1. S FBT("NOP","POVU")=0 ; not populated, no POV match found
  1. S FBT("PTR")=0 ; processed lines with old authorization pointer
  1. S FBT("PTR","7078M")=0 ; populated with same value based on 7078/583
  1. S FBT("PTR","7078C")=0 ; populated with diff value based on 7078/583
  1. S FBT("PTR","7078U")=0 ; populated with same value, no 7078/583 match
  1. S FBT("PTR","POVM")=0 ; populated with same value based on POV
  1. S FBT("PTR","POVC")=0 ; populated with diff value based on POV
  1. S FBT("PTR","POVU")=0 ; populated with same value, no POV match
  1. ;
  1. ; set header for XTMP with purge date in 120 days
  1. S ^XTMP("FB*3.5*154",0)=$$FMADD^XLFDT(DT,120)_"^"_DT_"^From patch FB*3.5*154 post init."
  1. ;
  1. ; determine if old field still exists
  1. S FBFE=$S($$GET1^DID(162.02,3,"","LABEL")="*AUTHORIZATION POINTER":1,1:0)
  1. ;
  1. ; loop thru outpatient and ancillary line items in FEE BASIS PAYMENT
  1. ; loop thru patients
  1. S DA(3)=0
  1. F S DA(3)=$O(^FBAAC(DA(3))) Q:'DA(3) D
  1. . ; loop thru vendors
  1. . S DA(2)=0
  1. . F S DA(2)=$O(^FBAAC(DA(3),1,DA(2))) Q:'DA(2) D
  1. . . ; loop thru dates of service
  1. . . S DA(1)=0
  1. . . F S DA(1)=$O(^FBAAC(DA(3),1,DA(2),1,DA(1))) Q:'DA(1) D
  1. . . . S FBYD=$G(^FBAAC(DA(3),1,DA(2),1,DA(1),0))
  1. . . . S FBP("DOS")=$P(FBYD,U,1) ; date of service
  1. . . . S FBP("FTP")=$S(FBFE:$P(FBYD,U,4),1:"") ; old value
  1. . . . ; don't use old value if authorization does not exist in file 161
  1. . . . I FBP("FTP"),'$D(^FBAAA(DA(3),1,FBP("FTP"),0)) S FBP("FTP")=""
  1. . . . S FBYA=$S(FBP("FTP"):$G(^FBAAA(DA(3),1,FBP("FTP"),0)),1:"")
  1. . . . S FBA("POV")=$P(FBYA,U,7) ; PURPOSE OF VISIT
  1. . . . S FBA("7078")=$P(FBYA,U,9) ; ASSOCIATED 7078/583
  1. . . . ; loop thru service provided
  1. . . . S DA=0
  1. . . . F S DA=$O(^FBAAC(DA(3),1,DA(2),1,DA(1),1,DA)) Q:'DA D
  1. . . . . S FBT("TLN")=FBT("TLN")+1
  1. . . . . S FBIENS=DA_","_DA(1)_","_DA(2)_","_DA(3)_","
  1. . . . . ;
  1. . . . . ; skip if already converted (i.e. new field populated)
  1. . . . . I $P($G(^FBAAC(DA(3),1,DA(2),1,DA(1),1,DA,3)),U,9) D Q
  1. . . . . . S FBT("TLN","SKIP")=FBT("TLN","SKIP")+1
  1. . . . . S FBT("TLN","PROC")=FBT("TLN","PROC")+1
  1. . . . . ;
  1. . . . . S FBYP=$G(^FBAAC(DA(3),1,DA(2),1,DA(1),1,DA,0))
  1. . . . . S FBP("7078")=$P(FBYP,U,13) ; ASSOCIATED 7078/583
  1. . . . . S FBP("POV")=$P(FBYP,U,18) ; PURPOSE OF VISIT
  1. . . . . ;
  1. . . . . I 'FBP("FTP") S FBT("NOP")=FBT("NOP")+1 ; no old pointer
  1. . . . . E S FBT("PTR")=FBT("PTR")+1 ; old pointer exists
  1. . . . . ;
  1. . . . . ; determine correct authorization pointer for line item
  1. . . . . S FBAUTHP="" ; init new auth pointer value
  1. . . . . ; if payment associated 7078/583 exists then match with that
  1. . . . . I FBP("7078")]"" D
  1. . . . . . ; if pointer exists and 7078/583 matches then copy old value
  1. . . . . . I FBP("FTP"),FBP("7078")=FBA("7078") D Q:FBAUTHP
  1. . . . . . . S FBAUTHP=FBP("FTP")
  1. . . . . . . S FBT("PTR","7078M")=FBT("PTR","7078M")+1
  1. . . . . . ; if 7078/583 does not match then look for an better auth.
  1. . . . . . I FBP("7078")'=FBA("7078") D Q:FBAUTHP
  1. . . . . . . S FBX=$$ASSOC(DA(3),FBP("DOS"),FBP("7078"))
  1. . . . . . . Q:'FBX
  1. . . . . . . S FBAUTHP=FBX
  1. . . . . . . I FBP("FTP") S FBT("PTR","7078C")=FBT("PTR","7078C")+1
  1. . . . . . . I 'FBP("FTP") S FBT("NOP","7078C")=FBT("NOP","7078C")+1
  1. . . . . . . S ^XTMP("FB*3.5*154","7078C",FBIENS)=FBP("FTP")_"^"_FBAUTHP
  1. . . . . . I 'FBAUTHP D
  1. . . . . . . ; if better auth. not found use old value when available
  1. . . . . . . I FBP("FTP") S FBAUTHP=FBP("FTP")
  1. . . . . . . I FBP("FTP") S FBT("PTR","7078U")=FBT("PTR","7078U")+1
  1. . . . . . . I 'FBP("FTP") S FBT("NOP","7078U")=FBT("NOP","7078U")+1
  1. . . . . . . S ^XTMP("FB*3.5*154","7078U",FBIENS)=FBP("FTP")_"^"_FBAUTHP
  1. . . . . ;
  1. . . . . ; if payment associated 7078/583 blank then match with POV
  1. . . . . I FBP("7078")="" D
  1. . . . . . ; if pointer exists and POV matches then copy old value
  1. . . . . . I FBP("FTP"),FBP("POV")=FBA("POV") D Q:FBAUTHP
  1. . . . . . . S FBAUTHP=FBP("FTP")
  1. . . . . . . S FBT("PTR","POVM")=FBT("PTR","POVM")+1
  1. . . . . . ; if POV does not match then look for an better auth.
  1. . . . . . I FBP("POV")'=FBA("POV") D Q:FBAUTHP
  1. . . . . . . S FBX=$$POV(DA(3),FBP("DOS"),FBP("POV"))
  1. . . . . . . Q:'FBX
  1. . . . . . . S FBAUTHP=FBX
  1. . . . . . . I FBP("FTP") S FBT("PTR","POVC")=FBT("PTR","POVC")+1
  1. . . . . . . I 'FBP("FTP") S FBT("NOP","POVC")=FBT("NOP","POVC")+1
  1. . . . . . . S ^XTMP("FB*3.5*154","POVC",FBIENS)=FBP("FTP")_"^"_FBAUTHP
  1. . . . . . ; if better auth. not found use old value when available
  1. . . . . . I 'FBAUTHP D
  1. . . . . . . I FBP("FTP") S FBAUTHP=FBP("FTP")
  1. . . . . . . I FBP("FTP") S FBT("PTR","POVU")=FBT("PTR","POVU")+1
  1. . . . . . . I 'FBP("FTP") S FBT("NOP","POVU")=FBT("NOP","POVU")+1
  1. . . . . . . S ^XTMP("FB*3.5*154","POVU",FBIENS)=FBP("FTP")_"^"_FBAUTHP
  1. . . . . ;
  1. . . . . ; save authorization pointer value in new field
  1. . . . . I FBAUTHP D
  1. . . . . . N FBFDA
  1. . . . . . S FBFDA(162.03,FBIENS,15.5)=FBAUTHP
  1. . . . . . D FILE^DIE("","FBFDA")
  1. . . . . . I $G(DIERR)'="" D MES^XPDUTL(" Error updating record with IENS "_FBIENS)
  1. ;
  1. ; report results
  1. S FBX=$J($FN(FBT("TLN"),","),10)_" payment line items in FEE BASIS PAYMENT file"
  1. D MES^XPDUTL(FBX)
  1. D MES^XPDUTL("----------")
  1. S FBX=$J($FN(FBT("TLN","SKIP"),","),10)_" lines skipped because new field already populated"
  1. D MES^XPDUTL(FBX)
  1. S FBX=$J($FN(FBT("TLN","PROC"),","),10)_" lines processed"
  1. D MES^XPDUTL(FBX)
  1. ;
  1. S FBX=$J($FN(FBT("NOP"),","),10)_" processed lines without an existing authorization pointer value"
  1. D BMES^XPDUTL(FBX)
  1. D MES^XPDUTL("----------")
  1. S FBX=$J($FN(FBT("NOP","7078C"),","),10)_" lines populated based on 7078/583 match"
  1. D MES^XPDUTL(FBX)
  1. S FBX=$J($FN(FBT("NOP","7078U"),","),10)_" lines not populated because 7078/583 match not found"
  1. D MES^XPDUTL(FBX)
  1. S FBX=$J($FN(FBT("NOP","POVC"),","),10)_" lines populated based on POV match"
  1. D MES^XPDUTL(FBX)
  1. S FBX=$J($FN(FBT("NOP","POVU"),","),10)_" lines not populated because POV match not found"
  1. D MES^XPDUTL(FBX)
  1. ;
  1. S FBX=$J($FN(FBT("PTR"),","),10)_" processed lines with an existing authorization pointer value"
  1. D BMES^XPDUTL(FBX)
  1. D MES^XPDUTL("----------")
  1. S FBX=$J($FN(FBT("PTR","7078M"),","),10)_" lines populated with same value based on 7078/583 match"
  1. D MES^XPDUTL(FBX)
  1. S FBX=$J($FN(FBT("PTR","7078C"),","),10)_" lines populated with different value based on 7078/583 match"
  1. D MES^XPDUTL(FBX)
  1. S FBX=$J($FN(FBT("PTR","7078U"),","),10)_" lines populated with same value since 7078/583 match not found"
  1. D MES^XPDUTL(FBX)
  1. S FBX=$J($FN(FBT("PTR","POVM"),","),10)_" lines populated with same value based on POV match"
  1. D MES^XPDUTL(FBX)
  1. S FBX=$J($FN(FBT("PTR","POVC"),","),10)_" lines populated with different value based on POV match"
  1. D MES^XPDUTL(FBX)
  1. S FBX=$J($FN(FBT("PTR","POVU"),","),10)_" lines populated with same value since POV match not found"
  1. D MES^XPDUTL(FBX)
  1. ;
  1. Q
  1. ;
  1. ASSOC(FBDFN,FBDOS,FB7078) ; find authorization for ASSOCIATED 7078/583
  1. ; input
  1. ; FBDFN - patient (internal, pointer to file 2 and file 161)
  1. ; FBDOS - date of service (internal, FM date)
  1. ; FB7078 - associated 7078/583 (internal)
  1. ; returns null value or authorization IEN in file 161 for patient
  1. N FBFTP
  1. S FBFTP=""
  1. I $G(FB7078)]"",$G(FBDFN)]"",$G(FBDOS)]"" D
  1. . N FBDA,FBY
  1. . ; loop thru authorizations for ASSOCIATED 7078/583 and PATIENT
  1. . S FBDA=0
  1. . F S FBDA=$O(^FBAAA("AG",FB7078,FBDFN,FBDA)) Q:'FBDA D Q:FBFTP
  1. . . S FBY=$G(^FBAAA(FBDFN,1,FBDA,0))
  1. . . Q:$P(FBY,U,1)="" ; invalid data
  1. . . Q:$P(FBY,U,1)>FBDOS ; auth from date is after date of service
  1. . . Q:$P(FBY,U,2)<FBDOS ; auth to date is before date of service
  1. . . ; passed all criterion, found matching authorization
  1. . . S FBFTP=FBDA
  1. ;
  1. Q FBFTP
  1. ;
  1. POV(FBDFN,FBDOS,FBPOV) ; find authorization for POV
  1. ; input
  1. ; FBDFN - patient (internal, pointer to file 2 and file 161)
  1. ; FBDOS - date of service (internal, FM date)
  1. ; FBPOV - purpose of visit (internal, pointer to 161.82)
  1. ; returns null value or authorization IEN in file 161 for patient
  1. N FBFTP
  1. S FBFTP=""
  1. I $G(FBPOV)]"",$G(FBDFN)]"",$G(FBDOS)]"" D
  1. . N FBDA,FBY
  1. . ; loop thru authorizations for patient
  1. . S FBDA=0
  1. . F S FBDA=$O(^FBAAA(FBDFN,1,FBDA)) Q:'FBDA D Q:FBFTP
  1. . . S FBY=$G(^FBAAA(FBDFN,1,FBDA,0))
  1. . . Q:$P(FBY,U,1)="" ; invalid data
  1. . . Q:$P(FBY,U,7)'=FBPOV ; POV does not match input value
  1. . . Q:$P(FBY,U,1)>FBDOS ; auth from date is after date of service
  1. . . Q:$P(FBY,U,2)<FBDOS ; auth to date is before date of service
  1. . . ; passed all criterion, found matching authorization
  1. . . S FBFTP=FBDA
  1. ;
  1. Q FBFTP
  1. ;
  1. ;
  1. RPT ; report of ^XTMP
  1. W !,"Report of XTMP(""FB*3.5*154"") data"
  1. ;
  1. D LIST("7078C")
  1. D LIST("7078U")
  1. D LIST("POVC")
  1. D LIST("POVU")
  1. Q
  1. ;
  1. ;
  1. LIST(FBSUB) ; list lines in subscript
  1. N FBIENS,FBFLD,FBFLDN,FBY
  1. ;
  1. W:FBSUB["C" !,"Lines with pointer changed based on "
  1. W:FBSUB["U" !,"Lines with no matching authorization found using "
  1. W:FBSUB["7078" "associated 7078/583"
  1. W:FBSUB["POV" "POV"
  1. I FBSUB["7078" S FBFLD=27,FBFLDN=" 7078/583: "
  1. I FBSUB["POV" S FBFLD=16,FBFLDN=" POV: "
  1. ;
  1. S FBIENS=""
  1. F S FBIENS=$O(^XTMP("FB*3.5*154",FBSUB,FBIENS)) Q:FBIENS="" D
  1. . S FBY=$G(^XTMP("FB*3.5*154",FBSUB,FBIENS))
  1. . W !,FBIENS," From: ",$P(FBY,U,1)," To: ",$P(FBY,U,2),FBFLDN,$$GET1^DIQ(162.03,FBIENS,FBFLD,"I")
  1. Q
  1. ;FBXIP154