- ORB3SPEC ; slc/CLA - Support routine for ORB3 ;4/4/02 14:40
- ;;3.0;ORDER ENTRY/RESULTS REPORTING;**139,220,215**;Dec 17, 1997
- SPECIAL(ORN,ORBASPEC,ORBU,ORBUI,ORNUM,ORDFN,ORDATA,ORBSMSG,ORBMSG,ORBSDEV,ORBPRIM,ORBATTD) ;
- ;process special notifs to get recips (users,teams,devices)
- ; ORN: notif ien
- ; ORBASPEC: recip DUZ array
- ; ORBU: recip debug array
- ; ORBUI: ORBU cntr
- ; ORNUM: order no
- ; ORDFN: pt id
- ; ORDATA: pkg data
- ; ORBSMSG: special notif msg rtn by SPECIAL
- ; ORBMSG: original notif msg
- ; ORBSDEV: array of recip devices
- ; ORBPRIM: pt's inpt primary care provider
- ; ORBATTD: pt's attending physician
- ;
- N ORPAR,ORPTLOC
- S ORPTLOC=$S($L($G(^DPT(ORDFN,.1))):"I",1:"O") ;DBIA #10035
- ;
- I ORPTLOC="I" D ;inpt flagged OI notifs
- .I ORN=32 S ORPAR="ORB OI RESULTS - INPT" D OI
- .I ORN=41 S ORPAR="ORB OI ORDERED - INPT" D OI
- .I ORN=64 S ORPAR="ORB OI EXPIRING - INPT" D OI
- ;
- I ORPTLOC="O" D ;outpt flagged OI notifs
- .I ORN=60 S ORPAR="ORB OI RESULTS - OUTPT" D OI
- .I ORN=61 S ORPAR="ORB OI ORDERED - OUTPT" D OI
- .I ORN=65 S ORPAR="ORB OI EXPIRING - OUTPT" D OI
- ;
- I ORN=3!(ORN=14)!(ORN=44)!(ORN=57) D ;lab results notifs
- .D LRALRTS(ORN,ORDFN,ORDATA,.ORBSMSG,ORBMSG)
- ;
- I ORN=33 D ;requested results notif
- .I $D(ORBU) D
- ..S ORBU(ORBUI)=" ",ORBUI=ORBUI+1
- ..S ORBU(ORBUI)="Potential Orderer-flagged Results recipient: ",ORBUI=ORBUI+1
- .N RECIP
- .S RECIP=$$RSLTFLG^ORQOR2(ORNUM)
- .I +$G(RECIP)>0 D
- ..S ORBASPEC(+$G(RECIP))=""
- ..I $D(ORBU) N NODE S NODE=$G(^VA(200,+$G(RECIP),0)) I $L(NODE) D
- ...S ORBU(ORBUI)=" "_$P(NODE,U)_" is a potential recipient.",ORBUI=ORBUI+1
- Q
- OI ;get potential recips for OI-flagged notifs
- N OROI,ORLST,ORERR,ORBX,ORBZ,ORBE,ORBDUZ,ORBDEV,ORBUF
- S OROI=+$G(^OR(100,+$G(ORNUM),.1,1,0)) ;get oi
- Q:+$G(OROI)<0
- I $D(ORBU) D
- .S ORBU(ORBUI)=" ",ORBUI=ORBUI+1
- .S ORBU(ORBUI)="Special potential recipients from parameter: "_ORPAR,ORBUI=ORBUI+1
- S ORBE=0,ORBX=0
- ;
- ;process special recip users, teams and devices:
- D ENVAL^XPAR(.ORLST,ORPAR,"`"_OROI,.ORERR)
- I 'ORERR,$G(ORLST)>0 D
- .F ORBX=1:1:ORLST S ORBE=$O(ORLST(ORBE)),ORBZ=$P(ORBE,";",2),ORBUF=0 D
- ..;
- ..; process USERS:
- ..I ORBZ="VA(200," S ORBDUZ=$P(ORBE,";") I $L(ORBDUZ) D
- ...I ORLST(ORBE,OROI)=1 S ORBASPEC(ORBDUZ)="",ORBUF=1
- ...I ORLST(ORBE,OROI)=0,$$PPLINK^ORQPTQ1(ORBDUZ,ORDFN) S ORBASPEC(ORBDUZ)="",ORBUF=1
- ...I $D(ORBU),ORBUF=1 N NODE S NODE=$G(^VA(200,ORBDUZ,0)) I $L(NODE) D
- ....S ORBU(ORBUI)=" "_$P(NODE,U)_" is a potential recipient.",ORBUI=ORBUI+1
- ..;
- ..; process DEVICES:
- ..I ORBZ="%ZIS(1," S ORBDEV=$P(ORBE,";") I $L(ORBDEV),$D(^%ZIS(1,ORBDEV))>0 D
- ...S ORBDEV=$G(^%ZIS(1,ORBDEV,0)) I $D(ORBDEV) D
- ....I ORLST(ORBE,OROI)=1 S ORBSDEV($P(ORBDEV,U))="",ORBUF=1
- ....I ORLST(ORBE,OROI)=0,$$PDLINK^ORQPTQ1(ORBDEV,ORDFN) S ORBSDEV($P(ORBDEV,U))="",ORBUF=1
- ....I $D(ORBU),ORBUF=1 D
- .....S ORBU(ORBUI)=" "_$P(ORBDEV,U)_" is a device recipient.",ORBUI=ORBUI+1
- ..;
- ..; process TEAMS:
- ..I ORBZ="OR(100.21," D SPECTEAM(ORBE)
- D TITLE(OROI,ORPAR)
- Q
- SPECTEAM(ORBE) ;get special team recips
- N ORBLST,IJ,ORBTM
- S ORBTM=$P(ORBE,";")
- D TEAMPROV^ORQPTQ1(.ORBLST,ORBTM)
- I $D(ORBU) N TNODE S TNODE=$G(^OR(100.21,ORBTM,0)) I $L(TNODE) D
- .S ORBU(ORBUI)=" Team potential recipients from team "_$P(TNODE,U)_":",ORBUI=ORBUI+1
- I +$G(ORBLST(1))>0 S IJ="" F S IJ=$O(ORBLST(IJ)) Q:IJ="" D
- .S ORBDUZ=$P(ORBLST(IJ),U),ORBUF=0 I $L(ORBDUZ) D
- ..I ORLST(ORBE,OROI)=1 S ORBASPEC(ORBDUZ_U_ORBTM)="",ORBUF=1
- ..I ORLST(ORBE,OROI)=0,$D(^OR(100.21,ORBTM,10,"B",ORDFN_";DPT(")) S ORBASPEC(ORBDUZ_U_ORBTM)="",ORBUF=1
- ..I $D(ORBU),ORBUF=1 N NODE S NODE=$G(^VA(200,ORBDUZ,0)) I $L(NODE) D
- ...S ORBU(ORBUI)=" "_$P(NODE,U),ORBUI=ORBUI+1
- ;
- S ORBTD=$P($$TMDEV^ORB31(ORBTM),U,2) ;tm's device
- I $L(ORBTD) D
- .S ORBSDEV(ORBTD)=""
- .I $D(ORBU) D
- ..S ORBU(ORBUI)=" Team's Device "_ORBTD_" is a recipient",ORBUI=ORBUI+1
- Q
- LRALRTS(ORN,ORDFN,ORDATA,ORBSMSG,ORBMSG) ;find & delete matching alerts and gather recips
- ; ORN: notif ien
- ; ORDFN: pt id
- ; ORDATA: pkg data
- ; ORBSMSG: special notif msg rtn by LRALRTS
- ; ORBMSG: original notif msg
- ;
- Q:+$G(ORN)<1
- Q:+$G(ORDFN)<1
- Q:+$G(ORDATA)<1
- N LRID,ORY,I,J,XQAID,XQ0,XQ1,ORNE,RECIP,ORDATAE,LRIDE,STDATE
- N ORTST,ORBMSGE,ORBMSGX,TXQAID,XQF,ORBHX,ORX,ORBI
- ;
- S LRID=$P($P(ORDATA,"|",2),"@") ;get lab unique results id (OE IDE)
- Q:+$G(LRID)<1
- ;
- ;get pt's alerts within 24 hours:
- S STDATE=$$FMADD^XLFDT($$NOW^XLFDT,"","-24","","")
- D PATIENT^XQALERT("ORY",ORDFN,STDATE,"") ;get pt's alerts
- ;
- ;look for pt's alerts with same notif ien and unique lab results id:
- F I=1:1:ORY D
- .S XQAID=$P(ORY(I),U,2)
- .S ORBMSGX=$P(ORY(I),U)
- .S ORNE=$P($P(XQAID,";"),",",3) ;get notif ien
- .Q:ORNE'=ORN
- .;
- .;find matching alert:
- .D AHISTORY^XQALBUTL(XQAID,"ORBHX")
- .S ORDATAE=$G(ORBHX(2))
- .Q:'$L(ORDATAE)
- .S LRIDE=$P($P(ORDATAE,"|",2),"@") ;get lab rslts id from existng alert
- .Q:LRIDE'=LRID
- .;
- .S:ORBMSG["[" ORTST=$P($P(ORBMSG,"[",2),"]")
- .I ORBMSG'["[" D
- ..S:ORBMSG["labs: " ORTST=$P(ORBMSG,"labs: ",2)
- ..S:ORBMSG["results: " ORTST=$P(ORBMSG,"results: ",2)
- .;
- .S ORBMSGE=$P(ORBMSGX,"): ",2)
- .;
- .S ORX=0
- .;if alert has recips, get recips from existing alert:
- .S:$L($G(ORBHX(20,0))) ORX=$P(ORBHX(20,0),U,4)
- .F ORBI=1:1:ORX D
- ..S RECIP=+ORBHX(20,ORBI,0)
- ..S ORBASPEC(RECIP)="" ;add recip to new alert recip list
- .;
- .;delete existing alert:
- .S XQAKILL=0 ;delete for all recips
- .D DELETE^XQALERT
- .K XQAKILL,XQAID
- ;
- ;if NO prev alert msg for this pt, notif, lab unique id:
- I '$L($G(ORBMSGE)) S ORBSMSG=ORBMSG
- ;
- ;if prev alert msg for this pt, notif, lab unique id:
- I $L($G(ORBMSGE)) D
- .S:ORBMSGE["[" ORBSMSG=$P(ORBMSGE,"]")_", "_ORTST_"]"
- .S:ORBMSGE'["[" ORBSMSG=ORBMSGE_", "_ORTST
- ;
- Q
- ;
- TITLE(OROI,ORPAR) ;get provider recips
- N ORTIT
- I $D(ORBU) D
- .S ORBU(ORBUI)=" ",ORBUI=ORBUI+1
- .S ORBU(ORBUI)="Special potential recipients from parameter: "_ORPAR_" PR",ORBUI=ORBUI+1
- ;
- ;process special recip users, teams and devices for Provider Recipients
- S ORTIT=$$GET^XPAR("ALL",ORPAR_" PR","`"_OROI,"E")
- Q:'$L(ORTIT)
- I ORTIT["P" D PRIMARY
- I ORTIT["A" D ATTEND
- I ORTIT["T" D TEAMS
- I ORTIT["O" D ORDERER
- I ORTIT["E" D ENTERBY
- I ORTIT["R" D PCMMPRIM
- I ORTIT["S" D PCMMASSC
- I ORTIT["M" D PCMMTEAM
- Q
- PRIMARY ;
- I $D(ORBU),+$G(ORBPRIM)>0 S ORBU(ORBUI)=" Flagged OI Inpt primary provider:",ORBUI=ORBUI+1
- I $D(ORBU),+$G(ORBPRIM)<1 S ORBU(ORBUI)=" Flagged OI Inpt primary provider: option cannot determine without A/D/T event data.",ORBUI=ORBUI+1
- I +$G(ORBPRIM)>0 S ORBASPEC(ORBPRIM)=""
- Q
- ATTEND ;
- I $D(ORBU),+$G(ORBATTD)>0 S ORBU(ORBUI)=" Flagged OI Attending physician:",ORBUI=ORBUI+1
- I $D(ORBU),+$G(ORBATTD)<1 S ORBU(ORBUI)=" Flagged OI Attending physician: option cannot determine without A/D/T event data.",ORBUI=ORBUI+1
- I +$G(ORBATTD)>0 S ORBASPEC(ORBATTD)=""
- Q
- TEAMS ;
- N ORBLST,ORBI,ORBJ,ORBTM,ORBTNAME,ORBTTYPE,ORBTD
- I $D(ORBU) S ORBU(ORBUI)=" Flagged OI Teams/Personal Lists related to patient:",ORBUI=ORBUI+1
- D TMSPT^ORQPTQ1(.ORBLST,ORDFN)
- Q:+$G(ORBLST(1))<1
- S ORBI="" F S ORBI=$O(ORBLST(ORBI)) Q:ORBI="" D
- .S ORBTM=$P(ORBLST(ORBI),U),ORBTNAME=$P(ORBLST(ORBI),U,2)
- .S ORBTTYPE=$P(ORBLST(ORBI),U,3)
- .I $D(ORBU) D
- ..S ORBU(ORBUI)=" Patient list "_ORBTNAME_" ["_ORBTTYPE_"]:",ORBUI=ORBUI+1
- .N ORBLST2 D TEAMPROV^ORQPTQ1(.ORBLST2,ORBTM)
- .Q:+$G(ORBLST2(1))<1
- .S ORBJ="" F S ORBJ=$O(ORBLST2(ORBJ)) Q:ORBJ="" D
- ..S ORBDUZ=$P(ORBLST2(ORBJ),U)_U_ORBTM I +$G(ORBDUZ)>0 S ORBASPEC(ORBDUZ)=""
- .S ORBTD=$P($$TMDEV^ORB31(ORBTM),U,2) ;tm's device
- .I $L(ORBTD) D
- ..S ORBSDEV(ORBTD)=""
- ..I $D(ORBU) D
- ...S ORBU(ORBUI)=" Team's Device "_ORBTD_" is a recipient",ORBUI=ORBUI+1
- Q
- ORDERER ;
- N ORBDUZ
- I $D(ORBU) S ORBU(ORBUI)=" Flagged OI Ordering provider:",ORBUI=ORBUI+1
- Q:+$G(ORNUM)<1
- S ORBDUZ=$$ORDERER^ORQOR2(ORNUM)
- I +$G(ORBDUZ)>0 D
- .S ORBASPEC(ORBDUZ)=""
- Q
- ENTERBY ;
- N ORBDUZ
- I $D(ORBU) S ORBU(ORBUI)=" Flagged OI User entering order's most recent activity:",ORBUI=ORBUI+1
- Q:+$G(ORNUM)<1
- I $D(^OR(100,ORNUM,8,0)) D
- .S ORBDUZ=$P(^OR(100,ORNUM,8,$P(^OR(100,ORNUM,8,0),U,3),0),U,13)
- I +$G(ORBDUZ)>0 S ORBASPEC(ORBDUZ)=""
- Q
- PCMMPRIM ;
- N ORBDUZ
- I $D(ORBU) S ORBU(ORBUI)=" Flagged OI PCMM Primary Care Practitioner:",ORBUI=ORBUI+1
- S ORBDUZ=+$$OUTPTPR^SDUTL3(ORDFN,$$NOW^XLFDT,1) ;DBIA #1252
- I +$G(ORBDUZ)>0 S ORBASPEC(ORBDUZ)=""
- Q
- PCMMASSC ;
- N ORBDUZ
- I $D(ORBU) S ORBU(ORBUI)=" Flagged OI PCMM Associate Provider:",ORBUI=ORBUI+1
- S ORBDUZ=+$$OUTPTAP^SDUTL3(ORDFN,$$NOW^XLFDT) ;DBIA #1252
- I +$G(ORBDUZ)>0 S ORBASPEC(ORBDUZ)=""
- Q
- PCMMTEAM ;
- N ORPCMM,ORPCMMDZ,ORBDUZ
- I $D(ORBU) S ORBU(ORBUI)=" Flagged OI PCMM Team Position Assignments:",ORBUI=ORBUI+1
- S ORPCMM=$$PRPT^SCAPMC(ORDFN,,,,,,"^TMP(""ORPCMM"",$J)",) ;DBIA #1916
- S ORPCMMDZ=0
- F S ORPCMMDZ=$O(^TMP("ORPCMM",$J,"SCPR",ORPCMMDZ)) Q:'ORPCMMDZ D
- .S ORBDUZ=ORPCMMDZ S ORBASPEC(ORBDUZ)=""
- K ^TMP("ORPCMM",$J)
- Q
- ORB3SPEC ; slc/CLA - Support routine for ORB3 ;4/4/02 14:40
- +1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**139,220,215**;Dec 17, 1997
- SPECIAL(ORN,ORBASPEC,ORBU,ORBUI,ORNUM,ORDFN,ORDATA,ORBSMSG,ORBMSG,ORBSDEV,ORBPRIM,ORBATTD) ;
- +1 ;process special notifs to get recips (users,teams,devices)
- +2 ; ORN: notif ien
- +3 ; ORBASPEC: recip DUZ array
- +4 ; ORBU: recip debug array
- +5 ; ORBUI: ORBU cntr
- +6 ; ORNUM: order no
- +7 ; ORDFN: pt id
- +8 ; ORDATA: pkg data
- +9 ; ORBSMSG: special notif msg rtn by SPECIAL
- +10 ; ORBMSG: original notif msg
- +11 ; ORBSDEV: array of recip devices
- +12 ; ORBPRIM: pt's inpt primary care provider
- +13 ; ORBATTD: pt's attending physician
- +14 ;
- +15 NEW ORPAR,ORPTLOC
- +16 ;DBIA #10035
- SET ORPTLOC=$SELECT($LENGTH($GET(^DPT(ORDFN,.1))):"I",1:"O")
- +17 ;
- +18 ;inpt flagged OI notifs
- IF ORPTLOC="I"
- Begin DoDot:1
- +19 IF ORN=32
- SET ORPAR="ORB OI RESULTS - INPT"
- DO OI
- +20 IF ORN=41
- SET ORPAR="ORB OI ORDERED - INPT"
- DO OI
- +21 IF ORN=64
- SET ORPAR="ORB OI EXPIRING - INPT"
- DO OI
- End DoDot:1
- +22 ;
- +23 ;outpt flagged OI notifs
- IF ORPTLOC="O"
- Begin DoDot:1
- +24 IF ORN=60
- SET ORPAR="ORB OI RESULTS - OUTPT"
- DO OI
- +25 IF ORN=61
- SET ORPAR="ORB OI ORDERED - OUTPT"
- DO OI
- +26 IF ORN=65
- SET ORPAR="ORB OI EXPIRING - OUTPT"
- DO OI
- End DoDot:1
- +27 ;
- +28 ;lab results notifs
- IF ORN=3!(ORN=14)!(ORN=44)!(ORN=57)
- Begin DoDot:1
- +29 DO LRALRTS(ORN,ORDFN,ORDATA,.ORBSMSG,ORBMSG)
- End DoDot:1
- +30 ;
- +31 ;requested results notif
- IF ORN=33
- Begin DoDot:1
- +32 IF $DATA(ORBU)
- Begin DoDot:2
- +33 SET ORBU(ORBUI)=" "
- SET ORBUI=ORBUI+1
- +34 SET ORBU(ORBUI)="Potential Orderer-flagged Results recipient: "
- SET ORBUI=ORBUI+1
- End DoDot:2
- +35 NEW RECIP
- +36 SET RECIP=$$RSLTFLG^ORQOR2(ORNUM)
- +37 IF +$GET(RECIP)>0
- Begin DoDot:2
- +38 SET ORBASPEC(+$GET(RECIP))=""
- +39 IF $DATA(ORBU)
- NEW NODE
- SET NODE=$GET(^VA(200,+$GET(RECIP),0))
- IF $LENGTH(NODE)
- Begin DoDot:3
- +40 SET ORBU(ORBUI)=" "_$PIECE(NODE,U)_" is a potential recipient."
- SET ORBUI=ORBUI+1
- End DoDot:3
- End DoDot:2
- End DoDot:1
- +41 QUIT
- OI ;get potential recips for OI-flagged notifs
- +1 NEW OROI,ORLST,ORERR,ORBX,ORBZ,ORBE,ORBDUZ,ORBDEV,ORBUF
- +2 ;get oi
- SET OROI=+$GET(^OR(100,+$GET(ORNUM),.1,1,0))
- +3 IF +$GET(OROI)<0
- QUIT
- +4 IF $DATA(ORBU)
- Begin DoDot:1
- +5 SET ORBU(ORBUI)=" "
- SET ORBUI=ORBUI+1
- +6 SET ORBU(ORBUI)="Special potential recipients from parameter: "_ORPAR
- SET ORBUI=ORBUI+1
- End DoDot:1
- +7 SET ORBE=0
- SET ORBX=0
- +8 ;
- +9 ;process special recip users, teams and devices:
- +10 DO ENVAL^XPAR(.ORLST,ORPAR,"`"_OROI,.ORERR)
- +11 IF 'ORERR
- IF $GET(ORLST)>0
- Begin DoDot:1
- +12 FOR ORBX=1:1:ORLST
- SET ORBE=$ORDER(ORLST(ORBE))
- SET ORBZ=$PIECE(ORBE,";",2)
- SET ORBUF=0
- Begin DoDot:2
- +13 ;
- +14 ; process USERS:
- +15 IF ORBZ="VA(200,"
- SET ORBDUZ=$PIECE(ORBE,";")
- IF $LENGTH(ORBDUZ)
- Begin DoDot:3
- +16 IF ORLST(ORBE,OROI)=1
- SET ORBASPEC(ORBDUZ)=""
- SET ORBUF=1
- +17 IF ORLST(ORBE,OROI)=0
- IF $$PPLINK^ORQPTQ1(ORBDUZ,ORDFN)
- SET ORBASPEC(ORBDUZ)=""
- SET ORBUF=1
- +18 IF $DATA(ORBU)
- IF ORBUF=1
- NEW NODE
- SET NODE=$GET(^VA(200,ORBDUZ,0))
- IF $LENGTH(NODE)
- Begin DoDot:4
- +19 SET ORBU(ORBUI)=" "_$PIECE(NODE,U)_" is a potential recipient."
- SET ORBUI=ORBUI+1
- End DoDot:4
- End DoDot:3
- +20 ;
- +21 ; process DEVICES:
- +22 IF ORBZ="%ZIS(1,"
- SET ORBDEV=$PIECE(ORBE,";")
- IF $LENGTH(ORBDEV)
- IF $DATA(^%ZIS(1,ORBDEV))>0
- Begin DoDot:3
- +23 SET ORBDEV=$GET(^%ZIS(1,ORBDEV,0))
- IF $DATA(ORBDEV)
- Begin DoDot:4
- +24 IF ORLST(ORBE,OROI)=1
- SET ORBSDEV($PIECE(ORBDEV,U))=""
- SET ORBUF=1
- +25 IF ORLST(ORBE,OROI)=0
- IF $$PDLINK^ORQPTQ1(ORBDEV,ORDFN)
- SET ORBSDEV($PIECE(ORBDEV,U))=""
- SET ORBUF=1
- +26 IF $DATA(ORBU)
- IF ORBUF=1
- Begin DoDot:5
- +27 SET ORBU(ORBUI)=" "_$PIECE(ORBDEV,U)_" is a device recipient."
- SET ORBUI=ORBUI+1
- End DoDot:5
- End DoDot:4
- End DoDot:3
- +28 ;
- +29 ; process TEAMS:
- +30 IF ORBZ="OR(100.21,"
- DO SPECTEAM(ORBE)
- End DoDot:2
- End DoDot:1
- +31 DO TITLE(OROI,ORPAR)
- +32 QUIT
- SPECTEAM(ORBE) ;get special team recips
- +1 NEW ORBLST,IJ,ORBTM
- +2 SET ORBTM=$PIECE(ORBE,";")
- +3 DO TEAMPROV^ORQPTQ1(.ORBLST,ORBTM)
- +4 IF $DATA(ORBU)
- NEW TNODE
- SET TNODE=$GET(^OR(100.21,ORBTM,0))
- IF $LENGTH(TNODE)
- Begin DoDot:1
- +5 SET ORBU(ORBUI)=" Team potential recipients from team "_$PIECE(TNODE,U)_":"
- SET ORBUI=ORBUI+1
- End DoDot:1
- +6 IF +$GET(ORBLST(1))>0
- SET IJ=""
- FOR
- SET IJ=$ORDER(ORBLST(IJ))
- IF IJ=""
- QUIT
- Begin DoDot:1
- +7 SET ORBDUZ=$PIECE(ORBLST(IJ),U)
- SET ORBUF=0
- IF $LENGTH(ORBDUZ)
- Begin DoDot:2
- +8 IF ORLST(ORBE,OROI)=1
- SET ORBASPEC(ORBDUZ_U_ORBTM)=""
- SET ORBUF=1
- +9 IF ORLST(ORBE,OROI)=0
- IF $DATA(^OR(100.21,ORBTM,10,"B",ORDFN_";DPT("))
- SET ORBASPEC(ORBDUZ_U_ORBTM)=""
- SET ORBUF=1
- +10 IF $DATA(ORBU)
- IF ORBUF=1
- NEW NODE
- SET NODE=$GET(^VA(200,ORBDUZ,0))
- IF $LENGTH(NODE)
- Begin DoDot:3
- +11 SET ORBU(ORBUI)=" "_$PIECE(NODE,U)
- SET ORBUI=ORBUI+1
- End DoDot:3
- End DoDot:2
- End DoDot:1
- +12 ;
- +13 ;tm's device
- SET ORBTD=$PIECE($$TMDEV^ORB31(ORBTM),U,2)
- +14 IF $LENGTH(ORBTD)
- Begin DoDot:1
- +15 SET ORBSDEV(ORBTD)=""
- +16 IF $DATA(ORBU)
- Begin DoDot:2
- +17 SET ORBU(ORBUI)=" Team's Device "_ORBTD_" is a recipient"
- SET ORBUI=ORBUI+1
- End DoDot:2
- End DoDot:1
- +18 QUIT
- LRALRTS(ORN,ORDFN,ORDATA,ORBSMSG,ORBMSG) ;find & delete matching alerts and gather recips
- +1 ; ORN: notif ien
- +2 ; ORDFN: pt id
- +3 ; ORDATA: pkg data
- +4 ; ORBSMSG: special notif msg rtn by LRALRTS
- +5 ; ORBMSG: original notif msg
- +6 ;
- +7 IF +$GET(ORN)<1
- QUIT
- +8 IF +$GET(ORDFN)<1
- QUIT
- +9 IF +$GET(ORDATA)<1
- QUIT
- +10 NEW LRID,ORY,I,J,XQAID,XQ0,XQ1,ORNE,RECIP,ORDATAE,LRIDE,STDATE
- +11 NEW ORTST,ORBMSGE,ORBMSGX,TXQAID,XQF,ORBHX,ORX,ORBI
- +12 ;
- +13 ;get lab unique results id (OE IDE)
- SET LRID=$PIECE($PIECE(ORDATA,"|",2),"@")
- +14 IF +$GET(LRID)<1
- QUIT
- +15 ;
- +16 ;get pt's alerts within 24 hours:
- +17 SET STDATE=$$FMADD^XLFDT($$NOW^XLFDT,"","-24","","")
- +18 ;get pt's alerts
- DO PATIENT^XQALERT("ORY",ORDFN,STDATE,"")
- +19 ;
- +20 ;look for pt's alerts with same notif ien and unique lab results id:
- +21 FOR I=1:1:ORY
- Begin DoDot:1
- +22 SET XQAID=$PIECE(ORY(I),U,2)
- +23 SET ORBMSGX=$PIECE(ORY(I),U)
- +24 ;get notif ien
- SET ORNE=$PIECE($PIECE(XQAID,";"),",",3)
- +25 IF ORNE'=ORN
- QUIT
- +26 ;
- +27 ;find matching alert:
- +28 DO AHISTORY^XQALBUTL(XQAID,"ORBHX")
- +29 SET ORDATAE=$GET(ORBHX(2))
- +30 IF '$LENGTH(ORDATAE)
- QUIT
- +31 ;get lab rslts id from existng alert
- SET LRIDE=$PIECE($PIECE(ORDATAE,"|",2),"@")
- +32 IF LRIDE'=LRID
- QUIT
- +33 ;
- +34 IF ORBMSG["["
- SET ORTST=$PIECE($PIECE(ORBMSG,"[",2),"]")
- +35 IF ORBMSG'["["
- Begin DoDot:2
- +36 IF ORBMSG["labs
- SET ORTST=$PIECE(ORBMSG,"labs: ",2)
- +37 IF ORBMSG["results
- SET ORTST=$PIECE(ORBMSG,"results: ",2)
- End DoDot:2
- +38 ;
- +39 SET ORBMSGE=$PIECE(ORBMSGX,"): ",2)
- +40 ;
- +41 SET ORX=0
- +42 ;if alert has recips, get recips from existing alert:
- +43 IF $LENGTH($GET(ORBHX(20,0)))
- SET ORX=$PIECE(ORBHX(20,0),U,4)
- +44 FOR ORBI=1:1:ORX
- Begin DoDot:2
- +45 SET RECIP=+ORBHX(20,ORBI,0)
- +46 ;add recip to new alert recip list
- SET ORBASPEC(RECIP)=""
- End DoDot:2
- +47 ;
- +48 ;delete existing alert:
- +49 ;delete for all recips
- SET XQAKILL=0
- +50 DO DELETE^XQALERT
- +51 KILL XQAKILL,XQAID
- End DoDot:1
- +52 ;
- +53 ;if NO prev alert msg for this pt, notif, lab unique id:
- +54 IF '$LENGTH($GET(ORBMSGE))
- SET ORBSMSG=ORBMSG
- +55 ;
- +56 ;if prev alert msg for this pt, notif, lab unique id:
- +57 IF $LENGTH($GET(ORBMSGE))
- Begin DoDot:1
- +58 IF ORBMSGE["["
- SET ORBSMSG=$PIECE(ORBMSGE,"]")_", "_ORTST_"]"
- +59 IF ORBMSGE'["["
- SET ORBSMSG=ORBMSGE_", "_ORTST
- End DoDot:1
- +60 ;
- +61 QUIT
- +62 ;
- TITLE(OROI,ORPAR) ;get provider recips
- +1 NEW ORTIT
- +2 IF $DATA(ORBU)
- Begin DoDot:1
- +3 SET ORBU(ORBUI)=" "
- SET ORBUI=ORBUI+1
- +4 SET ORBU(ORBUI)="Special potential recipients from parameter: "_ORPAR_" PR"
- SET ORBUI=ORBUI+1
- End DoDot:1
- +5 ;
- +6 ;process special recip users, teams and devices for Provider Recipients
- +7 SET ORTIT=$$GET^XPAR("ALL",ORPAR_" PR","`"_OROI,"E")
- +8 IF '$LENGTH(ORTIT)
- QUIT
- +9 IF ORTIT["P"
- DO PRIMARY
- +10 IF ORTIT["A"
- DO ATTEND
- +11 IF ORTIT["T"
- DO TEAMS
- +12 IF ORTIT["O"
- DO ORDERER
- +13 IF ORTIT["E"
- DO ENTERBY
- +14 IF ORTIT["R"
- DO PCMMPRIM
- +15 IF ORTIT["S"
- DO PCMMASSC
- +16 IF ORTIT["M"
- DO PCMMTEAM
- +17 QUIT
- PRIMARY ;
- +1 IF $DATA(ORBU)
- IF +$GET(ORBPRIM)>0
- SET ORBU(ORBUI)=" Flagged OI Inpt primary provider:"
- SET ORBUI=ORBUI+1
- +2 IF $DATA(ORBU)
- IF +$GET(ORBPRIM)<1
- SET ORBU(ORBUI)=" Flagged OI Inpt primary provider: option cannot determine without A/D/T event data."
- SET ORBUI=ORBUI+1
- +3 IF +$GET(ORBPRIM)>0
- SET ORBASPEC(ORBPRIM)=""
- +4 QUIT
- ATTEND ;
- +1 IF $DATA(ORBU)
- IF +$GET(ORBATTD)>0
- SET ORBU(ORBUI)=" Flagged OI Attending physician:"
- SET ORBUI=ORBUI+1
- +2 IF $DATA(ORBU)
- IF +$GET(ORBATTD)<1
- SET ORBU(ORBUI)=" Flagged OI Attending physician: option cannot determine without A/D/T event data."
- SET ORBUI=ORBUI+1
- +3 IF +$GET(ORBATTD)>0
- SET ORBASPEC(ORBATTD)=""
- +4 QUIT
- TEAMS ;
- +1 NEW ORBLST,ORBI,ORBJ,ORBTM,ORBTNAME,ORBTTYPE,ORBTD
- +2 IF $DATA(ORBU)
- SET ORBU(ORBUI)=" Flagged OI Teams/Personal Lists related to patient:"
- SET ORBUI=ORBUI+1
- +3 DO TMSPT^ORQPTQ1(.ORBLST,ORDFN)
- +4 IF +$GET(ORBLST(1))<1
- QUIT
- +5 SET ORBI=""
- FOR
- SET ORBI=$ORDER(ORBLST(ORBI))
- IF ORBI=""
- QUIT
- Begin DoDot:1
- +6 SET ORBTM=$PIECE(ORBLST(ORBI),U)
- SET ORBTNAME=$PIECE(ORBLST(ORBI),U,2)
- +7 SET ORBTTYPE=$PIECE(ORBLST(ORBI),U,3)
- +8 IF $DATA(ORBU)
- Begin DoDot:2
- +9 SET ORBU(ORBUI)=" Patient list "_ORBTNAME_" ["_ORBTTYPE_"]:"
- SET ORBUI=ORBUI+1
- End DoDot:2
- +10 NEW ORBLST2
- DO TEAMPROV^ORQPTQ1(.ORBLST2,ORBTM)
- +11 IF +$GET(ORBLST2(1))<1
- QUIT
- +12 SET ORBJ=""
- FOR
- SET ORBJ=$ORDER(ORBLST2(ORBJ))
- IF ORBJ=""
- QUIT
- Begin DoDot:2
- +13 SET ORBDUZ=$PIECE(ORBLST2(ORBJ),U)_U_ORBTM
- IF +$GET(ORBDUZ)>0
- SET ORBASPEC(ORBDUZ)=""
- End DoDot:2
- +14 ;tm's device
- SET ORBTD=$PIECE($$TMDEV^ORB31(ORBTM),U,2)
- +15 IF $LENGTH(ORBTD)
- Begin DoDot:2
- +16 SET ORBSDEV(ORBTD)=""
- +17 IF $DATA(ORBU)
- Begin DoDot:3
- +18 SET ORBU(ORBUI)=" Team's Device "_ORBTD_" is a recipient"
- SET ORBUI=ORBUI+1
- End DoDot:3
- End DoDot:2
- End DoDot:1
- +19 QUIT
- ORDERER ;
- +1 NEW ORBDUZ
- +2 IF $DATA(ORBU)
- SET ORBU(ORBUI)=" Flagged OI Ordering provider:"
- SET ORBUI=ORBUI+1
- +3 IF +$GET(ORNUM)<1
- QUIT
- +4 SET ORBDUZ=$$ORDERER^ORQOR2(ORNUM)
- +5 IF +$GET(ORBDUZ)>0
- Begin DoDot:1
- +6 SET ORBASPEC(ORBDUZ)=""
- End DoDot:1
- +7 QUIT
- ENTERBY ;
- +1 NEW ORBDUZ
- +2 IF $DATA(ORBU)
- SET ORBU(ORBUI)=" Flagged OI User entering order's most recent activity:"
- SET ORBUI=ORBUI+1
- +3 IF +$GET(ORNUM)<1
- QUIT
- +4 IF $DATA(^OR(100,ORNUM,8,0))
- Begin DoDot:1
- +5 SET ORBDUZ=$PIECE(^OR(100,ORNUM,8,$PIECE(^OR(100,ORNUM,8,0),U,3),0),U,13)
- End DoDot:1
- +6 IF +$GET(ORBDUZ)>0
- SET ORBASPEC(ORBDUZ)=""
- +7 QUIT
- PCMMPRIM ;
- +1 NEW ORBDUZ
- +2 IF $DATA(ORBU)
- SET ORBU(ORBUI)=" Flagged OI PCMM Primary Care Practitioner:"
- SET ORBUI=ORBUI+1
- +3 ;DBIA #1252
- SET ORBDUZ=+$$OUTPTPR^SDUTL3(ORDFN,$$NOW^XLFDT,1)
- +4 IF +$GET(ORBDUZ)>0
- SET ORBASPEC(ORBDUZ)=""
- +5 QUIT
- PCMMASSC ;
- +1 NEW ORBDUZ
- +2 IF $DATA(ORBU)
- SET ORBU(ORBUI)=" Flagged OI PCMM Associate Provider:"
- SET ORBUI=ORBUI+1
- +3 ;DBIA #1252
- SET ORBDUZ=+$$OUTPTAP^SDUTL3(ORDFN,$$NOW^XLFDT)
- +4 IF +$GET(ORBDUZ)>0
- SET ORBASPEC(ORBDUZ)=""
- +5 QUIT
- PCMMTEAM ;
- +1 NEW ORPCMM,ORPCMMDZ,ORBDUZ
- +2 IF $DATA(ORBU)
- SET ORBU(ORBUI)=" Flagged OI PCMM Team Position Assignments:"
- SET ORBUI=ORBUI+1
- +3 ;DBIA #1916
- SET ORPCMM=$$PRPT^SCAPMC(ORDFN,,,,,,"^TMP(""ORPCMM"",$J)",)
- +4 SET ORPCMMDZ=0
- +5 FOR
- SET ORPCMMDZ=$ORDER(^TMP("ORPCMM",$JOB,"SCPR",ORPCMMDZ))
- IF 'ORPCMMDZ
- QUIT
- Begin DoDot:1
- +6 SET ORBDUZ=ORPCMMDZ
- SET ORBASPEC(ORBDUZ)=""
- End DoDot:1
- +7 KILL ^TMP("ORPCMM",$JOB)
- +8 QUIT