DGQEREQ ;ALB/RPM - VIC REPLACEMENT VIC REQUEST 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 REQUEST (#39.6) file.
;
; $$FINDCID - locate NCMD Card ID
; $$FINDLST - locate last (most recent) VIC request
; $$GETREQ - retrieve a single VIC REQUEST record
; $$STOCID - store the NCMD Card ID
; $$STOSTAT - store the Card Print Release Status
; $$DELREQ - delete a single VIC REQUEST record
;
Q ;no direct entry
;
FINDCID(DGCID) ;locate record for a given NCMD Card ID
; This function performs a lookup of the VIC REQUEST (#39.6) file
; for a given Card ID.
;
; Input:
; DGCID - NCMD Card ID
;
; Output:
; Function value - IEN of VIC REQUEST on success;
; 0 on failure
;
Q:$G(DGCID)']"" 0
Q +$O(^DGQE(39.6,"B",DGCID,""))
;
;
FINDLST(DGDFN) ;locate the IEN of the last request for a given patient
;
; Input:
; DGDFN - pointer to patient in PATIENT (#2) file
;
; Output:
; Function value - IEN of VIC REQUEST (#39.6) file on success,
; 0 on failure
;
N DGDAT
;
S DGDFN=+$G(DGDFN)
S DGDAT=+$O(^DGQE(39.6,"APDAT",DGDFN,""),-1)
Q +$O(^DGQE(39.6,"APDAT",DGDFN,DGDAT,0))
;
;
GETREQ(DGIEN,DGREQ) ;retrieve a single record
; This function retrieves all fields belonging to a single record
; in the VIC REQUEST (#39.6) file for a given IEN. The field data
; is placed in an array format.
;
; Input:
; DGIEN - VIC REQUEST (#39.6) file record number
;
; Output:
; Function value - 1 on success, 0 on failure
; DGREQ - array of field data
; Array subscripts are:
; "DFN" - pointer to patient in PATIENT (#2) file
; "CARDID" - NCMD Card ID
; "NAME" - patient name
; "CPRSTAT" - card print release status
; "REQDATE" - VIC Request Date in internal format
;
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.6
;
I $G(DGIEN),$D(^DGQE(DGFIL,DGIEN)) D
. S DGIENS=DGIEN_","
. D GETS^DIQ(DGFIL,DGIENS,"*","IE","DGFLD","DGERR")
. Q:$D(DGERR)
. S DGREQ("CARDID")=$G(DGFLD(DGFIL,DGIENS,.01,"I"))
. S DGREQ("DFN")=$G(DGFLD(DGFIL,DGIENS,.02,"I"))
. S DGREQ("NAME")=$G(DGFLD(DGFIL,DGIENS,.02,"E"))
. S DGREQ("CPRSTAT")=$G(DGFLD(DGFIL,DGIENS,.03,"I"))
. S DGREQ("REQDT")=$G(DGFLD(DGFIL,DGIENS,.04,"I"))
. S DGRSLT=1 ;success
;
Q DGRSLT
;
;
STOCID(DGCID,DGDFN,DGSTAT) ;store the NCMD-assigned Card ID
; This procedure creates a record in the VIC REQUEST (#39.6) file.
;
; Input:
; DGCID - Card ID [format: lastname_"-"_SSN_"-"_number of requests]
; DGDFN - pointer to patient in PATIENT(#2) file
; DGSTAT - Card Print Release Status
;
; Output:
; none
;
N DGERR
N DGFDA
N DGFIL
N DGIEN
N DGIENS
;
S DGFIL=39.6
;
;validate input params
Q:+$G(DGDFN)'>0
Q:'$D(^DPT(DGDFN,0))
Q:$G(DGCID)']""
Q:$$EXTERNAL^DILFD(DGFIL,.03,"F",$G(DGSTAT),"")']""
;
S DGIEN=$$FINDCID(DGCID)
S DGIENS=$S('DGIEN:"+1,",1:DGIEN_",")
;
S DGFDA(DGFIL,DGIENS,.01)=DGCID
S DGFDA(DGFIL,DGIENS,.02)=DGDFN
S DGFDA(DGFIL,DGIENS,.03)=DGSTAT
S DGFDA(DGFIL,DGIENS,.04)=$$NOW^XLFDT()
D UPDATE^DIE("","DGFDA","","DGERR")
;
Q
;
;
STOSTAT(DGIEN,DGSTAT) ;update CARD PRINT RELEASE STATUS
; This procedure is used to update the CARD PRINT RELEASE STATUS(#.03)
; field of the VIC REQUEST (#39.6) file.
;
; Input:
; DGIEN - IEN of VIC REQUEST file record
; DGSTAT - card print release status
;
; Output:
; none
;
N DGERR
N DGFDA
N DGFIL
;
S DGFIL=39.6
;
;validate input parameters
Q:'$G(DGIEN)
Q:$G(DGSTAT)']""
Q:$$EXTERNAL^DILFD(DGFIL,.03,"F",DGSTAT,"")']""
;
S DGFDA(DGFIL,DGIEN_",",.03)=DGSTAT
D FILE^DIE("","DGFDA","DGERR")
Q
;
;
DELREQ(DGIEN) ;delete a single VIC REQUEST record
;
; Input:
; DGIEN - IEN of record in VIC REQUEST (#39.6) file
;
; Output:
; Function value - 1 on success, 0 on failure
;
N DGDT ;HL7 transmission date
N DGERR
N DGFDA
N DGLIEN ;pointer to VIC HL7 TRANSMISSION LOG (#39.7) file
N DGRSLT ;function value
;
S DGRSLT=0
I $G(DGIEN) D
. S DGFDA(39.6,DGIEN_",",.01)="@"
. D FILE^DIE("","DGFDA","DGERR")
. Q:$D(DGERR)
. ;
. ;cleanup HL7 TRANSMISSION LOG
. S DGDT=0
. F S DGDT=$O(^DGQE(39.7,"ADATE",DGIEN,DGDT)) Q:'DGDT D Q:$D(DGERR)
. . S DGLIEN=$O(^DGQE(39.7,"ADATE",DGIEN,DGDT,0))
. . I DGLIEN,'$$DELXMIT^DGQEHLL(DGLIEN) S DGERR=1
. Q:$D(DGERR)
. S DGRSLT=1 ;success
;
Q DGRSLT
DGQEREQ ;ALB/RPM - VIC REPLACEMENT VIC REQUEST 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 REQUEST (#39.6) file.
+5 ;
+6 ; $$FINDCID - locate NCMD Card ID
+7 ; $$FINDLST - locate last (most recent) VIC request
+8 ; $$GETREQ - retrieve a single VIC REQUEST record
+9 ; $$STOCID - store the NCMD Card ID
+10 ; $$STOSTAT - store the Card Print Release Status
+11 ; $$DELREQ - delete a single VIC REQUEST record
+12 ;
+13 ;no direct entry
QUIT
+14 ;
FINDCID(DGCID) ;locate record for a given NCMD Card ID
+1 ; This function performs a lookup of the VIC REQUEST (#39.6) file
+2 ; for a given Card ID.
+3 ;
+4 ; Input:
+5 ; DGCID - NCMD Card ID
+6 ;
+7 ; Output:
+8 ; Function value - IEN of VIC REQUEST on success;
+9 ; 0 on failure
+10 ;
+11 IF $GET(DGCID)']""
QUIT 0
+12 QUIT +$ORDER(^DGQE(39.6,"B",DGCID,""))
+13 ;
+14 ;
FINDLST(DGDFN) ;locate the IEN of the last request for a given patient
+1 ;
+2 ; Input:
+3 ; DGDFN - pointer to patient in PATIENT (#2) file
+4 ;
+5 ; Output:
+6 ; Function value - IEN of VIC REQUEST (#39.6) file on success,
+7 ; 0 on failure
+8 ;
+9 NEW DGDAT
+10 ;
+11 SET DGDFN=+$GET(DGDFN)
+12 SET DGDAT=+$ORDER(^DGQE(39.6,"APDAT",DGDFN,""),-1)
+13 QUIT +$ORDER(^DGQE(39.6,"APDAT",DGDFN,DGDAT,0))
+14 ;
+15 ;
GETREQ(DGIEN,DGREQ) ;retrieve a single record
+1 ; This function retrieves all fields belonging to a single record
+2 ; in the VIC REQUEST (#39.6) file for a given IEN. The field data
+3 ; is placed in an array format.
+4 ;
+5 ; Input:
+6 ; DGIEN - VIC REQUEST (#39.6) file record number
+7 ;
+8 ; Output:
+9 ; Function value - 1 on success, 0 on failure
+10 ; DGREQ - array of field data
+11 ; Array subscripts are:
+12 ; "DFN" - pointer to patient in PATIENT (#2) file
+13 ; "CARDID" - NCMD Card ID
+14 ; "NAME" - patient name
+15 ; "CPRSTAT" - card print release status
+16 ; "REQDATE" - VIC Request Date in internal format
+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.6
+26 ;
+27 IF $GET(DGIEN)
IF $DATA(^DGQE(DGFIL,DGIEN))
Begin DoDot:1
+28 SET DGIENS=DGIEN_","
+29 DO GETS^DIQ(DGFIL,DGIENS,"*","IE","DGFLD","DGERR")
+30 IF $DATA(DGERR)
QUIT
+31 SET DGREQ("CARDID")=$GET(DGFLD(DGFIL,DGIENS,.01,"I"))
+32 SET DGREQ("DFN")=$GET(DGFLD(DGFIL,DGIENS,.02,"I"))
+33 SET DGREQ("NAME")=$GET(DGFLD(DGFIL,DGIENS,.02,"E"))
+34 SET DGREQ("CPRSTAT")=$GET(DGFLD(DGFIL,DGIENS,.03,"I"))
+35 SET DGREQ("REQDT")=$GET(DGFLD(DGFIL,DGIENS,.04,"I"))
+36 ;success
SET DGRSLT=1
End DoDot:1
+37 ;
+38 QUIT DGRSLT
+39 ;
+40 ;
STOCID(DGCID,DGDFN,DGSTAT) ;store the NCMD-assigned Card ID
+1 ; This procedure creates a record in the VIC REQUEST (#39.6) file.
+2 ;
+3 ; Input:
+4 ; DGCID - Card ID [format: lastname_"-"_SSN_"-"_number of requests]
+5 ; DGDFN - pointer to patient in PATIENT(#2) file
+6 ; DGSTAT - Card Print Release Status
+7 ;
+8 ; Output:
+9 ; none
+10 ;
+11 NEW DGERR
+12 NEW DGFDA
+13 NEW DGFIL
+14 NEW DGIEN
+15 NEW DGIENS
+16 ;
+17 SET DGFIL=39.6
+18 ;
+19 ;validate input params
+20 IF +$GET(DGDFN)'>0
QUIT
+21 IF '$DATA(^DPT(DGDFN,0))
QUIT
+22 IF $GET(DGCID)']""
QUIT
+23 IF $$EXTERNAL^DILFD(DGFIL,.03,"F",$GET(DGSTAT),"")']""
QUIT
+24 ;
+25 SET DGIEN=$$FINDCID(DGCID)
+26 SET DGIENS=$SELECT('DGIEN:"+1,",1:DGIEN_",")
+27 ;
+28 SET DGFDA(DGFIL,DGIENS,.01)=DGCID
+29 SET DGFDA(DGFIL,DGIENS,.02)=DGDFN
+30 SET DGFDA(DGFIL,DGIENS,.03)=DGSTAT
+31 SET DGFDA(DGFIL,DGIENS,.04)=$$NOW^XLFDT()
+32 DO UPDATE^DIE("","DGFDA","","DGERR")
+33 ;
+34 QUIT
+35 ;
+36 ;
STOSTAT(DGIEN,DGSTAT) ;update CARD PRINT RELEASE STATUS
+1 ; This procedure is used to update the CARD PRINT RELEASE STATUS(#.03)
+2 ; field of the VIC REQUEST (#39.6) file.
+3 ;
+4 ; Input:
+5 ; DGIEN - IEN of VIC REQUEST file record
+6 ; DGSTAT - card print release status
+7 ;
+8 ; Output:
+9 ; none
+10 ;
+11 NEW DGERR
+12 NEW DGFDA
+13 NEW DGFIL
+14 ;
+15 SET DGFIL=39.6
+16 ;
+17 ;validate input parameters
+18 IF '$GET(DGIEN)
QUIT
+19 IF $GET(DGSTAT)']""
QUIT
+20 IF $$EXTERNAL^DILFD(DGFIL,.03,"F",DGSTAT,"")']""
QUIT
+21 ;
+22 SET DGFDA(DGFIL,DGIEN_",",.03)=DGSTAT
+23 DO FILE^DIE("","DGFDA","DGERR")
+24 QUIT
+25 ;
+26 ;
DELREQ(DGIEN) ;delete a single VIC REQUEST record
+1 ;
+2 ; Input:
+3 ; DGIEN - IEN of record in VIC REQUEST (#39.6) file
+4 ;
+5 ; Output:
+6 ; Function value - 1 on success, 0 on failure
+7 ;
+8 ;HL7 transmission date
NEW DGDT
+9 NEW DGERR
+10 NEW DGFDA
+11 ;pointer to VIC HL7 TRANSMISSION LOG (#39.7) file
NEW DGLIEN
+12 ;function value
NEW DGRSLT
+13 ;
+14 SET DGRSLT=0
+15 IF $GET(DGIEN)
Begin DoDot:1
+16 SET DGFDA(39.6,DGIEN_",",.01)="@"
+17 DO FILE^DIE("","DGFDA","DGERR")
+18 IF $DATA(DGERR)
QUIT
+19 ;
+20 ;cleanup HL7 TRANSMISSION LOG
+21 SET DGDT=0
+22 FOR
SET DGDT=$ORDER(^DGQE(39.7,"ADATE",DGIEN,DGDT))
IF 'DGDT
QUIT
Begin DoDot:2
+23 SET DGLIEN=$ORDER(^DGQE(39.7,"ADATE",DGIEN,DGDT,0))
+24 IF DGLIEN
IF '$$DELXMIT^DGQEHLL(DGLIEN)
SET DGERR=1
End DoDot:2
IF $DATA(DGERR)
QUIT
+25 IF $DATA(DGERR)
QUIT
+26 ;success
SET DGRSLT=1
End DoDot:1
+27 ;
+28 QUIT DGRSLT