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

BGPGUA.m

Go to the documentation of this file.
BGPGUA ; IHS/CMI/LAB - BGP Gui Utilities 03/11/2010 3:28:39 PM ; 16 Oct 2014  12:11 PM
 ;;16.1;IHS CLINICAL REPORTING;;MAR 22, 2016;Build 170
 ;
DEBUG(RETVAL,BGPSTR) ;run the debugger
 D DEBUG^%Serenji("SEARCH^BGPGUA(.RETVAL,.BGPSTR)")
 Q
 ;
ADO ;EP -- setup the ADO string for each call
 S BGPX="MERR^BGPGU",@^%ZOSF("TRAP") ; m error trap
 K ^BGPTMP($J)
 S RETVAL="^BGPTMP("_$J_")"
 Q
 ;
 N BGPDA,BGPI,P,BGPFL,BGPIDX,BGPGB,BGPS,BGPSZ,BGPL,BGPTGT,BGPFLDS,BGPSCR,BGPPR,BGPFLD1,BGPFLD2,BGPDT
 S P="|"
 S BGPI=0
 S X="MERR^BGPGU",@^%ZOSF("TRAP") ; m error trap
 S RETVAL="^BGPTMP("_$J_")"
 K ^BGPTMP($J)
 K ^BGPTMPD($J)
 S BGPTGT="^BGPTMPD("_$J_")"  ;target for find^dic lookup
 S BGPFL=$P(BGPSTR,P)
 I $E(BGPFL,1,1)=0 S BGPFL=+BGPFL
 S BGPIDX=$P(BGPSTR,P,2)
 I BGPIDX]"" S BGPIDX=$TR(BGPIDX,"*","^")
 S BGPS=$P(BGPSTR,P,3)
 I BGPFL=9002012.2,BGPS="" S BGPIDX="BA"
 S BGPFLD1=$P(BGPSTR,P,4)
 S BGPFLD2=$P(BGPSTR,P,5)
 S BGPSCR=$P(BGPSTR,P,6)
 S BGPDT=$P(BGPSTR,P,8)
 I $G(BGPSCR)["" S BGPSCR=$TR(BGPSCR,"*","^")
 S BGPPR=$P(BGPSTR,P,7)
 S BGPDT=$P(BGPSTR,P,8)
 I BGPFLD1["." S BGPFLD1=+BGPFLD1
 I BGPFLD2["." S BGPFLD2=+BGPFLD2
 I BGPFLD2=0 S BGPFLD2=""
 S BGPFLDS=$S(BGPFLD2]"":BGPFLD1_";"_BGPFLD2,1:BGPFLD1)
 I BGPS="" D
 . D LIST^DIC(BGPFL,"",BGPFLDS,"","","",BGPS,BGPIDX,BGPSCR,"",BGPTGT,"BGPERRR(1)")
 I BGPS]"" D
 . D FIND^DIC(BGPFL,"",BGPFLDS,"",BGPS,"",BGPIDX,BGPSCR,"",BGPTGT,"BGPERRR(1)")
 S @RETVAL@(0)="T00010BMXIEN^T00050Value1^T00080Value2"_$C(30)
 S BGPDA=0  F  S BGPDA=$O(@BGPTGT@("DILIST","ID",BGPDA)) Q:'BGPDA  D
 . N BGPIEN,BGPBMX
 . S BGPIEN=0 F  S BGPIEN=$O(@BGPTGT@("DILIST","ID",BGPDA,BGPIEN)) Q:'BGPIEN  D
 .. S BGPBMX=$G(@BGPTGT@("DILIST",2,BGPDA))
 .. S BGPFLD(BGPIEN)=$G(@BGPTGT@("DILIST","ID",BGPDA,BGPIEN))
 . Q:'$G(BGPBMX)
 . S BGPI=BGPI+1
 . S @RETVAL@(BGPI)=BGPBMX_U_BGPFLD(BGPFLD1)_U_$S($G(BGPFLD2):$G(BGPFLD(BGPFLD2)),1:"")_$C(30)
 S @RETVAL@(BGPI+1)=$C(31)
 Q
 ;
TIME(RETVAL,BGPSTR) ;-- get system time out based on user or location
 N P,BGPDUZ,BGPDUZ2,BGPI,BGPVAL,BGPVALI
 S P="|"
 S BGPDUZ=$P(BGPSTR,P)
 S BGPDUZ2=$P(BGPSTR,P,2)
 S BGPI=0
 S RETVAL="^BGPTMP("_$J_")"
 K ^BGPTMP($J)
 S @RETVAL@(BGPI)="T00010TimeOut"_$C(30)
 S BGPVAL=$$GET1^DIQ(200,BGPDUZ,200.1)
 I '$G(BGPVAL) D
 . S BGPVAL=$$GET1^DIQ(8989.3,1,210)
 S BGPI=BGPI+1
 S @RETVAL@(BGPI)=$G(BGPVAL)_$C(30)
 S @RETVAL@(BGPI+1)=$C(31)
 Q
 ;
AUTO(RETVAL,BGPSTR) ;-- save the automated gpra parameters
 S X="MERR^BGPGU",@^%ZOSF("TRAP") ; m error trap
 N BGPI,P,BGPLOC,BGPTAX,BGPTYP,BGPDIR,BGPIP,BGPUSER,BGPPASS,BGPQUEUE,BGPRET,BGPTASK
 S P="|"
 I $G(BGPSTR)="" D CATSTR^BGPGR(.BGPSTR,.BGPSTR)
 S BGPLOC=$P(BGPSTR,P)
 S BGPTAX=$P(BGPSTR,P,2)
 S BGPTYP=$P(BGPSTR,P,3)
 S BGPDIR=$P(BGPSTR,P,4)
 S BGPIP=$P(BGPSTR,P,5)
 S BGPUSER=$P(BGPSTR,P,6)
 S BGPPASS=$P(BGPSTR,P,7)
 S BGPQUEUE=$P(BGPSTR,P,8)
 S BGPI=0
 I '$O(^BGPGP2PM("B",BGPLOC,0)) D
 . N BGPFDA,BGPIENS,BGPERR
 . S BGPIENS(1)=BGPLOC
 . S BGPFDA(90241.04,"+1,",.01)=BGPLOC
 . S BGPFDA(90241.04,"+1,",.02)=BGPTYP
 . S BGPFDA(90241.04,"+1,",4.2)=BGPIP
 . S BGPFDA(90241.04,"+1,",4.3)=BGPDIR
 . S BGPFDA(90241.04,"+1,",4.4)=BGPUSER
 . S BGPFDA(90241.04,"+1,",4.5)=BGPPASS
 . S BGPFDA(90241.04,"+1,",5.1)=BGPTAX
 . D UPDATE^DIE("","BGPFDA","BGPIENS","BGPERR(1)")
 . S BGPRET=$G(BGPIENS(1))
 I $O(^BGPGP2PM("B",BGPLOC,0)) D
 . N BGPFDA,BGPIENS,BGPERR
 . S BGPIENS=$O(^BGPGP2PM("B",BGPLOC,0))_","
 . S BGPFDA(90241.04,BGPIENS,.02)=BGPTYP
 . S BGPFDA(90241.04,BGPIENS,4.2)=BGPIP
 . S BGPFDA(90241.04,BGPIENS,4.3)=BGPDIR
 . S BGPFDA(90241.04,BGPIENS,4.4)=BGPUSER
 . S BGPFDA(90241.04,BGPIENS,4.5)=BGPPASS
 . S BGPFDA(90241.04,BGPIENS,5.1)=BGPTAX
 . D FILE^DIE("K","BGPFDA","BGPERR(1)")
 . S BGPRET=$G(BGPIENS(1))
 I $G(BGPQUEUE) D
 . S BGPTASK=$$CHKFQT^BGP3AUEX(BGPLOC)  ;check for currently queued task
 . I BGPTASK D  Q
 .. S ZTSK=BGPTASK
 .. D KILL^%ZTLOAD
 . D SCHEDGUI^BGP3AUEX
 S RETVAL="^BGPTMP("_$J_")"
 K ^BGPTMP($J)
 S @RETVAL@(BGPI)="T00001Return"_$C(30)
 S BGPI=BGPI+1
 S @RETVAL@(BGPI)=$S($G(BGPRET)]"":BGPRET,$G(BGPTASK):BGPTASK,1:"")_$C(30)
 S @RETVAL@(BGPI+1)=$C(31)
 Q
 ;
