DGROHLQ ;DJH/AMA - ROM HL7 QRY/ORF PROCESSING ; 28 Apr 2004 4:21 PM
;;5.3;Registration;**533,572**;Aug 13, 1993
;
BLDQRY(DGDFN,DGICN,DGROOT,DGHL,DGUSER) ;Build QRY~R02 Message/Segments
;Called from SNDQRY^DGROHLS
; Input:
; DGDFN - (required) Pointer to patient in PATIENT (#2) file
; DGICN - (required) Patient's Integrated Control Number
; DGROOT - (required) Closed root array or global name for segment storage
; DGHL - (required) VistA HL7 environment array
; DGUSER - (required) String of user data from New Person File (SSN~Name~DUZ~Phone)
;
; Output:
; Function Value - 1 on success, 0 on failure
; DGROOT - array of HL7 segments on success
;
N DGCNT ;segment counter
N DGDEM ;pt. demographics array
N DGQRD ;formatted QRD segment
N DGQRF ;formatted QRF segment
N DGRSLT ;function value
N DGSTR ;field string
;
S (DGCNT,DGRSLT)=0
;
I +$G(DGDFN),+$G(DGICN),$G(DGROOT)]"" D
. ;
. ;get patient demographics
. Q:'$$GETPAT^DGROUT2(DGDFN,.DGDEM)
. ;build QRD
. S DGSTR="1,2,3,4,7,8,9,10"
. S DGQRD=$$QRD^DGROHLQ1(DGDFN,DGICN,DGSTR,.DGHL,DGUSER)
. Q:(DGQRD="")
. S DGCNT=DGCNT+1,@DGROOT@(DGCNT)=DGQRD
. ;
. ;build QRF
. S DGSTR="1,4,5"
. S DGQRF=$$QRF^DGROHLQ2($G(DGDEM("SSN")),$G(DGDEM("DOB")),DGSTR,.DGHL)
. Q:(DGQRF="")
. S DGCNT=DGCNT+1,@DGROOT@(DGCNT)=DGQRF
. ;
. S DGRSLT=1
Q DGRSLT
;
BLDORF(DGROOT,DGHL,DGDFN,DGQRY,DGSEGERR,DGQRYERR) ;Build ORF~R04 Message/Segments
;Called from SNDORF^DGROHLS
; Input:
; DGROOT - (required) Segment array, ^TMP("HLA",$J)
; DGHL - (required) HL7 environment array
; DGDFN - (required) Pointer to patient in PATIENT (#2) file
; DGQRY - (required) Array of parsed QRY data
; DGSEGERR - (optional) Array of errors encountered during QRY parsing
; DGQRYERR - (optional) Error encountered during ICN to DFN conversion
;
; Output:
; Function Value - 1 on success, 0 on failure
;
N DGACK ;acknowledgment code (i.e. AA, AE)
N DGAIENS ;array of assignment IENS
N DGCNT ;segment counter
N DGRSLT ;function value
N DGSEGSTR ;formatted segment string
N DGSTR ;comma-delimited list of fields to include
;
S DGRSLT=0
;
I $G(DGROOT)]"",+$G(DGDFN)>0,$D(DGQRY) D
. S DGCNT=0
. ;
. ;build MSA segment
. S DGACK=$S($D(DGSEGERR):"AR",$D(DGQRYERR):"AE",1:"AA")
. S DGSTR=$S(DGACK="AE":"1,2,6",1:"1,2")
. I '$D(DGHL("MID")) S DGHL("MID")=+$G(DGHL("ICN"))
. S DGSEGSTR=$$MSA^DGROHLU3(DGACK,DGHL("MID"),.DGQRYERR,DGSTR,.DGHL)
. Q:(DGSEGSTR="")
. S DGCNT=DGCNT+1,@DGROOT@(DGCNT)=DGSEGSTR
. ;
. ;build ERR segments for any segment parsing errors
. I DGACK="AR",'$$BLDERR^DGROHLU4(DGROOT,.DGSEGERR,.DGHL,.DGCNT) Q
. ;
. ;build QRD segment
. S DGSTR="1,2,3,4,5,7,8,9,10"
. S DGSEGSTR=$$QRD^DGROHLQ1($G(DGQRY("DFN")),$G(DGQRY("ICN")),DGSTR,.DGHL)
. Q:(DGSEGSTR="")
. S DGCNT=DGCNT+1,@DGROOT@(DGCNT)=DGSEGSTR
. ;
. ;gather all of the patient data
. N DGROFDA,DGX
. S DGROFDA=$NA(^TMP("DGROFDA",$J)) K @DGROFDA
. D DIQ^DGROHLU(.DGROFDA,2,DGDFN,.DGQRY)
. ;
. ;build FDA segment
. K DGSEGSTR
. D FDA^DGROHLU1(DGROFDA,.DGSEGSTR)
. K @DGROFDA
. ;
. Q:'$D(DGSEGSTR)
. S DGX=0 F S DGX=$O(DGSEGSTR(DGX)) Q:'DGX D
. . S @DGROOT@(DGCNT+DGX)=DGSEGSTR(DGX)
. ;
. S DGRSLT=1
Q DGRSLT
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDGROHLQ 3371 printed Nov 22, 2024@18:05:10 Page 2
DGROHLQ ;DJH/AMA - ROM HL7 QRY/ORF PROCESSING ; 28 Apr 2004 4:21 PM
+1 ;;5.3;Registration;**533,572**;Aug 13, 1993
+2 ;
BLDQRY(DGDFN,DGICN,DGROOT,DGHL,DGUSER) ;Build QRY~R02 Message/Segments
+1 ;Called from SNDQRY^DGROHLS
+2 ; Input:
+3 ; DGDFN - (required) Pointer to patient in PATIENT (#2) file
+4 ; DGICN - (required) Patient's Integrated Control Number
+5 ; DGROOT - (required) Closed root array or global name for segment storage
+6 ; DGHL - (required) VistA HL7 environment array
+7 ; DGUSER - (required) String of user data from New Person File (SSN~Name~DUZ~Phone)
+8 ;
+9 ; Output:
+10 ; Function Value - 1 on success, 0 on failure
+11 ; DGROOT - array of HL7 segments on success
+12 ;
+13 ;segment counter
NEW DGCNT
+14 ;pt. demographics array
NEW DGDEM
+15 ;formatted QRD segment
NEW DGQRD
+16 ;formatted QRF segment
NEW DGQRF
+17 ;function value
NEW DGRSLT
+18 ;field string
NEW DGSTR
+19 ;
+20 SET (DGCNT,DGRSLT)=0
+21 ;
+22 IF +$GET(DGDFN)
IF +$GET(DGICN)
IF $GET(DGROOT)]""
Begin DoDot:1
+23 ;
+24 ;get patient demographics
+25 if '$$GETPAT^DGROUT2(DGDFN,.DGDEM)
QUIT
+26 ;build QRD
+27 SET DGSTR="1,2,3,4,7,8,9,10"
+28 SET DGQRD=$$QRD^DGROHLQ1(DGDFN,DGICN,DGSTR,.DGHL,DGUSER)
+29 if (DGQRD="")
QUIT
+30 SET DGCNT=DGCNT+1
SET @DGROOT@(DGCNT)=DGQRD
+31 ;
+32 ;build QRF
+33 SET DGSTR="1,4,5"
+34 SET DGQRF=$$QRF^DGROHLQ2($GET(DGDEM("SSN")),$GET(DGDEM("DOB")),DGSTR,.DGHL)
+35 if (DGQRF="")
QUIT
+36 SET DGCNT=DGCNT+1
SET @DGROOT@(DGCNT)=DGQRF
+37 ;
+38 SET DGRSLT=1
End DoDot:1
+39 QUIT DGRSLT
+40 ;
BLDORF(DGROOT,DGHL,DGDFN,DGQRY,DGSEGERR,DGQRYERR) ;Build ORF~R04 Message/Segments
+1 ;Called from SNDORF^DGROHLS
+2 ; Input:
+3 ; DGROOT - (required) Segment array, ^TMP("HLA",$J)
+4 ; DGHL - (required) HL7 environment array
+5 ; DGDFN - (required) Pointer to patient in PATIENT (#2) file
+6 ; DGQRY - (required) Array of parsed QRY data
+7 ; DGSEGERR - (optional) Array of errors encountered during QRY parsing
+8 ; DGQRYERR - (optional) Error encountered during ICN to DFN conversion
+9 ;
+10 ; Output:
+11 ; Function Value - 1 on success, 0 on failure
+12 ;
+13 ;acknowledgment code (i.e. AA, AE)
NEW DGACK
+14 ;array of assignment IENS
NEW DGAIENS
+15 ;segment counter
NEW DGCNT
+16 ;function value
NEW DGRSLT
+17 ;formatted segment string
NEW DGSEGSTR
+18 ;comma-delimited list of fields to include
NEW DGSTR
+19 ;
+20 SET DGRSLT=0
+21 ;
+22 IF $GET(DGROOT)]""
IF +$GET(DGDFN)>0
IF $DATA(DGQRY)
Begin DoDot:1
+23 SET DGCNT=0
+24 ;
+25 ;build MSA segment
+26 SET DGACK=$SELECT($DATA(DGSEGERR):"AR",$DATA(DGQRYERR):"AE",1:"AA")
+27 SET DGSTR=$SELECT(DGACK="AE":"1,2,6",1:"1,2")
+28 IF '$DATA(DGHL("MID"))
SET DGHL("MID")=+$GET(DGHL("ICN"))
+29 SET DGSEGSTR=$$MSA^DGROHLU3(DGACK,DGHL("MID"),.DGQRYERR,DGSTR,.DGHL)
+30 if (DGSEGSTR="")
QUIT
+31 SET DGCNT=DGCNT+1
SET @DGROOT@(DGCNT)=DGSEGSTR
+32 ;
+33 ;build ERR segments for any segment parsing errors
+34 IF DGACK="AR"
IF '$$BLDERR^DGROHLU4(DGROOT,.DGSEGERR,.DGHL,.DGCNT)
QUIT
+35 ;
+36 ;build QRD segment
+37 SET DGSTR="1,2,3,4,5,7,8,9,10"
+38 SET DGSEGSTR=$$QRD^DGROHLQ1($GET(DGQRY("DFN")),$GET(DGQRY("ICN")),DGSTR,.DGHL)
+39 if (DGSEGSTR="")
QUIT
+40 SET DGCNT=DGCNT+1
SET @DGROOT@(DGCNT)=DGSEGSTR
+41 ;
+42 ;gather all of the patient data
+43 NEW DGROFDA,DGX
+44 SET DGROFDA=$NAME(^TMP("DGROFDA",$JOB))
KILL @DGROFDA
+45 DO DIQ^DGROHLU(.DGROFDA,2,DGDFN,.DGQRY)
+46 ;
+47 ;build FDA segment
+48 KILL DGSEGSTR
+49 DO FDA^DGROHLU1(DGROFDA,.DGSEGSTR)
+50 KILL @DGROFDA
+51 ;
+52 if '$DATA(DGSEGSTR)
QUIT
+53 SET DGX=0
FOR
SET DGX=$ORDER(DGSEGSTR(DGX))
if 'DGX
QUIT
Begin DoDot:2
+54 SET @DGROOT@(DGCNT+DGX)=DGSEGSTR(DGX)
End DoDot:2
+55 ;
+56 SET DGRSLT=1
End DoDot:1
+57 QUIT DGRSLT