source: WorldVistAEHR/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORWDPS.m@ 814

Last change on this file since 814 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 3.1 KB
RevLine 
[613]1ORWDPS ; SLC/KCM - Pharmacy Calls for Windows Dialog [ 08/04/96 6:57 PM ]
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;;Dec 17, 1997
3 ;
4LOAD(LST,OI,PTYP) ;
5 ; -- For a given orderable item, load appropriate lists & defaults
6 N I,X,CNT,ORTMP,ILST S ILST=0
7 S LST($$NXT)="~FORMULTN" D FRMLTN
8 S LST($$NXT)="~INSTRUCT" D INSTRCT
9 S LST($$NXT)="~ROUTE" D ROUTE
10 S LST($$NXT)="~SCHEDULE" D SCHED
11 S LST($$NXT)="~PRIORITY" D PRIOR
12 S LST($$NXT)="~MESSAGE" D MESSAGE
13 I PTYP="O" D
14 . S LST($$NXT)="~PICKUP" D PICKUP
15 . S LST($$NXT)="~SCSTATUS" D SCSTS
16 . S LST($$NXT)="~REFILLS" D REFILLS
17 Q
18DISPDRUG(LST,OI) ; list dispense drugs for an orderable item
19 N ILST,PTYP S ILST=0,PTYP="U" D FRMLTN
20 Q
21FRMLTN ; formulations
22 D ENDD^PSJORUTL("^^^"_+$P($G(^ORD(101.43,OI,0)),"^",2),PTYP,.ORTMP)
23 S I="" F S I=$O(ORTMP(I)) Q:I="" S LST($$NXT)="i"_ORTMP(I)
24 Q
25INSTRCT ; instructions
26 D ^PSSJORDF(+$P(^ORD(101.43,OI,0),U,2))
27 S I="" F S I=$O(^TMP("PSJINS",$J,I)) Q:I="" S X=^(I) D
28 . I PTYP="U",$P(X,U,1)="TAKE" S $P(X,U,1)="GIVE"
29 . S LST($$NXT)="i"_$P(X,U,2)_U_$P(X,U,1)_" "_$P(X,U,2)
30 ; S I=$O(^TMP("PSJINS",$J,0)) (default instruction text)
31 ; I I S X=$P($G(^TMP("PSJINS",$J,I)),U) S:$L(X) LST($$NXT)="d"_X_" "
32 Q
33ROUTE ; routes
34 S I="",CNT=0
35 F S I=$O(^TMP("PSJMR",$J,I)) Q:I="" D
36 . S LST($$NXT)="i"_I_U_^(I),CNT=CNT+1
37 I CNT=1 S X=LST(ILST),LST($$NXT)="d"_$P(X,"^",3)
38 K ^TMP("PSJINS",$J),^TMP("PSJMR",$J)
39 Q
40SCHED ; schedules
41 S I="" F S I=$O(^PS(51.1,"APPSJ",I)) Q:I="" D
42 . S LST($$NXT)="i"_$O(^(I,0))_U_I
43 Q
44PRIOR ; priorities
45 F X="ROUTINE","ASAP","STAT","DONE" D
46 . S LST($$NXT)="i"_$O(^ORD(101.42,"B",X,0))_U_X
47 S LST($$NXT)="dROUTINE"
48 Q
49PICKUP ; routing
50 F X="W^at Window","M^by Mail","C^in Clinic" S LST($$NXT)="i"_X
51 S LST($$NXT)="dat Window"
52 Q
53SCSTS ; SC for drug
54 F X="0^No","1^Yes" S LST($$NXT)="i"_X
55 ; later: see if last order for this OI was SC and set default
56 Q
57REFILLS ; refills
58 F X=0:1:11 S LST($$NXT)="i"_X_U_X
59 S LST($$NXT)="d0"
60 Q
61MESSAGE ; message
62 S I=0 F S I=$O(^ORD(101.43,OI,8,I)) Q:I'>0 S LST($$NXT)="i"_^(I,0)
63 Q
64NXT() ; -- Function returns next available index in return data array
65 S ILST=ILST+1
66 Q ILST
67DEF(LST,INOUT) ; Load defaults for pharmacy dialogs (common lists)
68 N TMPLST,IEN,I,X,ILST S ILST=0
69 S LST($$NXT)="~Common" D COMMON
70 Q
71COMMON ; get list of common meds
72 S X="ORWD COMMON MED "_$S($G(INOUT)="O":"OUTPT",1:"INPT")
73 D GETLST^XPAR(.TMPLST,"ALL",X)
74 S I=0 F S I=$O(TMPLST(I)) Q:'I D
75 . S IEN=$P(TMPLST(I),U,2)
76 . S LST($$NXT)="i"_IEN_U_$P(^ORD(101.43,IEN,0),U,1)
77 Q
78INPT(OK,DFN,PRV) ; For inpatient meds, check restrictions
79 N NAME,AUTH,INACT,X S OK=0
80 I '$D(^DPT(DFN,.1)) S OK="1^Patient is not an inpatient." Q
81 S NAME=$P($G(^VA(200,PRV,20)),U,2) S:'$L(NAME) NAME=$P(^(0),U)
82 S X=$G(^VA(200,PRV,"PS")),AUTH=$P(X,U),INACT=$P(X,U,4)
83 I 'AUTH!(INACT&(DT>INACT)) D
84 . S OK="1^"_NAME_" is not authorized to write medication orders."
85 Q
86OUTPT(OK,PRV) ; For outpatient meds, check restrictions
87 N NAME,AUTH,INACT,X S OK=0
88 S NAME=$P($G(^VA(200,PRV,20)),U,2) S:'$L(NAME) NAME=$P(^(0),U)
89 S X=$G(^VA(200,PRV,"PS")),AUTH=$P(X,U),INACT=$P(X,U,4)
90 I 'AUTH!(INACT&(DT>INACT)) D
91 . S OK="1^"_NAME_" is not authorized to write medication orders."
92 Q
Note: See TracBrowser for help on using the repository browser.