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

BPMXVP.m

Go to the documentation of this file.
BPMXVP ;IHS/PHXAO/AEF - REPOINT VARIABLE POINTER FIELDS - 6/26/12 ;
 ;;1.0;IHS PATIENT MERGE;**2**;MAR 01, 2010;Build 1
 ;IHS/OIT/LJF 10/26/2006 routine originated from Phoenix Area Office
 ;                       changed namespace from BZXM to BPM
 ;            11/30/2006 removed files that don't really store data (like parameter files)
 ;IHS/OIT/NKD  6/13/2012 Re-index all x-refs for merged entries in the Order file
 ;                       NEW local variable X in I1 loop
 ;;
DESC ;----- ROUTINE DESCRIPTION
 ;;BPMXVP:
 ;;THIS ROUTINE CONTAINS SUBROUTINES TO REPOINT VARIABLE POINTER FIELDS
 ;;
 ;;THIS ROUTINE IS CALLED BY THE SPECIAL MERGE ROUTINE DRIVER - ^BPMXDRV
 ;;
 ;;THE IHS PATIENT MERGE SOFTWARE ENTERS AT EN LINE LABEL.  IT IS EXPECTED
 ;;THAT THE FOLLOWING GLOBAL WOULD HAVE BEEN SET UP BY THE PATIENT MERGE
 ;;SOFTWARE:
 ;;  ^TMP("XDRFROM",$J,FROMIEN,TOIEN,FROMIEN_GLOBROOT,TOIEN_GLOBROOT)=FILE
 ;;EXAMPLE:
 ;;  ^TMP("XDRFROM",2804,6364,1991,"6364;DPT(","1991;DPT(")=2
 ;;WHERE =2 IS THE PARENT FILE (VA PATIENT FILE).
 ;;
 ;;$$END
 ;
 N I,X F I=1:1 S X=$P($T(DESC+I),";;",2) Q:X["$$END"  D EN^DDIOL(X)
 Q
EN(BPMRY) ;EP
 ;-----  MAIN ENTRY POINT FROM DUPLICATE PATIENT MERGE SOFTWARE
 ;
 ;       BPMRY  =  TEMP GLOBAL SET UP BY THE PATIENT MERGE SOFTWARE,
 ;                  I.E., "^TMP(""XDRFROM"",$J)"
 ;
 N BPMFR,BPMTO
 S BPMFR=$O(@BPMRY@(0))
 Q:'BPMFR
 S BPMTO=$O(@BPMRY@(BPMFR,0))
 Q:'BPMTO
 ;
 D PROC(BPMFR,BPMTO)
 Q
PROC(BPMFR,BPMTO) ;
 ;----- PROCESS VARIABLE POINTER FIELDS
 ;
 D I1(BPMFR,BPMTO)   ;A/R ACCOUNTS
 D I2(BPMFR,BPMTO)   ;GUARANTOR
 D I3(BPMFR,BPMTO)   ;3P CLAIM DATA
 D I4(BPMFR,BPMTO)   ;3P BILL
 ;
 D V1(BPMFR,BPMTO)   ;WKLD LOG FILE
 D V2(BPMFR,BPMTO)   ;WKLD DATA FILE
 D V3(BPMFR,BPMTO)   ;ORDER
 D V4(BPMFR,BPMTO)   ;OE/RR LIST
 D V5(BPMFR,BPMTO)   ;PATIENT RELATION
 Q
I1(BPMFR,BPMTO) ;
 ;----- REPOINT 'ACCOUNT' FIELD #.01 OF THE 'A/R ACCOUNTS/IHS' 
 ;      FILE #90050.02
 ;
 N BPMD0,BPMDUZ2,BPMPTR,DA,X
 ;
 S BPMDUZ2=$G(DUZ(2))
 S DUZ(2)=0     ; Sets DUZ(2) because cross-reference requires it
 F  S DUZ(2)=$O(^BARAC(DUZ(2))) Q:'DUZ(2)  D
 . S X=BPMFR_";AUPNPAT("
 . S BPMD0=0
 . F  S BPMD0=$O(^BARAC(DUZ(2),"B",X,BPMD0)) Q:'BPMD0  D
 . . N X  ;IHS/OIT/NKD BPM*1.0*2 NEW X LOCAL VARIABLE
 . . S BPMPTR=$P($G(^BARAC(DUZ(2),BPMD0,0)),U)
 . . Q:+BPMPTR'=BPMFR
 . . Q:$P(BPMPTR,";",2)'="AUPNPAT("
 . . S $P(^BARAC(DUZ(2),BPMD0,0),U)=BPMTO_";AUPNPAT("
 . . S DA=BPMD0
 . . S X=BPMFR_";AUPNPAT("
 . . X ^DD(90050.02,.01,1,1,2)
 . . X ^DD(90050.02,.01,1,2,2)
 . . S X=BPMTO_";AUPNPAT("
 . . X ^DD(90050.02,.01,1,1,1)
 . . X ^DD(90050.02,.01,1,2,1)
 I BPMDUZ2 S DUZ(2)=BPMDUZ2    ;resetting DUZ(2) back to original value
 Q
 ;
I2(BPMFR,BPMTO) ;
 ; ----- REPOINT "GUARANTOR" FIELD (#.01) UNDER GUARANTOR SUBFIELD (#101)
 ;         IN GUARANTOR FILE (#9000043)
 ;
 NEW BPMD0,BPMD1,VP,X,DA
 S BPMD0=0 F  S BPMD0=$O(^AUPNGUAR(BPMD0)) Q:'BPMD0  D
 . S BPMD1=0 F  S BPMD1=$O(^AUPNGUAR(BPMD0,1,BPMD1)) Q:'BPMD1  D
 . . S VP=$P($G(^AUPNGUAR(BPMD0,1,BPMD1,0)),U)
 . . Q:+VP'=BPMFR
 . . Q:$P(VP,";",2)'="AUPNPAT("
 . . S $P(^AUPNGUAR(BPMD0,1,BPMD1,0),U)=BPMTO_";AUPNPAT("
 . . S DA(1)=BPMD0,DA=BPMD1
 . . S X=VP
 . . X ^DD(9000043.0101,.01,1,1,2)
 . . X ^DD(9000043.0101,.01,1,2,2)
 . . S X=BPMTO_";AUPNPAT("
 . . X ^DD(9000043.0101,.01,1,1,1)
 . . X ^DD(9000043.0101,.01,1,2,1)
 Q
 ;
I3(BPMFR,BPMTO) ;
 ; ----- REPOINT DESTINATION FIELD (#.127) IN 3P CLAIM DATA FILE
 ;
 NEW BPMD0,BPMDUZ2,BPMPTR
 ;
 S BPMDUZ2=0
 F  S BPMDUZ2=$O(^ABMDCLM(BPMDUZ2)) Q:'BPMDUZ2  D
 . S BPMD0=0
 . F  S BPMD0=$O(^ABMDCLM(BPMDUZ2,BPMD0)) Q:'BPMD0  D
 . . S BPMPTR=$P($G(^ABMDCLM(BPMDUZ2,BPMD0,12)),U,7)
 . . Q:+BPMPTR'=BPMFR
 . . Q:$P(BPMPTR,";",2)'="AUPNPAT("
 . . S $P(^ABMDCLM(BPMDUZ2,BPMD0,12),U,7)=BPMTO_";AUPNPAT("
 ;
 ; no cross references on field to fix
 Q
 ;
I4(BPMFR,BPMTO) ;
 ; ----- REPOINT DESTINATION FIELD (#.127) IN 3P BILL FILE
 ;
 NEW BPMD0,BPMDUZ2,BPMPTR
 ;
 S BPMDUZ2=0
 F  S BPMDUZ2=$O(^ABMDBILL(BPMDUZ2)) Q:'BPMDUZ2  D
 . S BPMD0=0
 . F  S BPMD0=$O(^ABMDBILL(BPMDUZ2,BPMD0)) Q:'BPMD0  D
 . . S BPMPTR=$P($G(^ABMDBILL(BPMDUZ2,BPMD0,12)),U,7)
 . . Q:+BPMPTR'=BPMFR
 . . Q:$P(BPMPTR,";",2)'="AUPNPAT("
 . . S $P(^ABMDBILL(BPMDUZ2,BPMD0,12),U,7)=BPMTO_";AUPNPAT("
 ;
 ; no cross references on field to fix
 Q
 ;
V1(BPMFR,BPMTO) ;
 ;----- REPOINT 'PATIENT NAME' FIELD #2 OF THE 'WKLD LOG FILE' #64.03
 ;      Part of Lab but Lab Merge doesn't handle it
 ;
 N BPMD0,BPMPTR
 ;
 S BPMD0=0
 F  S BPMD0=$O(^LRO(64.03,BPMD0))  Q:'BPMD0  D
 . S BPMPTR=$P($G(^LRO(64.03,BPMD0,0)),U,3)
 . Q:+BPMPTR'=BPMFR
 . Q:$P(BPMPTR,";",2)'="DPT("
 . S $P(^LRO(64.03,BPMD0,0),U,3)=BPMTO_";DPT("
 Q
 ;
V2(BPMFR,BPMTO) ;
 ;----- REPOINT 'PATIENT' FIELD #9 OF THE 'ACCESSION WKLD
 ;      CODE TIME' SUBFIELD #1 OF THE 'WKLD CODE' SUBFIELD
 ;      #1 OF THE 'DATE' SUBFIELD #.03 OF THE 'WKLD DATA'
 ;      FILE #64.1
 ;      Part of Lab but Lab Merge doesn't handle it
 ;
 N BPMD0,BPMD1,BPMD2,BPMD3,BPMPTR
 ;
 S BPMD0=0
 F  S BPMD0=$O(^LRO(64.1,BPMD0)) Q:'BPMD0  D
 . S BPMD1=0
 . F  S BPMD1=$O(^LRO(64.1,BPMD0,1,BPMD1)) Q:'BPMD1  D
 . . S BPMD2=0
 . . F  S BPMD2=$O(^LRO(64.1,BPMD0,1,BPMD1,1,BPMD2)) Q:'BPMD2  D
 . . . S BPMD3=0
 . . . F  S BPMD3=$O(^LRO(64.1,BPMD0,1,BPMD1,1,BPMD2,1,BPMD3)) Q:'BPMD3  D
 . . . . S BPMPTR=$P($G(^LRO(64.1,BPMD0,1,BPMD1,1,BPMD2,1,BPMD3,0)),U,10)
 . . . . Q:+BPMPTR'=BPMFR
 . . . . Q:$P(BPMPTR,";",2)'="DPT("
 . . . . S $P(^LRO(64.1,BPMD0,1,BPMD1,1,BPMD2,1,BPMD3,0),U,10)=BPMTO_";DPT("
 Q
 ;
V3(BPMFR,BPMTO) ;
 ;----- REPOINT 'OBJECT OF ORDER' FIELD #.02 OF THE 'ORDER' FILE #100
 ;   Waiting for VA to release patch that handles variable pointers correctly
 ;
 N BPM0,BPMD0,BPMPTR,DA,X,DIK
 ;
 S BPMD0=0
 F  S BPMD0=$O(^OR(100,BPMD0)) Q:'BPMD0  D
 . S BPMPTR=$P($G(^OR(100,BPMD0,0)),U,2)
 . Q:+BPMPTR'=BPMFR
 . Q:$P(BPMPTR,";",2)'="DPT("
 . S BPM0=$G(^OR(100,BPMD0,0))
 . ;
 . ;----- XECUTE KILL LOGIC FOR XREFS
 .;IHS/OIT/NKD BPM*1.0*2 RE-INDEXING ALL X-REFS
 .; ;"AC" XREF #2:
 .; I +$P(BPM0,U,2),$P(BPM0,U,7) D
 .; . S DA=BPMD0
 .; . S X=BPMPTR
 .; . X ^DD(100,.02,1,2,2) ;KILL
 .; ;"AS" XREF #5:
 .; S DA=BPMD0
 .; S X=BPMPTR
 .; X ^DD(100,.02,1,5,2)
 .; ;"AR" XREF #7:
 .; S DA=BPMD0
 .; S X=BPMPTR
 .; X ^DD(100,.02,1,7,2)
 .; ;"AW" XREF #9:
 .; I +$P(BPM0,U,2),$P(BPM0,U,11) D
 .; . S DA=BPMD0
 .; . S X=BPMPTR
 .; . X ^DD(100,.02,1,9,2)
 .; ;"AOI1" XREF #10:
 .; I +$P(BPM0,U,2) D
 .; . S DA=BPMD0
 .; . S X=BPMPTR
 .; . X ^DD(100,.02,1,10,2)
 .; ;"ACT1" XREF #11:
 .; I $P(BPM0,U,11) D
 .; . S DA=BPMD0
 .; . S X=BPMPTR
 .; . X ^DD(100,.02,1,11,2)
 . S DIK="^OR(100,",DA=BPMD0
 . D IX2^DIK
 . ;
 . ;----- RESET VARIABLE POINTER
 . S $P(^OR(100,BPMD0,0),U,2)=BPMTO_";DPT("
 . S BPM0=$G(^OR(100,BPMD0,0))
 . ;
 . ;----- XECUTE SET LOGIC FOR XREFS
 .;IHS/OIT/NKD BPM*1.0*2 RE-INDEXING ALL X-REFS
 .; ;"AC" XREF #2:
 .; I +$P(BPM0,U,2),$P(BPM0,U,7) D
 .; . S DA=BPMD0
 .; . S X=BPMTO_";DPT("
 .; . X ^DD(100,.02,1,2,1) ;SET
 .; ;"AS" XREF #5:
 .; S DA=BPMD0
 .; S X=BPMTO_";DPT("
 .; X ^DD(100,.02,1,5,1)
 .; ;"AR" XREF #7:
 .; S DA=BPMD0
 .; S X=BPMTO_";DPT("
 .; X ^DD(100,.02,1,7,1)
 .; ;"AW" XREF #9:
 .; I +$P(BPM0,U,2),$P(BPM0,U,11) D
 .; . S DA=BPMD0
 .; . S X=BPMTO_";DPT("
 .; . X ^DD(100,.02,1,9,1)
 .; ;"AOI1" XREF #10:
 .; I +$P(BPM0,U,2) D
 .; . S DA=BPMD0
 .; . S X=BPMTO_";DPT("
 .; . X ^DD(100,.02,1,10,1)
 .; ;"ACT1" XREF #11:
 .; I $P(BPM0,U,11) D
 .; . S DA=BPMD0
 .; . S X=BPMTO_";DPT("
 .; . X ^DD(100,.02,1,11,1)
 . S DIK="^OR(100,",DA=BPMD0
 . D IX1^DIK
 Q
 ;
V4(BPMFR,BPMTO) ;
 ;----- REPOINT 'MEMBER' FIELD #.01 OF THE 'MEMBER' SUBFIELD #10
 ;      OF THE 'OE/RR LIST' FILE #100.21
 ;
 N BPMD0,BPMD1,BPMPTR,DA,X
 ;
 S BPMD0=0
 F  S BPMD0=$O(^OR(100.21,BPMD0)) Q:'BPMD0  D
 . S BPMD1=0
 . F  S BPMD1=$O(^OR(100.21,BPMD0,10,BPMD1)) Q:'BPMD1  D
 . . S BPMPTR=$P($G(^OR(100.21,BPMD0,10,BPMD1,0)),U)
 . . Q:+BPMPTR'=BPMFR
 . . Q:$P(BPMPTR,";",2)'="DPT("
 . . S $P(^OR(100.21,BPMD0,10,BPMD1,0),U)=BPMTO_";DPT("
 . . S DA=BPMD1
 . . S DA(1)=BPMD0
 . . S X=BPMPTR
 . . X ^DD(100.2101,.01,1,1,2)
 . . X ^DD(100.2101,.01,1,2,2)
 . . S X=BPMTO_";DPT("
 . . X ^DD(100.2101,.01,1,1,1)
 . . X ^DD(100.2101,.01,1,2,1)
 Q
 ;
V5(BPMFR,BPMTO) ;
 ;----- REPOINT 'PERSON' FIELD #.03 OF THE 'PATIENT RELATION'
 ;      FILE #408.12
 ;
 N BPMD0,BPMPTR,DA,X
 ;
 S BPMD0=0
 F  S BPMD0=$O(^DGPR(408.12,BPMD0)) Q:'BPMD0  D
 . S BPMPTR=$P($G(^DGPR(408.12,BPMD0,0)),U,3)
 . Q:+BPMPTR'=BPMFR
 . Q:$P(BPMPTR,";",2)'="DPT("
 . S $P(^DGPR(408.12,BPMD0,0),U,3)=BPMTO_";DPT("
 . S DA=BPMD0
 . S X=BPMPTR
 . X ^DD(408.12,.03,1,1,2)
 . S X=BPMTO_";DPT("
 . X ^DD(408.12,.03,1,1,1)
 Q