source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SDAMUTDT.m@ 1476

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

initial load of WorldVistAEHR

File size: 3.5 KB
Line 
1SDAMUTDT ;BPOIFO/JFW-Scheduling Encapsulation Utilities ; 5/17/04 1:00pm
2 ;;5.3;Scheduling;**266**;13 Aug 1993
3 ;
4 ;*****************************************************************
5 ; CHANGE LOG
6 ;
7 ; DATE PATCH DESCRIPTION
8 ;-------- ---------- -----------------------------------------
9 ;1/24/06 SD*5.3*413 ROUTINE COMPLETED
10 ;
11 ;*****************************************************************
12 ;
13FMTGMT(SDFMDT) ;convert internal fileman format to extended GMT
14 ;initialize variables
15 ;*****************************************************************
16 ;INPUT SDFMDT - Fileman date/time
17 ;OUTPUT -1 error occurred in translation
18 ; GMT date/time in ISO 8601 extended format (No Errors)
19 ;*****************************************************************
20 N SDDTM,SDGMT,SDTIME,SDOFFSET
21 S SDDTM=$$FMTHL7^XLFDT(SDFMDT)
22 Q:SDDTM<0 -1
23 ;extract out date and convert to ISO 8601 extended format
24 S SDGMT=$E(SDDTM,1,4)_"-"_$E(SDDTM,5,6)_"-"_$E(SDDTM,7,8)
25 ;if time is included, extract and convert to ISO 8601 external format
26 I $L(SDDTM)>8 D
27 .S SDTIME=$E(+SDDTM,9,99),SDOFFSET=$$TZ^XLFDT()
28 .;determine if seconds are included in time
29 .I $L(SDTIME)<5 D
30 ..;no seconds included in date/time
31 ..S SDGMT=SDGMT_"T"_$E(SDDTM,9,10)_":"_$E(SDDTM,11,99)
32 .;seconds included in date/time
33 .E S SDGMT=SDGMT_"T"_$E(SDTIME,1,2)_":"_$E(SDTIME,3,4)_":"_$E(SDTIME,5,6)_SDOFFSET
34 Q SDGMT
35 ;
36GMTTFM(SDGMTDT) ;convert ISO 8601 extended GMT date/time to fileman format
37 ;initialize variables
38 ;*****************************************************************
39 ;INPUT SDGMTDT - ISO 8601 extended GMT date/time
40 ;OUTPUT -1 error occurred in translation
41 ; FM date/time (No Errors)
42 ;*****************************************************************
43 N SDFM,SDTIME,SDOFFSET,SDFMDTM,X,Y,%DT
44 ;get offset for VistA Instance
45 S SDOFFSET=$$TZ^XLFDT()
46 ;pattern match date(/time) for correctness
47 Q:((SDGMTDT["T")&'(SDGMTDT?4N1"-"2N1"-"2N1"T"2N1":"2N.E)) -1
48 Q:((SDGMTDT'["T")&'(SDGMTDT?4N1"-"2N1"-"2N)) -1
49 ;extract out date, removing punctuation
50 S SDFM=$E(SDGMTDT,1,4)_$E(SDGMTDT,6,7)_$E(SDGMTDT,9,10)
51 ;set parameters to validate date/time
52 S %DT="TXS"
53 ;extract out time if entered, removing all punctuation except for TZ offset
54 I SDGMTDT>10 D
55 .S SDTIME=$P($E(SDGMTDT,12,99),$E(SDOFFSET,1,1))
56 .;exclude time if 0's else FMTE returns previous date with .24
57 .Q:((SDTIME["00:00")!(SDTIME["00:00:00"))
58 .;determine if seconds are included in time
59 .I $L(SDTIME)<6 D
60 ..;no seconds include in date/time
61 ..S SDFM=SDFM_$E(SDGMTDT,12,13)_$E(SDGMTDT,15,99)
62 .;seconds included in date/time
63 .E S SDFM=SDFM_$E(SDTIME,1,2)_$E(SDTIME,4,5)_$E(SDTIME,7,8)_"-"_SDOFFSET
64 ;convert date(/time) from HL7 format back to Fileman
65 S SDFMDTM=$$HL7TFM^XLFDT(SDFM)
66 Q:SDFMDTM<0 SDFMDTM ;error occurred in conversion
67 ;check validity of date (including leap year check)
68 S X=$$FMTE^XLFDT(SDFMDTM)
69 D ^%DT
70 Q:Y<0 -1 ;date(/time) not valid
71 Q SDFMDTM
72 ;
73SDAPIERR() ; SDAPI Error Messages.
74 ;*****************************************************************
75 ;INPUT N/A
76 ;OUTPUT Extrinsic call returns error message
77 ;*****************************************************************
78 N SDERR S SDERR=$O(^TMP($J,"SDAMA301",""))
79 I SDERR="" Q ""
80 I +SDERR=101 Q "Error 101: The Appointment Database is not currently available. Please try again later."
81 I +SDERR=115 Q "Error 115: Appointment request contains invalid values. Please contact National Help Desk."
82 Q "Error 117: An error has occurred, check the RSA Error Log."
83 ;
Note: See TracBrowser for help on using the repository browser.