| 1 | ORQOR2 ; slc/CLA - Extrinsic functions which return order information ;6/14/96  10:15 [ 04/02/97  1:35 PM ] | 
|---|
| 2 | ;;3.0;ORDER ENTRY/RESULTS REPORTING;**6,32,92,122,144,190,251**;Dec 17, 1997 | 
|---|
| 3 | STATUS(ORN) ;extrinsic function returns the current status of an order in | 
|---|
| 4 | ;the format: status ien^external text | 
|---|
| 5 | ;DBIA #3458 supported api for outpt pharmacy | 
|---|
| 6 | Q:'$L($G(ORN)) "" | 
|---|
| 7 | Q:'$L($G(^OR(100,ORN,3))) "" | 
|---|
| 8 | N ORSTATUS | 
|---|
| 9 | S ORSTATUS=$P(^OR(100,ORN,3),U,3) | 
|---|
| 10 | S ORSTATUS=ORSTATUS_U_$G(^ORD(100.01,+ORSTATUS,0)) | 
|---|
| 11 | Q ORSTATUS | 
|---|
| 12 | RECENT(PT,OI,ST) ;extrinsic funct returns pt's most recent order for an orderable item and status in format: | 
|---|
| 13 | ; order number^order text (truncated to 60 chars)^start d/t^status | 
|---|
| 14 | N INDT,ORN,CDT,ORSTATUS,ORTEXT,RESULT S RESULT="",ORN="",INDT="" | 
|---|
| 15 | F  S INDT=$O(^OR(100,"AOI",OI,PT_";DPT(",INDT)) Q:INDT=""!(RESULT'="")  D | 
|---|
| 16 | .F  S ORN=$O(^OR(100,"AOI",OI,PT_";DPT(",INDT,ORN)) Q:ORN=""  D | 
|---|
| 17 | ..S ORSTATUS=$P(^OR(100,ORN,3),U,3) | 
|---|
| 18 | ..I '$L($G(ST))!($G(ORSTATUS)=ST) D | 
|---|
| 19 | ...S ORSTATUS=$G(^ORD(100.01,ORSTATUS,0)),CDT=9999999-INDT | 
|---|
| 20 | ...S ORTEXT=$P($$TEXT^ORKOR(ORN,60),U,2) | 
|---|
| 21 | ...S RESULT=ORN_U_ORTEXT_U_CDT_U_ORSTATUS | 
|---|
| 22 | Q RESULT | 
|---|
| 23 | DUPRANGE(OI,DG,ODT,ORPT) ;extrinsic funct returns duplicate order range beginning date in the format: | 
|---|
| 24 | ;fileman d/t^inverse fileman d/t | 
|---|
| 25 | ;OI   = orderable item ien | 
|---|
| 26 | ;DG   = display group abbrev. (e.g. 'LR') | 
|---|
| 27 | ;ODT  = order effective/start date/time in FM format | 
|---|
| 28 | ;ORPT = patient dfn | 
|---|
| 29 | N DHRS,BDT,INBDT,ORSRV,ORLOC | 
|---|
| 30 | S BDT="",INBDT="" | 
|---|
| 31 | ; | 
|---|
| 32 | ;get patient's location flag (INPATIENT ONLY - outpt locations cannot be | 
|---|
| 33 | ;reliably determined, and many simultaneous outpt locations can occur): | 
|---|
| 34 | I +$G(ORPT)>0 D | 
|---|
| 35 | .N DFN S DFN=ORPT,VA200="" D OERR^VADPT | 
|---|
| 36 | .I +$G(VAIN(4))>0 S ORLOC=+$G(^DIC(42,+$G(VAIN(4)),44)) | 
|---|
| 37 | .K VA200,VAIN | 
|---|
| 38 | ; | 
|---|
| 39 | S ORSRV=$G(^VA(200,DUZ,5)) I +ORSRV>0 S ORSRV=$P(ORSRV,U) | 
|---|
| 40 | S DHRS=$$GET^XPAR("LOC.`"_$G(ORLOC)_"^SRV.`"_$G(ORSRV)_"^DIV^SYS","ORK DUP ORDER RANGE OI",OI,"I") | 
|---|
| 41 | Q:$G(DHRS)=0 "0^0" ;quit if number of hours for this OI is zero | 
|---|
| 42 | I +$G(DHRS)<1 D | 
|---|
| 43 | .I DG="LR" S DHRS=$$GET^XPAR("LOC.`"_$G(ORLOC)_"^SRV.`"_$G(ORSRV)_"^DIV^SYS^PKG","ORK DUP ORDER RANGE LAB",1,"I") | 
|---|
| 44 | .I DG="RA" S DHRS=$$GET^XPAR("LOC.`"_$G(ORLOC)_"^SRV.`"_$G(ORSRV)_"^DIV^SYS^PKG","ORK DUP ORDER RANGE RADIOLOGY",1,"I") | 
|---|
| 45 | I +$G(DHRS)<1 S DHRS=48  ;non-lab and non-radiology default is 48 hrs | 
|---|
| 46 | S BDT=$$FMADD^XLFDT(ODT,"","-"_DHRS,"",""),INBDT=9999999-BDT | 
|---|
| 47 | Q BDT_U_INBDT | 
|---|
| 48 | ORDERER(ORNUM) ;ext. funct. gets ordering provider DUZ from ORDER File (#100) | 
|---|
| 49 | Q:'$L($G(ORNUM)) "" | 
|---|
| 50 | S ORNUM=+$G(ORNUM) | 
|---|
| 51 | N ORQDUZ,ORQI S ORQDUZ="" | 
|---|
| 52 | I $L($G(^OR(100,ORNUM,8,0))) D | 
|---|
| 53 | .S ORQI=0,ORQI=$O(^OR(100,ORNUM,8,"C","NW",ORQI))  ;8 node for New order | 
|---|
| 54 | Q:+$G(ORQI)<1 "" | 
|---|
| 55 | S ORQDUZ=$P(^OR(100,ORNUM,8,ORQI,0),U,3) | 
|---|
| 56 | Q ORQDUZ | 
|---|
| 57 | UNSIGNOR(ORNUM) ;ext. funct. gets ordering provider DUZ from ORDER File (#100) | 
|---|
| 58 | ; based on order action number (8 node) | 
|---|
| 59 | ; if no action number return orderer for New order | 
|---|
| 60 | ;ORNUM in format: <order ien>;<action number> | 
|---|
| 61 | Q:'$L(+$G(ORNUM)) "" | 
|---|
| 62 | N ORQDUZ,ORQI S ORQDUZ="" | 
|---|
| 63 | S ORQI=$P(ORNUM,";",2) | 
|---|
| 64 | S ORNUM=$P(ORNUM,";") | 
|---|
| 65 | Q:+$G(ORNUM)<1 "" | 
|---|
| 66 | I +$G(ORQI)<1 S ORQI=$P($G(^OR(100,ORNUM,8,0)),U,3) | 
|---|
| 67 | I $L(ORQI),$L($G(^OR(100,ORNUM,8,ORQI,0))) D | 
|---|
| 68 | .S ORQDUZ=$P(^OR(100,ORNUM,8,ORQI,0),U,3) | 
|---|
| 69 | Q ORQDUZ | 
|---|
| 70 | OI(ORNUM) ;ext. funct. gets Orderable Item ien from ORDER File (#100) | 
|---|
| 71 | Q:+$G(ORNUM)<1 "" | 
|---|
| 72 | N OI S OI="" | 
|---|
| 73 | S OI=+$G(^OR(100,+$G(ORNUM),.1,1,0)) | 
|---|
| 74 | Q OI | 
|---|
| 75 | DG(ORNUM) ;ext. funct. gets Display Group ien from ORDER File (#100) | 
|---|
| 76 | Q:'$L($G(ORNUM)) "" | 
|---|
| 77 | N DG S DG="" | 
|---|
| 78 | S DG=$G(^OR(100,ORNUM,0)) | 
|---|
| 79 | I $L(DG) S DG=$P(DG,U,11) | 
|---|
| 80 | Q DG | 
|---|
| 81 | DGRX(ORNUM)        ;ext. funct. determines if order is pharmacy order | 
|---|
| 82 | Q:+$G(ORNUM)<1 "" | 
|---|
| 83 | N DG,DGNAME,RXDG | 
|---|
| 84 | S DG=$$DG(ORNUM) | 
|---|
| 85 | S DGNAME=$P($G(^ORD(100.98,+DG,0)),U) Q:'$L(DGNAME) "" | 
|---|
| 86 | F RXDG="PHARMACY","INPATIENT MEDICATIONS","OUTPATIENT MEDICATIONS","UNIT DOSE MEDICATIONS","IV MEDICATIONS","NON-VA MEDICATIONS","CLINIC ORDERS","" Q:(DGNAME=RXDG) | 
|---|
| 87 | Q RXDG | 
|---|
| 88 | PT(ORNUM) ;ext. funct. gets Patient dfn from ORDER File (#100) | 
|---|
| 89 | Q:'$L($G(ORNUM)) "" | 
|---|
| 90 | N PT S PT="" | 
|---|
| 91 | S PT=$G(^OR(100,ORNUM,0)) | 
|---|
| 92 | I $L(PT) S PT=$P(PT,U,2),PT=$P(PT,";DPT") | 
|---|
| 93 | Q PT | 
|---|
| 94 | RSLTFLG(ORNUM) ;ext. funct. returns duz of user to receive alert if order was | 
|---|
| 95 | ; flagged to alert when resulted | 
|---|
| 96 | Q:'$L($G(ORNUM)) "" | 
|---|
| 97 | N FLG S FLG="" | 
|---|
| 98 | S FLG=$G(^OR(100,+ORNUM,3)) | 
|---|
| 99 | I $L(FLG) S FLG=$P(FLG,U,10) | 
|---|
| 100 | Q FLG | 
|---|