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

BPMXLR2.m

Go to the documentation of this file.
BPMXLR2 ;IHS/PHXAO/AEF - REPOINT LAB ^LR("BLRA") ESIG XREF
 ;;1.0;IHS PATIENT MERGE;;MAR 01, 2010
 ;IHS/OIT/LJF 10/26/2006 routine originated from Phoenix Area Office
 ;                       changed namespace from BZXM to BPM; BLR to BPM
 ;;
DESC ;----- ROUTINE DESCRIPTION
 ;;BPMXLR2:
 ;;THIS ROUTINE LOOPS THROUGH THE "BLRA" XREF ON THE LAB DATA FILE AND FINDS ALL
 ;;ENTRIES BELONGING TO THE PAIENT BEING MERGED FROM AND REPOINTS THEM TO THE 
 ;;PATIENT BEING MERGED TO.
 ;;
 ;;INPUT:
 ;;BPMFM  =  LRDFN OF PATIENT BEING MERGED FROM
 ;;BPMTO  =  LRDFN OF PATIENT BEING MERGED TO
 ;;
 ;;$$END
 ;
 N I,X F I=1:1 S X=$P($T(DESC+I),";;",2) Q:X["$$END"  D EN^DDIOL(X)
 Q
EN(BPMFM,BPMTO) ;EP
 ;----- MAIN ENTRY POINT
 ;
 D ^XBKVAR
 D HOME^%ZIS
 ;
 D FIND(BPMFM)
 D MERGE(BPMFM,BPMTO)
 ;
 K ^TMP("BLRA",$J)
 ;
 Q
FIND(BPMFM) ;
 ;----- FIND "BLRA" XREFS FOR THE "FROM" PATIENT
 ;
 N BPMAPHY,BPMARFL,BPMDFN,BPMIDT,BPMSS
 ;
 K ^TMP("BPMLRA",$J)
 ;
 S BPMAPHY=0
 F  S BPMAPHY=$O(^LR("BLRA",BPMAPHY)) Q:'BPMAPHY  D
 . S BPMARFL=""
 . F  S BPMARFL=$O(^LR("BLRA",BPMAPHY,BPMARFL)) Q:BPMARFL']""  D
 . . S BPMIDT=""
 . . F  S BPMIDT=$O(^LR("BLRA",BPMAPHY,BPMARFL,BPMIDT)) Q:'BPMIDT  D
 . . . S BPMDFN=0
 . . . F  S BPMDFN=$O(^LR("BLRA",BPMAPHY,BPMARFL,BPMIDT,BPMDFN)) Q:'BPMDFN  D
 . . . . Q:BPMDFN'=BPMFM
 . . . . S BPMSS=""
 . . . . S BPMSS=$O(^LR("BLRA",BPMAPHY,BPMARFL,BPMIDT,BPMDFN,""))
 . . . . S ^TMP("BPMLRA",$J,BPMDFN,BPMIDT)=BPMAPHY_U_BPMARFL_U_BPMIDT_U_BPMDFN_U_BPMSS
 Q
 ;
MERGE(BPMFM,BPMTO) ;
 ;----- MERGE ENTRIES
 ;
 N BPMAPHY,BPMARFL,DATA,DATE,BPMDFN,BPMIDT,BPMSS
 ;
 S DATE=0
 F  S DATE=$O(^TMP("BPMLRA",$J,BPMFM,DATE)) Q:'DATE  D
 . S DATA=^TMP("BPMLRA",$J,BPMFM,DATE)
 . S BPMAPHY=$P(DATA,U)
 . S BPMARFL=$P(DATA,U,2)
 . S BPMIDT=$P(DATA,U,3)
 . S BPMDFN=$P(DATA,U,4)
 . S BPMSS=$P(DATA,U,5)
 . Q:'$D(^LR("BLRA",BPMAPHY,BPMARFL,BPMIDT,BPMFM))
 . ;S ^LR("BLRA",BPMAPHY,BPMARFL,BPMIDT,BPMTO)=BPMSS
 . S ^LR("BLRA",BPMAPHY,BPMARFL,BPMIDT,BPMTO,BPMSS)=BPMSS ; IHS/OIT/MKK - Data structure Change
 . K ^LR("BLRA",BPMAPHY,BPMARFL,BPMIDT,BPMFM)
 . K ^TMP("BPMLRA",$J,BPMFM,DATE)
 ;
 Q
 ;