source: FOIAVistA/trunk/r/LEXICON_UTILITY-LEX-GMPT/LEXXST4.m@ 1458

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

initial load of FOIAVistA 6/30/08 version

File size: 3.6 KB
Line 
1LEXXST4 ; ISL Lexicon Status (Dates) ; 05-17-97
2 ;;2.0;LEXICON UTILITY;**4,5**;Sep 23, 1996
3 Q
4DTS(LEXX) ; Date to sequential
5 ; PCH 5 default quit value 0
6 S LEXX=$$UP^XLFSTR($$TRIM($G(LEXX))) Q:LEXX="" 0
7 N LEXCUR,LEXMON S LEXCUR=$$CUR
8 N LEXMON S LEXMON="JAN^FEB^MAR^APR^MAY^JUN^JUL^AUG^SEP^OCT^NOV^DEC"
9 S:LEXX["@" LEXX=$P(LEXX,"@",1)
10 S LEXX=$TR(LEXX,"-"," "),LEXX=$TR(LEXX,"/"," ") S:$L(LEXX," ")>3 LEXX=$P(LEXX," ",1,3)
11 N LEX1,LEX2,LEX3 S LEX1=$P(LEXX," ",1),LEX2=$P(LEXX," ",2),LEX3=$P(LEXX," ",3)
12 S LEXM=$$NM(LEX1) I +LEXM>0,+LEXM<13 D Q LEXX
13 . S:$L(LEXM)=1 LEXM="0"_LEXM S LEXD=$$DTN(LEX2),LEXY=$$YTN(LEX3,$P(LEXCUR,"^",1)),LEXX=LEXY_LEXM_LEXD
14 S LEXM=$$NM(LEX2) I +LEXM>0,+LEXM<13 D Q LEXX
15 . S:$L(LEXM)=1 LEXM="0"_LEXM S LEXD=$$DTN(LEX1),LEXY=$$YTN(LEX3,$P(LEXCUR,"^",1)),LEXX=LEXY_LEXM_LEXD
16 S LEXM=$$AN(LEX1) I +LEXM>0,+LEXM<13 D Q LEXX
17 . S:$L(LEXM)=1 LEXM="0"_LEXM S LEXD=$$DTN(LEX2),LEXY=$$YTN(LEX3,$P(LEXCUR,"^",1)),LEXX=LEXY_LEXM_LEXD
18 S LEXM=$$AN(LEX2) I +LEXM>0,+LEXM<13 D Q LEXX
19 . S:$L(LEXM)=1 LEXM="0"_LEXM S LEXD=$$DTN(LEX1),LEXY=$$YTN(LEX3,$P(LEXCUR,"^",1)),LEXX=LEXY_LEXM_LEXD
20 S LEXX=0 Q LEXX
21FTE(LEXX) ; Fileman to External (other)
22 S LEXX=$G(LEXX) Q:LEXX="" LEXX
23 S:LEXX["." LEXX=$P(LEXX,".",1) N LEXY,LEXM,LEXD S LEXY=+($E(LEXX,1,3)),LEXY=LEXY+1700
24 S LEXM=$E(LEXX,4,5) S:$E(LEXM,1)="0" LEXM=+($E(LEXM,2)) S:LEXM=0 LEXM=1
25 S LEXD=$E(LEXX,6,7) S:$E(LEXD,1)="0" LEXD=+($E(LEXD,2)) S:LEXD=0 LEXD=1 S:$L(LEXD)=1 LEXD=" "_LEXD
26 S LEXM=$S(LEXM=1:"Jan",LEXM=2:"FEB",LEXM=3:"Mar",LEXM=4:"Apr",LEXM=5:"May",LEXM=6:"Jun",LEXM=7:"Jul",LEXM=8:"Aug",LEXM=9:"Sep",LEXM=10:"Oct",LEXM=11:"Nov",LEXM=12:"Dec",1:"Jan")
27 S LEXX=LEXM_" "_LEXD_", "_LEXY
28 Q LEXX
29MTN(LEXX,LEXC) ; Alpha Month to 2 character numeric
30 S LEXC=$G(LEXC),LEXX=$$UP^XLFSTR($G(LEXX)) Q:'$L(LEXX) LEXC
31 S LEXX=$S(LEXX["JAN":"01",LEXX["FEB":"02",LEXX["MAR":"03",LEXX["APR":"04",LEXX["MAY":"05",LEXX["JUN":"06",LEXX["JUL":"07",LEXX["AUG":"08",LEXX["SEP":"09",LEXX["OCT":"10",LEXX["NOV":"11",LEXX["DEC":"12",1:LEXC)
32 Q LEXX
33DTN(LEXX) ; Day to 2 character numeric
34 S LEXX=$G(LEXX) Q:'$L(LEXX) "01"
35 S LEXX=$TR(LEXX,",",""),LEXX=$TR(LEXX,"-",""),LEXX=$TR(LEXX,"/",""),LEXX=$$TRIM(LEXX)
36 S:$L(LEXX)=1 LEXX="0"_LEXX
37 Q LEXX
38YTN(LEXX,LEXC) ; Year to 4 character year
39 S LEXC=$G(LEXC),LEXX=$$TRIM($G(LEXX)) Q:'$L(LEXX) LEXC S LEXX=$TR(LEXX,"-",""),LEXX=$TR(LEXX,"/","") Q:$L(LEXX)'=2&($L(LEXX)'=4) LEXC
40 S:$L(LEXX)=2&(+LEXX>83) LEXX="19"_LEXX S:$L(LEXX)=2&(+LEXX'>83) LEXX="20"_LEXX
41 Q LEXX
42STL(LEXX) ; Sequential to Long
43 S LEXX=$G(LEXX) N LEXC S LEXC=$TR($$CUR,"^","") S:'$L(LEXX) LEXX=LEXC
44 N LEXM,LEXD,LEXY S LEXY=$E(LEXX,1,4),LEXM=$E(LEXX,5,6),LEXD=$E(LEXX,7,8)
45 S:$E(LEXM,1)="0" LEXM=$E(LEXM,2) S LEXM=+LEXM
46 S LEXM=$S(LEXM=1:"Jan",LEXM=2:"Feb",LEXM=3:"Mar",LEXM=4:"Apr",LEXM=5:"May",LEXM=6:"Jun",LEXM=7:"Jul",LEXM=8:"Aug",LEXM=9:"Sep",LEXM=10:"Oct",LEXM=11:"Nov",LEXM=12:"Dec",1:"Jan")
47 S:$E(LEXD,1)="0" LEXD=" "_$E(LEXD,2) S LEXX=LEXM_" "_LEXD_", "_LEXY Q LEXX
48CUR(LEXX) ; Current Date
49 N I,%,%I,%H,X D NOW^%DTC
50 S LEXX=(+($E(X,1,3))+1700)_"^"_$E(X,4,5)_"^"_$E(X,6,7)
51 Q LEXX
52NM(LEXX) ; Numeric Month
53 S LEXX=$$UP^XLFSTR($G(LEXX)) Q:+LEXX>0 ""
54 N LEXMON S LEXMON="JAN^FEB^MAR^APR^MAY^JUN^JUL^AUG^SEP^OCT^NOV^DEC"
55 Q:LEXMON'[LEXX "" N LEXI,LEXM F LEXI=1:1:12 S LEXM=$P(LEXMON,"^",LEXI) S:LEXX=LEXM LEXX=LEXI Q:+LEXX>0
56 S LEXX=+LEXX S:LEXX=0 LEXX="" Q LEXX
57AN(LEXX) ; Alpha to Numeric
58 S LEXX=$G(LEXX) S:$E(LEXX,1)="0" LEXX=$E(LEXX,2) S LEXX=+LEXX
59 Q LEXX
60TRIM(LEXX) ; Trim Spaces
61 S LEXX=$G(LEXX),LEXX=$TR(LEXX,"*","") F Q:$E(LEXX,1)'=" " S LEXX=$E(LEXX,2,$L(LEXX))
62 F Q:$E(LEXX,$L(LEXX))'=" " S LEXX=$E(LEXX,1,($L(LEXX)-1))
63 F Q:LEXX'[" " S LEXX=$P(LEXX," ",1)_" "_$P(LEXX," ",2)
64 Q LEXX
Note: See TracBrowser for help on using the repository browser.