Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: LEXXM4

LEXXM4.m

Go to the documentation of this file.
LEXXM4 ;ISL/KER - Convert Text to Mix Case (4) ;04/21/2014
 ;;2.0;General Lexicon Utilities;**80**;Sep 23, 1996;Build 10
 ;               
 ; Global Variables
 ;    None
 ;               
 ; External References
 ;    None
 ;               
 ; Local Variables NEWed or KILLed Elsewhere
 ;     LEXCTL,LEXIN,LEXNXT,LEXPRE,LEXUSE Newed in LEXXM
 ;     Y set and returned to LEXXM
 ;               
T4 ; 4 Characters
 N XU,CHR,NUM,TRL,PRE,UIN,NXT,USE,P1,P2 S PRE=$G(LEXPRE),NXT=$G(LEXNXT),USE=$G(LEXUSE),UIN=$G(UIN),XU=$$UP(X),CHR=$E(XU,1)
 ;   Exceptions
 S P1=$E(XU,1,($L(XU)-2)),P2=$E(XU,($L(XU)-1),$L(XU)) I "^CC^ML^GM^"[("^"_P2_"^"),$E(P1,$L(P1))?1N S Y=$$LO(XU) Q
 S NUM=$E(XU,1,2),TRL=$E(XU,3,4) I +NUM=NUM,((TRL="TH")!(TRL="ST")!(TRL="RD")) S Y=$$LO(XU) Q:$L($G(Y))
 S:$E(XU,1)?1U&($E(XU,4)?1N) Y=XU Q:$L($G(Y))  S:$E(XU,1)?1N&($E(XU,4)?1U) Y=XU Q:$L($G(Y))
 I "SIZE"=XU&(PRE="ANY") S Y=$$LO(X) Q
 I XU="MESA",$G(LEXCTL)["(MESA)" S Y=XU Q
 S:XU="TRAM"&((UIN["TRANSVERSE")!(UIN["BREAST")) Y=XU Q:$L($G(Y))
 S:XU="OPEN"&((UIN["OPEN HEART")) Y=$$MX(XU) Q:$L($G(Y))
 S:XU="DRIL"&(UIN["DISTAL REVASCULARIZATION")&(UIN["INTERVAL LIGATION") Y=$$UP(XU) Q:$L($G(Y))
 S:XU="TRAM"&((UIN["PROTEIN")!(UIN["GENE")!(UIN["ENDOPLASMIC RETICULUM"))&(UIN'["ACCIDENT")&(UIN'["VEHICLE") Y="TraM" Q:$L($G(Y))
 S:XU="TIPS"&($G(LEXIN)["(TIPS)") Y=XU S:XU="TIPS"&($G(LEXCTL)["(TIPS") Y=XU S:XU="TIPS"&($G(LEXCTL)["TIPS)") Y=XU Q:$L($G(Y))
 ;   Special Case
 S:XU="APOA" Y="ApoA" S:XU="BBVI" Y="BbvI" S:XU="BPTH" Y="bPTH" Q:$L($G(Y))
 S:XU="BSUE" Y="BsuE" S:XU="PCO2" Y="pCO2" S:XU="CGMP" Y="cGMP" Q:$L($G(Y))
 S:XU="COTE" Y="CotE" S:XU="DATP" Y="dATP" S:XU="DCMP" Y="dCMP" Q:$L($G(Y))
 S:XU="DCTP" Y="dCTP" S:XU="DGMP" Y="dGMP" S:XU="DGTP" Y="dGTP" Q:$L($G(Y))
 S:XU="DSBA" Y="dsbA" S:XU="DTDP" Y="dTDP" S:XU="DTTP" Y="dTTP" Q:$L($G(Y))
 S:XU="DUMP" Y="dUMP" S:XU="DURD" Y="dUrd" S:XU="DUTP" Y="dUTP" Q:$L($G(Y))
 S:XU="ECAI" Y="EcaI" S:XU="ECOK" Y="EcoK" S:XU="ERBB" Y="erbB" Q:$L($G(Y))
 S:XU="FELV" Y="FeLV" S:XU="FMET" Y="fMet" S:XU="GNRH" Y="GnRH" Q:$L($G(Y))
 S:XU="GPII" Y="gpII" S:XU="HARG" Y="hArg" S:XU="HELA" Y="HeLa" Q:$L($G(Y))
 S:XU="HGRF" Y="hGRF" S:XU="HHAI" Y="HhaI" S:XU="HPAI" Y="HpaI" Q:$L($G(Y))
 S:XU="HPTH" Y="hPTH" S:XU="KPNI" Y="KpnI" S:XU="MCRB" Y="McrB" Q:$L($G(Y))
 S:XU="MESH" Y="MeSH" S:XU="MRNA" Y="mRNA" S:XU="NHET" Y="NHEt" Q:$L($G(Y))
 S:XU="NHME" Y="NHMe" S:XU="OBZL" Y="OBzl" S:XU="OTBU" Y="OtBu" Q:$L($G(Y))
 S:XU="PGLU" Y="pGlu" S:XU="PSTI" Y="PstI" S:XU="REGA" Y="regA" Q:$L($G(Y))
 S:XU="RRNA" Y="rRNA" S:XU="SCEI" Y="SceI" S:XU="TAQI" Y="TaqI" Q:$L($G(Y))
 S:XU="TRFA" Y="TrfA" S:XU="TRKA" Y="trkA" S:XU="TRKB" Y="trkB" Q:$L($G(Y))
 S:XU="TRNA" Y="tRNA" Q:$L($G(Y))
 ;   Lower Case
 I "LESS"=XU&($E(NXT,1,4)="THAN") S Y=$$LO(X) Q
 I "^ALSO^AREA^BEEN^BEST^DONE^DTMN^EACH^EVEN^FIVE^FOUR^FROM^"[("^"_XU_"^") S Y=$$LO(X) Q
 I "^HAVE^HERE^HOUR^INTO^IT'S^KIND^LATE^LEFT^LESS^LIKE^LOST^"[("^"_XU_"^") S Y=$$LO(X) Q
 I "^MANY^MERE^MORE^MOST^MUST^NINE^NOTE^ONLY^OPEN^OURS^OVER^"[("^"_XU_"^") S Y=$$LO(X) Q
 I "^PART^PLUS^SAME^SEEN^SITE^SOME^SUCH^SURE^TAKE^THAN^THAN^"[("^"_XU_"^") S Y=$$LO(X) Q
 I "^THAT^THEN^THEY^THIS^THUS^UPON^USED^WERE^WHAT^WHEN^WHOM^"[("^"_XU_"^") S Y=$$LO(X) Q
 I "^WITH^"[("^"_XU_"^") S Y=$$LO(X) Q
 ;   Mixed Case
 I "^BATH^CITH^CITY^EAST^ERIE^FORT^HOME^IOWA^IRON^JUAN^JULY^"[("^"_XU_"^") S Y=$$MX(X) Q
 I "^JUNE^KELL^LAKE^LOMA^LONG^LYON^PALM^PALO^PARK^RENO^ROCK^"[("^"_XU_"^") S Y=$$MX(X) Q
 I "^SALT^SIDE^TYPE^WACO^WEST^YORK^"[("^"_XU_"^") S Y=$$MX(X) Q
 ;   Uppercase
 I CHR?1N!("^A^B^C^D^E^F^"[("^"_CHR_"^")) D  Q:$L($G(Y))
 . I "^A1B5^A1BG^A4A7^A4A8^A6K7^ABL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FE3^THBR^TIMP^TIUJ^TIUW^TIUX^TLSO^TLSO^TORP^TP53^"[("^"_XU_"^") S Y=XU Q
 . I "^UDPG^UMLS^VALM^VAPR^VDDR^VEEM^VIIA^VIII^VLDL^VRSA^VSIT^"[("^"_XU_"^") S Y=XU Q
 . I "^WHFO^WMMT^XIII^XQOR^XUFI^XVII^XXII^YS01^ZIFT^"[("^"_XU_"^") S Y=XU Q
 Q
 ;          
LO(X) ; Lower Case
 Q $TR(X,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")
UP(X) ; Uppercase
 Q $TR(X,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
MX(X) ; Mix Case
 Q $TR($E(X,1),"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")_$TR($E(X,2,$L(X)),"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")
LD(X) ; Leading Character
 Q $TR($E(X,1),"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")_$E(X,2,$L(X))
TRIM(X) ; Trim Spaces
 S X=$G(X) F  Q:$E(X,1)'=" "  S X=$E(X,2,$L(X))
 F  Q:$E(X,$L(X))'=" "  S X=$E(X,1,($L(X)-1))
 Q X