AUTOA(RETVAL,BGPSTR) ;-- save the area automated gpra parameters
 S X="MERR^BGPGU",@^%ZOSF("TRAP") ; m error trap
 N BGPI,P,BGPNAM,BGPTYP,BGPDIR,BGPSDIR,BGPALERT,BGPFAC,BGPREC,BGPQUEUE,BGPRUN,BGPRET,BGPTASK,BGPFACI,BGPRECI
 S P="|"
 I $G(BGPSTR)="" D CATSTR^BGPGR(.BGPSTR,.BGPSTR)
 S BGPNAM=$P(BGPSTR,P)
 S BGPTYP=$P(BGPSTR,P,2)
 S BGPDIR=$P(BGPSTR,P,3)
 S BGPSDIR=$P(BGPSTR,P,4)
 S BGPALERT=$P(BGPSTR,P,5)
 S BGPQUEUE=$P(BGPSTR,P,6)
 S BGPRUN=$P(BGPSTR,P,7)
 S BGPFAC=$P(BGPSTR,P,8)
 S BGPREC=$P(BGPSTR,P,9)
 I '$O(^BGPGP1PM("B",BGPNAM,0)) D
 . N BGPFDA,BGPIENS,BGPERR
 . S BGPIENS="+1,"
 . S BGPFDA(90245,"+1,",.01)=BGPNAM
 . S BGPFDA(90245,"+1,",.02)=BGPTYP
 . S BGPFDA(90245,"+1,",1.1)=BGPDIR
 . S BGPFDA(90245,"+1,",1.2)=BGPSDIR
 . S BGPFDA(90245,"+1,",99.1)=BGPALERT
 . D UPDATE^DIE("","BGPFDA","BGPIENS","BGPERR(1)")
 . S BGPRET=$G(BGPIENS(1))
 I $O(^BGPGP1PM("B",BGPNAM,0)) D
 . N BGPFDA,BGPIENS,BGPERR
 . S BGPIENS=$O(^BGPGP1PM("B",BGPNAM,0))_","
 . S BGPFDA(90245,BGPIENS,.02)=BGPTYP
 . S BGPFDA(90245,BGPIENS,1.1)=BGPDIR
 . S BGPFDA(90245,BGPIENS,1.2)=BGPSDIR
 . S BGPFDA(90245,BGPIENS,99.1)=BGPALERT
 . D FILE^DIE("K","BGPFDA","BGPERR(1)")
 . S BGPRET=$G(BGPIENS(1))
 S BGPIEN=$O(^BGPGP1PM("B",BGPNAM,0))
 D CLNFAC(BGPIEN),CLNREC(BGPIEN)
 F I=1:1 D  Q:'BGPFACI
 . N BGPTDA,BGPTERR,BGPTIENS
 . S BGPFACI=$P($P(BGPFAC,"*",I),"~",1)
 . Q:'BGPFACI
 . S BGPTIENS="+2,"_BGPIEN_","
 . S BGPTDA(90245.09,BGPTIENS,.01)=BGPFACI
 . S BGPTDA(90245.09,BGPTIENS,.02)=$$GET1^DIQ(9999999.06,BGPFACI,.12)
 . S BGPTDA(90245.09,BGPTIENS,.03)=1
 . D UPDATE^DIE("","BGPTDA","BGPTIENS","BGPTERR(1)")
 F J=1:1 D  Q:'BGPRECI
 . N BGPRDA,BGPRERR,BGPRIENS
 . S BGPRECI=$P($P(BGPREC,"*",J),"~",1)
 . Q:'BGPRECI
 . S BGPRIENS="+2,"_BGPIEN_","
 . S BGPTDA(90245.992,BGPRIENS,.01)=BGPRECI
 . D UPDATE^DIE("","BGPTDA","BGPRIENS","BGPRERR(1)")
 I $G(BGPQUEUE) D
 . S BGPTASK=$$CHKFQT^BGP3AUUL()  ;check for currently queued task
 . I BGPTASK D  Q
 .. S ZTSK=BGPTASK
 .. D KILL^%ZTLOAD
 . D SCHGUI^BGP3AUUL
 I $G(BGPRUN) D
 . D GUIDQ^BGP3AUUP
 S RETVAL="^BGPTMP("_$J_")"
 K ^BGPTMP($J)
 S BGPI=0
 S @RETVAL@(BGPI)="T00001Return"_$C(30)
 S BGPI=BGPI+1
 S @RETVAL@(BGPI)=$S($G(BGPRET)]"":BGPRET,$G(BGPTASK):BGPTASK,1:"")_$C(30)
 S @RETVAL@(BGPI+1)=$C(31)
 Q
 ;
