DGQEHLL ;ALB/RPM - VIC REPLACEMENT VIC HL7 TRAN LOG FILE ACCESS API'S ; 12/09/03
;;5.3;Registration;**571,1015**;Aug 13, 1993;Build 21
;
; This routine contains the functions and procedures used to access
; and manipulate the VIC HL7 TRANSMISSION LOG (#39.7) file.
;
; $$FINDMID - locate transmission record for a given HL7 message ID
; $$FINDLST - locate last transmission record for a given request
; $$GETLOG - retrieve a single VIC HL7 TRANSMISSION LOG record
; STOXMIT - store a new VIC HL7 TRANSMISSION LOG record
; STOACK - store acknowledgment status and date
; $$DELXMIT - delete a single VIC HL7 TRANSMISSION LOG record
;
Q ;no direct entry
;
FINDMID(DGMID) ;locate record for a given HL7 message ID
; This function performs a lookup of the VIC HL7 TRANSMISSION LOG
; (#39.7) file for a given HL7 Message ID.
;
; Input:
; DGMID - HL7 message ID
;
; Output:
; Function value - IEN of VIC HL7 TRANSMISSION LOG (#39.7) on success;
; 0 on failure
;
S DGMID=+$G(DGMID)
Q +$O(^DGQE(39.7,"B",DGMID,""))
;
;
FINDLST(DGREQ) ;locate the last transmission record for a given request
;
; Input:
; DGIEN - pointer to VIC REQUEST (#39.6) file
;
; Output:
; Function value - IEN of VIC HL7 TRANSMISSION LOG (#39.7) on success,
; 0 on failure
;
N DGDAT
;
S DGDAT=+$O(^DGQE(39.7,"ADATE",DGREQ,""),-1)
Q +$O(^DGQE(39.7,"ADATE",DGREQ,DGDAT,0))
;
;
GETLOG(DGIEN,DGLOG) ;retrieve a single record
; This function retrieves all fields belonging to a single record
; in the VIC HL7 TRANSMISSION LOG (#39.7) file for a given IEN.
; The field data is placed in an array format.
;
; Input:
; DGIEN - VIC HL7 TRANSMISSION LOG (#39.7) file record number
;
; Output:
; Function value - 1 on success, 0 on failure
; DGLOG - array of field data
; Array subscripts are:
; "HLMID" - HL7 Message ID
; "REQIEN" - pointer to request in VIC REQUEST (#39.6) file
; "XMITDT" - HL7 Transmission date/time
; "XMSTAT" - Transmission status
; "ACKDT" - ACK received date/time
;
N DGERR ;FM result error message
N DGFIL ;FM file number
N DGFLD ;FM result field array
N DGIENS ;FM IENS value
N DGRSLT ;function value
;
S DGRSLT=0
S DGFIL=39.7
;
I $G(DGIEN),$D(^DGQE(DGFIL,DGIEN)) D
. S DGIENS=DGIEN_","
. D GETS^DIQ(DGFIL,DGIENS,"*","I","DGFLD","DGERR")
. Q:$D(DGERR)
. S DGLOG("HLMID")=$G(DGFLD(DGFIL,DGIENS,.01,"I"))
. S DGLOG("REQIEN")=$G(DGFLD(DGFIL,DGIENS,.02,"I"))
. S DGLOG("XMITDT")=$G(DGFLD(DGFIL,DGIENS,.03,"I"))
. S DGLOG("XMSTAT")=$G(DGFLD(DGFIL,DGIENS,.04,"I"))
. S DGLOG("ACKDT")=$G(DGFLD(DGFIL,DGIENS,.05,"I"))
. S DGRSLT=1 ;success
;
Q DGRSLT
;
;
STOXMIT(DGMID,DGRIEN) ;create a transmit record
; This procedure creates a record in the VIC HL7 TRANSMISSION LOG
; (#39.7) file.
;
; Input:
; DGMID - HL7 Message Control ID
; DGRIEN - IEN of record in VIC REQUEST (#39.6) file
;
; Output:
; none
;
N DGERR
N DGFDA
N DGFIL
N DGIEN
N DGIENS
;
;validate input params
Q:$G(DGMID)'>0
Q:'$G(DGRIEN)
Q:'$D(^DGQE(39.6,DGRIEN))
;
S DGFIL=39.7
S DGIEN=$$FINDMID(DGMID)
S DGIENS=$S('DGIEN:"+1,",1:DGIEN_",")
;
S DGFDA(DGFIL,DGIENS,.01)=DGMID
S DGFDA(DGFIL,DGIENS,.02)=DGRIEN
S DGFDA(DGFIL,DGIENS,.03)=$$NOW^XLFDT()
S DGFDA(DGFIL,DGIENS,.04)="T" ;transmitted
D UPDATE^DIE("","DGFDA","","DGERR")
;
Q
;
;
STOACK(DGIEN,DGSTAT) ;update STATUS
; This procedure updates the STATUS (#.04) field of the VIC HL7
; TRANSMISSION LOG (#39.7) file
;
; Input:
; DGIEN - IEN of record in VIC HL7 TRANSMISSION LOG (#39.7) file
; DGSTAT - transmission status ("A":Accepted,"RJ":Rejected)
;
; Output:
; none
;
N DGERR
N DGFDA
N DGIENS
;
;validate input params
Q:'$G(DGIEN)
Q:$G(DGSTAT)']""
Q:$$EXTERNAL^DILFD(39.7,.04,"F",DGSTAT,"")']""
;
S DGIENS=DGIEN_","
S DGFDA(39.7,DGIENS,.04)=DGSTAT
S DGFDA(39.7,DGIENS,.05)=$$NOW^XLFDT()
D FILE^DIE("","DGFDA","DGERR")
Q
;
;
DELXMIT(DGIEN) ;delete a single VIC HL7 TRANSMISSION LOG record
;
; Input:
; DGIEN - IEN of record in VIC HL7 TRANSMISSION LOG (#39.7) file
;
; Output:
; Function value - 1 on success, 0 on failure
;
N DGERR
N DGFDA
N DGRSLT ;function value
;
S DGRSLT=0
I $G(DGIEN) D
. S DGFDA(39.7,DGIEN_",",.01)="@"
. D FILE^DIE("","DGFDA","DGERR")
. Q:$D(DGERR)
. S DGRSLT=1 ;success
;
Q DGRSLT
DGQEHLL ;ALB/RPM - VIC REPLACEMENT VIC HL7 TRAN LOG FILE ACCESS API'S ; 12/09/03
+1 ;;5.3;Registration;**571,1015**;Aug 13, 1993;Build 21
+2 ;
+3 ; This routine contains the functions and procedures used to access
+4 ; and manipulate the VIC HL7 TRANSMISSION LOG (#39.7) file.
+5 ;
+6 ; $$FINDMID - locate transmission record for a given HL7 message ID
+7 ; $$FINDLST - locate last transmission record for a given request
+8 ; $$GETLOG - retrieve a single VIC HL7 TRANSMISSION LOG record
+9 ; STOXMIT - store a new VIC HL7 TRANSMISSION LOG record
+10 ; STOACK - store acknowledgment status and date
+11 ; $$DELXMIT - delete a single VIC HL7 TRANSMISSION LOG record
+12 ;
+13 ;no direct entry
QUIT
+14 ;
FINDMID(DGMID) ;locate record for a given HL7 message ID
+1 ; This function performs a lookup of the VIC HL7 TRANSMISSION LOG
+2 ; (#39.7) file for a given HL7 Message ID.
+3 ;
+4 ; Input:
+5 ; DGMID - HL7 message ID
+6 ;
+7 ; Output:
+8 ; Function value - IEN of VIC HL7 TRANSMISSION LOG (#39.7) on success;
+9 ; 0 on failure
+10 ;
+11 SET DGMID=+$GET(DGMID)
+12 QUIT +$ORDER(^DGQE(39.7,"B",DGMID,""))
+13 ;
+14 ;
FINDLST(DGREQ) ;locate the last transmission record for a given request
+1 ;
+2 ; Input:
+3 ; DGIEN - pointer to VIC REQUEST (#39.6) file
+4 ;
+5 ; Output:
+6 ; Function value - IEN of VIC HL7 TRANSMISSION LOG (#39.7) on success,
+7 ; 0 on failure
+8 ;
+9 NEW DGDAT
+10 ;
+11 SET DGDAT=+$ORDER(^DGQE(39.7,"ADATE",DGREQ,""),-1)
+12 QUIT +$ORDER(^DGQE(39.7,"ADATE",DGREQ,DGDAT,0))
+13 ;
+14 ;
GETLOG(DGIEN,DGLOG) ;retrieve a single record
+1 ; This function retrieves all fields belonging to a single record
+2 ; in the VIC HL7 TRANSMISSION LOG (#39.7) file for a given IEN.
+3 ; The field data is placed in an array format.
+4 ;
+5 ; Input:
+6 ; DGIEN - VIC HL7 TRANSMISSION LOG (#39.7) file record number
+7 ;
+8 ; Output:
+9 ; Function value - 1 on success, 0 on failure
+10 ; DGLOG - array of field data
+11 ; Array subscripts are:
+12 ; "HLMID" - HL7 Message ID
+13 ; "REQIEN" - pointer to request in VIC REQUEST (#39.6) file
+14 ; "XMITDT" - HL7 Transmission date/time
+15 ; "XMSTAT" - Transmission status
+16 ; "ACKDT" - ACK received date/time
+17 ;
+18 ;FM result error message
NEW DGERR
+19 ;FM file number
NEW DGFIL
+20 ;FM result field array
NEW DGFLD
+21 ;FM IENS value
NEW DGIENS
+22 ;function value
NEW DGRSLT
+23 ;
+24 SET DGRSLT=0
+25 SET DGFIL=39.7
+26 ;
+27 IF $GET(DGIEN)
IF $DATA(^DGQE(DGFIL,DGIEN))
Begin DoDot:1
+28 SET DGIENS=DGIEN_","
+29 DO GETS^DIQ(DGFIL,DGIENS,"*","I","DGFLD","DGERR")
+30 IF $DATA(DGERR)
QUIT
+31 SET DGLOG("HLMID")=$GET(DGFLD(DGFIL,DGIENS,.01,"I"))
+32 SET DGLOG("REQIEN")=$GET(DGFLD(DGFIL,DGIENS,.02,"I"))
+33 SET DGLOG("XMITDT")=$GET(DGFLD(DGFIL,DGIENS,.03,"I"))
+34 SET DGLOG("XMSTAT")=$GET(DGFLD(DGFIL,DGIENS,.04,"I"))
+35 SET DGLOG("ACKDT")=$GET(DGFLD(DGFIL,DGIENS,.05,"I"))
+36 ;success
SET DGRSLT=1
End DoDot:1
+37 ;
+38 QUIT DGRSLT
+39 ;
+40 ;
STOXMIT(DGMID,DGRIEN) ;create a transmit record
+1 ; This procedure creates a record in the VIC HL7 TRANSMISSION LOG
+2 ; (#39.7) file.
+3 ;
+4 ; Input:
+5 ; DGMID - HL7 Message Control ID
+6 ; DGRIEN - IEN of record in VIC REQUEST (#39.6) file
+7 ;
+8 ; Output:
+9 ; none
+10 ;
+11 NEW DGERR
+12 NEW DGFDA
+13 NEW DGFIL
+14 NEW DGIEN
+15 NEW DGIENS
+16 ;
+17 ;validate input params
+18 IF $GET(DGMID)'>0
QUIT
+19 IF '$GET(DGRIEN)
QUIT
+20 IF '$DATA(^DGQE(39.6,DGRIEN))
QUIT
+21 ;
+22 SET DGFIL=39.7
+23 SET DGIEN=$$FINDMID(DGMID)
+24 SET DGIENS=$SELECT('DGIEN:"+1,",1:DGIEN_",")
+25 ;
+26 SET DGFDA(DGFIL,DGIENS,.01)=DGMID
+27 SET DGFDA(DGFIL,DGIENS,.02)=DGRIEN
+28 SET DGFDA(DGFIL,DGIENS,.03)=$$NOW^XLFDT()
+29 ;transmitted
SET DGFDA(DGFIL,DGIENS,.04)="T"
+30 DO UPDATE^DIE("","DGFDA","","DGERR")
+31 ;
+32 QUIT
+33 ;
+34 ;
STOACK(DGIEN,DGSTAT) ;update STATUS
+1 ; This procedure updates the STATUS (#.04) field of the VIC HL7
+2 ; TRANSMISSION LOG (#39.7) file
+3 ;
+4 ; Input:
+5 ; DGIEN - IEN of record in VIC HL7 TRANSMISSION LOG (#39.7) file
+6 ; DGSTAT - transmission status ("A":Accepted,"RJ":Rejected)
+7 ;
+8 ; Output:
+9 ; none
+10 ;
+11 NEW DGERR
+12 NEW DGFDA
+13 NEW DGIENS
+14 ;
+15 ;validate input params
+16 IF '$GET(DGIEN)
QUIT
+17 IF $GET(DGSTAT)']""
QUIT
+18 IF $$EXTERNAL^DILFD(39.7,.04,"F",DGSTAT,"")']""
QUIT
+19 ;
+20 SET DGIENS=DGIEN_","
+21 SET DGFDA(39.7,DGIENS,.04)=DGSTAT
+22 SET DGFDA(39.7,DGIENS,.05)=$$NOW^XLFDT()
+23 DO FILE^DIE("","DGFDA","DGERR")
+24 QUIT
+25 ;
+26 ;
DELXMIT(DGIEN) ;delete a single VIC HL7 TRANSMISSION LOG record
+1 ;
+2 ; Input:
+3 ; DGIEN - IEN of record in VIC HL7 TRANSMISSION LOG (#39.7) file
+4 ;
+5 ; Output:
+6 ; Function value - 1 on success, 0 on failure
+7 ;
+8 NEW DGERR
+9 NEW DGFDA
+10 ;function value
NEW DGRSLT
+11 ;
+12 SET DGRSLT=0
+13 IF $GET(DGIEN)
Begin DoDot:1
+14 SET DGFDA(39.7,DGIEN_",",.01)="@"
+15 DO FILE^DIE("","DGFDA","DGERR")
+16 IF $DATA(DGERR)
QUIT
+17 ;success
SET DGRSLT=1
End DoDot:1
+18 ;
+19 QUIT DGRSLT