HDISVU01 ;BPFO/JRP - UTILITY CALLS;12/21/2004
;;1.0;HEALTH DATA & INFORMATICS;**6**;Feb 22, 2005
;
XMLTFM(XMLDT,LTZ) ;Convert XML date/time to FM date/time
; Input : XMLDT - XML date/time
; LTZ - Flag indicating if time should be converted to local
; time (XML d/t contains time zone designation)
; 0 = No (default) 1 = Yes
;Output : Date/time in FileMan format
; Notes : Null ("") returned on error
N HL7DT,FMDT
S XMLDT=$G(XMLDT)
I XMLDT="" Q ""
S LTZ=+$G(LTZ)
S LTZ=$S(LTZ:"L",1:"U")
;Convert to HL7 format
S HL7DT=$TR($P(XMLDT,"T",1),"-")_$TR($P(XMLDT,"T",2),":")
;Convert HL7 format to FileMan format
S FMDT=$$HL7TFM^XLFDT(HL7DT,LTZ)
I FMDT=-1 S FMDT=""
Q FMDT
;
FMTXML(FMDT,NOTIME,MIDNIGHT) ;Convert FM date/time to XML date/time
; Input : FMDT - FileMan date/time
; NOTIME - Flag indicating if time shouldn't be included
; 0 = No (include time)(default) 1 = Yes (no time)
; MIDNIGHT - Flag indicating if midnight should be used when
; no time is passed in
; 0 = No (leave as is)(default) 1 = Yes
;Output : Date/time in XML format
; Notes : Null ("") returned on error
N XTRNDT,XMLDT,FLAG
S NOTIME=+$G(NOTIME)
S MIDNIGHT=+$G(MIDNIGHT)
I $P(FMDT,".",2)="" I 'MIDNIGHT S NOTIME=1
I $P(FMDT,".",2)?1."0" I 'NOTIME S MIDNIGHT=1
;No time overrides midnight addition
I NOTIME S MIDNIGHT=0
;Drop time
S FLAG=$S(NOTIME:"7FD",1:"7FS")
;Convert
S XTRNDT=$$FMTE^XLFDT(FMDT,FLAG)
;Append midnight
I MIDNIGHT I $P(XTRNDT,"@",2)="" S $P(XTRNDT,"@",2)="00:00:00"
S XMLDT=$TR(XTRNDT,"@ /","T0-")
I 'NOTIME S XMLDT=XMLDT_$$TZ^XLFDT()
Q XMLDT
;
ERR2XTMP(NODE,DESC,TEXTARR) ;Add error info to XTMP global
; Input : NODE - Namespaced node name to store info off of
; (Defaults to "HDI")
; DESC - Error description (short text)
; TEXTARR - Array containing error text (full global ref)
;Output : None
; Notes : Sets the following nodes in XTMP
; ^XTMP(NODE,0) = Purge Date (T+10) ^ Create Date (NOW)
; ^ "HDI software issues"
; ^XTMP(NODE,x,0) = Create Date (NOW) ^ DESC
; ^XTMP(NODE,x,"ERR") = TEXTARR
S NODE=$G(NODE)
S:NODE="" NODE="HDI"
S DESC=$G(DESC)
S TEXTARR=$G(TEXTARR)
N CDATE,PDATE,SUB
;Set main node in XTMP
S CDATE=$$NOW^XLFDT()
S PDATE=$$FMADD^XLFDT(CDATE,10)
S ^XTMP(NODE,0)=PDATE_"^"_CDATE_"^HDI software issues"
;Get next error node
S SUB=1+$O(^XTMP(NODE,""),-1)
;Set main error node
S ^XTMP(NODE,SUB,0)=CDATE_"^"_DESC
;Store error text
I TEXTARR'="" M ^XTMP(NODE,SUB,"TXT")=@TEXTARR
;Done
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHDISVU01 2744 printed Oct 16, 2024@17:57:55 Page 2
HDISVU01 ;BPFO/JRP - UTILITY CALLS;12/21/2004
+1 ;;1.0;HEALTH DATA & INFORMATICS;**6**;Feb 22, 2005
+2 ;
XMLTFM(XMLDT,LTZ) ;Convert XML date/time to FM date/time
+1 ; Input : XMLDT - XML date/time
+2 ; LTZ - Flag indicating if time should be converted to local
+3 ; time (XML d/t contains time zone designation)
+4 ; 0 = No (default) 1 = Yes
+5 ;Output : Date/time in FileMan format
+6 ; Notes : Null ("") returned on error
+7 NEW HL7DT,FMDT
+8 SET XMLDT=$GET(XMLDT)
+9 IF XMLDT=""
QUIT ""
+10 SET LTZ=+$GET(LTZ)
+11 SET LTZ=$SELECT(LTZ:"L",1:"U")
+12 ;Convert to HL7 format
+13 SET HL7DT=$TRANSLATE($PIECE(XMLDT,"T",1),"-")_$TRANSLATE($PIECE(XMLDT,"T",2),":")
+14 ;Convert HL7 format to FileMan format
+15 SET FMDT=$$HL7TFM^XLFDT(HL7DT,LTZ)
+16 IF FMDT=-1
SET FMDT=""
+17 QUIT FMDT
+18 ;
FMTXML(FMDT,NOTIME,MIDNIGHT) ;Convert FM date/time to XML date/time
+1 ; Input : FMDT - FileMan date/time
+2 ; NOTIME - Flag indicating if time shouldn't be included
+3 ; 0 = No (include time)(default) 1 = Yes (no time)
+4 ; MIDNIGHT - Flag indicating if midnight should be used when
+5 ; no time is passed in
+6 ; 0 = No (leave as is)(default) 1 = Yes
+7 ;Output : Date/time in XML format
+8 ; Notes : Null ("") returned on error
+9 NEW XTRNDT,XMLDT,FLAG
+10 SET NOTIME=+$GET(NOTIME)
+11 SET MIDNIGHT=+$GET(MIDNIGHT)
+12 IF $PIECE(FMDT,".",2)=""
IF 'MIDNIGHT
SET NOTIME=1
+13 IF $PIECE(FMDT,".",2)?1."0"
IF 'NOTIME
SET MIDNIGHT=1
+14 ;No time overrides midnight addition
+15 IF NOTIME
SET MIDNIGHT=0
+16 ;Drop time
+17 SET FLAG=$SELECT(NOTIME:"7FD",1:"7FS")
+18 ;Convert
+19 SET XTRNDT=$$FMTE^XLFDT(FMDT,FLAG)
+20 ;Append midnight
+21 IF MIDNIGHT
IF $PIECE(XTRNDT,"@",2)=""
SET $PIECE(XTRNDT,"@",2)="00:00:00"
+22 SET XMLDT=$TRANSLATE(XTRNDT,"@ /","T0-")
+23 IF 'NOTIME
SET XMLDT=XMLDT_$$TZ^XLFDT()
+24 QUIT XMLDT
+25 ;
ERR2XTMP(NODE,DESC,TEXTARR) ;Add error info to XTMP global
+1 ; Input : NODE - Namespaced node name to store info off of
+2 ; (Defaults to "HDI")
+3 ; DESC - Error description (short text)
+4 ; TEXTARR - Array containing error text (full global ref)
+5 ;Output : None
+6 ; Notes : Sets the following nodes in XTMP
+7 ; ^XTMP(NODE,0) = Purge Date (T+10) ^ Create Date (NOW)
+8 ; ^ "HDI software issues"
+9 ; ^XTMP(NODE,x,0) = Create Date (NOW) ^ DESC
+10 ; ^XTMP(NODE,x,"ERR") = TEXTARR
+11 SET NODE=$GET(NODE)
+12 if NODE=""
SET NODE="HDI"
+13 SET DESC=$GET(DESC)
+14 SET TEXTARR=$GET(TEXTARR)
+15 NEW CDATE,PDATE,SUB
+16 ;Set main node in XTMP
+17 SET CDATE=$$NOW^XLFDT()
+18 SET PDATE=$$FMADD^XLFDT(CDATE,10)
+19 SET ^XTMP(NODE,0)=PDATE_"^"_CDATE_"^HDI software issues"
+20 ;Get next error node
+21 SET SUB=1+$ORDER(^XTMP(NODE,""),-1)
+22 ;Set main error node
+23 SET ^XTMP(NODE,SUB,0)=CDATE_"^"_DESC
+24 ;Store error text
+25 IF TEXTARR'=""
MERGE ^XTMP(NODE,SUB,"TXT")=@TEXTARR
+26 ;Done
+27 QUIT