source: FOIAVistA/trunk/r/MENTAL_HEALTH-YS-RUCL-YI-YT/YSAST.m@ 1540

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

initial load of FOIAVistA 6/30/08 version

File size: 2.5 KB
Line 
1YSAST ;ALB/ASF/692/DCL-ASI TIME FUNCTION ;7/30/96 11:20
2 ;;5.01;MENTAL HEALTH;**24**;Dec 30, 1994
3 ;CODE TAKEN FROM PRSATIM ROUTINE
4 Q
5X(X) Q:$G(X)="" ""
6 N X1
7 S X=$TR(X,"adimnop","ADIMNOP")
8 I X?1"12".A S X=$S(X="12M":"MID",X="12N":"NOON",1:X)
9 I X?1.A S X=$S(X["MID":2400,X["NOON":1200,1:"")
10 S:$E(X,$L(X))="M" X=$E(X,1,$L(X)-1) S X1=$E(X,$L(X)) I X1?1U,"AP"'[X1 Q ""
11 S X1=$P(X,":",2) I X1'="",X1'?2N1.2U Q ""
12 I X'?4N,$S($L(+X)<3:+X,1:+X\100)>12 Q ""
13 S X=$P(X,":",1)_$P(X,":",2),X1=X
14 G:X?4N A I X'?1.4N1.2U Q ""
15 S:X<13 X=X*100 I X1["A" Q:X>1259 "" S X=$S(X=1200:2400,X>1159:X-1200,1:X)
16 E I X<1200,X1["P"!(X<600) S X=X+1200 I X<1300 Q ""
17A I X>2400!('X&(X'="0000"))!(X#100>59) Q ""
18 S X1=+X I 'X1!(X1=1200)!(X1=2400) S X=$S(X1=1200:"NOON",1:"MID") Q X
19 S X1=$S(X1>1259:X1-1200,1:X1),X1=$E("000",0,4-$L(X1))_X1_$S(X=2400:"A",X>1159:"P",1:"A")
20 ;I "00^15^30^45"'[$E(X1,3,4) Q "" ;NOT NEEDED FOR THIS PROJECT
21 S X=$E(X1,1,2)_":"_$E(X1,3,5)
22 Q X
23 ;
24DNE K X1 Q
25ERR K X,X1 Q
26 ;
27CNV(X) ; Convert Start/Stop to minutes AFTER MIDNIGHT RETURN startmin^stopmin
28 ;PASS START^STOP
29 N CNX,Y
30 ; X=start_"^"_stop Output: Y=start(min)_"^"_stop(min)
31 S CNX=X,X=$P(CNX,"^",1),Y=0,Y=$$MIL(X,Y),Y=Y\100*60+(Y#100),$P(CNX,"^",1)=Y
32 S X=$P(CNX,"^",2),Y=1,Y=$$MIL(X,Y),Y=Y\100*60+(Y#100)
33 S Y=$P(CNX,"^",1)_"^"_Y
34 Q Y
35 ;
36MIL(X,Y) ; Convert from AM/PM to 2400
37 ; X=time Y: 0=Mid=0,1=Mid=2400 Output: Y=time in 2400
38 I X="MID"!(X="NOON") S Y=$S(X="NOON":1200,Y:2400,1:0) Q Y
39 S Y=$P(X,":",1)_$P(X,":",2),Y=+Y Q:X["A" Y
40 S:Y<1200 Y=Y+1200
41 Q Y
42 ;
43DVAL051 ;
44 N YSAS
45 S YSAS=$$GET^DDSVAL(DIE,.DA,.052)
46 Q:YSAS=""
47 S YSAS=$$CNV(X_"^"_YSAS)
48 Q:$P(YSAS,"^",2)'<$P(YSAS,"^")
49 W $C(7)
50 S DDSERROR=1
51 D HLP^DDSUTL(YSASI1_" * * >> Time Begun cannot be after Time Ended << * *"_YSASI0)
52 Q
53 ;
54DVAL052 ;
55 N YSAS
56 S YSAS=$$GET^DDSVAL(DIE,.DA,.051)
57 Q:YSAS=""
58 S YSAS=$$CNV(YSAS_"^"_X)
59 Q:$P(YSAS,"^",2)'<$P(YSAS,"^")
60 W $C(7)
61 S DDSERROR=1
62 D HLP^DDSUTL(YSASI1_" * * >> Time Ended cannot be before Time Begun << * *"_YSASI0)
63 Q
64 ;
65 ;
66HELP ; Time Help
67 W !?5,"Time may be entered as 8A or 8a, 8:00A, 8:15A, 8:15AM or military"
68 W !?5,"time: 0800, 1300; or MID or 12M for midnight; NOON or 12N for noon."
69 W !?5,"Time must be in quarter hours; e.g., 8A or 8:15A or 8:30A or 8:45A.",!
70 Q
71HLP ;
72 N YSAS
73 S YSAS(1)="Time may be entered as 8A or 8a, 8:00A, 8:15A, 8:15AM or military"
74 S YSAS(2)="time: 0800, 1300; or MID or 12M for midnight; NOON or 12N for noon."
75 S YSAS(3)="Time must be in quarter hours; e.g., 8A or 8:15A or 8:30A or 8:45A."
76 D HLP^DDSUTL(.YSAS)
77 Q
Note: See TracBrowser for help on using the repository browser.