HLUTIL1 ;ALB/RJS - HL7 UTILITIES ;1/17/95  11:15
 ;;1.6;HEALTH LEVEL SEVEN;;Oct 13, 1995
 ;
DAT1(X) ; Convert a FileMan date to a displayable (mm/dd/yy) format.
 Q $S(X:$E(X,4,5)_"/"_$E(X,6,7)_"/"_$E(X,2,3),1:"")
 ;
DAT2(Y) ; Convert a FileMan date to a displayable (mmm dd yyyy) format.
 Q:'$G(Y) ""
 N % D D^DIQ
 Q $TR(Y,"@"," ")
 ;
HLFM(Y) ; Convert a quasi HL7 formatted date to a Fileman date.
 I Y="" Q ""
 N % S Y=$TR(Y,".",""),%=$E(Y,9,14)
 Q $E(Y,1,2)-17_$E(Y,3,8)_$S(+%:+("."_%),1:"")
 ;
TASK(X) ; Is the background task currently running?
 ;  Input:   X  --  Task number for the background job
 ;  Output:  0  --  No, the job is not currently running
 ;           1  --  Yes, the job is currently running
 Q +$G(^%ZTSK(+$G(X),.1))=5
 ;
PAUSE() ; Pause for CRT output.
 ;  Input:   IOST, IOSL
 ;  Output:  0  --  Continue to display output
 ;           1  --  Quit
 Q:$E(IOST,1,2)'["C-" 0
 N DIR,DIRUT,DTOUT,DUOUT,HLJ
 F HLJ=$Y:1:(IOSL-5) W !
 S DIR(0)="E" D ^DIR
 Q $D(DIRUT)!($D(DUOUT))
EXPAND(FILE,FIELD,VALUE)        ; - returns internal data in an output format
 ; Taken from IVMUFNC w/help of CPM
 N Y,C S Y=VALUE
 I 'FILE!('FIELD)!(VALUE="") G EXPQ
 S Y=VALUE,C=$P(^DD(FILE,FIELD,0),"^",2) D Y^DIQ
