source: ccr/trunk/p/C0CUTIL.m@ 728

Last change on this file since 728 was 559, checked in by Christopher Edwards, 15 years ago

fixed call to GPLXPATH to C0CXPATH

File size: 5.0 KB
Line 
1C0CUTIL ;WV/C0C/SMH - Various Utilites for generating the CCR/CCD;06/15/08
2 ;;0.1;C0C;;Jun 15, 2008;Build 29
3 ;Copyright 2008-2009 Sam Habiel & George Lilly.
4 ;Licensed under the terms of the GNU
5 ;General Public License See attached copy of the License.
6 ;
7 ;This program is free software; you can redistribute it and/or modify
8 ;it under the terms of the GNU General Public License as published by
9 ;the Free Software Foundation; either version 2 of the License, or
10 ;(at your option) any later version.
11 ;
12 ;This program is distributed in the hope that it will be useful,
13 ;but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;GNU General Public License for more details.
16 ;
17 ;You should have received a copy of the GNU General Public License along
18 ;with this program; if not, write to the Free Software Foundation, Inc.,
19 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 ;
21 W "No Entry at Top!"
22 Q
23 ;
24FMDTOUTC(DATE,FORMAT) ; Convert Fileman Date to UTC Date Format; PUBLIC; Extrinsic
25 ; FORMAT is Format of Date. Can be either D (Day) or DT (Date and Time)
26 ; If not passed, or passed incorrectly, it's assumed that it is D.
27 ; FM Date format is "YYYMMDD.HHMMSS" HHMMSS may not be supplied.
28 ; UTC date is formatted as follows: YYYY-MM-DDThh:mm:ss_offsetfromUTC
29 ; UTC, Year, Month, Day, Hours, Minutes, Seconds, Time offset (obtained from Mailman Site Parameters)
30 N UTC,Y,M,D,H,MM,S,OFF
31 S Y=1700+$E(DATE,1,3)
32 S M=$E(DATE,4,5)
33 S D=$E(DATE,6,7)
34 S H=$E(DATE,9,10)
35 I $L(H)=1 S H="0"_H
36 S MM=$E(DATE,11,12)
37 I $L(MM)=1 S MM="0"_MM
38 S S=$E(DATE,13,14)
39 I $L(S)=1 S S="0"_S
40 S OFF=$$TZ^XLFDT ; See Kernel Manual for documentation.
41 S OFFS=$E(OFF,1,1)
42 S OFF0=$TR(OFF,"+-")
43 S OFF1=$E(OFF0+10000,2,3)
44 S OFF2=$E(OFF0+10000,4,5)
45 S OFF=OFFS_OFF1_":"_OFF2
46 ;S OFF2=$E(OFF,1,2) ;
47 ;S OFF2=$E(100+OFF2,2,3) ; GPL 11/08 CHANGED TO -05:00 FORMAT
48 ;S OFF3=$E(OFF,3,4) ;MINUTES
49 ;S OFF=$S(OFF2="":"00",0:"00",1:OFF2)_"."_$S(OFF3="":"00",1:OFF3)
50 ; If H, MM and S are empty, it means that the FM date didn't supply the time.
51 ; In this case, set H, MM and S to "00"
52 ; S:('$L(H)&'$L(MM)&'$L(S)) (H,MM,S)="00" ; IF ONLY SOME ARE MISSING?
53 S:'$L(H) H="00"
54 S:'$L(MM) MM="00"
55 S:'$L(S) S="00"
56 S UTC=Y_"-"_M_"-"_D_"T"_H_":"_MM_$S(S="":":00",1:":"_S)_OFF ; Skip's code to fix hanging colon if no seconds
57 I $L($G(FORMAT)),FORMAT="DT" Q UTC ; Date with time.
58 E Q $P(UTC,"T")
59 ;
60SORTDT(V1,V2,ORDR) ; DATE SORT ARRAY AND RETURN INDEX IN V1 AND COUNT
61 ; AS EXTRINSIC ORDR IS 1 OR -1 FOR FORWARD OR REVERSE
62 ; DATE AND TIME ORDER. DEFAULT IS FORWARD
63 ; V2 IS AN ARRAY OF DATES IN FILEMAN FORMAT
64 ; V1 IS RETURNS INDIRECT INDEXES OF V2 IN REVERSE DATE ORDER
65 ; SO V2(V1(X)) WILL RETURN THE DATES IN DATE/TIME ORDER
66 ; THE COUNT OF THE DATES IS RETURNED AS AN EXTRINSIC
67 ; BOTH V1 AND V2 ARE PASSED BY REFERENCE
68 N VSRT ; TEMP FOR HASHING DATES
69 N ZI,ZJ,ZTMP,ZCNT,ZP1,ZP2
70 S ZCNT=V2(0) ; COUNTING NUMBER OF DATES
71 F ZI=1:1:ZCNT D ; FOR EACH DATE IN THE ARRAY
72 . I $D(V2(ZI)) D ; IF THE DATE EXISTS
73 . . S ZP1=$P(V2(ZI),".",1) ; THE DATE PIECE
74 . . S ZP2=$P(V2(ZI),".",2) ; THE TIME PIECE
75 . . ; W "DATE: ",ZP1," TIME: ",ZP2,!
76 . . S VSRT(ZP1,ZP2,ZI)=ZI ; INDEX OF DATE, TIME AND COUNT
77 N ZG
78 S ZG=$Q(VSRT(""))
79 F D Q:ZG="" ;
80 . ; W ZG,!
81 . D PUSH^C0CXPATH("V1",@ZG)
82 . S ZG=$Q(@ZG)
83 I ORDR=-1 D ; HAVE TO REVERSE ORDER
84 . N ZG2
85 . F ZI=1:1:V1(0) D ; FOR EACH ELELMENT
86 . . S ZG2(V1(0)-ZI+1)=V1(ZI) ; SET IN REVERSE ORDER
87 . S ZG2(0)=V1(0)
88 . D CP^C0CXPATH("ZG2","V1") ; COPY OVER THE NEW ARRAY
89 Q ZCNT
90 ;
91DA2SNO(RTN,DNAME) ; LOOK UP DRUG ALLERGY CODE IN ^LEX
92 ; RETURNS AN ARRAY RTN PASSED BY REFERENCE
93 ; THIS ROUTINE CAN BE USED AS AN RPC
94 ; RTN(0) IS THE NUMBER OF ELEMENTS IN THE ARRAY
95 ; RTN(1) IS THE SNOMED CODE FOR THE DRUG ALLERGY
96 ;
97 N LEXIEN
98 I $O(^LEX(757.21,"ADIS",DNAME,""))'="" D ; IEN FOUND FOR THIS DRUG
99 . S LEXIEN=$O(^LEX(757.21,"ADIS",DNAME,"")) ; GET THE IEN IN THE LEXICON
100 . W LEXIEN,!
101 . S RTN(1)=$P(^LEX(757.02,LEXIEN,0),"^",2) ; SNOMED CODE IN P2
102 . S RTN(0)=1 ; ONE THING RETURNED
103 E S RTN(0)=0 ; NOT FOUND
104 Q
105 ;
106DASNO(DANAME) ; PRINTS THE SNOMED CODE FOR ALLERGY TO DRUG DANAME
107 ;
108 N DARTN
109 D DA2SNO(.DARTN,DANAME) ; CALL THE LOOKUP ROUTINE
110 I DARTN(0)>0 D ; GOT RESULTS
111 . W !,DARTN(1) ;PRINT THE SNOMED CODE
112 E W !,"NOT FOUND",!
113 Q
114 ;
115DASNALL(WHICH) ; ROUTINE TO EXAMINE THE ADIS INDEX IN LEX AND RETRIEVE ALL
116 ; ASSOCIATED SNOMED CODES
117 N DASTMP,DASIEN,DASNO
118 S DASTMP=""
119 F S DASTMP=$O(^LEX(757.21,WHICH,DASTMP)) Q:DASTMP="" D ; NAME OF MED
120 . S DASIEN=$O(^LEX(757.21,WHICH,DASTMP,"")) ; IEN OF MED
121 . S DASNO=$P(^LEX(757.02,DASIEN,0),"^",2) ; SNOMED CODE FOR ENTRY
122 . W DASTMP,"=",DASNO,! ; PRINT IT OUT
123 Q
124 ;
125RPMS() ; Are we running on an RPMS system rather than Vista?
126 Q $G(DUZ("AG"))="I" ; If User Agency is Indian Health Service
127VISTA() ; Are we running on Vanilla Vista?
128 Q $G(DUZ("AG"))="V" ; If User Agency is VA
129WV() ; Are we running on WorldVista?
130 Q $G(DUZ("AG"))="E" ; Code for WV.
131OV() ; Are we running on OpenVista?
132 Q $G(DUZ("AG"))="O" ; Code for OpenVista
133
Note: See TracBrowser for help on using the repository browser.