DGQEHLRQ ;ALB/RPM - VIC REPLACEMENT HL7 BUILD RQD SEGMENT ;1/20/04
;;5.3;Registration;**571,1015**;Aug 13, 1993;Build 21
;
Q
;
RQD(DGREQ,DGFLD,DGHL) ;RQD Segment API
;This function wraps the data retrieval and segment creation APIs and
;returns a formatted RQD segment.
;
; Input:
; DGREQ - (required) VIC REQUEST data array
; DGFLD - (optional) List of comma-separated fields (sequence #'s)
; to include. Defaults to all required fields (4).
; DGHL - HL7 environment array
;
; Output:
; Function Value - RQD segment on success, "" on failure
;
N DGI
N DGRQD
N DGVAL
;
S DGRQD=""
I $D(DGREQ) D
. S DGFLD=","_DGFLD_","
. ;validate the field string - at least one of the three fields RQD-2,
. ;RQD-3 or RQD-4 must be valued.
. F DGI=2:1:4 I DGFLD[(","_DGI_",") D Q
. . I $$RQDVAL(DGFLD,.DGREQ,.DGVAL) D
. . . S DGRQD=$$BLDSEG^DGQEHLUT("RQD",.DGVAL,.DGHL)
Q DGRQD
;
RQDVAL(DGFLD,DGREQ,DGVAL) ;build RQD value array
;
; Input:
; DGFLD - (required) Fields string
; DGREQ - (required) VIC REQUEST data array
;
; Output:
; Function Value - 1 on sucess, 0 on failure
; DGVAL - RQD field array [SUB1:field, SUB2:repetition,
; SUB3:component, SUB4:sub-component]
;
N DGRSLT ;function value
;
S DGRSLT=0
I $G(DGFLD)]"",+$G(DGREQ("DFN"))>0 D
. ;
. ; seq 1 Requisition Line Number
. I DGFLD[",1," D
. . S DGVAL(1)=1 ;always "1"
. ;
. ; seq 2 Item Code - Internal
. I DGFLD[",2," D
. ;
. ; seq 3 Item Code - External ;required
. I DGFLD[",3," D
. . S DGVAL(3)=$G(DGREQ("CARDID"))
. Q:DGVAL(3)=""
. ;
. ; seq 4 Hospital Item Code
. I DGFLD[",4," D
. ;
. ; seq 5 Requisition Quantity
. I DGFLD[",5," D
. ;
. ; seq 6 Requisition Unit of Measure
. I DGFLD[",6," D
. ;
. ; seq 7 Dept. Cost Center
. I DGFLD[",7," D
. ;
. ; seq 8 Item Natural Account Code
. I DGFLD[",8," D
. ;
. ; seq 9 Deliver To ID
. I DGFLD[",9," D
. ;
. ; seq 10 Date Needed
. I DGFLD[",10," D
. ;
. S DGRSLT=1
I 'DGRSLT K DGVAL
Q DGRSLT
DGQEHLRQ ;ALB/RPM - VIC REPLACEMENT HL7 BUILD RQD SEGMENT ;1/20/04
+1 ;;5.3;Registration;**571,1015**;Aug 13, 1993;Build 21
+2 ;
+3 QUIT
+4 ;
RQD(DGREQ,DGFLD,DGHL) ;RQD Segment API
+1 ;This function wraps the data retrieval and segment creation APIs and
+2 ;returns a formatted RQD segment.
+3 ;
+4 ; Input:
+5 ; DGREQ - (required) VIC REQUEST data array
+6 ; DGFLD - (optional) List of comma-separated fields (sequence #'s)
+7 ; to include. Defaults to all required fields (4).
+8 ; DGHL - HL7 environment array
+9 ;
+10 ; Output:
+11 ; Function Value - RQD segment on success, "" on failure
+12 ;
+13 NEW DGI
+14 NEW DGRQD
+15 NEW DGVAL
+16 ;
+17 SET DGRQD=""
+18 IF $DATA(DGREQ)
Begin DoDot:1
+19 SET DGFLD=","_DGFLD_","
+20 ;validate the field string - at least one of the three fields RQD-2,
+21 ;RQD-3 or RQD-4 must be valued.
+22 FOR DGI=2:1:4
IF DGFLD[(","_DGI_",")
Begin DoDot:2
+23 IF $$RQDVAL(DGFLD,.DGREQ,.DGVAL)
Begin DoDot:3
+24 SET DGRQD=$$BLDSEG^DGQEHLUT("RQD",.DGVAL,.DGHL)
End DoDot:3
End DoDot:2
QUIT
End DoDot:1
+25 QUIT DGRQD
+26 ;
RQDVAL(DGFLD,DGREQ,DGVAL) ;build RQD value array
+1 ;
+2 ; Input:
+3 ; DGFLD - (required) Fields string
+4 ; DGREQ - (required) VIC REQUEST data array
+5 ;
+6 ; Output:
+7 ; Function Value - 1 on sucess, 0 on failure
+8 ; DGVAL - RQD field array [SUB1:field, SUB2:repetition,
+9 ; SUB3:component, SUB4:sub-component]
+10 ;
+11 ;function value
NEW DGRSLT
+12 ;
+13 SET DGRSLT=0
+14 IF $GET(DGFLD)]""
IF +$GET(DGREQ("DFN"))>0
Begin DoDot:1
+15 ;
+16 ; seq 1 Requisition Line Number
+17 IF DGFLD[",1,"
Begin DoDot:2
+18 ;always "1"
SET DGVAL(1)=1
End DoDot:2
+19 ;
+20 ; seq 2 Item Code - Internal
+21 IF DGFLD[",2,"
Begin DoDot:2
End DoDot:2
+22 ;
+23 ; seq 3 Item Code - External ;required
+24 IF DGFLD[",3,"
Begin DoDot:2
+25 SET DGVAL(3)=$GET(DGREQ("CARDID"))
End DoDot:2
+26 IF DGVAL(3)=""
QUIT
+27 ;
+28 ; seq 4 Hospital Item Code
+29 IF DGFLD[",4,"
Begin DoDot:2
End DoDot:2
+30 ;
+31 ; seq 5 Requisition Quantity
+32 IF DGFLD[",5,"
Begin DoDot:2
End DoDot:2
+33 ;
+34 ; seq 6 Requisition Unit of Measure
+35 IF DGFLD[",6,"
Begin DoDot:2
End DoDot:2
+36 ;
+37 ; seq 7 Dept. Cost Center
+38 IF DGFLD[",7,"
Begin DoDot:2
End DoDot:2
+39 ;
+40 ; seq 8 Item Natural Account Code
+41 IF DGFLD[",8,"
Begin DoDot:2
End DoDot:2
+42 ;
+43 ; seq 9 Deliver To ID
+44 IF DGFLD[",9,"
Begin DoDot:2
End DoDot:2
+45 ;
+46 ; seq 10 Date Needed
+47 IF DGFLD[",10,"
Begin DoDot:2
End DoDot:2
+48 ;
+49 SET DGRSLT=1
End DoDot:1
+50 IF 'DGRSLT
KILL DGVAL
+51 QUIT DGRSLT