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

ORQQPS.m

Go to the documentation of this file.
  1. ORQQPS ; slc/CLA - Functions which return patient medication data ;12/15/97 [ 04/02/97 3:52 PM ]
  1. ;;3.0;ORDER ENTRY/RESULTS REPORTING;**9,74,94**;Dec 17, 1997
  1. Q
  1. LIST(ORY,ORPT,ORSTRTDT,ORSTOPDT) ;return pt's condensed medication list
  1. ;id^nameform^stop date^route^schedule/infusion rate^refills remaining
  1. K ^TMP("PS",$J),^TMP("ORPS",$J)
  1. D OCL^PSOORRL(ORPT,ORSTRTDT,ORSTOPDT)
  1. N I,J,K,X,Z,ZZ,NODE,RSORT,NAME,SCH,MDR,RATE,TYPE,ADD,SOL,IVX
  1. S I=0,X=0,NODE=0,SCH="",MDR=""
  1. F S X=$O(^TMP("PS",$J,X)) Q:X<1 D
  1. .Q:+$P(^TMP("PS",$J,X,0),U)<1
  1. .S TYPE=$P(^TMP("PS",$J,X,0),U)
  1. .I +$G(^TMP("PS",$J,X,"MDR",0))>0 D ;get abbrev med route
  1. ..S ZZ=^TMP("PS",$J,X,"MDR",0) F Z=1:1:ZZ D
  1. ...I Z=1 S MDR=^TMP("PS",$J,X,"MDR",Z,0)
  1. ...E S MDR=MDR_", "_^TMP("PS",$J,X,"MDR",Z,0)
  1. .I +$G(^TMP("PS",$J,X,"SCH",0))>0 D ;get schedule
  1. ..S ZZ=^TMP("PS",$J,X,"SCH",0) F Z=1:1:ZZ D
  1. ...I Z=1 S SCH=$P(^TMP("PS",$J,X,"SCH",Z,0),U)
  1. ...E S SCH=SCH_", "_$P(^TMP("PS",$J,X,"SCH",Z,0),U)
  1. .;
  1. .I TYPE["I",+$G(^TMP("PS",$J,X,"B",0))>0 D ;IV meds - get solution
  1. ..S ZZ=^TMP("PS",$J,X,"B",0) F Z=1:1:ZZ D
  1. ...I Z=1 S SOL=$P(^TMP("PS",$J,X,"B",Z,0),U)_" "_$P(^(0),U,2)
  1. ...E S SOL=SOL_", "_$P(^TMP("PS",$J,X,"B",Z,0),U)_" "_$P(^(0),U,2)
  1. ..I +$G(^TMP("PS",$J,X,"A",0))>0 D ;get additive
  1. ...S ZZ=^TMP("PS",$J,X,"A",0) F Z=1:1:ZZ D
  1. ....S ADD=$P(^TMP("PS",$J,X,"A",Z,0),U)_" "_$P(^(0),U,2)
  1. ....S NAME=ADD_" in "_$G(SOL)
  1. ....S RSORT=9999999-$P(^TMP("PS",$J,X,0),U,4)_$P(^(0),U)_NAME
  1. ....S RSORT=$E(RSORT,1,128) ;limit gbl subscript length to 128 chars
  1. ....S ^TMP("ORPS",$J,RSORT)=$P(^TMP("PS",$J,X,0),U)_U_NAME_U_$P(^(0),U,4)_U_$G(MDR)_U_$P(^(0),U,3)
  1. ..E D
  1. ...S NAME=$G(SOL)
  1. ...S RSORT=9999999-$P(^TMP("PS",$J,X,0),U,4)_$P(^(0),U)
  1. ...S RSORT=$E(RSORT,1,128) ;limit gbl subscript length to 128 chars
  1. ...S ^TMP("ORPS",$J,RSORT)=$P(^TMP("PS",$J,X,0),U)_U_NAME_U_$P(^(0),U,4)_U_$G(MDR)_U_$P(^(0),U,3)
  1. .;
  1. .I TYPE["I",'(+$G(^TMP("PS",$J,X,"B",0))>0) D ;unit dose inpatient meds
  1. ..S RSORT=9999999-$P(^TMP("PS",$J,X,0),U,4)_$P(^(0),U)_$P(^(0),U,2)
  1. ..S RSORT=$E(RSORT,1,128) ;limit gbl subscript length to 128 chars
  1. ..S ^TMP("ORPS",$J,RSORT)=$P(^TMP("PS",$J,X,0),U)_U_$P(^(0),U,2)_U_$P(^(0),U,4)_U_$G(MDR)_U_$G(SCH)
  1. .;
  1. .I TYPE["O" D ;outpatient meds
  1. ..S RSORT=9999999-$P(^TMP("PS",$J,X,0),U,4)_$P(^(0),U)_$P(^(0),U,2)
  1. ..S RSORT=$E(RSORT,1,128) ;limit gbl subscript length to 128 chars
  1. ..S ^TMP("ORPS",$J,RSORT)=$P(^TMP("PS",$J,X,0),U)_U_$P(^(0),U,2)_U_$P(^(0),U,4)_U_$G(MDR)_U_$G(SCH)_U_$P(^(0),U,5)
  1. .;
  1. ;
  1. F S NODE=$O(^TMP("ORPS",$J,NODE)) Q:NODE<1 D
  1. .S I=I+1
  1. .S ORY(I)=^TMP("ORPS",$J,NODE)
  1. S:+$G(ORY(1))<1 ORY(1)="^No medications found."
  1. K ^TMP("PS",$J),^TMP("ORPS",$J)
  1. Q
  1. DETAIL(ORY,ORPT,ORMED) ; return detailed information for a drug
  1. K ^TMP("PS",$J)
  1. D OEL^PSOORRL(ORPT,ORMED)
  1. N I,J,CR,X,Z,ZZ,MDR,SCH,SIG,COM,ADD,SOL,ORDATE,TYPE
  1. S I=0,J=1,CR=$CHAR(13),ORDATE=""
  1. S TYPE=$P(ORMED,";",2)
  1. S X=$G(^TMP("PS",$J,0))
  1. I '$L($G(X)) S ORY(J)="No detailed information found." Q
  1. S ORY(J)=" "_$P(X,U)
  1. ;get abbreviated med route(s):
  1. I +$G(^TMP("PS",$J,"MDR",0))>0 D
  1. .S ZZ=^TMP("PS",$J,"MDR",0) F Z=1:1:ZZ D
  1. ..I Z=1 S MDR=^TMP("PS",$J,"MDR",Z,0)
  1. ..E S MDR=MDR_", "_^TMP("PS",$J,"MDR",Z,0)
  1. I $L($G(MDR)) S ORY(J)=ORY(J)_" "_MDR
  1. S ORY(J)=ORY(J)_" "_$P(X,U,2)
  1. ; get schedule(s):
  1. I +$G(^TMP("PS",$J,"SCH",0))>0 D
  1. .S ZZ=^TMP("PS",$J,"SCH",0) F Z=1:1:ZZ D
  1. ..I Z=1 S SCH=$P(^TMP("PS",$J,"SCH",Z,0),U)
  1. ..E S SCH=SCH_", "_$P(^TMP("PS",$J,"SCH",Z,0),U)
  1. I $L($G(SCH)) S ORY(J)=ORY(J)_" "_SCH
  1. S ORY(J)=ORY(J),J=J+1
  1. ; get SIG(s):
  1. I +$G(^TMP("PS",$J,"SIG",0))>0 D
  1. .S ZZ=^TMP("PS",$J,"SIG",0) F Z=1:1:ZZ D
  1. ..I Z=1 S SIG=^TMP("PS",$J,"SIG",Z,0)
  1. ..E S SIG=SIG_", "_^TMP("PS",$J,"SIG",Z,0)
  1. I $L($G(SIG)) S ORY(J)=" "_SIG,J=J+1
  1. S ORY(J)=" ",J=J+1
  1. ; get solution(s):
  1. I +$G(^TMP("PS",$J,"B",0))>0 D
  1. .S ZZ=^TMP("PS",$J,"B",0) F Z=1:1:ZZ D
  1. ..S SOL=^TMP("PS",$J,"B",Z,0),ORY(J)=" "_$P(SOL,U)_" "_$P(SOL,U,2),J=J+1
  1. ; get additive(s):
  1. I +$G(^TMP("PS",$J,"A",0))>0 D
  1. .S ZZ=^TMP("PS",$J,"A",0) F Z=1:1:ZZ D
  1. ..S ADD=^TMP("PS",$J,"A",Z,0)
  1. ..S ORY(J)=" "_$P(ADD,U)
  1. ..S IVX=$P(ADD,U,2)
  1. ..S ORY(J)=ORY(J)_$S($D(IVX):" "_IVX,1:"")_" "_$P(ADD,U,3),J=J+1
  1. I $L($G(SOL))!($L($G(ADD))) S ORY(J)=" ",J=J+1
  1. ; get other information:
  1. S ORY(J)=" Status: "_$P(X,U,6),J=J+1
  1. S ORDATE=$P(X,U,5) I $L($G(ORDATE)) D
  1. .D DT^DILF("ET",ORDATE,.ORDATE,"","")
  1. S ORY(J)=" Start date: "_$G(ORDATE(0)),J=J+1
  1. S ORDATE=$P(X,U,3) I $L($G(ORDATE)) D
  1. .D DT^DILF("ET",ORDATE,.ORDATE,"","")
  1. S ORY(J)=" Stop date: "_$G(ORDATE(0)),J=J+1
  1. I TYPE="O" D ; if outpatient med
  1. .S ORY(J)="Refills remaining: "_$P(X,U,4),J=J+1
  1. .S ORY(J)=" Days supply: "_$P(X,U,7),J=J+1
  1. .S ORY(J)=" Quantity: "_$P(X,U,8),J=J+1
  1. .S ORY(J)=" ",J=J+1
  1. S ORY(J)="Comments:",J=J+1
  1. S I=0 F S I=$O(^TMP("PS",$J,"PC",I)) Q:'I D
  1. .S ORY(J)=^TMP("PS",$J,"PC",I,0),J=J+1
  1. K ^TMP("PS",$J)
  1. Q