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

BPMRP1.m

Go to the documentation of this file.
BPMRP1 ;IHS/PHXAO/AEF - BPM 1.0 P2 PRINT LIST OF PATIENTS MERGED - 6/26/12 ;
 ;;1.0;IHS PATIENT MERGE;**2**;MAR 01, 2010;Build 1
 ;IHS/OIT/LJF 11/15/2006 routine originated from Phoenix Area Office
 ;                       changed namespace from BZXM to BPM
 ;            11/16/2006 added DOB & SSN display for TO patient
 ;IHS/OIT/NKD  6/13/2012 Corrected logic used to find the DPT node in ^XDRM
 ;
DESC ;----- ROUTINE DESCRIPTION
 ;;
 ;;BPMRP1
 ;;THIS ROUTINE LOOPS THROUGH THE MERGE IMAGES FILE #15.4
 ;;AND PRINTS A REPORT OF THOSE PATIENTS THAT HAVE BEEN MERGED
 ;;SHOWING THE MERGE DATE, PATIENT NAME, DOB, AND SSN OF THE
 ;;'MERGED FROM' PATIENT AND WHICH ENTRY IT WAS 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 ;EP -- MAIN ENTRY POINT
 ;
 N ZTDESC,ZTRTN,ZTSAVE
 ;
 S ZTRTN="DQ^BPMRP1"
 S ZTDESC="MERGED PATIENT LIST"
 D QUE(ZTRTN,ZTDESC)
 Q
DQ ;EP -- QUEUED JOB STARTS HERE
 ;
 D ^XBKVAR
 ;
 K ^TMP("BPMRP1",$J)
 D LOOP
 D PRT
 D ^%ZISC
 Q
LOOP ;----- MAIN LOOP THROUGH MERGE IMAGES FILE
 ;
 N BPMD0,BPMD1,BPMD2,BPMDATA,BPMDATE,BPMDOB,BPMFR,BPMFRN,BPMOUT,BPMSSN,BPMTO,BPMTON
 ;
 S BPMOUT=0
 S BPMD0=0
 F  S BPMD0=$O(^XDRM(BPMD0)) Q:'BPMD0  D
 . S BPMDATA=$G(^XDRM(BPMD0,0))
 . S BPMFR=+$P(BPMDATA,U)
 . S BPMFRN=$P($G(^DPT(BPMFR,0)),U)
 . S BPMTO=+$P(BPMDATA,U,2)
 . S BPMTON=$P($G(^DPT(BPMTO,0)),U)
 . S BPMDATE=$P(BPMDATA,U,3)
 . I BPMDATE S BPMDATE=$$SLDATE(BPMDATE)
 . S BPMD1=0
 . F  S BPMD1=$O(^XDRM(BPMD0,1,BPMD1)) Q:'BPMD1  D  Q:BPMOUT
 . . S BPMD2=0
 . . F  S BPMD2=$O(^XDRM(BPMD0,1,BPMD1,1,BPMD2)) Q:'BPMD2  D  Q:BPMOUT
 . . . ;IHS/OIT/NKD BPM*1.0*2 Corrected logic due to Cache resolving the expression as a number (instead of a string)
 . . . ;I ^XDRM(BPMD0,1,BPMD1,1,BPMD2,0)="DPT("_BPMFR_",0)" D  Q:BPMOUT
 . . . I ^XDRM(BPMD0,1,BPMD1,1,BPMD2,0)=("DPT("_BPMFR_",0)") D  Q:BPMOUT
 . . . . S BPMOUT=1
 . . . . ; get DOB and SSN for FROM patient
 . . . . S BPMDATA=$G(^XDRM(BPMD0,1,BPMD1,1,BPMD2,1))
 . . . . S BPMDOB=$P(BPMDATA,U,3)
 . . . . I BPMDOB S BPMDOB=$$SLDATE(BPMDOB)
 . . . . S BPMSSN=$P(BPMDATA,U,9)
 . . . . S ^TMP("BPMRP1",$J,BPMFRN_";"_BPMFR)=BPMD0_U_BPMFR_U_BPMFRN_U_BPMDOB_U_BPMSSN_U_BPMTO_U_BPMTON_U_BPMDATE
 . . . . ; now get DOB and SSN for TO patient;IHS/OIT/LJF 11/16/2006
 . . . . S BPMDATA=$G(^XDRM(BPMD0,2,BPMD1,1,BPMD2,1))
 . . . . S BPMDOB=$P(BPMDATA,U,3)
 . . . . I BPMDOB S BPMDOB=$$SLDATE(BPMDOB)
 . . . . S BPMSSN=$P(BPMDATA,U,9)
 . . . . S $P(^TMP("BPMRP1",$J,BPMFRN_";"_BPMFR),U,9)=BPMDOB_U_BPMSSN
 Q
