DGPFHLQ1 ;ALB/RPM - PRF HL7 BUILD QRD SEGMENT ; 02/02/03
;;5.3;Registration;**425**;Aug 13, 1993
;
;
QRD(DGQID,DGWHO,DGFLD,DGHL) ;QRD HL7 segment API
;This function wraps the data retrieval and segment creation APIs and
;returns a formatted QRD segment.
;
; Input:
; DGQID - (required) Query ID (DFN)
; DGWHO - (required) Who Subject Filter (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
;
; Output:
; Function Value - QRD segment on success, "" on failure
;
N DGQRD
N DGVAL
;
S DGQRD=""
I $G(DGQID)>0,$G(DGWHO)]"" D
. S DGFLD=$$CKSTR^DGPFHLUT("1,2,3,4,7,8,9,10",DGFLD) ;validate fields
. S DGFLD=","_DGFLD_","
. I $$QRDVAL(DGFLD,DGQID,DGWHO,.DGVAL) D
. . S DGQRD=$$BLDSEG^DGPFHLUT("QRD",.DGVAL,.DGHL)
Q DGQRD
;
QRDVAL(DGFLD,DGQID,DGWHO,DGVAL) ;build QRD value array
;
; Input:
; DGFLD - Fields string
; DGQID - Query ID (DFN)
; DGWHO - Who Subject filter (ICN)
;
; 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(DGQID)>0,$G(DGWHO)]"",$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) Query ID
. I DGFLD[",4," D
. . S DGVAL(4)=DGQID
. ;
. ; seq 5 (optional) Deferred Response Type
. I DGFLD[",5," D
. . S DGVAL(5)=""
. ;
. ; 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) Who Subject Filter
. I DGFLD[",8," D
. . S DGVAL(8,1,1)=DGWHO
. . 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)="PRFA"
. . S DGVAL(10,1,2)="Patient Record Flag Assignments"
. . 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[HDGPFHLQ1 2906 printed Oct 16, 2024@18:48:18 Page 2
DGPFHLQ1 ;ALB/RPM - PRF HL7 BUILD QRD SEGMENT ; 02/02/03
+1 ;;5.3;Registration;**425**;Aug 13, 1993
+2 ;
+3 ;
QRD(DGQID,DGWHO,DGFLD,DGHL) ;QRD HL7 segment API
+1 ;This function wraps the data retrieval and segment creation APIs and
+2 ;returns a formatted QRD segment.
+3 ;
+4 ; Input:
+5 ; DGQID - (required) Query ID (DFN)
+6 ; DGWHO - (required) Who Subject Filter (Integrated Control Number)
+7 ; DGFLD - (optional) List of comma-separated fields (sequence #'s)
+8 ; to include. Defaults to all required fields (1-4,7-10).
+9 ; DGHL - VistA HL7 environment array
+10 ;
+11 ; Output:
+12 ; Function Value - QRD segment on success, "" on failure
+13 ;
+14 NEW DGQRD
+15 NEW DGVAL
+16 ;
+17 SET DGQRD=""
+18 IF $GET(DGQID)>0
IF $GET(DGWHO)]""
Begin DoDot:1
+19 ;validate fields
SET DGFLD=$$CKSTR^DGPFHLUT("1,2,3,4,7,8,9,10",DGFLD)
+20 SET DGFLD=","_DGFLD_","
+21 IF $$QRDVAL(DGFLD,DGQID,DGWHO,.DGVAL)
Begin DoDot:2
+22 SET DGQRD=$$BLDSEG^DGPFHLUT("QRD",.DGVAL,.DGHL)
End DoDot:2
End DoDot:1
+23 QUIT DGQRD
+24 ;
QRDVAL(DGFLD,DGQID,DGWHO,DGVAL) ;build QRD value array
+1 ;
+2 ; Input:
+3 ; DGFLD - Fields string
+4 ; DGQID - Query ID (DFN)
+5 ; DGWHO - Who Subject filter (ICN)
+6 ;
+7 ; Output:
+8 ; Function Value - 1 on success, 0 on failure
+9 ; DGVAL - QRD field array [SUB1:field, SUB2:repetition,
+10 ; SUB3:component, SUB4:sub-component
+11 ;
+12 NEW DGRSLT
+13 ;
+14 SET DGRSLT=0
+15 IF $GET(DGQID)>0
IF $GET(DGWHO)]""
IF $GET(DGFLD)]""
Begin DoDot:1
+16 ;
+17 ; seq 1 (required) Query Date/Time
+18 IF DGFLD[",1,"
Begin DoDot:2
+19 SET DGVAL(1)=$$FMTHL7^XLFDT($$NOW^XLFDT())
End DoDot:2
if (+DGVAL(1)'>0)
QUIT
+20 ;
+21 ; seq 2 (required) Query Format Code
+22 IF DGFLD[",2,"
Begin DoDot:2
+23 ;always "R"ecord
SET DGVAL(2)="R"
End DoDot:2
+24 ;
+25 ; seq 3 (required) Query Priority
+26 IF DGFLD[",3,"
Begin DoDot:2
+27 ;always "I"mmediate
SET DGVAL(3)="I"
End DoDot:2
+28 ;
+29 ; seq 4 (required) Query ID
+30 IF DGFLD[",4,"
Begin DoDot:2
+31 SET DGVAL(4)=DGQID
End DoDot:2
+32 ;
+33 ; seq 5 (optional) Deferred Response Type
+34 IF DGFLD[",5,"
Begin DoDot:2
+35 SET DGVAL(5)=""
End DoDot:2
+36 ;
+37 ; seq 6 (optional) Deferred Response Date/Time
+38 IF DGFLD[",6,"
Begin DoDot:2
+39 SET DGVAL(6)=""
End DoDot:2
+40 ;
+41 ; seq 7 (required) Quantity Limited Request
+42 IF DGFLD[",7,"
Begin DoDot:2
+43 SET DGVAL(7,1,1)=10
+44 ;records
SET DGVAL(7,1,2)="RD"
End DoDot:2
+45 ;
+46 ; seq 8 (required) Who Subject Filter
+47 IF DGFLD[",8,"
Begin DoDot:2
+48 SET DGVAL(8,1,1)=DGWHO
+49 SET DGVAL(8,1,9,1)="USVHA"
+50 SET DGVAL(8,1,9,2)=""
+51 SET DGVAL(8,1,9,3)="L"
End DoDot:2
+52 ;
+53 ; seq 9 (required) What Subject Filter
+54 IF DGFLD[",9,"
Begin DoDot:2
+55 SET DGVAL(9,1,1)="OTH"
+56 SET DGVAL(9,1,2)="Other"
+57 SET DGVAL(9,1,3)="HL0048"
End DoDot:2
+58 ;
+59 ; seq 10 (required) What Dept. Data Code
+60 IF DGFLD[",10,"
Begin DoDot:2
+61 SET DGVAL(10,1,1)="PRFA"
+62 SET DGVAL(10,1,2)="Patient Record Flag Assignments"
+63 SET DGVAL(10,1,3)="L"
End DoDot:2
+64 ;
+65 ; seq 11 (optional) What Data Code Value Qual.
+66 IF DGFLD[",11,"
Begin DoDot:2
+67 SET DGVAL(11)=""
End DoDot:2
+68 ;
+69 ; seq 12 (optional) Query Results Level
+70 IF DGFLD[",12,"
Begin DoDot:2
+71 SET DGVAL(12)=""
End DoDot:2
+72 ;
+73 SET DGRSLT=1
End DoDot:1
+74 IF 'DGRSLT
KILL DGVAL
+75 QUIT DGRSLT