DGROHLQ1 ;DJH/AMA - ROM HL7 BUILD QRD SEGMENT ; 28 Apr 2004 4:31 PM
;;5.3;Registration;**533,572**;Aug 13, 1993
;
QRD(DGDFN,DGICN,DGFLD,DGHL,DGUSER) ;QRD HL7 segment API
;This function wraps the data retrieval and segment creation APIs
;and returns a formatted QRD segment.
; Called from BLDQRY and BLDORF^DGROHLQ
;
; Input:
; DGDFN - (required) DFN
; DGICN - (required) Integrated Control Number
; DGFLD - (optional) List of comma-separated fields (sequence #'s)
; to include. Defaults to all required fields (1-4,7-10).
; DGHL - VistA HL7 environment array
; DGUSER - (optional) String of user data from New Person File
; (SSN~Name~DUZ~Phone). If this is populated, it means
; this is the QRY to the LST. If not, it's the ORF going
; back to the Querying Site. ;added in DG*5.3*572
;
; Output:
; Function Value - QRD segment on success, "" on failure
;
N DGQRD,DGVAL
;
S DGQRD=""
I $G(DGDFN)>0,$G(DGICN)]"" D
. S DGFLD=$$CKSTR^DGROHLUT("1,2,3,4,5,6,7,8,9,10",DGFLD) ;validte flds
. S DGFLD=","_DGFLD_","
. I $$QRDVAL(DGFLD,DGDFN,DGICN,.DGVAL,$G(DGUSER)) D ;DG*5.3*572 added DGUSER
. . S DGQRD=$$BLDSEG^DGROHLUT("QRD",.DGVAL,.DGHL)
Q DGQRD
;
QRDVAL(DGFLD,DGDFN,DGICN,DGVAL,DGUSER) ;build QRD value array
;
; Input:
; DGFLD - Fields string
; DGDFN - DFN
; DGICN - ICN
; DGUSER - (optional) String of user data from New Person File
; (SSN~Name~DUZ~Phone) ;DG*5.3*572
;
; Output:
; Function Value - 1 on success, 0 on failure
; DGVAL - QRD field array [SUB1:field, SUB2:repetition,
; SUB3:component, SUB4:sub-component]
;
N DGRSLT
;
S DGRSLT=0
I $G(DGDFN)>0,$G(DGICN)]"",$G(DGFLD)]"" D
. ;
. ; seq 1 (required) Query Date/Time
. I DGFLD[",1," D Q:(+DGVAL(1)'>0)
. . S DGVAL(1)=$$FMTHL7^XLFDT($$NOW^XLFDT())
. ;
. ; seq 2 (required) Query Format Code
. I DGFLD[",2," D
. . S DGVAL(2)="R" ;always "R"ecord
. ;
. ; seq 3 (required) Query Priority
. I DGFLD[",3," D
. . S DGVAL(3)="I" ;always "I"mmediate
. ;
. ; seq 4 (required) Identifying Information
. ;DG*5.3*572 - if the QRY to the LST, send the QS DFN and User info
. ; - if the ORF back to the QS, just send the QS DFN
. I DGFLD[",4," D
. . S DGVAL(4)=DGDFN_$S($G(DGUSER):"~"_DGUSER,1:"") ;DG*5.3*572
. ;
. ; seq 5 (optional) Deferred Response Type
. ; Indicates version of ROM messages
. I DGFLD[",5," D
. . S DGVAL(5)="572"
. ;
. ; seq 6 (optional) Deferred Response Date/Time
. I DGFLD[",6," D
. . S DGVAL(6)=""
. ;
. ; seq 7 (required) Quantity Limited Request
. I DGFLD[",7," D
. . S DGVAL(7,1,1)=10
. . S DGVAL(7,1,2)="RD" ;records
. ;
. ; seq 8 (required) ICN
. I DGFLD[",8," D
. . S DGVAL(8,1,1)=DGICN
. . S DGVAL(8,1,9,1)="USVHA"
. . S DGVAL(8,1,9,2)=""
. . S DGVAL(8,1,9,3)="L"
. ;
. ; seq 9 (required) What Subject Filter
. I DGFLD[",9," D
. . S DGVAL(9,1,1)="OTH"
. . S DGVAL(9,1,2)="Other"
. . S DGVAL(9,1,3)="HL0048"
. ;
. ; seq 10 (required) What Dept. Data Code
. I DGFLD[",10," D
. . S DGVAL(10,1,1)="ROMDD"
. . S DGVAL(10,1,2)="Register Once Messaging Demographic Data"
. . S DGVAL(10,1,3)="L"
. ;
. ; seq 11 (optional) What Data Code Value Qual.
. I DGFLD[",11," D
. . S DGVAL(11)=""
. ;
. ; seq 12 (optional) Query Results Level
. I DGFLD[",12," D
. . S DGVAL(12)=""
. ;
. S DGRSLT=1
I 'DGRSLT K DGVAL
Q DGRSLT
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDGROHLQ1 3585 printed Nov 22, 2024@18:05:11 Page 2
DGROHLQ1 ;DJH/AMA - ROM HL7 BUILD QRD SEGMENT ; 28 Apr 2004 4:31 PM
+1 ;;5.3;Registration;**533,572**;Aug 13, 1993
+2 ;
QRD(DGDFN,DGICN,DGFLD,DGHL,DGUSER) ;QRD HL7 segment API
+1 ;This function wraps the data retrieval and segment creation APIs
+2 ;and returns a formatted QRD segment.
+3 ; Called from BLDQRY and BLDORF^DGROHLQ
+4 ;
+5 ; Input:
+6 ; DGDFN - (required) DFN
+7 ; DGICN - (required) Integrated Control Number
+8 ; DGFLD - (optional) List of comma-separated fields (sequence #'s)
+9 ; to include. Defaults to all required fields (1-4,7-10).
+10 ; DGHL - VistA HL7 environment array
+11 ; DGUSER - (optional) String of user data from New Person File
+12 ; (SSN~Name~DUZ~Phone). If this is populated, it means
+13 ; this is the QRY to the LST. If not, it's the ORF going
+14 ; back to the Querying Site. ;added in DG*5.3*572
+15 ;
+16 ; Output:
+17 ; Function Value - QRD segment on success, "" on failure
+18 ;
+19 NEW DGQRD,DGVAL
+20 ;
+21 SET DGQRD=""
+22 IF $GET(DGDFN)>0
IF $GET(DGICN)]""
Begin DoDot:1
+23 ;validte flds
SET DGFLD=$$CKSTR^DGROHLUT("1,2,3,4,5,6,7,8,9,10",DGFLD)
+24 SET DGFLD=","_DGFLD_","
+25 ;DG*5.3*572 added DGUSER
IF $$QRDVAL(DGFLD,DGDFN,DGICN,.DGVAL,$GET(DGUSER))
Begin DoDot:2
+26 SET DGQRD=$$BLDSEG^DGROHLUT("QRD",.DGVAL,.DGHL)
End DoDot:2
End DoDot:1
+27 QUIT DGQRD
+28 ;
QRDVAL(DGFLD,DGDFN,DGICN,DGVAL,DGUSER) ;build QRD value array
+1 ;
+2 ; Input:
+3 ; DGFLD - Fields string
+4 ; DGDFN - DFN
+5 ; DGICN - ICN
+6 ; DGUSER - (optional) String of user data from New Person File
+7 ; (SSN~Name~DUZ~Phone) ;DG*5.3*572
+8 ;
+9 ; Output:
+10 ; Function Value - 1 on success, 0 on failure
+11 ; DGVAL - QRD field array [SUB1:field, SUB2:repetition,
+12 ; SUB3:component, SUB4:sub-component]
+13 ;
+14 NEW DGRSLT
+15 ;
+16 SET DGRSLT=0
+17 IF $GET(DGDFN)>0
IF $GET(DGICN)]""
IF $GET(DGFLD)]""
Begin DoDot:1
+18 ;
+19 ; seq 1 (required) Query Date/Time
+20 IF DGFLD[",1,"
Begin DoDot:2
+21 SET DGVAL(1)=$$FMTHL7^XLFDT($$NOW^XLFDT())
End DoDot:2
if (+DGVAL(1)'>0)
QUIT
+22 ;
+23 ; seq 2 (required) Query Format Code
+24 IF DGFLD[",2,"
Begin DoDot:2
+25 ;always "R"ecord
SET DGVAL(2)="R"
End DoDot:2
+26 ;
+27 ; seq 3 (required) Query Priority
+28 IF DGFLD[",3,"
Begin DoDot:2
+29 ;always "I"mmediate
SET DGVAL(3)="I"
End DoDot:2
+30 ;
+31 ; seq 4 (required) Identifying Information
+32 ;DG*5.3*572 - if the QRY to the LST, send the QS DFN and User info
+33 ; - if the ORF back to the QS, just send the QS DFN
+34 IF DGFLD[",4,"
Begin DoDot:2
+35 ;DG*5.3*572
SET DGVAL(4)=DGDFN_$SELECT($GET(DGUSER):"~"_DGUSER,1:"")
End DoDot:2
+36 ;
+37 ; seq 5 (optional) Deferred Response Type
+38 ; Indicates version of ROM messages
+39 IF DGFLD[",5,"
Begin DoDot:2
+40 SET DGVAL(5)="572"
End DoDot:2
+41 ;
+42 ; seq 6 (optional) Deferred Response Date/Time
+43 IF DGFLD[",6,"
Begin DoDot:2
+44 SET DGVAL(6)=""
End DoDot:2
+45 ;
+46 ; seq 7 (required) Quantity Limited Request
+47 IF DGFLD[",7,"
Begin DoDot:2
+48 SET DGVAL(7,1,1)=10
+49 ;records
SET DGVAL(7,1,2)="RD"
End DoDot:2
+50 ;
+51 ; seq 8 (required) ICN
+52 IF DGFLD[",8,"
Begin DoDot:2
+53 SET DGVAL(8,1,1)=DGICN
+54 SET DGVAL(8,1,9,1)="USVHA"
+55 SET DGVAL(8,1,9,2)=""
+56 SET DGVAL(8,1,9,3)="L"
End DoDot:2
+57 ;
+58 ; seq 9 (required) What Subject Filter
+59 IF DGFLD[",9,"
Begin DoDot:2
+60 SET DGVAL(9,1,1)="OTH"
+61 SET DGVAL(9,1,2)="Other"
+62 SET DGVAL(9,1,3)="HL0048"
End DoDot:2
+63 ;
+64 ; seq 10 (required) What Dept. Data Code
+65 IF DGFLD[",10,"
Begin DoDot:2
+66 SET DGVAL(10,1,1)="ROMDD"
+67 SET DGVAL(10,1,2)="Register Once Messaging Demographic Data"
+68 SET DGVAL(10,1,3)="L"
End DoDot:2
+69 ;
+70 ; seq 11 (optional) What Data Code Value Qual.
+71 IF DGFLD[",11,"
Begin DoDot:2
+72 SET DGVAL(11)=""
End DoDot:2
+73 ;
+74 ; seq 12 (optional) Query Results Level
+75 IF DGFLD[",12,"
Begin DoDot:2
+76 SET DGVAL(12)=""
End DoDot:2
+77 ;
+78 SET DGRSLT=1
End DoDot:1
+79 IF 'DGRSLT
KILL DGVAL
+80 QUIT DGRSLT