DGPFHLL1 ;ALB/RPM - PRF HL7 EVENT LOG API'S ; 2/23/06
;;5.3;Registration;**650**;Aug 13, 1993;Build 3
;
Q
;
GETEVNT(DGLIEN,DGPFL) ;retrieve a given record from PRF HL7 EVENT LOG (#26.21)
;
; Input:
; DGLIEN - IEN of PRF HL7 EVENT (#26.21)
;
; Output:
; Function value - 1 on success; 0 on failure
; DGPFL - array of event data fields
; Subscript Field#
; --------- ------
; "DFN" .01
; "EDT" .02
; "STAT" .03
;
N DGERR ;error array
N DGFLDS ;field result array
N DGIENS ;FM IENS string
N DGRSLT ;function value
;
S DGRSLT=0
I $G(DGLIEN),$D(^DGPF(26.21,DGLIEN)) D
. S DGIENS=DGLIEN_","
. D GETS^DIQ(26.21,DGIENS,"**","IEZ","DGFLDS","DGERR")
. Q:$D(DGERR)
. S DGRSLT=1
. S DGPFL("DFN")=$G(DGFLDS(26.21,DGIENS,.01,"I"))_U_$G(DGFLDS(26.21,DGIENS,.01,"E"))
. S DGPFL("EDT")=$G(DGFLDS(26.21,DGIENS,.02,"I"))_U_$G(DGFLDS(26.21,DGIENS,.02,"E"))
. S DGPFL("STAT")=$G(DGFLDS(26.21,DGIENS,.03,"I"))_U_$G(DGFLDS(26.21,DGIENS,.03,"E"))
;
Q DGRSLT
;
GETSTAT(DGDFN) ;retrieve event status for a given patient
;This function retrieves the internal value of the CURRENT STATUS
;(#.03) field in the PRF HL7 EVENT (#26.21) file and returns it as the
;function value.
;
; Input:
; DGDFN - pointer to patient in PATIENT (#2) file
;
; Output:
; Function value - returns CURRENT STATUS field value in Internal
; format on success; otherwise returns ""
;
N DGERR ;DIQ error array
;
Q:'+$G(DGDFN) ""
Q $$GET1^DIQ(26.21,$$FNDEVNT(DGDFN)_",",.03,"I","","DGERR")
;
FNDEVNT(DGDFN) ;find PRF HL7 EVENT (#26.21) file record number
;This function finds and returns the PRF HL7 EVENT (#26.21) file record
;number for a given patient.
;
; Input:
; DGDFN - pointer to patient in PATIENT (#2) file
;
; Output:
; Function value - IEN of PRF HL7 EVENT (#26.21) file on success;
; 0 on failure
;
N DGIEN ;function value
;
I +$G(DGDFN) D
. S DGIEN=$O(^DGPF(26.21,"B",DGDFN,0))
Q $S($G(DGIEN)>0:DGIEN,1:0)
;
STOEVNT(DGDFN,DGSTAT,DGERR) ;store event in PRF HL7 EVENT (#26.21) file
;
; Input:
; DGDFN - (required) pointer to patient in PATIENT (#2) file
; DGSTAT - (optional) event status [default = INCOMPLETE]
; DGERR - (optional) passed by reference to hold any FM errors
;
; Output:
; DGERR - only defined when FM call fails
;
N DGFDA ;FM FDA array
N DGFDAIEN ;UPDATE^DIE result
N DGLIEN ;PRF HL7 EVENT (#26.21) file IEN
N DGRSLT ;CHK^DIE result
;
S DGSTAT=$S($G(DGSTAT)]"":DGSTAT,1:"I")
I $G(DGDFN),$D(^DPT(DGDFN,0)) D
. S DGLIEN=$$FNDEVNT(DGDFN)
. D CHK^DIE(26.21,.03,,DGSTAT,.DGRSLT,"DGERR")
. Q:$D(DGERR)
. I DGLIEN D
. . S DGFDA(26.21,DGLIEN_",",.03)=DGSTAT
. . D FILE^DIE("","DGFDA","DGERR")
. E D
. . S DGFDA(26.21,"+1,",.01)=DGDFN
. . S DGFDA(26.21,"+1,",.02)=$$NOW^XLFDT()
. . S DGFDA(26.21,"+1,",.03)=DGSTAT
. . D UPDATE^DIE("","DGFDA","DGFDAIEN","DGERR")
;
Q
;
LOCK(DGIEN) ;lock HL7 event record
;This function locks a single PRF HL7 EVENT (#26.21) file record
;to prevent more than one PRF query being run at a time.
;
; Input:
; DGIEN - IEN of PRF HL7 EVENT (#26.21) file record
;
; Output:
; Function value - 1 on success; 0 on failure
;
I $G(DGIEN) L +^DGPF(26.21,DGIEN):2
;
Q $T
;
UNLOCK(DGIEN) ;unlock HL7 event record
;This procedure releases a lock on a PRF HL7 EVENT (#26.21) file record
;created by $$LOCK.
;
; Input:
; DGIEN - IEN of PRF HL7 EVENT (#26.21) file record
;
; Output:
;
I $G(DGIEN) L -^DGPF(26.21,DGIEN)
Q
;
ISINCOMP(DGIEN) ;is the HL7 event status INCOMPLETE?
;
; Input:
; DGIEN - IEN of PRF HL7 EVENT (#26.21) file record
;
; Output:
; Function value - return "1" when status is INCOMPLETE;
; otherwise return "0".
;
Q $D(^DGPF(26.21,"ASTAT","I",+$G(DGIEN)))
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDGPFHLL1 4026 printed Nov 22, 2024@17:57:37 Page 2
DGPFHLL1 ;ALB/RPM - PRF HL7 EVENT LOG API'S ; 2/23/06
+1 ;;5.3;Registration;**650**;Aug 13, 1993;Build 3
+2 ;
+3 QUIT
+4 ;
GETEVNT(DGLIEN,DGPFL) ;retrieve a given record from PRF HL7 EVENT LOG (#26.21)
+1 ;
+2 ; Input:
+3 ; DGLIEN - IEN of PRF HL7 EVENT (#26.21)
+4 ;
+5 ; Output:
+6 ; Function value - 1 on success; 0 on failure
+7 ; DGPFL - array of event data fields
+8 ; Subscript Field#
+9 ; --------- ------
+10 ; "DFN" .01
+11 ; "EDT" .02
+12 ; "STAT" .03
+13 ;
+14 ;error array
NEW DGERR
+15 ;field result array
NEW DGFLDS
+16 ;FM IENS string
NEW DGIENS
+17 ;function value
NEW DGRSLT
+18 ;
+19 SET DGRSLT=0
+20 IF $GET(DGLIEN)
IF $DATA(^DGPF(26.21,DGLIEN))
Begin DoDot:1
+21 SET DGIENS=DGLIEN_","
+22 DO GETS^DIQ(26.21,DGIENS,"**","IEZ","DGFLDS","DGERR")
+23 if $DATA(DGERR)
QUIT
+24 SET DGRSLT=1
+25 SET DGPFL("DFN")=$GET(DGFLDS(26.21,DGIENS,.01,"I"))_U_$GET(DGFLDS(26.21,DGIENS,.01,"E"))
+26 SET DGPFL("EDT")=$GET(DGFLDS(26.21,DGIENS,.02,"I"))_U_$GET(DGFLDS(26.21,DGIENS,.02,"E"))
+27 SET DGPFL("STAT")=$GET(DGFLDS(26.21,DGIENS,.03,"I"))_U_$GET(DGFLDS(26.21,DGIENS,.03,"E"))
End DoDot:1
+28 ;
+29 QUIT DGRSLT
+30 ;
GETSTAT(DGDFN) ;retrieve event status for a given patient
+1 ;This function retrieves the internal value of the CURRENT STATUS
+2 ;(#.03) field in the PRF HL7 EVENT (#26.21) file and returns it as the
+3 ;function value.
+4 ;
+5 ; Input:
+6 ; DGDFN - pointer to patient in PATIENT (#2) file
+7 ;
+8 ; Output:
+9 ; Function value - returns CURRENT STATUS field value in Internal
+10 ; format on success; otherwise returns ""
+11 ;
+12 ;DIQ error array
NEW DGERR
+13 ;
+14 if '+$GET(DGDFN)
QUIT ""
+15 QUIT $$GET1^DIQ(26.21,$$FNDEVNT(DGDFN)_",",.03,"I","","DGERR")
+16 ;
FNDEVNT(DGDFN) ;find PRF HL7 EVENT (#26.21) file record number
+1 ;This function finds and returns the PRF HL7 EVENT (#26.21) file record
+2 ;number for a given patient.
+3 ;
+4 ; Input:
+5 ; DGDFN - pointer to patient in PATIENT (#2) file
+6 ;
+7 ; Output:
+8 ; Function value - IEN of PRF HL7 EVENT (#26.21) file on success;
+9 ; 0 on failure
+10 ;
+11 ;function value
NEW DGIEN
+12 ;
+13 IF +$GET(DGDFN)
Begin DoDot:1
+14 SET DGIEN=$ORDER(^DGPF(26.21,"B",DGDFN,0))
End DoDot:1
+15 QUIT $SELECT($GET(DGIEN)>0:DGIEN,1:0)
+16 ;
STOEVNT(DGDFN,DGSTAT,DGERR) ;store event in PRF HL7 EVENT (#26.21) file
+1 ;
+2 ; Input:
+3 ; DGDFN - (required) pointer to patient in PATIENT (#2) file
+4 ; DGSTAT - (optional) event status [default = INCOMPLETE]
+5 ; DGERR - (optional) passed by reference to hold any FM errors
+6 ;
+7 ; Output:
+8 ; DGERR - only defined when FM call fails
+9 ;
+10 ;FM FDA array
NEW DGFDA
+11 ;UPDATE^DIE result
NEW DGFDAIEN
+12 ;PRF HL7 EVENT (#26.21) file IEN
NEW DGLIEN
+13 ;CHK^DIE result
NEW DGRSLT
+14 ;
+15 SET DGSTAT=$SELECT($GET(DGSTAT)]"":DGSTAT,1:"I")
+16 IF $GET(DGDFN)
IF $DATA(^DPT(DGDFN,0))
Begin DoDot:1
+17 SET DGLIEN=$$FNDEVNT(DGDFN)
+18 DO CHK^DIE(26.21,.03,,DGSTAT,.DGRSLT,"DGERR")
+19 if $DATA(DGERR)
QUIT
+20 IF DGLIEN
Begin DoDot:2
+21 SET DGFDA(26.21,DGLIEN_",",.03)=DGSTAT
+22 DO FILE^DIE("","DGFDA","DGERR")
End DoDot:2
+23 IF '$TEST
Begin DoDot:2
+24 SET DGFDA(26.21,"+1,",.01)=DGDFN
+25 SET DGFDA(26.21,"+1,",.02)=$$NOW^XLFDT()
+26 SET DGFDA(26.21,"+1,",.03)=DGSTAT
+27 DO UPDATE^DIE("","DGFDA","DGFDAIEN","DGERR")
End DoDot:2
End DoDot:1
+28 ;
+29 QUIT
+30 ;
LOCK(DGIEN) ;lock HL7 event record
+1 ;This function locks a single PRF HL7 EVENT (#26.21) file record
+2 ;to prevent more than one PRF query being run at a time.
+3 ;
+4 ; Input:
+5 ; DGIEN - IEN of PRF HL7 EVENT (#26.21) file record
+6 ;
+7 ; Output:
+8 ; Function value - 1 on success; 0 on failure
+9 ;
+10 IF $GET(DGIEN)
LOCK +^DGPF(26.21,DGIEN):2
+11 ;
+12 QUIT $TEST
+13 ;
UNLOCK(DGIEN) ;unlock HL7 event record
+1 ;This procedure releases a lock on a PRF HL7 EVENT (#26.21) file record
+2 ;created by $$LOCK.
+3 ;
+4 ; Input:
+5 ; DGIEN - IEN of PRF HL7 EVENT (#26.21) file record
+6 ;
+7 ; Output:
+8 ;
+9 IF $GET(DGIEN)
LOCK -^DGPF(26.21,DGIEN)
+10 QUIT
+11 ;
ISINCOMP(DGIEN) ;is the HL7 event status INCOMPLETE?
+1 ;
+2 ; Input:
+3 ; DGIEN - IEN of PRF HL7 EVENT (#26.21) file record
+4 ;
+5 ; Output:
+6 ; Function value - return "1" when status is INCOMPLETE;
+7 ; otherwise return "0".
+8 ;
+9 QUIT $DATA(^DGPF(26.21,"ASTAT","I",+$GET(DGIEN)))