source: WorldVistAEHR/trunk/r/BAR_CODE_MED_ADMIN-ALPB-PSB/PSBVAR.m@ 1608

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

initial load of WorldVistAEHR

File size: 3.2 KB
Line 
1PSBVAR ;BIRMINGHAM/EFC-BCMA VARIANCE LOG FUNCTIONS ;Mar 2004
2 ;;3.0;BAR CODE MED ADMIN;*31*;Mar 2004;Build 1
3 ;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5 ; Reference/IA
6 ; ^DPT/10035
7 ; ^DIC(42/10039
8 ;
9EN ;
10 Q
11 ;
12CHKPRN(DFN,PSBMIN,PSBLOG) ;
13 Q:PSBMIN=""
14 Q:PSBMIN'>$$GET^XPAR("DIV","PSB ADMIN PRN EFFECT")
15 D ADD(.RESULTS,DFN,3,PSBMIN,"",PSBLOG)
16 Q
17 ;
18 ;CHECK^PSBVAR() calling point is used to create a new variance entry. Triggered by Order Administration Variance Field # 14 in the BCMA Medication Log File (#53.79).
19 ;
20CHECK(DFN,PSBMIN,PSBLOG) ;
21 Q:PSBMIN=""
22 N RESULTS
23 ; Checks the timing from the Med Log Entry X-Ref
24 I PSBMIN<0 D:(PSBMIN*-1)>$$GET^XPAR("DIV","PSB ADMIN BEFORE") ADD(.RESULTS,DFN,2,PSBMIN,"",PSBLOG)
25 I PSBMIN>0 D:PSBMIN>$$GET^XPAR("DIV","PSB ADMIN AFTER") ADD(.RESULTS,DFN,2,PSBMIN,"",PSBLOG)
26 Q
27 ;
28ADD(RESULTS,DFN,PSBEVNT,PSBMIN,PSBDRUG,PSBLOG) ;
29 ;
30 ; DFN: Patient File (#2) Pointer
31 ; PSBEVNT: Event Code (See DD for 53.78)
32 ; PSBMIN: Minutes off of schedule (Optional)
33 ; PSBDRUG: Drug File (#50) Pointer (Optional)
34 ; PSBLOG: BCMA Med Log IEN (Optional)
35 ;
36 ;Do not create variance for med order with missing dose status.
37 I $G(PSBLOG),$P($G(^PSB(53.79,PSBLOG,0)),U,9)="M" Q
38 ;
39 N PSBDT,PSBRB,PSBWRD,PSBXX
40 ;
41 D EN^DDIOL("Filing Variance...")
42 D NOW^%DTC
43 L +(^PSB(53.78,0)):5 E S RESULTS(0)="-1^Variance Log Locked" Q
44 S PSBXX=$O(^PSB(53.78,"A"),-1)+1
45 S $P(^PSB(53.78,0),U,3)=PSBXX
46 S $P(^PSB(53.78,0),U,4)=$P(^PSB(53.78,0),U,4)+1
47 ;
48WARD ;Extract the ward and room/bed information.
49 ;DFN is pre-defined.
50 S PSBRB=$P($G(^DPT(DFN,.101)),U)
51 S PSBRB=$S(PSBRB'="":PSBRB,1:"***")
52 S PSBWRD=$P($G(^DPT(DFN,.1)),U)
53 ;Convert Ward Name to Ward IEN
54 I PSBWRD'="" D
55 . S PSBDT=%
56 . S PSBWRD=$$FIND1^DIC(42,"","X",PSBWRD,"","","ERR")
57 . S %=PSBDT ;reset after $$FIND1^DIC fileman call
58 S PSBWRD=$S($G(PSBWRD):PSBWRD,1:"***")
59 ;
60 ; Set Variance Entry
61 S ^PSB(53.78,PSBXX,0)=DFN_U_PSBRB_U_DUZ_U_%_U_PSBEVNT_U_$G(PSBMIN)_U_$G(PSBDRUG)_U_$G(PSBLOG)_U_PSBWRD
62 ;
63 S ^PSB(53.78,"ADT",%,PSBXX)=""
64 S ^PSB(53.78,"B",DFN,PSBXX)=""
65 L -(^PSB(53.78,0))
66 S RESULTS(0)="1^Data Filed"
67 Q
68 ;
69 ; Unable to UPDATE^DIE WHILE IN UPDATE^DIE
70 W !,"Filing Variance..."
71 D EN^DDIOL("Filing Variance...")
72 N PSBVFDA,PSBVMSG,PSBVIEN
73 D VAL(.01,"`"_DFN) ; Patient Pointer
74 S Y=$G(^DPT(DFN,.1),"Unk Ward")_" "_$G(^DPT(DFN,.101),"Unk Bed")
75 D VAL(.02,Y) ; Patient Location
76 D VAL(.03,"`"_DUZ) ; New Person Pointer
77 D VAL(.04,"NOW") ; DT Entered
78 D VAL(.05,PSBEVNT) ; Event Code
79 D:$G(PSBMIN) VAL(.06,PSBMIN) ; Minutes Early/Late
80 D:$G(PSBDRUG) VAL(.07,"`"_PSBDRUG) ; Drug File Pointer
81 D:$G(PSBLOG) VAL(.08,"`"_PSBLOG)
82 ; Call UPDATE^DIE and set Results(0)
83 D UPDATE^DIE("","PSBVFDA","PSBVIEN","PSBVMSG") ; PSBVFDA set into file 53.68, BCMA MEDICATION VARIANCE LOG at VAL+3
84 I $D(PSBVMSG) S RESULTS(0)="-1^"_PSBVMSG("DIERR",1)_": "_PSBVMSG("DIERR",1,"TEXT",1)
85 E S RESULTS(0)="1^Data Successfully Filed^"_PSBVIEN(1)
86 W !,RESULTS(0)
87 Q
88 ;
89VAL(PSBVFLD,PSBVVAL) ;
90 N PSBVRET
91 K ^TMP("DIERR",$J)
92 D VAL^DIE(53.78,"+1,",PSBVFLD,"F",PSBVVAL,.PSBVRET,"PSBVFDA")
93 I PSBVRET="^" F X=0:0 S X=$O(^TMP("DIERR",$J,X)) Q:'X S Y=^TMP("DIERR",$J,X)_": "_$G(^(X,"TEXT",1),"**"),RESULTS($O(RESULTS(""),-1)+1)="Data Validation Error: "_Y
94 K ^TMP("DIERR",$J)
95 Q
96 ;
Note: See TracBrowser for help on using the repository browser.