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

ORB3.m

Go to the documentation of this file.
  1. ORB3 ; slc/CLA,WAT - Main routine for OE/RR 3 notifications ;23-Nov-2011 11:43;PLS
  1. ;;3.0;ORDER ENTRY/RESULTS REPORTING;**31,74,91,105,139,190,1002,1004,220,253,265,296,1010**;Dec 17, 1997;Build 47
  1. ;;Per VHA Directive 2004-038, this routine should not be modified.
  1. ;
  1. ;This routine invokes to following ICR(s):
  1. ;ICR 4156 ;REGISTRATION, COMBAT VETERAN STATUS
  1. ;Modified - IHS/CIA/MGH - 5/14/2010 - Line TITLE+15, IHSPRIM, IHSTEAM and IHSDP
  1. EN(ORN,ORBDFN,ORNUM,ORBADUZ,ORBPMSG,ORBPDATA) ;
  1. ;
  1. N ORBENT
  1. S ORBENT=$$ENTITY^ORB31(ORNUM)
  1. ;
  1. Q:$$GET^XPAR(ORBENT,"ORB SYSTEM ENABLE/DISABLE",1,"I")="D"
  1. Q:'$L($G(^ORD(100.9,ORN,0)))
  1. Q:+$$ONOFF^ORB3FN(ORN)=0
  1. ;
  1. S ORBPMSG=$E($G(ORBPMSG),1,51)
  1. ;
  1. ;if msg from notif file or oc notif (#54), quit if dup w/in past 1 min:
  1. N ORBDUP,ORBN
  1. S ORBN=^ORD(100.9,ORN,0)
  1. I ($P(ORBN,"^",4)="NOT")!(ORN=54) D
  1. .S ORBDUP=$$DUP^ORB31(ORN,ORBDFN,ORBPMSG,ORNUM)
  1. Q:+$G(ORBDUP)=1
  1. ;
  1. N ORBDESC
  1. S ORBDESC=" Send Alert Notification ("_(+ORN)_") "_$P($G(^ORD(100.9,+ORN,0)),U,1)_" "
  1. ;
  1. D QUEUE^ORB31(ORN,ORBDFN,$G(ORNUM),.ORBADUZ,$G(ORBPMSG),$G(ORBPDATA),$H,ORBDESC,$G(DGPMA))
  1. Q
  1. ZTSK ;
  1. D START
  1. S ZTREQ="@"
  1. Q
  1. UTL(ORBU,ORN,ORBDFN,ORNUM,ORBADUZ,ORBPMSG,ORBPDATA) ;
  1. Q:$G(ORBU)'=1
  1. START Q:$G(ORN)=""!($G(ORBDFN)="")
  1. Q:'$L($G(^ORD(100.9,ORN,0)))
  1. N ORBNOW,ORBID,ORBLOCK,ORBDESC
  1. S ORBNOW=$$NOW^XLFDT
  1. S ORBLOCK=0
  1. ;
  1. ;lock to prevent concurrent processing by other resource slots:
  1. I '$D(ORBU) D
  1. .S ^XTMP("ORBLOCK",0)=$$FMADD^XLFDT(ORBNOW,1,"","","")_"^"_ORBNOW
  1. .S ORBID=$P($P($G(ORBPDATA),"|",2),"@") ;get unique data id
  1. .I $L(ORBID) D
  1. ..LOCK +^XTMP("ORBLOCK",ORBDFN,ORN,ORBID):60 E D Q
  1. ...S ORBDESC=" Requeue Alert Notification ("_(+ORN)_") "_$P($G(^ORD(100.9,+ORN,0)),U,1)_" "
  1. ...D QUEUE^ORB31(ORN,ORBDFN,$G(ORNUM),.ORBADUZ,$G(ORBPMSG),$G(ORBPDATA),$$HADD^XLFDT($H,"","",5,""),ORBDESC,$G(DGPMA)) ;requeue in 5 min.
  1. ...S ORBLOCK=1
  1. .;
  1. .I '$L(ORBID) D
  1. ..LOCK +^XTMP("ORBLOCK",ORBDFN,ORN):60 E D Q
  1. ...S ORBDESC=" Requeue Alert Notification ("_(+ORN)_") "_$P($G(^ORD(100.9,+ORN,0)),U,1)_" "
  1. ...D QUEUE^ORB31(ORN,ORBDFN,$G(ORNUM),.ORBADUZ,$G(ORBPMSG),$G(ORBPDATA),$$HADD^XLFDT($H,"","",5,""),ORBDESC,$G(DGPMA)) ;requeue in 5 min.
  1. ...S ORBLOCK=1
  1. .;
  1. I ORBLOCK=1 D QUIT Q
  1. ;
  1. DOALERT ; Entry point for alert logic outside of TaskMan
  1. N ORBDUZ,ORBN,ORBXQAID,ORPTNAM,ORBPRIM,ORBATTD,ORBDEV,ORBENT
  1. N ORBUI,ORBASPEC,ORBSMSG,ORBADT,ORBSDEV,ORBDEL,ORBDI,ORBTDEV,ORY
  1. S ORBUI=1,ORBADT=0
  1. S:'$L($G(ORBPMSG)) ORBPMSG=""
  1. I '$L(ORBPDATA),(+$G(ORNUM)>0) S ORBPDATA=+$G(ORNUM)_"@"
  1. S ORBN=^ORD(100.9,ORN,0)
  1. ;
  1. S ORBENT=$$ENTITY^ORB31(ORNUM)
  1. ;
  1. N DFN S DFN=ORBDFN,VA200="" D OERR^VADPT
  1. I ('$L($G(VA("BID"))))!('$L($G(VADM(1)))) D QUIT Q
  1. I (ORN=18)!(ORN=20)!(ORN=35) S ORBADT=1 ;A/D/T notif
  1. ;if not an A/D/T notif, get primary & attending from OERR^VADPT:
  1. I ORBADT=0 S ORBPRIM=+$P(VAIN(2),U),ORBATTD=+$P(VAIN(11),U)
  1. I ORBADT=1 D ADT^ORB31(ORN,ORBDFN,.ORBPRIM,.ORBATTD,$G(ORDGPMA)) ;A/D/T notif
  1. I $D(ORBU) D ;create debug msg
  1. .S ORBU(ORBUI)="Processing notification: "_$P(ORBN,U),ORBUI=ORBUI+1
  1. .S ORBU(ORBUI)=" for patient: "_VADM(1),ORBUI=ORBUI+1
  1. .I $G(ORNUM)>0 S ORBU(ORBUI)=" for order: "_ORNUM,ORBUI=ORBUI+1
  1. D REGULAR^ORB3REG(ORN,.XQA,.ORBU,.ORBUI,.ORBDEV,ORBDFN)
  1. D SPECIAL^ORB3SPEC(ORN,.ORBASPEC,.ORBU,.ORBUI,$G(ORNUM),ORBDFN,$G(ORBPDATA),.ORBSMSG,$G(ORBPMSG),.ORBSDEV,$G(ORBPRIM),$G(ORBATTD))
  1. I $L($G(ORBSMSG)) S ORBPMSG=$E(ORBSMSG,1,51)
  1. I $D(ORBASPEC)>1 D SPECDUZS ;special recips
  1. I $D(ORBADUZ)>1 D PKGDUZS ;pkg-supplied recips
  1. D TITLE ;provider recips
  1. S ORBXQAID=$P(ORBN,"^",2)_","_ORBDFN_","_ORN
  1. ;
  1. I ($D(XQA)>1)!($D(ORBDEV)>1)!($D(ORBSDEV)>1) D ;recips found
  1. .S XQAFLG=$P(ORBN,"^",5)
  1. .S XQADFN=ORBDFN
  1. .I XQAFLG="R" S XQAROU=$P(ORBN,"^",6)_"^"_$P(ORBN,"^",7)
  1. .I $G(ORBPDATA)'="" S XQADATA=ORBPDATA
  1. .S ORPTNAM=$E(VADM(1)_" ",1,9)
  1. .I $G(ORN)=27 N CVMRKR,RSLT S RSLT=$$CVEDT^DGCV(DFN) I $P($G(RSLT),U)&($P($G(RSLT),U,3)) S CVMRKR=" CV "_$$FMTE^XLFDT($P($G(RSLT),U,2),"5DZ") ;WAT
  1. .S XQAMSG=ORPTNAM_" "_"("_$E(ORPTNAM)_$E(VA("BID"),1,4)_")"_$G(CVMRKR)_": " ;WAT
  1. .S XQAMSG=XQAMSG_$S(ORBPMSG'="":ORBPMSG,1:$P(ORBN,"^",3))
  1. .S XQAARCH=$$GET^XPAR(ORBENT,"ORB ARCHIVE PERIOD",ORN,"I")
  1. .S XQASUPV=$$GET^XPAR(ORBENT,"ORB FORWARD SUPERVISOR",ORN,"I")
  1. .S XQASURO=$$GET^XPAR(ORBENT,"ORB FORWARD SURROGATES",ORN,"I")
  1. .S XQAREVUE=$$GET^XPAR(ORBENT,"ORB FORWARD BACKUP REVIEWER",ORN,"I")
  1. .S XQACNDEL=$$GET^XPAR(ORBENT,"ORB REMOVE",ORN,"I")
  1. .S XQACNDEL=$S(XQACNDEL=1:1,1:"")
  1. .I $D(ORBDEV)>1 D REGDEV^ORB31(.ORBDEV)
  1. .I $D(ORBSDEV)>1 D REGDEV^ORB31(.ORBSDEV)
  1. .I $D(ORBTDEV)>1 D REGDEV^ORB31(.ORBTDEV)
  1. .S XQAID=ORBXQAID
  1. .I $D(XQA) D SETUP^XQALERT ;if no [new] recips don't send alert
  1. QUIT ;
  1. K VA,VA200,VADM,VAERR,VAIN,XQA,XQADATA,XQAID,XQAFLG,XQAMSG,XQAROU,XQAARCH,XQASUPV,XQASURO,XQADFN
  1. K ^XTMP("ORBUSER",$J)
  1. I '$D(ORBU),$D(ORBLOCK) D
  1. .I $G(ORBID)]"" LOCK -^XTMP("ORBLOCK",ORBDFN,ORN,ORBID)
  1. .E LOCK -^XTMP("ORBLOCK",ORBDFN,ORN)
  1. Q
  1. PKGDUZS ;get DUZs from pkg-passed ORBADUZ() array
  1. N ORBPDUZ
  1. I $D(ORBU) D
  1. .S ORBU(ORBUI)=" ",ORBUI=ORBUI+1
  1. .I ORN=68 S ORBU(ORBUI)="Recipients with Lab Threshold Exceeded:",ORBUI=ORBUI+1
  1. .E S ORBU(ORBUI)="Recipients defined when notif was triggered:",ORBUI=ORBUI+1
  1. S ORBPDUZ=""
  1. F S ORBPDUZ=$O(ORBADUZ(ORBPDUZ)) Q:ORBPDUZ="" S ORBDUZ=ORBPDUZ D USER
  1. Q
  1. SPECDUZS ;get DUZs rtn by SPECIAL^ORB3SPEC
  1. N ORBSDUZ
  1. I $D(ORBU) D
  1. .S ORBU(ORBUI)=" ",ORBUI=ORBUI+1
  1. .S ORBU(ORBUI)="Special recipients associated with the notification:",ORBUI=ORBUI+1
  1. S ORBSDUZ=""
  1. F S ORBSDUZ=$O(ORBASPEC(ORBSDUZ)) Q:ORBSDUZ="" S ORBDUZ=ORBSDUZ D USER
  1. Q
  1. TITLE ;get provider recips
  1. N TITLES
  1. I $D(ORBU) D
  1. .S ORBU(ORBUI)=" ",ORBUI=ORBUI+1
  1. .S ORBU(ORBUI)="Recipients determined by Provider Recipient parameter:",ORBUI=ORBUI+1
  1. ;
  1. S TITLES=$$GET^XPAR(ORBENT,"ORB PROVIDER RECIPIENTS",ORN,"I")
  1. I TITLES["P" D PRIMARY
  1. I TITLES["A" D ATTEND
  1. I TITLES["T" D TEAMS
  1. I TITLES["O" D ORDERER
  1. I TITLES["E" D ENTERBY
  1. I TITLES["R" D PCMMPRIM
  1. I TITLES["S" D PCMMASSC
  1. I TITLES["M" D PCMMTEAM
  1. ;IHS/CIA/MGH Next 3 choices were for provider recipients
  1. I TITLES["D" D IHSPRIM
  1. I TITLES["I" D IHSTEAM
  1. I TITLES["G" D IHSDP
  1. Q
  1. PRIMARY ;
  1. I $D(ORBU),ORBADT=0 S ORBU(ORBUI)=" Inpt primary provider:",ORBUI=ORBUI+1
  1. I $D(ORBU),ORBADT=1 S ORBU(ORBUI)=" Inpt primary provider: option cannot determine without A/D/T event data.",ORBUI=ORBUI+1
  1. I +$G(ORBPRIM)>0 S ORBDUZ=ORBPRIM D USER
  1. Q
  1. ATTEND ;
  1. I $D(ORBU),ORBADT=0 S ORBU(ORBUI)=" Attending physician:",ORBUI=ORBUI+1
  1. I $D(ORBU),ORBADT=1 S ORBU(ORBUI)=" Attending physician: option cannot determine without A/D/T event data.",ORBUI=ORBUI+1
  1. I +$G(ORBATTD)>0 S ORBDUZ=ORBATTD D USER
  1. Q
  1. TEAMS ;
  1. I $D(ORBU) S ORBU(ORBUI)=" Teams/Personal Lists related to patient:",ORBUI=ORBUI+1
  1. N ORBLST,ORBI,ORBJ,ORBTM,ORBTNAME,ORBTTYPE,ORBTD
  1. D TMSPT^ORQPTQ1(.ORBLST,ORBDFN)
  1. Q:+$G(ORBLST(1))<1
  1. S ORBI="" F S ORBI=$O(ORBLST(ORBI)) Q:ORBI="" D
  1. .S ORBTM=$P(ORBLST(ORBI),U),ORBTNAME=$P(ORBLST(ORBI),U,2)
  1. .S ORBTTYPE=$P(ORBLST(ORBI),U,3)
  1. .I $D(ORBU) D
  1. ..S ORBU(ORBUI)=" Patient list "_ORBTNAME_" ["_ORBTTYPE_"]:",ORBUI=ORBUI+1
  1. .N ORBLST2 D TEAMPROV^ORQPTQ1(.ORBLST2,ORBTM)
  1. .Q:+$G(ORBLST2(1))<1
  1. .S ORBJ="" F S ORBJ=$O(ORBLST2(ORBJ)) Q:ORBJ="" D
  1. ..S ORBDUZ=$P(ORBLST2(ORBJ),U)_U_ORBTM I +$G(ORBDUZ)>0 D USER
  1. .;
  1. .S ORBTD=$P($$TMDEV^ORB31(ORBTM),U,2) ;Team's device
  1. .I $L(ORBTD) D
  1. ..S ORBTDEV(ORBTD)=""
  1. ..I $D(ORBU) D
  1. ...S ORBU(ORBUI)=" Team's Device "_ORBTD_" is a recipient",ORBUI=ORBUI+1
  1. Q
  1. ORDERER ;
  1. Q:+$G(ORNUM)<1
  1. I $D(ORBU) S ORBU(ORBUI)=" Ordering provider:",ORBUI=ORBUI+1
  1. N ORBLST,ORBI,ORBTM,ORBJ,ORBTNAME,ORBPLST,ORBPI,ORBPTM,ORBTTYPE
  1. S ORBDUZ=$S(ORN=12:+$$UNSIGNOR^ORQOR2(ORNUM),1:$$ORDERER^ORQOR2(ORNUM))
  1. I +$G(ORBDUZ)>0 D
  1. .D USER
  1. .;if notif = Order Req E/S (#12) or Order Req Co-sign (#37) and
  1. .;user doesn't have ES authority, send to fellow team members w/ES:
  1. .I ((ORN=12)!(ORN=37)),('$D(^XUSEC("ORES",ORBDUZ))) D
  1. ..I $D(ORBU) S ORBU(ORBUI)=" Orderer can't elec sign, getting teams orderer belongs to:",ORBUI=ORBUI+1
  1. ..D TEAMPR^ORQPTQ1(.ORBLST,ORBDUZ) ;get orderer's tms
  1. ..Q:+$G(ORBLST(1))<1
  1. ..D TMSPT^ORQPTQ1(.ORBPLST,ORBDFN) ;get pt's tms
  1. ..Q:+$G(ORBPLST(1))<1
  1. ..S ORBI="" F S ORBI=$O(ORBLST(ORBI)) Q:ORBI="" D
  1. ...S ORBPI="" F S ORBPI=$O(ORBPLST(ORBPI)) Q:ORBPI="" D
  1. ....S ORBTM=$P(ORBLST(ORBI),U),ORBPTM=$P(ORBPLST(ORBPI),U)
  1. ....I ORBTM=ORBPTM D ;if pt is on provider's team
  1. .....I +$G(ORBPTM)>0 D
  1. ......S ORBTNAME=$P(ORBPLST(ORBPI),U,2)
  1. ......S ORBTTYPE=$P(ORBPLST(ORBPI),U,3)
  1. ......I $D(ORBU) S ORBU(ORBUI)=" Orderer's pt list "_ORBTNAME_" ["_ORBTTYPE_"] recipients: ",ORBUI=ORBUI+1
  1. ......N ORBLST2 D TEAMPROV^ORQPTQ1(.ORBLST2,ORBPTM)
  1. ......Q:+$G(ORBLST2(1))<1
  1. ......S ORBJ="" F S ORBJ=$O(ORBLST2(ORBJ)) Q:ORBJ="" D
  1. .......S ORBDUZ=$P(ORBLST2(ORBJ),U)_U_ORBPTM I +$G(ORBDUZ)>0,($D(^XUSEC("ORES",+ORBDUZ))) D USER
  1. Q
  1. ENTERBY ;
  1. I $D(ORBU) S ORBU(ORBUI)=" User entering order's most recent activity:",ORBUI=ORBUI+1
  1. Q:+$G(ORNUM)<1
  1. I $D(^OR(100,ORNUM,8,0)) D
  1. .S ORBDUZ=$P(^OR(100,ORNUM,8,$P(^OR(100,ORNUM,8,0),U,3),0),U,13)
  1. I +$G(ORBDUZ)>0 D USER
  1. Q
  1. PCMMPRIM ;
  1. I $D(ORBU) S ORBU(ORBUI)=" PCMM Primary Care Practitioner:",ORBUI=ORBUI+1
  1. S ORBDUZ=+$$OUTPTPR^SDUTL3(ORBDFN,$$NOW^XLFDT,1) ;DBIA #1252
  1. I +$G(ORBDUZ)>0 D USER
  1. Q
  1. PCMMASSC ;
  1. I $D(ORBU) S ORBU(ORBUI)=" PCMM Associate Provider:",ORBUI=ORBUI+1
  1. S ORBDUZ=+$$OUTPTAP^SDUTL3(ORBDFN,$$NOW^XLFDT) ;DBIA #1252
  1. I +$G(ORBDUZ)>0 D USER
  1. Q
  1. PCMMTEAM ;
  1. N ORPCMM,ORPCMMDZ
  1. I $D(ORBU) S ORBU(ORBUI)=" PCMM Team Position Assignments:",ORBUI=ORBUI+1
  1. S ORPCMM=$$PRPT^SCAPMC(ORBDFN,,,,,,"^TMP(""ORPCMM"",$J)",) ;DBIA #1916
  1. S ORPCMMDZ=0
  1. F S ORPCMMDZ=$O(^TMP("ORPCMM",$J,"SCPR",ORPCMMDZ)) Q:'ORPCMMDZ D
  1. .S ORBDUZ=ORPCMMDZ D USER
  1. K ^TMP("ORPCMM",$J)
  1. Q
  1. ;IHS/CIA/MGH
  1. IHSPRIM ;Send alert to designated provider
  1. I $D(ORBU) S ORBU(ORBUI)=" IHS Primary Care Provider:",ORBUI=ORBUI+1
  1. S ORBDUZ=$$GET1^DIQ(9000001,ORBDFN,.14,"I") ;pcp ien
  1. I +$G(ORBDUZ)>0 D USER
  1. Q
  1. IHSTEAM ;IHS/CIA/MGH
  1. ;Send alert to primary team
  1. N ORIHS,ORIHDUZ
  1. I $D(ORBU) S ORBU(ORBUI)=" IHS Primary Care Team:",ORBUI=ORBUI+1
  1. S ORBDUZ=$$GET1^DIQ(9000001,ORBDFN,.14,"I")
  1. I +$G(ORBDUZ)>0 D TEAM^BEHOPTPC(ORBDUZ)
  1. S ORIHDUZ=""
  1. F S ORIHDUZ=$O(^TMP("ORIHS",$J,ORIHDUZ)) Q:ORIHDUZ="" D
  1. .S ORBDUZ=ORIHDUZ D USER
  1. K ^TMP("ORIHS",$J)
  1. Q
  1. ;IHS/CIA/MGH - Send alert to all designated providers
  1. IHSDP N I,X,BDPQ,BEHOTYPE,BEHOCT,BEHOPR,BDPCPRV,BEHORIEN
  1. Q:'$D(^BDPRECN("AA",ORBDFN))
  1. I $D(ORBU) S ORBU(ORBUI)=" IHS Designated Providers:",ORBUI=ORBUI+1
  1. S I=0,BDPQ=0,BEHOTYPE="",BEHOCT=0
  1. F S BEHOTYPE=$O(^BDPRECN("AA",ORBDFN,BEHOTYPE)) Q:BEHOTYPE="" D
  1. .S BEHOPR=0
  1. .F S BEHOPR=$O(^BDPRECN("AA",ORBDFN,BEHOTYPE,BEHOPR)) Q:BEHOPR="" D
  1. ..S ORBDUZ=$P($G(^BDPRECN(BEHOPR,0)),U,3) ;Current Provider IEN
  1. ..D USER
  1. Q
  1. USER ;should USER (ORBDUZ) be a recip
  1. D USER^ORB3USER(.XQA,ORBDUZ,ORN,.ORBU,.ORBUI,ORBDFN,+$G(ORNUM))
  1. Q