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

BPMXPRB.m

Go to the documentation of this file.
BPMXPRB ;IHS/PHXAO/AEF - REPOINT & RESEQUENCE PROBLEM FILE - 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
 ;IHS/OIT/NKD  6/13/2012 Changed re-sequencing process based on division
 ;                        and sequence
 ;                       Update "MODIFIED" x-ref
 ;;
DESC ;----- ROUTINE DESCRIPTION
 ;;
 ;;BPMXPRB:
 ;;THIS ROUTINE MERGES THE ENTRIES IN THE PROBLEM FILE #9000011.
 ;;SINCE BOTH FROM AND TO PATIENTS MAY HAVE PROBLEM #1, THEY NEED TO
 ;;BE RESEQUENCED IN ADDITION TO HAVING THE PATIENT POINTERS UPDATED.
 ;;
 ;;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 DATA
 ; GET THE FROM PATIENT'S PROBLEM LIST, AND STORE IN A LOCAL VARIABLE
 ; THEN MERGE ENTRIES INTO THE TO PATIENT, BY FACILITY THEN SEQUENCE NUMBER
 ;
 ;IHS/OIT/NKD BPM*1.0*2 START OLD CODE
 ;N BPM
 ;D BLD(BPMTO,.BPM)
 ;D LOOP(BPMFR,BPMTO,.BPM)
 ;IHS/OIT/NKD BPM*1.0*2 END OLD CODE - START NEW CODE
 N BPMRES,BPMTMP,BPMCNT,I,BPMI,BPMF,BPMN
 D FIND^DIC(9000011,,"@;.06I;.07","PQ",BPMFR,,"AC",,,"BPMRES")
 S BPMCNT=$P(BPMRES("DILIST",0),"^",1)
 Q:BPMCNT=0
 F I=1:1:BPMCNT D
 . S BPMI=$P(BPMRES("DILIST",I,0),"^",1),BPMF=$P(BPMRES("DILIST",I,0),"^",2),BPMN=$P(BPMRES("DILIST",I,0),"^",3)
 . ; IF NO FACILITY, SET TO 0 (FOR THE PURPOSE OF SETTING LOCAL VARIABLE)
 . S:BPMF="" BPMF=0
 . S:BPMN="" BPMN=1
 . S BPMTMP(BPMF,BPMN,BPMI)=""
 S BPMF=""
 F  S BPMF=$O(BPMTMP(BPMF)) Q:$L(BPMF)<1  D
 . S BPMN=""
 . F  S BPMN=$O(BPMTMP(BPMF,BPMN)) Q:$L(BPMN)<1  D
 . . S BPMI=""
 . . F  S BPMI=$O(BPMTMP(BPMF,BPMN,BPMI)) Q:$L(BPMI)<1  D
 . . . D ONE(BPMFR,BPMTO,BPMI)
 ;IHS/OIT/NKD BPM*1.0*2 UPDATE MODIFIED X-REF
 K ^AUPNPROB("MODIFIED",BPMFR),^AUPNPROB("MODIFIED",BPMTO)
 S ^AUPNPROB("MODIFIED",BPMTO,$$NOW^XLFDT())=""
 Q
 ;
 ;IHS/OIT/NKD BPM*1.0*2 START OLD CODE
 ;LOOP(BPMFR,BPMTO,BPM) ;
 ;----- LOOP THROUGH AC XREF TO FIND ENTRIES TO MERGE
 ;
 ;N BPMD0
 ;
 ;S BPMD0=0
 ;F  S BPMD0=$O(^AUPNPROB("AC",BPMFR,BPMD0)) Q:'BPMD0  D
 ;. D ONE(BPMFR,BPMTO,BPMD0,.BPM)
 ;
 ;Q
 ;ONE(BPMFR,BPMTO,BPMD0,BPM) ;
 ;N BPMNUM,DA,DIE,DITC,DR,X,Y
 ;S BPMNUM=$$NUM(BPMTO,BPMD0,.BPM),DITC=1,DIE="^AUPNPROB(",DA=BPMD0,DR=".02////"_BPMTO,DR=DR_";.07////"_BPMNUM
 ;D ^DIE
 ;S BPM(BPMTO,BPMNUM)=BPMD0
 ;IHS/OIT/NKD BPM*1.0*2 END OLD CODE - START NEW CODE
ONE(BPMFR,BPMTO,BPMI) ;
 ;----- PROCESS ONE ENTRY
 ;
 N FDA
 S FDA(9000011,BPMI_",",.02)=BPMTO ; Name (.02)
 S FDA(9000011,BPMI_",",.07)=$$NEXT(BPMTO,$$GET1^DIQ(9000011,BPMI,.06,"I")) ; NMBR (.07)
 D UPDATE^DIE(,"FDA",)
 ;
 Q
NEXT(DFN,FAC) ;
 ;----- RETURN THE NEXT HIGHEST AVAILABLE SEQUENCE NUMBER
 N BPMOUT,I,X
 S U="^",X=0
 ; SCREEN ENTRIES BASED ON FACILITY
 D FIND^DIC(9000011,,"@;.02I;.06I;.07","PQ",DFN,,"AC","I $P(^(0),U,6)=FAC",,"BPMOUT")
 ; FIND THE HIGHEST CURRENT SEQUENCE NUMBER
 F I=1:1:$P(BPMOUT("DILIST",0),U,1) S:$P(BPMOUT("DILIST",I,0),U,4)>X X=$P(BPMOUT("DILIST",I,0),U,4)
 ; INCREMENT TO THE NEXT WHOLE NUMBER
 S X=X-(X#1)+1
 Q X
 ;IHS/OIT/NKD BPM*1.0*2 END NEW CODE - START OLD CODE
 ;BLD(BPMTO,BPM) ;
 ;----- BUILD ARRAY OF PROBLEMS FOR "TO" ENTRY
 ;
 ;N N,X,Y
 ;
 ;S X=0
 ;F  S X=$O(^AUPNPROB("AC",BPMTO,X)) Q:'X  D
 ;. S Y=$G(^AUPNPROB(X,0))
 ;. S N=$P(Y,U,7)
 ;. I N S BPM(BPMTO,N)=X
 ;Q
 ;NUM(BPMTO,BPMD0,BPM) ;
 ;----- RETURNS PROBLEM NUMBER
 ;
 ;N Y
 ;S Y=$P($G(^AUPNPROB(BPMD0,0)),U,7) S:Y="" Y=1
 ;I $D(BPM(BPMTO,Y)) D
 ;. F Y=1:1 Q:'$D(BPM(BPMTO,Y))
 ;Q Y
 ;IHS/OIT/NKD BPM*1.0*2 END OLD CODE