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

ORRCDPT1.m

Go to the documentation of this file.
  1. ORRCDPT1 ;SLC/MKB - Patient List for Nursing Dashboard ; 19 Sept 2003 10:10 AM
  1. ;;1.0;CARE MANAGEMENT;**5**;Jul 15, 2003;Build 4
  1. ;
  1. EN(ORY,ORUSR,ORLST) ; -- Return each patient in ORLSTs for ORUSR
  1. ; where ORLST(#) = <list-type>:<list-ID>:<clinic start>:<clinic stop>
  1. ; in @ORY@(#) = "Patient=<dfn>^<name>^<ssn>^<dob>^<age>"
  1. ; = "Result=ORR:##^ORR:##^...^*ORR:##"
  1. ; = "Task=TSK:##^TSK:##^...^*TSK:##"
  1. ; = "Event=VST:ID^VST:ID^...^VST:ID"
  1. ; = "Unverified=ORV:##^...^ORV:##"
  1. ; = "Nursing=ORN:##^...^!ORN:##"
  1. ; = "Vital=VIT:ID^...^*VIT:ID"
  1. ; = "Error=^<error description>"
  1. ; RPC = ORRC NURS DASHBD PATIENTS
  1. ;
  1. ;
  1. K ^TMP($J,"ORRCPTS"),^TMP($J,"ORRCY")
  1. N ORI,ORX,X,ORID,ORBEG,OREND,ORTN,ORPAT,ORJ,PAT,ORDMIN,ORDMAX,ERRI
  1. N ORSRV,FROM
  1. S ORSRV=$G(^VA(200,DUZ,5)) I +ORSRV>0 S ORSRV=$P(ORSRV,U)
  1. S FROM=$$GET^XPAR("USR^SRV.`"_+$G(ORSRV),"ORLP DEFAULT LIST SOURCE",1,"Q")
  1. S ORUSR=+$G(ORUSR),ERRI=0 D PARAMS
  1. S ORI=0 F S ORI=$O(ORLST(ORI)) Q:ORI<1 S ORX=$G(ORLST(ORI)) D
  1. . S X=$$UP^XLFSTR($P(ORX,":")),ORID=+$P(ORX,":",2) D Q:'$G(ORPAT(1))
  1. .. I X="X" D DEFLIST^ORQPTQ11(.ORPAT) D:$G(FROM)="M" Q
  1. ... S ORJ=0 F S ORJ=$O(^TMP("OR",$J,"PATIENTS",ORJ)) Q:ORJ<1 S PAT=+$G(^(ORJ,0)),ORPAT(ORJ)=PAT
  1. .. I X="T" D TEAMPTS^ORQPTQ1(.ORPAT,ORID) Q
  1. .. S ORTN=$S(X="P":"PROV",X="S":"SPEC",X="W":"WARD",X="C":"CLIN",1:"") Q:'$L(ORTN)
  1. .. I X'="C" S ORTN=ORTN_"PTS^ORQPTQ2(.ORPAT,ORID)" D @ORTN Q
  1. .. S ORBEG=$P(ORX,":",3),OREND=$P(ORX,":",4)
  1. .. S ORTN=ORTN_"PTS^ORQPTQ2(.ORPAT,ORID,ORBEG,OREND)" D @ORTN
  1. .. I $D(ORPAT(1)),'+$G(ORPAT(1)),ORPAT(1)'="^No appointments." S ERRI=ERRI+1,^TMP($J,"ORRCDPT1_ERROR",ERRI)=ORPAT(1)
  1. . S ORJ=0 F S ORJ=$O(ORPAT(ORJ)) Q:ORJ<1 S PAT=+$G(ORPAT(ORJ)) D
  1. .. Q:$D(^TMP($J,"ORRCY",PAT)) ;already processed
  1. .. ; build ^TMP($J,"ORRCY",DFN,"<type>",ID)=* or null:
  1. .. D RSLT,TASK,EVNT,UNVR,TEXT,VITL
  1. .. S ^TMP($J,"ORRCY",PAT)="" ;return all pts on list
  1. I $D(^TMP($J,"ORRCY")) D FORMAT
  1. I $D(^TMP($J,"ORRCDPT1_ERROR")) D ERROR(.ORY)
  1. K ^TMP($J,"ORRCY"),^TMP($J,"ORRCDPT1_ERROR")
  1. Q
  1. ;
  1. ERROR(ORY) ;Process errors to be returned
  1. N I,J S I=0,J=0
  1. I '$D(ORY) S ORY=$$GETRET
  1. F S I=$O(@ORY@(I)) Q:I'>0 S J=I
  1. S I=0
  1. F S I=$O(^TMP($J,"ORRCDPT1_ERROR",I)) Q:I'>0 S J=J+1,@ORY@(J)="Error="_^TMP($J,"ORRCDPT1_ERROR",I)
  1. Q
  1. ;
  1. PARAMS ; -- Return date range parameters ORDMIN(type),ORDMAX(type) for ORUSR
  1. N SERV,ORX,X,Y,%DT S SERV=+$G(^VA(200,ORUSR,5))
  1. F ORX="RESULT","EVENT","TEXT ORDER","UNVERIFIED","VITALS" D
  1. . S X=$$GET^XPAR("ALL^USR.`"_ORUSR_"^SRV.`"_SERV,"ORRC NURSE "_ORX_" DATE MIN"),%DT="TX"
  1. . D ^%DT S ORDMIN(ORX)=$S(Y>0:Y,1:"")
  1. . S X=$$GET^XPAR("ALL^USR.`"_ORUSR_"^SRV.`"_SERV,"ORRC NURSE "_ORX_" DATE MAX"),%DT="TX"
  1. . D ^%DT S ORDMAX(ORX)=$S(Y>0:Y,1:"")
  1. Q
  1. ;
  1. RSLT ; -- find PAT's results unack'd by ORUSR
  1. N ORACK,ORDBEG,ORDEND
  1. S ORDBEG=ORDMIN("RESULT"),ORDEND=ORDMAX("RESULT")
  1. D IDS^ORRCACK(.ORACK,PAT,ORUSR,ORDBEG,ORDEND)
  1. M ^TMP($J,"ORRCY",PAT,"R")=@ORACK@(PAT) K @ORACK
  1. Q
  1. ;
  1. TASK ; -- find PAT's due tasks
  1. N ORTSK
  1. D IDS^ORRCTSK(.ORTSK,PAT)
  1. M ^TMP($J,"ORRCY",PAT,"T")=@ORTSK@(PAT) K @ORTSK
  1. Q
  1. ;
  1. EVNT ; -- find PAT's appointments
  1. N OREVT,ORABEG,ORAEND
  1. S ORABEG=ORDMIN("EVENT"),ORAEND=ORDMAX("EVENT")
  1. D IDS^ORRCEVT(.OREVT,PAT,ORABEG,ORAEND)
  1. M ^TMP($J,"ORRCY",PAT,"E")=@OREVT@(PAT) K @OREVT
  1. Q
  1. ;
  1. UNVR ; -- find PAT's unverified orders, by nursing
  1. N ORDER,ORDBEG,ORDEND
  1. S ORDBEG=ORDMIN("UNVERIFIED"),ORDEND=ORDMAX("UNVERIFIED")
  1. D IDS^ORRCOR(.ORDER,PAT,"ORV",ORDBEG,ORDEND)
  1. M ^TMP($J,"ORRCY",PAT,"U")=@ORDER@(PAT) K @ORDER
  1. Q
  1. ;
  1. TEXT ; -- find patients with active generic text orders
  1. N ORDER,ORDBEG,ORDEND
  1. S ORDBEG=ORDMIN("TEXT ORDER"),ORDEND=ORDMAX("TEXT ORDER")
  1. D IDS^ORRCOR(.ORDER,PAT,"ORN",ORDBEG,ORDEND)
  1. M ^TMP($J,"ORRCY",PAT,"N")=@ORDER@(PAT) K @ORDER
  1. Q
  1. ;
  1. VITL ; -- find patients with recent vitals
  1. N ORVIT,ORVBEG,ORVEND
  1. S ORVBEG=ORDMIN("VITALS"),ORVEND=ORDMAX("VITALS")
  1. D IDS^ORRCVIT(.ORVIT,PAT,ORVBEG,ORVEND)
  1. M ^TMP($J,"ORRCY",PAT,"V")=@ORVIT@(PAT) K @ORVIT
  1. Q
  1. ;
  1. FORMAT ; -- Format return array ^TMP($J,"ORRCPTS") from temp array ^TMP($J,"ORRCY")
  1. N ORPT,ORN,DFN,VADM,VA,VAERR
  1. S ORY=$$GETRET
  1. S (ORPT,ORN)=0 F S ORPT=$O(^TMP($J,"ORRCY",ORPT)) Q:ORPT<1 D
  1. . S DFN=ORPT D DEM^VADPT
  1. . S ORN=ORN+1,@ORY@(ORN)="Patient="_DFN_U_VADM(1)_U_VA("PID")_U_$$FMTHL7^XLFDT(+VADM(3))_U_VADM(4)
  1. . I $D(^TMP($J,"ORRCY",ORPT,"R")) D ADD("Result")
  1. . I $D(^TMP($J,"ORRCY",ORPT,"T")) D ADD("Task")
  1. . I $D(^TMP($J,"ORRCY",ORPT,"E")) D ADD("Event")
  1. . I $D(^TMP($J,"ORRCY",ORPT,"U")) D ADD("Unverified")
  1. . I $D(^TMP($J,"ORRCY",ORPT,"N")) D ADD("Nursing")
  1. . I $D(^TMP($J,"ORRCY",ORPT,"V")) D ADD("Vital")
  1. Q
  1. ;
  1. ADD(TYPE) ; -- Add item IDs from ^TMP($J,"ORRCY",PAT,<TYPE>) into return array
  1. N ORX,ORSUB,ORID,X,ORU
  1. S ORX=TYPE_"=",ORSUB=$E(TYPE),ORID="",ORU=""
  1. F S ORID=$O(^TMP($J,"ORRCY",ORPT,ORSUB,ORID)) Q:ORID="" S X=$G(^(ORID))_ORID D
  1. . I $L(ORX)+$L(X)>254 S ORN=ORN+1,@ORY@(ORN)=ORX,ORX=TYPE_"=",ORU=""
  1. . S ORX=ORX_ORU_X,ORU=U
  1. S ORN=ORN+1,@ORY@(ORN)=ORX
  1. Q
  1. ;
  1. GETRET() ;Returns the return variable pointer
  1. Q $NA(^TMP($J,"ORRCPTS"))
  1. ;