DGROHLQ3 ;DJH/AMA - ROM HL7 QRY/ORF PROCESSING ; 27 Apr 2004 4:50 PM
;;5.3;Registration;**533,572,1015**;Aug 13, 1993;Build 21
;
PARSQRY(DGWRK,DGHL,DGQRY,DGROERR) ;Parse QRY~R02 Message/Segments
;Called from RCVQRY^DGROHLR
; Input:
; DGWRK - Closed root global reference, ^TMP("DGROHL7",$J)
; DGHL - VistA HL7 environment array
;
; Output:
; DGQRY - Patient lookup components array
; DGROERR - Undefined on success, ERR segment data array on failure
; Format: DGROERR(seg_id,sequence,fld_pos)=error_code
;
N DGFS ;field separator
N DGCS ;component separator
N DGRS ;repetition separator
N DGSS ;sub-component separator
N DGCURLIN ;current segment line
N DGSEG ;segment field data array
N DGROERR ;error processing array
;
S DGFS=DGHL("FS")
S DGCS=$E(DGHL("ECH"),1)
S DGRS=$E(DGHL("ECH"),2)
S DGSS=$E(DGHL("ECH"),4)
S DGCURLIN=0
;
;loop through the message segments and retrieve the field data
F D Q:'DGCURLIN
. N DGSEG
. S DGCURLIN=$$NXTSEG^DGROHLUT(DGWRK,DGCURLIN,DGFS,.DGSEG)
. Q:'DGCURLIN
. D @(DGSEG("TYPE")_"(.DGSEG,DGCS,DGRS,DGSS,.DGQRY,.DGROERR)")
Q
;
PARSORF(DGWRK,DGHL,DGORF,DGMSG,DGDATA) ;Parse ORF~R04 Message/Segments
;Called RCVORF^DGROHLR
; Input:
; DGWRK - Closed root work global reference, ^TMP("DGROHL7",$J)
; DGHL - HL7 environment array
;
; Output:
; DGORF - array of ORF results
; "ACKCODE" - acknowledgment code ("AA","AE","AR")
; "DFN" - DFN
; "ICN" - patient's Integrated Control Number
; "MSGDTM" - message creation date/time in FileMan format
; "MSGID" - Message ID for HL7
; "RCVFAC" - receiving facility
; "SNDFAC" - sending facility
; DGDATA - array of patient data to upload, ^TMP("DGROFDA",$J)
; DGMSG - undefined on success, array of MailMan text on failure
;
N DGFS,DGCS,DGRS,DGSS,DGCURLIN
;
S DGFS=DGHL("FS")
S DGCS=$E(DGHL("ECH"),1)
S DGRS=$E(DGHL("ECH"),2)
S DGSS=$E(DGHL("ECH"),4)
S DGCURLIN=0
;
;loop through the message segments and retrieve the field data
F D Q:'DGCURLIN
. N DGSEG
. S DGCURLIN=$$NXTSEG^DGROHLUT(DGWRK,DGCURLIN,DGFS,.DGSEG)
. Q:'DGCURLIN
. I DGSEG("TYPE")'="FDA" D @(DGSEG("TYPE")_"(.DGSEG,DGCS,DGRS,DGSS,.DGORF,.DGMSG)") I 1
. E D FDA^DGROHLU(DGWRK,.DGCURLIN,DGFS,DGCS,DGRS,.DGDATA)
Q
;
MSH(DGSEG,DGCS,DGRS,DGSS,DGORF,DGERR) ;
;
; Input:
; DGSEG - MSH segment field array
; DGCS - HL7 component separator
; DGRS - HL7 repetition separator
; DGSS - HL7 sub-component separator
;
; Output:
; DGORF - array of ORF results
; "SNDFAC" - sending facility
; "RCVFAC" - receiving facility
; "MSGDTM" - message creation date/time in FileMan format
; DGERR - undefined on success, error array on failure
;
D MSH^DGROHLU4(.DGSEG,DGCS,DGRS,DGSS,.DGORF,.DGERR)
Q
;
MSA(DGSEG,DGCS,DGRS,DGSS,DGORF,DGERR) ;
;
; Input:
; DGSEG - MSH segment field array
; DGCS - HL7 component separator
; DGRS - HL7 repetition separator
; DGSS - HL7 sub-component separator
;
; Output:
; DGORF - array of ORF results
; "ACKCODE" - Acknowledgment code
; "MSGID" - Message Control ID of the message being ACK'ed
; DGERR - undefined on success, error array on failure
;
D MSA^DGROHLU4(.DGSEG,DGCS,DGRS,DGSS,.DGORF,.DGERR)
Q
;
ERR(DGSEG,DGCS,DGRS,DGSS,DGORF,DGERR) ;
;
; Input:
; DGSEG - MSH segment field array
; DGCS - HL7 component separator
; DGRS - HL7 repetition separator
; DGSS - HL7 sub-component separator
;
; Output:
; DGORF - array of ORF results
; DGERR - undefined on success, error array on failure
;
D ERR^DGROHLU4(.DGSEG,DGCS,DGRS,DGSS,.DGORF,.DGERR)
Q
;
QRD(DGSEG,DGCS,DGRS,DGSS,DGQRY,DGERR) ;
;
; Input:
; DGSEG - MSH segment field array
; DGCS - HL7 component separator
; DGRS - HL7 repetition separator
; DGSS - HL7 sub-component separator
;
; Output:
; DGQRY("ICN") - Patient's Integrated Control Number
; DGQRY("DFN") - Query ID
; DGQRY("USER") - Query Site user's info ;DG*5.3*572
; DGERR - undefined on success, error array on failure
; format: DGERR(seg_id,sequence,fld_pos)=error code
;
S DGQRY("DFN")=$P($G(DGSEG(4)),"~")
S DGQRY("USER")=$P($G(DGSEG(4)),"~",2,99)
S DGQRY("ICN")=+$P($G(DGSEG(8)),DGCS,1)
S DGQRY("PATCH")=$G(DGSEG(5))
I DGQRY("ICN")="" D
. S DGERR("QRD",1,8)="NM"
Q
;
QRF(DGSEG,DGCS,DGRS,DGSS,DGQRY,DGERR) ;
;
; Input:
; DGSEG - PID segment field array
; DGCS - HL7 component separator
; DGRS - HL7 repetition separator
; DGSS - HL7 sub-component separator
;
; Output:
; DGQRY("SSN") - Patient's Social Security Number
; DGQRY("DOB") - Patient's Date of Birth
; DGERR - undefined on success, error array on failure
; format: DGERR(seg_id,sequence,fld_pos)=error code
;
S DGQRY("SSN")=$G(DGSEG(4))
I DGQRY("SSN")="" S DGERR("QRF",1,4)="NM" ;no match
;
S DGQRY("DOB")=+$$HL7TFM^XLFDT($G(DGSEG(5)))
I DGQRY("DOB")'>0 S DGERR("QRF",1,5)="NM" ;no match
Q
DGROHLQ3 ;DJH/AMA - ROM HL7 QRY/ORF PROCESSING ; 27 Apr 2004 4:50 PM
+1 ;;5.3;Registration;**533,572,1015**;Aug 13, 1993;Build 21
+2 ;
PARSQRY(DGWRK,DGHL,DGQRY,DGROERR) ;Parse QRY~R02 Message/Segments
+1 ;Called from RCVQRY^DGROHLR
+2 ; Input:
+3 ; DGWRK - Closed root global reference, ^TMP("DGROHL7",$J)
+4 ; DGHL - VistA HL7 environment array
+5 ;
+6 ; Output:
+7 ; DGQRY - Patient lookup components array
+8 ; DGROERR - Undefined on success, ERR segment data array on failure
+9 ; Format: DGROERR(seg_id,sequence,fld_pos)=error_code
+10 ;
+11 ;field separator
NEW DGFS
+12 ;component separator
NEW DGCS
+13 ;repetition separator
NEW DGRS
+14 ;sub-component separator
NEW DGSS
+15 ;current segment line
NEW DGCURLIN
+16 ;segment field data array
NEW DGSEG
+17 ;error processing array
NEW DGROERR
+18 ;
+19 SET DGFS=DGHL("FS")
+20 SET DGCS=$EXTRACT(DGHL("ECH"),1)
+21 SET DGRS=$EXTRACT(DGHL("ECH"),2)
+22 SET DGSS=$EXTRACT(DGHL("ECH"),4)
+23 SET DGCURLIN=0
+24 ;
+25 ;loop through the message segments and retrieve the field data
+26 FOR
Begin DoDot:1
+27 NEW DGSEG
+28 SET DGCURLIN=$$NXTSEG^DGROHLUT(DGWRK,DGCURLIN,DGFS,.DGSEG)
+29 IF 'DGCURLIN
QUIT
+30 DO @(DGSEG("TYPE")_"(.DGSEG,DGCS,DGRS,DGSS,.DGQRY,.DGROERR)")
End DoDot:1
IF 'DGCURLIN
QUIT
+31 QUIT
+32 ;
PARSORF(DGWRK,DGHL,DGORF,DGMSG,DGDATA) ;Parse ORF~R04 Message/Segments
+1 ;Called RCVORF^DGROHLR
+2 ; Input:
+3 ; DGWRK - Closed root work global reference, ^TMP("DGROHL7",$J)
+4 ; DGHL - HL7 environment array
+5 ;
+6 ; Output:
+7 ; DGORF - array of ORF results
+8 ; "ACKCODE" - acknowledgment code ("AA","AE","AR")
+9 ; "DFN" - DFN
+10 ; "ICN" - patient's Integrated Control Number
+11 ; "MSGDTM" - message creation date/time in FileMan format
+12 ; "MSGID" - Message ID for HL7
+13 ; "RCVFAC" - receiving facility
+14 ; "SNDFAC" - sending facility
+15 ; DGDATA - array of patient data to upload, ^TMP("DGROFDA",$J)
+16 ; DGMSG - undefined on success, array of MailMan text on failure
+17 ;
+18 NEW DGFS,DGCS,DGRS,DGSS,DGCURLIN
+19 ;
+20 SET DGFS=DGHL("FS")
+21 SET DGCS=$EXTRACT(DGHL("ECH"),1)
+22 SET DGRS=$EXTRACT(DGHL("ECH"),2)
+23 SET DGSS=$EXTRACT(DGHL("ECH"),4)
+24 SET DGCURLIN=0
+25 ;
+26 ;loop through the message segments and retrieve the field data
+27 FOR
Begin DoDot:1
+28 NEW DGSEG
+29 SET DGCURLIN=$$NXTSEG^DGROHLUT(DGWRK,DGCURLIN,DGFS,.DGSEG)
+30 IF 'DGCURLIN
QUIT
+31 IF DGSEG("TYPE")'="FDA"
DO @(DGSEG("TYPE")_"(.DGSEG,DGCS,DGRS,DGSS,.DGORF,.DGMSG)")
IF 1
+32 IF '$TEST
DO FDA^DGROHLU(DGWRK,.DGCURLIN,DGFS,DGCS,DGRS,.DGDATA)
End DoDot:1
IF 'DGCURLIN
QUIT
+33 QUIT
+34 ;
MSH(DGSEG,DGCS,DGRS,DGSS,DGORF,DGERR) ;
+1 ;
+2 ; Input:
+3 ; DGSEG - MSH segment field array
+4 ; DGCS - HL7 component separator
+5 ; DGRS - HL7 repetition separator
+6 ; DGSS - HL7 sub-component separator
+7 ;
+8 ; Output:
+9 ; DGORF - array of ORF results
+10 ; "SNDFAC" - sending facility
+11 ; "RCVFAC" - receiving facility
+12 ; "MSGDTM" - message creation date/time in FileMan format
+13 ; DGERR - undefined on success, error array on failure
+14 ;
+15 DO MSH^DGROHLU4(.DGSEG,DGCS,DGRS,DGSS,.DGORF,.DGERR)
+16 QUIT
+17 ;
MSA(DGSEG,DGCS,DGRS,DGSS,DGORF,DGERR) ;
+1 ;
+2 ; Input:
+3 ; DGSEG - MSH segment field array
+4 ; DGCS - HL7 component separator
+5 ; DGRS - HL7 repetition separator
+6 ; DGSS - HL7 sub-component separator
+7 ;
+8 ; Output:
+9 ; DGORF - array of ORF results
+10 ; "ACKCODE" - Acknowledgment code
+11 ; "MSGID" - Message Control ID of the message being ACK'ed
+12 ; DGERR - undefined on success, error array on failure
+13 ;
+14 DO MSA^DGROHLU4(.DGSEG,DGCS,DGRS,DGSS,.DGORF,.DGERR)
+15 QUIT
+16 ;
ERR(DGSEG,DGCS,DGRS,DGSS,DGORF,DGERR) ;
+1 ;
+2 ; Input:
+3 ; DGSEG - MSH segment field array
+4 ; DGCS - HL7 component separator
+5 ; DGRS - HL7 repetition separator
+6 ; DGSS - HL7 sub-component separator
+7 ;
+8 ; Output:
+9 ; DGORF - array of ORF results
+10 ; DGERR - undefined on success, error array on failure
+11 ;
+12 DO ERR^DGROHLU4(.DGSEG,DGCS,DGRS,DGSS,.DGORF,.DGERR)
+13 QUIT
+14 ;
QRD(DGSEG,DGCS,DGRS,DGSS,DGQRY,DGERR) ;
+1 ;
+2 ; Input:
+3 ; DGSEG - MSH segment field array
+4 ; DGCS - HL7 component separator
+5 ; DGRS - HL7 repetition separator
+6 ; DGSS - HL7 sub-component separator
+7 ;
+8 ; Output:
+9 ; DGQRY("ICN") - Patient's Integrated Control Number
+10 ; DGQRY("DFN") - Query ID
+11 ; DGQRY("USER") - Query Site user's info ;DG*5.3*572
+12 ; DGERR - undefined on success, error array on failure
+13 ; format: DGERR(seg_id,sequence,fld_pos)=error code
+14 ;
+15 SET DGQRY("DFN")=$PIECE($GET(DGSEG(4)),"~")
+16 SET DGQRY("USER")=$PIECE($GET(DGSEG(4)),"~",2,99)
+17 SET DGQRY("ICN")=+$PIECE($GET(DGSEG(8)),DGCS,1)
+18 SET DGQRY("PATCH")=$GET(DGSEG(5))
+19 IF DGQRY("ICN")=""
Begin DoDot:1
+20 SET DGERR("QRD",1,8)="NM"
End DoDot:1
+21 QUIT
+22 ;
QRF(DGSEG,DGCS,DGRS,DGSS,DGQRY,DGERR) ;
+1 ;
+2 ; Input:
+3 ; DGSEG - PID segment field array
+4 ; DGCS - HL7 component separator
+5 ; DGRS - HL7 repetition separator
+6 ; DGSS - HL7 sub-component separator
+7 ;
+8 ; Output:
+9 ; DGQRY("SSN") - Patient's Social Security Number
+10 ; DGQRY("DOB") - Patient's Date of Birth
+11 ; DGERR - undefined on success, error array on failure
+12 ; format: DGERR(seg_id,sequence,fld_pos)=error code
+13 ;
+14 SET DGQRY("SSN")=$GET(DGSEG(4))
+15 ;no match
IF DGQRY("SSN")=""
SET DGERR("QRF",1,4)="NM"
+16 ;
+17 SET DGQRY("DOB")=+$$HL7TFM^XLFDT($GET(DGSEG(5)))
+18 ;no match
IF DGQRY("DOB")'>0
SET DGERR("QRF",1,5)="NM"
+19 QUIT