DGQEHLOR ;ALB/RPM - VIC REPLACEMENT HL7 BUILD ORC SEGMENT ; 2/23/04
;;5.3;Registration;**571,1015**;Aug 13, 1993;Build 21
;
Q
;
ORC(DGREQ,DGFLD,DGHL) ;ORC Segment API
;This function wraps the data retrieval and segment creation APIs and
;returns a formatted ORC 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 - ORC segment on success, "" on failure
;
N DGORC
N DGVAL
;
S DGORC=""
I $D(DGREQ) D
. S DGFLD=$$CKSTR^DGQEHLUT("1",DGFLD) ;validate the field string
. S DGFLD=","_DGFLD_","
. I $$ORCVAL(DGFLD,.DGREQ,.DGVAL) D
. . S DGORC=$$BLDSEG^DGQEHLUT("ORC",.DGVAL,.DGHL)
Q DGORC
;
ORCVAL(DGFLD,DGREQ,DGVAL) ;build ORC value array
;
; Input:
; DGFLD - (required) Fields string
; DGREQ - (required) VIC REQUEST data array
;
; Output:
; Function Value - 1 on sucess, 0 on failure
; DGVAL - ORC field array [SUB1:field, SUB2:repetition,
; SUB3:component, SUB4:sub-component]
;
N DGRSLT ;function value
N DGSTAT ;temp value of DGREQ("CPRSTAT")
;
S DGRSLT=0
I $G(DGFLD)]"",+$G(DGREQ("DFN"))>0,$G(DGREQ("CARDID"))]"" D
. ;
. ; seq 1 Order Control
. I DGFLD[",1," D ;required field
. . S DGSTAT=$G(DGREQ("CPRSTAT"))
. . S DGVAL(1)=$S(DGSTAT="P":"RL",DGSTAT="C":"CA",DGSTAT="I":"CA",1:"")
. Q:DGVAL(1)=""
. ;
. ; seq 2 Placer Order Number
. I DGFLD[",2," D
. ;
. ; seq 3 Filler Order Number
. I DGFLD[",3," D
. ;
. ; seq 4 Placer Group Number
. I DGFLD[",4," D
. ;
. ; seq 5 Order Status
. I DGFLD[",5," D
. ;
. ; seq 6 Response Flag
. I DGFLD[",6," D
. ;
. ; seq 7 Quantity/Timing
. I DGFLD[",7," D
. ;
. ; seq 8 Parent
. I DGFLD[",8," D
. ;
. ; seq 9 Date/Time of Transaction
. I DGFLD[",9," D
. ;
. ; seq 10 Entered By
. I DGFLD[",10," D
. ;
. ; seq 11 Verified By
. I DGFLD[",11," D
. ;
. ; seq 12 Ordering Provider
. I DGFLD[",12," D
. ;
. ; seq 13 Enterer's Location
. I DGFLD[",13," D
. ;
. ; seq 14 Call Back Phone Number
. I DGFLD[",14," D
. ;
. ; seq 15 Order Effective Date/Time
. I DGFLD[",15," D
. ;
. ; seq 16 Order Control Code Reason
. I DGFLD[",16," D
. ;
. ; seq 17 Entering Organization
. I DGFLD[",17," D
. ;
. ; seq 18 Entering Device
. I DGFLD[",18," D
. ;
. ; seq 19 Action By
. I DGFLD[",19," D
. ;
. S DGRSLT=1
I 'DGRSLT K DGVAL
Q DGRSLT
DGQEHLOR ;ALB/RPM - VIC REPLACEMENT HL7 BUILD ORC SEGMENT ; 2/23/04
+1 ;;5.3;Registration;**571,1015**;Aug 13, 1993;Build 21
+2 ;
+3 QUIT
+4 ;
ORC(DGREQ,DGFLD,DGHL) ;ORC Segment API
+1 ;This function wraps the data retrieval and segment creation APIs and
+2 ;returns a formatted ORC 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 - ORC segment on success, "" on failure
+12 ;
+13 NEW DGORC
+14 NEW DGVAL
+15 ;
+16 SET DGORC=""
+17 IF $DATA(DGREQ)
Begin DoDot:1
+18 ;validate the field string
SET DGFLD=$$CKSTR^DGQEHLUT("1",DGFLD)
+19 SET DGFLD=","_DGFLD_","
+20 IF $$ORCVAL(DGFLD,.DGREQ,.DGVAL)
Begin DoDot:2
+21 SET DGORC=$$BLDSEG^DGQEHLUT("ORC",.DGVAL,.DGHL)
End DoDot:2
End DoDot:1
+22 QUIT DGORC
+23 ;
ORCVAL(DGFLD,DGREQ,DGVAL) ;build ORC 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 - ORC field array [SUB1:field, SUB2:repetition,
+9 ; SUB3:component, SUB4:sub-component]
+10 ;
+11 ;function value
NEW DGRSLT
+12 ;temp value of DGREQ("CPRSTAT")
NEW DGSTAT
+13 ;
+14 SET DGRSLT=0
+15 IF $GET(DGFLD)]""
IF +$GET(DGREQ("DFN"))>0
IF $GET(DGREQ("CARDID"))]""
Begin DoDot:1
+16 ;
+17 ; seq 1 Order Control
+18 ;required field
IF DGFLD[",1,"
Begin DoDot:2
+19 SET DGSTAT=$GET(DGREQ("CPRSTAT"))
+20 SET DGVAL(1)=$SELECT(DGSTAT="P":"RL",DGSTAT="C":"CA",DGSTAT="I":"CA",1:"")
End DoDot:2
+21 IF DGVAL(1)=""
QUIT
+22 ;
+23 ; seq 2 Placer Order Number
+24 IF DGFLD[",2,"
Begin DoDot:2
End DoDot:2
+25 ;
+26 ; seq 3 Filler Order Number
+27 IF DGFLD[",3,"
Begin DoDot:2
End DoDot:2
+28 ;
+29 ; seq 4 Placer Group Number
+30 IF DGFLD[",4,"
Begin DoDot:2
End DoDot:2
+31 ;
+32 ; seq 5 Order Status
+33 IF DGFLD[",5,"
Begin DoDot:2
End DoDot:2
+34 ;
+35 ; seq 6 Response Flag
+36 IF DGFLD[",6,"
Begin DoDot:2
End DoDot:2
+37 ;
+38 ; seq 7 Quantity/Timing
+39 IF DGFLD[",7,"
Begin DoDot:2
End DoDot:2
+40 ;
+41 ; seq 8 Parent
+42 IF DGFLD[",8,"
Begin DoDot:2
End DoDot:2
+43 ;
+44 ; seq 9 Date/Time of Transaction
+45 IF DGFLD[",9,"
Begin DoDot:2
End DoDot:2
+46 ;
+47 ; seq 10 Entered By
+48 IF DGFLD[",10,"
Begin DoDot:2
End DoDot:2
+49 ;
+50 ; seq 11 Verified By
+51 IF DGFLD[",11,"
Begin DoDot:2
End DoDot:2
+52 ;
+53 ; seq 12 Ordering Provider
+54 IF DGFLD[",12,"
Begin DoDot:2
End DoDot:2
+55 ;
+56 ; seq 13 Enterer's Location
+57 IF DGFLD[",13,"
Begin DoDot:2
End DoDot:2
+58 ;
+59 ; seq 14 Call Back Phone Number
+60 IF DGFLD[",14,"
Begin DoDot:2
End DoDot:2
+61 ;
+62 ; seq 15 Order Effective Date/Time
+63 IF DGFLD[",15,"
Begin DoDot:2
End DoDot:2
+64 ;
+65 ; seq 16 Order Control Code Reason
+66 IF DGFLD[",16,"
Begin DoDot:2
End DoDot:2
+67 ;
+68 ; seq 17 Entering Organization
+69 IF DGFLD[",17,"
Begin DoDot:2
End DoDot:2
+70 ;
+71 ; seq 18 Entering Device
+72 IF DGFLD[",18,"
Begin DoDot:2
End DoDot:2
+73 ;
+74 ; seq 19 Action By
+75 IF DGFLD[",19,"
Begin DoDot:2
End DoDot:2
+76 ;
+77 SET DGRSLT=1
End DoDot:1
+78 IF 'DGRSLT
KILL DGVAL
+79 QUIT DGRSLT