source: WorldVistAEHR/trunk/r/VDEF-VDEF/VDEFUTIL.m@ 1579

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

initial load of WorldVistAEHR

File size: 4.5 KB
Line 
1VDEFUTIL ;INTEGIC/AM & BPOIFO/JG - VDEF Utilities ; 21 Nov 2005 2:17 PM
2 ;;1.0;VDEF;**3**;Dec 28, 2004
3 ;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5 ; IA: #10103 - $$HTE^XLFDT
6 ;
7 Q ; No bozos
8 ;
9FUTURE(WAKEUP) ;
10 ; Function that calculates $H date/time a WAKEUP number of
11 ; seconds in the future
12 ; Calculate the time WAKEUP number of seconds in the future as
13 ; expressed in the number of seconds since 1840
14 N X S X=$H,X=$P(X,",",1)*86400+$P(X,",",2)+WAKEUP
15 ; Convert the time from the number of seconds since 1840 to $H format
16 Q X\86400_","_(X#86400)
17 ;
18 ; Function to calculate the number of seconds between two dates
19DIFF(FIRST,SECOND) ;
20 N X
21 ; Convert the dates from Fileman to $H format if necessary
22 I FIRST?.E1".".E S X=FIRST D H^%DTC S FIRST=%H_","_%T
23 I SECOND?.E1".".E S X=SECOND D H^%DTC S SECOND=%H_","_%T
24 ;
25 ; Convert $H date/time values to the number of seconds since 1840
26 S FIRST=$P(FIRST,",",1)*86400+$P(FIRST,",",2)
27 S SECOND=$P(SECOND,",",1)*86400+$P(SECOND,",",2)
28 ; Return the number of seconds between the two dates
29 Q SECOND-FIRST
30 ;
31ALERT(XQAMSG) ;
32 ; Subroutine to send an Alert message to the VISTA HL7 IRM
33 ; Input Parameters:
34 ; XQAMSG - Text of the message to send to the Vista HL7 IRM
35 N ALERTS,XQA,X,Y,VDEFMSGX
36 S Y=$$HTE^XLFDT($H,2) S XQAMSG=Y_" "_XQAMSG,VDEFMSGX=XQAMSG
37 ; Retrieve the Mailman Group to send VDEF alerts to.
38 ; If site has no VDEF ALERTS Mail Group,
39 ; send it to HL7 Mail Group.
40 S X=$P($$GETAPP^HLCS2("VDEF ALERTS"),U)
41 I X="" S X=$$GET1^DIQ(869.3,"1,",".05")
42 S XQA("G."_X)="",X=$$SETUP1^XQALERT
43 ;
44 ; Send a mail message to VDEF ALERT group on FORUM
45 N XMDUZ,XMY,XMSUB,XMTEXT,SITEPARM,VDEFMSG
46 S SITEPARM=$$PARAM^HLCS2,SITEPARM=$P(SITEPARM,U,5)_" ("_$P(SITEPARM,U,6)_")"
47 S XMY("G.VDEF NATIONAL ALERTS@FORUM.VA.GOV")=""
48 S XMY("GARDNER.JEFF@FORUM.VA.GOV")=""
49 S XMDUZ="VDEF ALERT - "_SITEPARM,XMSUB="VDEF ALERT - "_SITEPARM,XMTEXT="VDEFMSG("
50 S VDEFMSG(1)="THIS IS AN ALERT GENERATED BY VDEF AT "_SITEPARM
51 S VDEFMSG(2)=" ",VDEFMSG(3)="ALERT TEXT:",VDEFMSG(4)=VDEFMSGX
52 D ^XMD
53 Q
54 ;
55TIMEI(T) ;
56 N TIME,CH,F,I,D,H,M,S,NUM,DONE
57 S TIME="",NUM="",DONE=0,F="DHMS",T=T_" "
58 F I=1:1:$L(T) S CH=$E(T,I) D Q:DONE
59 . I CH?1.N S NUM=NUM*10+$E(T,I) Q
60 . I CH=" ",NUM="" Q
61 . I CH=" " S CH=$E(F)
62 . I NUM="" S DONE=1 Q
63 . I CH="D" S D=NUM,NUM="",F=$P(F,CH,2) Q
64 . I CH="H" S H=NUM,NUM="",F=$P(F,CH,2) S:H>24 DONE=1 Q
65 . I CH="M" S M=NUM,NUM="",F=$P(F,CH,2) S:M>60 DONE=1 Q
66 . I CH="S" S S=NUM,NUM="",F=$P(F,CH,2) S:S>60 DONE=1 Q
67 . S DONE=1 W "*",CH,"*"
68 I DONE Q ""
69 ;W !,$G(D),"D ",$G(H),"H ",$G(M),"M ",$G(S),"S",!
70 S TIME=TIME+($G(D)*86400)+($G(H)*3600)+($G(M)*60)+$G(S)
71 Q TIME
72 ;
73TIMEE(T) ;
74 N TIME S TIME=""
75 I T'<86400 S TIME=TIME_(T\86400)_"D ",T=T#86400
76 I T'<3600 S TIME=TIME_(T\3600)_"H ",T=T#3600
77 I T'<60 S TIME=TIME_(T\60)_"M ",T=T#60
78 I T>0 S TIME=TIME_T_"S "
79 S TIME=$E(TIME,1,$L(TIME)-1)
80 Q TIME
81 ;
82 ; Delete all entries in a given Request Queue
83CLEANREQ(Q) ;
84 ; For development and testing only.
85 ; DO NOT USE IN PRODUCTION SYSTEMS.
86 I $$PROD^XUPROD(1) W:'$D(ZTQUEUED) !,"Can't be used in a production environment!" Q
87 N QUE S QUE=$P($G(^VDEFHL7(579.3,Q,0)),U)
88 I QUE="" W !,"Invalid queue" Q
89 K DIR S DIR(0)="Y",DIR("A")="Are you sure you want to continue",DIR("B")="No"
90 W !,"This action will delete all entries from Request Queue '"_QUE_"'."
91 D ^DIR I Y=0 W !,"Entries not deleted." Q
92 W !,"Deleting records ..."
93 N IEN S IEN=0 F S IEN=$O(^VDEFHL7(579.3,Q,1,IEN)) Q:'IEN D
94 . K FDA,MSG S FDA(579.31,IEN_","_Q_",",.01)="@" D FILE^DIE(,"FDA","MSG")
95 W !,"Entries deleted from "_QUE_" queue."
96 Q
97 ;
98PURGEQ ; Purge all Request Queues of their entries
99 ; For development and testing only.
100 ; DO NOT USE IN PRODUCTION SYSTEMS.
101 I $$PROD^XUPROD(1) W:'$D(ZTQUEUED) !,"Can't be used in a production environment!" Q
102 N QIEN S QIEN=0 F S QIEN=$O(^VDEFHL7(579.3,QIEN)) Q:'QIEN D CLEANREQ(QIEN)
103 Q
104 ;
105CLEANUP ; Delete records from VDEF files before installing the VDEF KIDS package
106 ; For development and testing only.
107 ; DO NOT USE IN PRODUCTION SYSTEMS.
108 I $$PROD^XUPROD(1) W:'$D(ZTQUEUED) !,"Can't be used in a production environment!" Q
109 K DIR S DIR(0)="Y",DIR("A")="Do you want to continue",DIR("B")="No"
110 W !,"This action will DELETE all data from VDEF globals in preparation for a KIDS install."
111 D ^DIR K DIR I Y=0 W !,"VDEF Globals not deleted." Q
112 W !,"Deleting records from VDEF globals ..."
113 N SUB S SUB="" F S SUB=$O(^VDEFHL7(SUB)) Q:SUB="" D
114 . S X=^VDEFHL7(SUB,0) K ^VDEFHL7(SUB) S ^VDEFHL7(SUB,0)=X
115 S SUB="" F S SUB=$O(^VDEFOUT(SUB)) Q:SUB="" D
116 . S X=^VDEFOUT(SUB,0) K ^VDEFOUT(SUB) S ^VDEFOUT(SUB,0)=X
117 W !,"VDEF Globals deleted."
118 Q
Note: See TracBrowser for help on using the repository browser.