PRT ;----- PRINT THE ACTUAL REPORT
 ;
 N BPMOUT,BPMPAGE,BPMPAT,BPMX
 ;
 S BPMOUT=0
 S BPMPAGE=0
 ;
 D HDR(.BPMPAGE,.BPMOUT)
 Q:$G(BPMOUT)
 ;
 S BPMPAT=""
 F  S BPMPAT=$O(^TMP("BPMRP1",$J,BPMPAT)) Q:BPMPAT']""  D  Q:BPMOUT
 . I $Y>(IOSL-5) D HDR(.BPMPAGE,.BPMOUT)
 . Q:$G(BPMOUT)
 . I '$D(^TMP("BPMRP1",$J)) D  Q
 . . W !!?5,"NO DATA TO PRINT"
 . . S BPMOUT=1
 . S BPMX=$G(^TMP("BPMRP1",$J,BPMPAT))
 . W !?0,"FROM:"
 . W ?7,$P(BPMX,U,2)
 . W ?14,$P(BPMX,U,3)
 . W ?46,$P(BPMX,U,4)
 . W ?56,$P(BPMX,U,5)
 . W ?67,$P(BPMX,U,8)
 . W !?0,"  TO:"
 . W ?7,$P(BPMX,U,6)
 . W ?14,$P(BPMX,U,7)
 . W ?46,$P(BPMX,U,9)
 . W ?56,$P(BPMX,U,10)
 . W !
 ;
 Q
HDR(BPMPAGE,BPMOUT) ;
 ;----- PRINT HEADER
 ;
 N DIR,DIRUT,DTOUT,DUOUT,I,X,Y
 ;
 I $E(IOST)="C",$G(BPMPAGE) D
 . S DIR(0)="E"
 . D ^DIR
 . K DIR
 . I 'Y S BPMOUT=1
 Q:BPMOUT
 ;
 S BPMPAGE=$G(BPMPAGE)+1
 W @IOF
 W !,"MERGED PATIENTS"
 W ?49,$$NOW
 W "   PAGE ",BPMPAGE
 W !?7,"DFN",?14,"PATIENT NAME",?46,"DOB",?56,"SSN",?67,"DATE MERGED"
 W !
 F I=1:1:IOM W "-"
 Q
QUE(ZTRTN,ZTDESC) ;
 ;
 N %ZIS,IO,POP,ZTIO,ZTSK
 S %ZIS="Q"
 D ^%ZIS
 Q:POP
 I $D(IO("Q")) D  Q
 . K IO("Q")
 . S ZTIO=ION_";"_IOST_";"_IOM_";"_IOSL
 . D ^%ZTLOAD
 . I $G(ZTSK) W !,"Task #",$G(ZTSK)," queued"
 D @ZTRTN
 Q
NOW()    ;EP -- RETURNS CURRENT DATE/TIME
 ;
 N %,%H,%I,X
 D ^XBKVAR
 D NOW^%DTC
 S Y=DT
 X ^DD("DD")
 Q Y_" "_$E($P(%,".",2),1,2)_":"_$E($P(%,".",2),3,4)
 ;
SLDATE(X) ;EP
 ;----- RETURNS DATE IN MM/DD/YY FORMAT
 ;
 ;      X = INTERNAL FILEMANAGER DATE IN YYYMMDD FORMAT
 ;
 N Y
 S Y=""
 I X D
 . Q:$L(X)'=7
 . S Y=$E(X,4,5)_"/"_$E(X,6,7)_"/"_$E(X,2,3)
 Q Y