| 1 | ORB31 ; slc/CLA - Routine to support OE/RR 3 notifications ;6/28/00  12:00 [ 04/02/97  11:12 AM ] | 
|---|
| 2 | ;;3.0;ORDER ENTRY/RESULTS REPORTING;**6,31,88,105,139,173,220,215**;Dec 17, 1997 | 
|---|
| 3 | QUEUE(ORN,ORBDFN,ORNUM,ORBADUZ,ORBPMSG,ORBPDATA,ORBH,ORBD,ORDGPMA) ; | 
|---|
| 4 | ;queue up notif for Taskman processing | 
|---|
| 5 | ;ORN       notification ien from file 100.9 | 
|---|
| 6 | ;ORBDFN    patient dfn from file 2 | 
|---|
| 7 | ;ORNUM     order number from file 100 | 
|---|
| 8 | ;ORBADUZ   array of potential user recipients (iens from file 100) | 
|---|
| 9 | ;ORBPMSG   alert message from triggering process | 
|---|
| 10 | ;ORBPDATA  data potentially used in alert follow-up action | 
|---|
| 11 | ;ORBH      $H formatted time to begin Taskman process | 
|---|
| 12 | ;ORBD      process description for Taskman | 
|---|
| 13 | ;ORDGPMA   DGPMA if alert triggered by A/D/T event | 
|---|
| 14 | ; | 
|---|
| 15 | N ZTCPU,ZTDESC,ZTDTH,ZTIO,ZTPAR,ZTPRE,ZTPRI,ZTREQ,ZTRTN,ZTSAVE,ZTSK,ZTUCI,X,Y,DIC | 
|---|
| 16 | ; | 
|---|
| 17 | S DIC="3.5",X="ORB NOTIFICATION RESOURCE",DIC(0)="X" D ^DIC | 
|---|
| 18 | I (Y) S ZTIO=$P(Y,U,2) | 
|---|
| 19 | E  S ZTIO="" | 
|---|
| 20 | S ZTDTH=ORBH,ZTRTN="ZTSK^ORB3" | 
|---|
| 21 | S ZTDESC=ORBD | 
|---|
| 22 | S ZTDESC=ZTDESC_"for ("_ORBDFN_") "_$P($G(^DPT(+ORBDFN,0)),U,1) | 
|---|
| 23 | K ZTSAVE,ZTCPU,ZTUCI,ZTPRI,ZTPAR,ZTPRE,DIC,Y,DTOUT,DUOUT | 
|---|
| 24 | ; | 
|---|
| 25 | S ZTSAVE("ORN")="" | 
|---|
| 26 | S ZTSAVE("ORBDFN")="" | 
|---|
| 27 | S ZTSAVE("ORNUM")="" | 
|---|
| 28 | S ZTSAVE("ORBADUZ(")="" | 
|---|
| 29 | S ZTSAVE("ORBPMSG")="" | 
|---|
| 30 | S ZTSAVE("ORBPDATA")="" | 
|---|
| 31 | S ZTSAVE("ORDGPMA")="" | 
|---|
| 32 | D ^%ZTLOAD | 
|---|
| 33 | Q | 
|---|
| 34 | DUP(ORN,ORBDFN,ORBPMSG,ORNUM) ;ext funct return "1" if a duplicate notif w/in 1 min. | 
|---|
| 35 | N ORBDUP,ORBNOW,ORBLAST,ORLNUM,ORSAMEP | 
|---|
| 36 | S ORBDUP=0 | 
|---|
| 37 | S ORSAMEP=0 | 
|---|
| 38 | S ORBNOW=$$NOW^XLFDT | 
|---|
| 39 | S ^XTMP("ORBDUP",0)=$$FMADD^XLFDT(ORBNOW,1,"","","")_"^"_ORBNOW | 
|---|
| 40 | I '$L($G(^XTMP("ORBDUP",ORBDFN_";"_ORN_";"_ORBPMSG))) S ^XTMP("ORBDUP",ORBDFN_";"_ORN_";"_ORBPMSG)=ORBNOW_"^"_$G(ORNUM) | 
|---|
| 41 | E  D | 
|---|
| 42 | .S ORBLAST=$G(^XTMP("ORBDUP",ORBDFN_";"_ORN_";"_ORBPMSG)) | 
|---|
| 43 | .S ORLNUM=$P(ORBLAST,"^",2) | 
|---|
| 44 | .S ORBLAST=$P(ORBLAST,"^") | 
|---|
| 45 | .I $L($G(ORNUM)),$L($G(ORLNUM)),($$ORDERER^ORQOR2(ORNUM)=$$ORDERER^ORQOR2(ORLNUM)) S ORSAMEP=1 ;same provider as last order that triggered this notif | 
|---|
| 46 | .;if last occurrence of this "NOT" notif was w/in past 1 min, its a dup | 
|---|
| 47 | .I ORBNOW<$$FMADD^XLFDT(ORBLAST,"","",1,""),ORSAMEP=1 S ORBDUP=1  ;dup | 
|---|
| 48 | .E  S ^XTMP("ORBDUP",ORBDFN_";"_ORN_";"_ORBPMSG)=ORBNOW_"^"_ORNUM  ;refresh last pt/noti occ. | 
|---|
| 49 | D DUPCLN(ORBNOW)  ;clean up old ^XTMP("ORBUP") entries | 
|---|
| 50 | Q ORBDUP | 
|---|
| 51 | REGDEV(ORBDA) ;send to regular recipient devices | 
|---|
| 52 | N ORBDT,ORBD | 
|---|
| 53 | S ORBD="" | 
|---|
| 54 | S ORBDT=$$NOW^XLFDT | 
|---|
| 55 | F   S ORBD=$O(ORBDA(ORBD)) Q:ORBD=""  D | 
|---|
| 56 | .S ZTRTN="PRINTD^ORB31",ZTDESC="Print Notification to Device",ZTDTH=$H | 
|---|
| 57 | .S ZTIO=ORBD,ZTSAVE("XQAMSG")="",ZTSAVE("ORBDT")="" | 
|---|
| 58 | .D ^%ZTLOAD | 
|---|
| 59 | Q | 
|---|
| 60 | PRINTD ;print queued notification to device - setup via REGDEV^ORB3 | 
|---|
| 61 | I $G(ZTSK) D KILL^%ZTLOAD | 
|---|
| 62 | I IOT="HFS" W XQAMSG Q  ;write msg to a file then quit | 
|---|
| 63 | W !!!,"          ***** NOTIFICATION PROCESSED *****",!! | 
|---|
| 64 | W $$FMTE^XLFDT(ORBDT),"   " | 
|---|
| 65 | W XQAMSG | 
|---|
| 66 | I $E(IOST,1,2)'="C-" W @IOF | 
|---|
| 67 | Q | 
|---|
| 68 | FWD(ORY,ORBLST,ORBRECIP,ORBTYPE,ORBCOMNT) ; forward a notification | 
|---|
| 69 | I ORBLST="" S ORY=0 Q | 
|---|
| 70 | S ORBLST(1)=ORBLST | 
|---|
| 71 | D FORWARD^XQALFWD(.ORBLST,.ORBRECIP,ORBTYPE,ORBCOMNT) | 
|---|
| 72 | S ORY=1 | 
|---|
| 73 | Q | 
|---|
| 74 | RENEW(ORY,XQAID) ; renew/restore an alert/notification | 
|---|
| 75 | Q:$L($G(XQAID))<1 | 
|---|
| 76 | K XQAKILL | 
|---|
| 77 | I '$D(^XTV(8992,"AXQA",XQAID,DUZ)) D RESTORE^XQALERT1 ;DBIA #4100 | 
|---|
| 78 | S ORY=1 | 
|---|
| 79 | Q | 
|---|
| 80 | TERMLKUP(OCXARR,OCXTERM) ; extrinsic function returns the local terms | 
|---|
| 81 | ; linked to the nat'l OCX term in an array and the file where those | 
|---|
| 82 | ; array terms can be found. The value of the extrinsic function is the | 
|---|
| 83 | ; file pointed to for the local terms. | 
|---|
| 84 | ; | 
|---|
| 85 | ; OCXARR  - Array of local terms | 
|---|
| 86 | ; OCXTERM - OCX nat'l term from file ^OCXS(860.9 | 
|---|
| 87 | ; | 
|---|
| 88 | N OCXI,OCXJ,FILE,I | 
|---|
| 89 | S OCXI="",OCXJ=0,FILE="",I=1 | 
|---|
| 90 | S OCXI=$O(^OCXS(860.9,"B",OCXTERM,OCXI)) | 
|---|
| 91 | I +$G(OCXI)>0 D | 
|---|
| 92 | .S FILE=$P(^OCXS(860.9,OCXI,0),U,2) | 
|---|
| 93 | .F  S OCXJ=$O(^OCXS(860.9,OCXI,1,OCXJ)) Q:+OCXJ<1  D | 
|---|
| 94 | ..S OCXARR(I)=$P(^OCXS(860.9,OCXI,1,OCXJ,0),U,2)_U_$P(^(0),U) | 
|---|
| 95 | ..S OCXARR=I,I=I+1 | 
|---|
| 96 | Q FILE | 
|---|
| 97 | DUPCLN(ORBNOW) ;clean up old entires in ^XTMP("ORBDUP") | 
|---|
| 98 | N ORBX,ORBDT,ORNDT | 
|---|
| 99 | S ORNDT=$$FMADD^XLFDT(ORBNOW,"","",-5,"")  ;entries older than 5 minutes | 
|---|
| 100 | S ORBX=0 | 
|---|
| 101 | F  S ORBX=$O(^XTMP("ORBDUP",ORBX)) Q:ORBX=""  D | 
|---|
| 102 | .S ORBDT=+$G(^XTMP("ORBDUP",ORBX)) | 
|---|
| 103 | .I $L(ORBDT),(ORBDT<ORNDT) K ^XTMP("ORBDUP",ORBX) | 
|---|
| 104 | Q | 
|---|
| 105 | TMDEV(ORBTM) ;returns Device for a team in format device ien^device name | 
|---|
| 106 | N ORBTDEV,ORBTDEVN | 
|---|
| 107 | S ORBTDEVN="" | 
|---|
| 108 | Q:'$L($G(ORBTM)) "" | 
|---|
| 109 | Q:'$D(^OR(100.21,ORBTM,0)) "" | 
|---|
| 110 | S ORBTDEV=$P(^OR(100.21,ORBTM,0),U,4)  ;get Team's device | 
|---|
| 111 | Q:+$G(ORBTDEV)<1 "" | 
|---|
| 112 | S X="`"_ORBTDEV,DIC=3.5,DIC(0)="" D ^DIC  ;DBIA #10114 | 
|---|
| 113 | Q:+Y<1 "" | 
|---|
| 114 | S ORBTDEVN=$P(Y,U,2) | 
|---|
| 115 | K DIC,Y,X | 
|---|
| 116 | Q ORBTDEV_U_ORBTDEVN | 
|---|
| 117 | ENTITY(ORNUM) ;ext funct. rtns entity for parameter use | 
|---|
| 118 | N ORBENT | 
|---|
| 119 | S ORBENT="DIV^SYS^PKG" | 
|---|
| 120 | I $L($G(ORNUM)) D  ;if order number use pt's location division | 
|---|
| 121 | .N ORDIV | 
|---|
| 122 | .S ORDIV=0,ORDIV=$$ORDIV(ORNUM) | 
|---|
| 123 | .I +$G(ORDIV)>0 S ORBENT=ORDIV_";DIC(4,^SYS^PKG" | 
|---|
| 124 | Q ORBENT | 
|---|
| 125 | ; | 
|---|
| 126 | ADT(ORN,ORBDFN,ORBPRIM,ORBATTD,ORDGPMA) ;get inpt primary and attending for ADT notifs | 
|---|
| 127 | N ORBADTDT,VAINDT | 
|---|
| 128 | ;if notif is deceased or discharge use prev visit d/t: | 
|---|
| 129 | I (ORN=20)!(ORN=35) D | 
|---|
| 130 | .S ORBADTDT=$S($D(ORDGPMA):$P(ORDGPMA,U),1:$P($G(^DPT(ORBDFN,.35)),U)) | 
|---|
| 131 | .I $L(ORBADTDT) S VAINDT=$$FMADD^XLFDT(ORBADTDT,"","","","-1") | 
|---|
| 132 | ; | 
|---|
| 133 | I ORN=18 S VAINDT=$P($G(ORDGPMA),U)  ;if admission use this visit d/t | 
|---|
| 134 | ; | 
|---|
| 135 | I $L($G(VAINDT)) D | 
|---|
| 136 | .D INP^VADPT  ;get new VAIN array for appropriate visit | 
|---|
| 137 | .S ORBPRIM=+$P(VAIN(2),U),ORBATTD=+$P(VAIN(11),U) | 
|---|
| 138 | Q | 
|---|
| 139 | ; | 
|---|
| 140 | DEFDIV(ORDUZ) ; Return user's default division, if specified. | 
|---|
| 141 | ; | 
|---|
| 142 | N ORDD,ORDIV,ORGOOD,ORZ,ORZERR | 
|---|
| 143 | ; | 
|---|
| 144 | S ORDIV="" | 
|---|
| 145 | S Y=0,(ORDD,ORGOOD)=0             ; Initialize variables. | 
|---|
| 146 | ; | 
|---|
| 147 | ; Get list of divisions from NEW PERSON file multiple: | 
|---|
| 148 | D LIST^DIC(200.02,","_ORDUZ_",","@;.01;1","QP","","","","","","","ORZ","ORZERR") | 
|---|
| 149 | I $P(ORZ("DILIST",0),U)=0 Q       ; No Divisions listed. | 
|---|
| 150 | ; | 
|---|
| 151 | F  S ORDD=$O(ORZ("DILIST",ORDD)) Q:+ORDD=0!'($L(ORDD))  D  Q:ORGOOD | 
|---|
| 152 | .; See if current entry being processed is "Default" (done if so): | 
|---|
| 153 | .I $P(ORZ("DILIST",ORDD,0),U,3)["Y" S ORDIV=$P(ORZ("DILIST",ORDD,0),U,1,2),ORGOOD=1 | 
|---|
| 154 | Q ORDIV | 
|---|
| 155 | ; | 
|---|
| 156 | ORDIV(ORNUM) ; Return order's division based upon patient's location when order was placed | 
|---|
| 157 | ; | 
|---|
| 158 | Q:+$G(ORNUM)<1 "" | 
|---|
| 159 | Q:'$D(^OR(100,ORNUM,0)) "" | 
|---|
| 160 | N ORDIV,PTLOC | 
|---|
| 161 | S ORDIV="" | 
|---|
| 162 | S PTLOC=+$P(^OR(100,ORNUM,0),U,10) | 
|---|
| 163 | Q:$G(PTLOC)<1 "" | 
|---|
| 164 | S ORDIV=$P(^SC(PTLOC,0),U,4)  ;DBIA #10040 | 
|---|
| 165 | Q ORDIV | 
|---|