1 | ORRCDPT1 ;SLC/MKB - Patient List for Nursing Dashboard ; 19 Sept 2003 10:10 AM
|
---|
2 | ;;1.0;CARE MANAGEMENT;**5**;Jul 15, 2003;Build 4
|
---|
3 | ;
|
---|
4 | EN(ORY,ORUSR,ORLST) ; -- Return each patient in ORLSTs for ORUSR
|
---|
5 | ; where ORLST(#) = <list-type>:<list-ID>:<clinic start>:<clinic stop>
|
---|
6 | ; in @ORY@(#) = "Patient=<dfn>^<name>^<ssn>^<dob>^<age>"
|
---|
7 | ; = "Result=ORR:##^ORR:##^...^*ORR:##"
|
---|
8 | ; = "Task=TSK:##^TSK:##^...^*TSK:##"
|
---|
9 | ; = "Event=VST:ID^VST:ID^...^VST:ID"
|
---|
10 | ; = "Unverified=ORV:##^...^ORV:##"
|
---|
11 | ; = "Nursing=ORN:##^...^!ORN:##"
|
---|
12 | ; = "Vital=VIT:ID^...^*VIT:ID"
|
---|
13 | ; = "Error=^<error description>"
|
---|
14 | ; RPC = ORRC NURS DASHBD PATIENTS
|
---|
15 | ;
|
---|
16 | ;
|
---|
17 | K ^TMP($J,"ORRCPTS"),^TMP($J,"ORRCY")
|
---|
18 | N ORI,ORX,X,ORID,ORBEG,OREND,ORTN,ORPAT,ORJ,PAT,ORDMIN,ORDMAX,ERRI
|
---|
19 | N ORSRV,FROM
|
---|
20 | S ORSRV=$G(^VA(200,DUZ,5)) I +ORSRV>0 S ORSRV=$P(ORSRV,U)
|
---|
21 | S FROM=$$GET^XPAR("USR^SRV.`"_+$G(ORSRV),"ORLP DEFAULT LIST SOURCE",1,"Q")
|
---|
22 | S ORUSR=+$G(ORUSR),ERRI=0 D PARAMS
|
---|
23 | S ORI=0 F S ORI=$O(ORLST(ORI)) Q:ORI<1 S ORX=$G(ORLST(ORI)) D
|
---|
24 | . S X=$$UP^XLFSTR($P(ORX,":")),ORID=+$P(ORX,":",2) D Q:'$G(ORPAT(1))
|
---|
25 | .. I X="X" D DEFLIST^ORQPTQ11(.ORPAT) D:$G(FROM)="M" Q
|
---|
26 | ... S ORJ=0 F S ORJ=$O(^TMP("OR",$J,"PATIENTS",ORJ)) Q:ORJ<1 S PAT=+$G(^(ORJ,0)),ORPAT(ORJ)=PAT
|
---|
27 | .. I X="T" D TEAMPTS^ORQPTQ1(.ORPAT,ORID) Q
|
---|
28 | .. S ORTN=$S(X="P":"PROV",X="S":"SPEC",X="W":"WARD",X="C":"CLIN",1:"") Q:'$L(ORTN)
|
---|
29 | .. I X'="C" S ORTN=ORTN_"PTS^ORQPTQ2(.ORPAT,ORID)" D @ORTN Q
|
---|
30 | .. S ORBEG=$P(ORX,":",3),OREND=$P(ORX,":",4)
|
---|
31 | .. S ORTN=ORTN_"PTS^ORQPTQ2(.ORPAT,ORID,ORBEG,OREND)" D @ORTN
|
---|
32 | .. I $D(ORPAT(1)),'+$G(ORPAT(1)),ORPAT(1)'="^No appointments." S ERRI=ERRI+1,^TMP($J,"ORRCDPT1_ERROR",ERRI)=ORPAT(1)
|
---|
33 | . S ORJ=0 F S ORJ=$O(ORPAT(ORJ)) Q:ORJ<1 S PAT=+$G(ORPAT(ORJ)) D
|
---|
34 | .. Q:$D(^TMP($J,"ORRCY",PAT)) ;already processed
|
---|
35 | .. ; build ^TMP($J,"ORRCY",DFN,"<type>",ID)=* or null:
|
---|
36 | .. D RSLT,TASK,EVNT,UNVR,TEXT,VITL
|
---|
37 | .. S ^TMP($J,"ORRCY",PAT)="" ;return all pts on list
|
---|
38 | I $D(^TMP($J,"ORRCY")) D FORMAT
|
---|
39 | I $D(^TMP($J,"ORRCDPT1_ERROR")) D ERROR(.ORY)
|
---|
40 | K ^TMP($J,"ORRCY"),^TMP($J,"ORRCDPT1_ERROR")
|
---|
41 | Q
|
---|
42 | ;
|
---|
43 | ERROR(ORY) ;Process errors to be returned
|
---|
44 | N I,J S I=0,J=0
|
---|
45 | I '$D(ORY) S ORY=$$GETRET
|
---|
46 | F S I=$O(@ORY@(I)) Q:I'>0 S J=I
|
---|
47 | S I=0
|
---|
48 | F S I=$O(^TMP($J,"ORRCDPT1_ERROR",I)) Q:I'>0 S J=J+1,@ORY@(J)="Error="_^TMP($J,"ORRCDPT1_ERROR",I)
|
---|
49 | Q
|
---|
50 | ;
|
---|
51 | PARAMS ; -- Return date range parameters ORDMIN(type),ORDMAX(type) for ORUSR
|
---|
52 | N SERV,ORX,X,Y,%DT S SERV=+$G(^VA(200,ORUSR,5))
|
---|
53 | F ORX="RESULT","EVENT","TEXT ORDER","UNVERIFIED","VITALS" D
|
---|
54 | . S X=$$GET^XPAR("ALL^USR.`"_ORUSR_"^SRV.`"_SERV,"ORRC NURSE "_ORX_" DATE MIN"),%DT="TX"
|
---|
55 | . D ^%DT S ORDMIN(ORX)=$S(Y>0:Y,1:"")
|
---|
56 | . S X=$$GET^XPAR("ALL^USR.`"_ORUSR_"^SRV.`"_SERV,"ORRC NURSE "_ORX_" DATE MAX"),%DT="TX"
|
---|
57 | . D ^%DT S ORDMAX(ORX)=$S(Y>0:Y,1:"")
|
---|
58 | Q
|
---|
59 | ;
|
---|
60 | RSLT ; -- find PAT's results unack'd by ORUSR
|
---|
61 | N ORACK,ORDBEG,ORDEND
|
---|
62 | S ORDBEG=ORDMIN("RESULT"),ORDEND=ORDMAX("RESULT")
|
---|
63 | D IDS^ORRCACK(.ORACK,PAT,ORUSR,ORDBEG,ORDEND)
|
---|
64 | M ^TMP($J,"ORRCY",PAT,"R")=@ORACK@(PAT) K @ORACK
|
---|
65 | Q
|
---|
66 | ;
|
---|
67 | TASK ; -- find PAT's due tasks
|
---|
68 | N ORTSK
|
---|
69 | D IDS^ORRCTSK(.ORTSK,PAT)
|
---|
70 | M ^TMP($J,"ORRCY",PAT,"T")=@ORTSK@(PAT) K @ORTSK
|
---|
71 | Q
|
---|
72 | ;
|
---|
73 | EVNT ; -- find PAT's appointments
|
---|
74 | N OREVT,ORABEG,ORAEND
|
---|
75 | S ORABEG=ORDMIN("EVENT"),ORAEND=ORDMAX("EVENT")
|
---|
76 | D IDS^ORRCEVT(.OREVT,PAT,ORABEG,ORAEND)
|
---|
77 | M ^TMP($J,"ORRCY",PAT,"E")=@OREVT@(PAT) K @OREVT
|
---|
78 | Q
|
---|
79 | ;
|
---|
80 | UNVR ; -- find PAT's unverified orders, by nursing
|
---|
81 | N ORDER,ORDBEG,ORDEND
|
---|
82 | S ORDBEG=ORDMIN("UNVERIFIED"),ORDEND=ORDMAX("UNVERIFIED")
|
---|
83 | D IDS^ORRCOR(.ORDER,PAT,"ORV",ORDBEG,ORDEND)
|
---|
84 | M ^TMP($J,"ORRCY",PAT,"U")=@ORDER@(PAT) K @ORDER
|
---|
85 | Q
|
---|
86 | ;
|
---|
87 | TEXT ; -- find patients with active generic text orders
|
---|
88 | N ORDER,ORDBEG,ORDEND
|
---|
89 | S ORDBEG=ORDMIN("TEXT ORDER"),ORDEND=ORDMAX("TEXT ORDER")
|
---|
90 | D IDS^ORRCOR(.ORDER,PAT,"ORN",ORDBEG,ORDEND)
|
---|
91 | M ^TMP($J,"ORRCY",PAT,"N")=@ORDER@(PAT) K @ORDER
|
---|
92 | Q
|
---|
93 | ;
|
---|
94 | VITL ; -- find patients with recent vitals
|
---|
95 | N ORVIT,ORVBEG,ORVEND
|
---|
96 | S ORVBEG=ORDMIN("VITALS"),ORVEND=ORDMAX("VITALS")
|
---|
97 | D IDS^ORRCVIT(.ORVIT,PAT,ORVBEG,ORVEND)
|
---|
98 | M ^TMP($J,"ORRCY",PAT,"V")=@ORVIT@(PAT) K @ORVIT
|
---|
99 | Q
|
---|
100 | ;
|
---|
101 | FORMAT ; -- Format return array ^TMP($J,"ORRCPTS") from temp array ^TMP($J,"ORRCY")
|
---|
102 | N ORPT,ORN,DFN,VADM,VA,VAERR
|
---|
103 | S ORY=$$GETRET
|
---|
104 | S (ORPT,ORN)=0 F S ORPT=$O(^TMP($J,"ORRCY",ORPT)) Q:ORPT<1 D
|
---|
105 | . S DFN=ORPT D DEM^VADPT
|
---|
106 | . S ORN=ORN+1,@ORY@(ORN)="Patient="_DFN_U_VADM(1)_U_VA("PID")_U_$$FMTHL7^XLFDT(+VADM(3))_U_VADM(4)
|
---|
107 | . I $D(^TMP($J,"ORRCY",ORPT,"R")) D ADD("Result")
|
---|
108 | . I $D(^TMP($J,"ORRCY",ORPT,"T")) D ADD("Task")
|
---|
109 | . I $D(^TMP($J,"ORRCY",ORPT,"E")) D ADD("Event")
|
---|
110 | . I $D(^TMP($J,"ORRCY",ORPT,"U")) D ADD("Unverified")
|
---|
111 | . I $D(^TMP($J,"ORRCY",ORPT,"N")) D ADD("Nursing")
|
---|
112 | . I $D(^TMP($J,"ORRCY",ORPT,"V")) D ADD("Vital")
|
---|
113 | Q
|
---|
114 | ;
|
---|
115 | ADD(TYPE) ; -- Add item IDs from ^TMP($J,"ORRCY",PAT,<TYPE>) into return array
|
---|
116 | N ORX,ORSUB,ORID,X,ORU
|
---|
117 | S ORX=TYPE_"=",ORSUB=$E(TYPE),ORID="",ORU=""
|
---|
118 | F S ORID=$O(^TMP($J,"ORRCY",ORPT,ORSUB,ORID)) Q:ORID="" S X=$G(^(ORID))_ORID D
|
---|
119 | . I $L(ORX)+$L(X)>254 S ORN=ORN+1,@ORY@(ORN)=ORX,ORX=TYPE_"=",ORU=""
|
---|
120 | . S ORX=ORX_ORU_X,ORU=U
|
---|
121 | S ORN=ORN+1,@ORY@(ORN)=ORX
|
---|
122 | Q
|
---|
123 | ;
|
---|
124 | GETRET() ;Returns the return variable pointer
|
---|
125 | Q $NA(^TMP($J,"ORRCPTS"))
|
---|
126 | ;
|
---|