source: WorldVistAEHR/trunk/r/HEALTH_SUMMARY-GMTS/GMTSUMX.m@ 1270

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

initial load of WorldVistAEHR

File size: 3.8 KB
Line 
1GMTSUMX ; SLC/KER - Convert Text to Mix Case ; 07/18/2000
2 ;;2.7;Health Summary;**30,37**;Oct 20, 1995
3 Q
4EN(X) ; Convert Case
5 N Y,GMTSOK,GMTSOC,GMTSWORD,GMTSPC,GMTSLEAD,GMTSTLR,GMTSTR,GMTSCTR,GMTSPRE
6 S (GMTSTR,GMTSWORD,GMTSPC)="",X=$$UP(X)
7 ; Parse by Spaces
8 F GMTSCTR=1:1:$L(X," ") D
9 . S GMTSWORD=$P(X," ",GMTSCTR)
10 . S (GMTSPC,GMTSLEAD,GMTSTLR)=""
11 . I $E(GMTSWORD,1)="(" S GMTSWORD=$E(GMTSWORD,2,$L(GMTSWORD)),GMTSLEAD="("
12 . I $E(GMTSWORD,$L(GMTSWORD))=")" S GMTSWORD=$E(GMTSWORD,1,($L(GMTSWORD)-1)),GMTSTLR=")"
13 . ; String contains special characters
14 . S GMTSOK=1 F GMTSOC="(",")","-","*","+","{","&","}","[","]","/","\","|",",","'" S:GMTSWORD[GMTSOC GMTSOK=0 Q:'GMTSOK
15 . I 'GMTSOK D SP
16 . I GMTSOK D GMTSWORD
17 . S:GMTSLEAD'="" GMTSWORD=GMTSLEAD_GMTSWORD
18 . S:GMTSTLR'="" GMTSWORD=GMTSWORD_GMTSTLR
19 . S GMTSTR=GMTSTR_" "_GMTSWORD
20 S X=$$TRIM(GMTSTR) Q X
21EN2(X) ; Convert Case 2
22 S X=$$CK($$EN($G(X))) Q X
23SP ; Special Characters
24 ; Special Cases of Special Characters
25 I $$UP(GMTSWORD)="W/&W/O" S GMTSWORD="w/&w/o" Q
26 I $$UP(GMTSWORD)="W&W/O" S GMTSWORD="w&w/o" Q
27 I $$UP(GMTSWORD)="&/OR" S GMTSWORD="&/or" Q
28 I GMTSWORD="W/O" S GMTSWORD="w/o" Q
29 N GMTSOK,GMTSWD1,GMTSWD2,GMTSW,GMTSWCTR,GMTSCHR
30 S GMTSWD1=GMTSWORD,GMTSWD2="",GMTSW=""
31 F GMTSWCTR=1:1:$L(GMTSWD1) D
32 . S GMTSCHR=$E(GMTSWD1,GMTSWCTR) I "()-*+{}'&[]/\|,"[GMTSCHR,$L(GMTSW) D Q
33 . . S GMTSPRE=""
34 . . S:$E(GMTSW,1,2)="ZZ"&($L(GMTSW)>2) GMTSPRE="ZZ",GMTSW=$E(GMTSW,3,$L(GMTSW))
35 . . S GMTSW=GMTSPRE_$$CASE(GMTSW,GMTSCHR)
36 . . S GMTSWD2=GMTSWD2_GMTSW_GMTSCHR,GMTSW=""
37 . S GMTSW=GMTSW_GMTSCHR
38 I $L(GMTSW) D
39 . N GMTSPSN F GMTSPSN=1:1:$L(GMTSW) Q:"()-*+{}'&[]/\|,"'[$E(GMTSW,GMTSPSN)
40 . N GMTSOW,GMTSLW S GMTSLW=$E(GMTSW,0,(GMTSPSN-1))
41 . S GMTSOW=$E(GMTSW,GMTSPSN,$L(GMTSW))
42 . S GMTSPRE="" S:$E(GMTSOW,1,2)="ZZ"&($L(GMTSOW)>2) GMTSPRE="ZZ",GMTSOW=$E(GMTSOW,3,$L(GMTSOW))
43 . S GMTSOW=GMTSPRE_$$CASE(GMTSOW,$E($G(GMTSWD2),$L($G(GMTSWD2))))
44 . S GMTSW=GMTSLW_GMTSOW
45 . S GMTSWD2=GMTSWD2_GMTSW
46 S GMTSWORD=GMTSWD2 S:GMTSCTR=1 GMTSWORD=$$LD(GMTSWORD)
47 K GMTSWD1,GMTSWD2
48 Q
49GMTSWORD ; Convert word
50 S GMTSPRE="" S:$E(GMTSWORD,1,2)="ZZ"&($L(GMTSWORD)>2) GMTSPRE="ZZ",GMTSWORD=$E(GMTSWORD,3,$L(GMTSWORD))
51 S GMTSWORD=GMTSPRE_$$CASE(GMTSWORD,"")
52 Q
53CASE(X,J) ; Set to Mixed/lower/UPPER case
54 N GMTSTAG,GMTSRTN,Y S X=$$UP($G(X)),Y="",GMTSTAG=$L(X),GMTSRTN="GMTSUMX2"
55 S:+GMTSTAG>4 GMTSRTN="GMTSUMX3" S:+GMTSTAG>9 GMTSTAG="M"
56 Q:+GMTSTAG=0&(GMTSTAG'="M") X
57 S GMTSRTN=GMTSTAG_"^"_GMTSRTN D @GMTSRTN
58 I $L(Y) S X=Y Q X
59 S X=$$MX(X)
60 Q X
61LO(X) Q $TR(X,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")
62UP(X) Q $TR(X,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
63MX(X) Q $TR($E(X,1),"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")_$TR($E(X,2,$L(X)),"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")
64LD(X) Q $TR($E(X,1),"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")_$E(X,2,$L(X))
65TRIM(X) S X=$G(X) F Q:$E(X,1)'=" " S X=$E(X,2,$L(X))
66 F Q:$E(X,$L(X))'=" " S X=$E(X,1,($L(X)-1))
67 Q X
68CK(X) ;
69 S X=$G(X)
70 F Q:X'["(S)" S X=$P(X,"(S)",1)_"(s)"_$P(X,"(S)",2,299)
71 F Q:X'[" A " S X=$P(X," A ",1)_" a "_$P(X," A ",2,229)
72 I X["Class a" F Q:X'["Class a" S X=$P(X,"Class a",1)_"Class A"_$P(X,"Class a",2,229)
73 I X["Type a" F Q:X'["Type a" S X=$P(X,"Type a",1)_"Type A"_$P(X,"Type a",2,229)
74 F Q:X'["'S" S X=$P(X,"'S",1)_"'s"_$P(X,"'S",2,229)
75 I X["mg Diet" F Q:X'["mg Diet" S X=$P(X,"mg Diet",1)_"MG Diet"_$P(X,"mg Diet",2,229)
76 I X["LO-Fat" F Q:X'["LO-Fat" S X=$P(X,"LO-Fat",1)_"Lo-Fat"_$P(X,"LO-Fat",2,229)
77 I $E(X,1)="'" S X="'"_$$LD($E(X,2,$L(X)))
78 S X=$TR($E(X,1),"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")_$E(X,2,$L(X))
79 Q X
80TYPES ;
81 N GMTSIEN S GMTSIEN=0 F S GMTSIEN=$O(^GMT(142,GMTSIEN)) Q:+GMTSIEN=0 D
82 . N GMTSTXT S GMTSTXT=$P($G(^GMT(142,GMTSIEN,0)),"^",1)
83 . I $L(GMTSTXT) W !!,GMTSTXT,!,$$EN^GMTSUMX(GMTSTXT)
84 Q
Note: See TracBrowser for help on using the repository browser.