EXPQ    Q Y
EVENT(EID,NODES,RESULT) ;Entry point to get event data from the Protocol file
 ;
 ;This is a subroutine call with parameter passing.  It returns each
 ;of the nodes from the Protocol file for the entry specified by EID
 ;in the array specified by the RESULT parameter
 ;
 ;Required Input Parameters
 ;     EID = The IEN of the protocol in the Protocol file for which
 ;             data is being requested
 ;   NODES = The node subscripts to be returned separated by commas.
 ;             Allowable subscripts are 15, 20, 770, 771, 772, 773
 ;             Example:  15,20,770
 ;  RESULT = The name of the array in which the nodes will be returned.
 ;             The node subscripts will be used as the array subscripts.
 ;             Example:  RESULT(15)=...
 ;
 ;Check for required parameter
 I '$G(EID)!($G(NODES)']"") Q
 I '$D(^ORD(101,EID,0)) Q
 ;Get data for nodes requested
 I NODES[15 S RESULT(15)=$G(^ORD(101,EID,15))
 I NODES[20 S RESULT(20)=$G(^ORD(101,EID,20))
 I NODES[770 S RESULT(770)=$G(^ORD(101,EID,770))
 I NODES[771 S RESULT(771)=$G(^ORD(101,EID,771))
 I NODES[772 S RESULT(772)=$G(^ORD(101,EID,772))
 I NODES[773 S RESULT(773)=$G(^ORD(101,EID,773))
 Q
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHLUTIL1   2465     printed  Sep 23, 2025@19:36:34                                                                                                                                                                                                     Page 2
HLUTIL1   ;ALB/RJS - HL7 UTILITIES ;1/17/95  11:15
 +1       ;;1.6;HEALTH LEVEL SEVEN;;Oct 13, 1995
 +2       ;
DAT1(X)   ; Convert a FileMan date to a displayable (mm/dd/yy) format.
 +1        QUIT $SELECT(X:$EXTRACT(X,4,5)_"/"_$EXTRACT(X,6,7)_"/"_$EXTRACT(X,2,3),1:"")
 +2       ;
DAT2(Y)   ; Convert a FileMan date to a displayable (mmm dd yyyy) format.
 +1        if '$GET(Y)
               QUIT ""
 +2        NEW %
           DO D^DIQ
 +3        QUIT $TRANSLATE(Y,"@"," ")
 +4       ;
HLFM(Y)   ; Convert a quasi HL7 formatted date to a Fileman date.
 +1        IF Y=""
               QUIT ""
 +2        NEW %
           SET Y=$TRANSLATE(Y,".","")
           SET %=$EXTRACT(Y,9,14)
 +3        QUIT $EXTRACT(Y,1,2)-17_$EXTRACT(Y,3,8)_$SELECT(+%:+("."_%),1:"")
 +4       ;
TASK(X)   ; Is the background task currently running?
 +1       ;  Input:   X  --  Task number for the background job
 +2       ;  Output:  0  --  No, the job is not currently running
 +3       ;           1  --  Yes, the job is currently running
 +4        QUIT +$GET(^%ZTSK(+$GET(X),.1))=5
 +5       ;
PAUSE()   ; Pause for CRT output.
 +1       ;  Input:   IOST, IOSL
 +2       ;  Output:  0  --  Continue to display output
 +3       ;           1  --  Quit
 +4        if $EXTRACT(IOST,1,2)'["C-"
               QUIT 0
 +5        NEW DIR,DIRUT,DTOUT,DUOUT,HLJ
 +6        FOR HLJ=$Y:1:(IOSL-5)
               WRITE !
 +7        SET DIR(0)="E"
           DO ^DIR
 +8        QUIT $DATA(DIRUT)!($DATA(DUOUT))
EXPAND(FILE,FIELD,VALUE) ; - returns internal data in an output format
 +1       ; Taken from IVMUFNC w/help of CPM
 +2        NEW Y,C
           SET Y=VALUE
 +3        IF 'FILE!('FIELD)!(VALUE="")
               GOTO EXPQ
 +4        SET Y=VALUE
           SET C=$PIECE(^DD(FILE,FIELD,0),"^",2)
           DO Y^DIQ
EXPQ       QUIT Y
EVENT(EID,NODES,RESULT) ;Entry point to get event data from the Protocol file
 +1       ;
 +2       ;This is a subroutine call with parameter passing.  It returns each
 +3       ;of the nodes from the Protocol file for the entry specified by EID
 +4       ;in the array specified by the RESULT parameter
 +5       ;
 +6       ;Required Input Parameters
 +7       ;     EID = The IEN of the protocol in the Protocol file for which
 +8       ;             data is being requested
 +9       ;   NODES = The node subscripts to be returned separated by commas.
 +10      ;             Allowable subscripts are 15, 20, 770, 771, 772, 773
 +11      ;             Example:  15,20,770
 +12      ;  RESULT = The name of the array in which the nodes will be returned.
 +13      ;             The node subscripts will be used as the array subscripts.
 +14      ;             Example:  RESULT(15)=...
 +15      ;
 +16      ;Check for required parameter
 +17       IF '$GET(EID)!($GET(NODES)']"")
               QUIT 
 +18       IF '$DATA(^ORD(101,EID,0))
               QUIT 
 +19      ;Get data for nodes requested
 +20       IF NODES[15
               SET RESULT(15)=$GET(^ORD(101,EID,15))
 +21       IF NODES[20
               SET RESULT(20)=$GET(^ORD(101,EID,20))
 +22       IF NODES[770
               SET RESULT(770)=$GET(^ORD(101,EID,770))
 +23       IF NODES[771
               SET RESULT(771)=$GET(^ORD(101,EID,771))
 +24       IF NODES[772
               SET RESULT(772)=$GET(^ORD(101,EID,772))
 +25       IF NODES[773
               SET RESULT(773)=$GET(^ORD(101,EID,773))
 +26       QUIT