CLNFAC(IE) ;-- clean out the facilities
 S DA(1)=IE
 S DIK="^BGPGP1PM("_DA(1)_",9,"
 S DA=0 F  S DA=$O(^BGPGP1PM(IE,9,DA)) Q:'DA  D
 . D ^DIK
 Q
 ;
CLNREC(IR) ;-- clean out recipients
 S DA(1)=IR
 S DIK="^BGPGP1PM("_DA(1)_",99.2,"
 S DA=0 F  S DA=$O(^BGPGP1PM(IR,99.2,DA)) Q:'DA  D
 . D ^DIK
 Q
 ;
CHKFQT(X) ;EP - check for queued task (BGP AUTO GPRA EXTRACT and BGPSITE variable within the task
 NEW Y
 S Y=$P($G(^BGPGUIK(X,0)),U,9)
 I '$G(Y) Q 0
 I '$D(^%ZTSK(Y,0)),$P($G(^BGPGUIK(X,0)),U,6)="R" Q 1  ;v16.0 check for deleted task and mark as errored if so
 I $P($G(^%ZTSK(Y,.1)),U)="C" Q 1
 I $P($G(^%ZTSK(Y,.1)),U)="E" Q 1
 Q 0
 ;
UPLOG(GIEN,TSK) ;EP
 S DIE="^BGPGUIK(",DR=".09///"_TSK
 S DA=GIEN
 D ^DIE
 Q
 ;