source: FOIAVistA/trunk/r/REGISTRATION-DGQE-DG-DPT-GRPX-VAD-VAF-VAS-VAT-VAU--VA-VIC--DGBT--DGJ--DGYA--VALM/DGROHLQ.m@ 1397

Last change on this file since 1397 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 3.2 KB
Line 
1DGROHLQ ;DJH/AMA - ROM HL7 QRY/ORF PROCESSING ; 28 Apr 2004 4:21 PM
2 ;;5.3;Registration;**533,572**;Aug 13, 1993
3 ;
4BLDQRY(DGDFN,DGICN,DGROOT,DGHL,DGUSER) ;Build QRY~R02 Message/Segments
5 ;Called from SNDQRY^DGROHLS
6 ; Input:
7 ; DGDFN - (required) Pointer to patient in PATIENT (#2) file
8 ; DGICN - (required) Patient's Integrated Control Number
9 ; DGROOT - (required) Closed root array or global name for segment storage
10 ; DGHL - (required) VistA HL7 environment array
11 ; DGUSER - (required) String of user data from New Person File (SSN~Name~DUZ~Phone)
12 ;
13 ; Output:
14 ; Function Value - 1 on success, 0 on failure
15 ; DGROOT - array of HL7 segments on success
16 ;
17 N DGCNT ;segment counter
18 N DGDEM ;pt. demographics array
19 N DGQRD ;formatted QRD segment
20 N DGQRF ;formatted QRF segment
21 N DGRSLT ;function value
22 N DGSTR ;field string
23 ;
24 S (DGCNT,DGRSLT)=0
25 ;
26 I +$G(DGDFN),+$G(DGICN),$G(DGROOT)]"" D
27 . ;
28 . ;get patient demographics
29 . Q:'$$GETPAT^DGROUT2(DGDFN,.DGDEM)
30 . ;build QRD
31 . S DGSTR="1,2,3,4,7,8,9,10"
32 . S DGQRD=$$QRD^DGROHLQ1(DGDFN,DGICN,DGSTR,.DGHL,DGUSER)
33 . Q:(DGQRD="")
34 . S DGCNT=DGCNT+1,@DGROOT@(DGCNT)=DGQRD
35 . ;
36 . ;build QRF
37 . S DGSTR="1,4,5"
38 . S DGQRF=$$QRF^DGROHLQ2($G(DGDEM("SSN")),$G(DGDEM("DOB")),DGSTR,.DGHL)
39 . Q:(DGQRF="")
40 . S DGCNT=DGCNT+1,@DGROOT@(DGCNT)=DGQRF
41 . ;
42 . S DGRSLT=1
43 Q DGRSLT
44 ;
45BLDORF(DGROOT,DGHL,DGDFN,DGQRY,DGSEGERR,DGQRYERR) ;Build ORF~R04 Message/Segments
46 ;Called from SNDORF^DGROHLS
47 ; Input:
48 ; DGROOT - (required) Segment array, ^TMP("HLA",$J)
49 ; DGHL - (required) HL7 environment array
50 ; DGDFN - (required) Pointer to patient in PATIENT (#2) file
51 ; DGQRY - (required) Array of parsed QRY data
52 ; DGSEGERR - (optional) Array of errors encountered during QRY parsing
53 ; DGQRYERR - (optional) Error encountered during ICN to DFN conversion
54 ;
55 ; Output:
56 ; Function Value - 1 on success, 0 on failure
57 ;
58 N DGACK ;acknowledgment code (i.e. AA, AE)
59 N DGAIENS ;array of assignment IENS
60 N DGCNT ;segment counter
61 N DGRSLT ;function value
62 N DGSEGSTR ;formatted segment string
63 N DGSTR ;comma-delimited list of fields to include
64 ;
65 S DGRSLT=0
66 ;
67 I $G(DGROOT)]"",+$G(DGDFN)>0,$D(DGQRY) D
68 . S DGCNT=0
69 . ;
70 . ;build MSA segment
71 . S DGACK=$S($D(DGSEGERR):"AR",$D(DGQRYERR):"AE",1:"AA")
72 . S DGSTR=$S(DGACK="AE":"1,2,6",1:"1,2")
73 . I '$D(DGHL("MID")) S DGHL("MID")=+$G(DGHL("ICN"))
74 . S DGSEGSTR=$$MSA^DGROHLU3(DGACK,DGHL("MID"),.DGQRYERR,DGSTR,.DGHL)
75 . Q:(DGSEGSTR="")
76 . S DGCNT=DGCNT+1,@DGROOT@(DGCNT)=DGSEGSTR
77 . ;
78 . ;build ERR segments for any segment parsing errors
79 . I DGACK="AR",'$$BLDERR^DGROHLU4(DGROOT,.DGSEGERR,.DGHL,.DGCNT) Q
80 . ;
81 . ;build QRD segment
82 . S DGSTR="1,2,3,4,5,7,8,9,10"
83 . S DGSEGSTR=$$QRD^DGROHLQ1($G(DGQRY("DFN")),$G(DGQRY("ICN")),DGSTR,.DGHL)
84 . Q:(DGSEGSTR="")
85 . S DGCNT=DGCNT+1,@DGROOT@(DGCNT)=DGSEGSTR
86 . ;
87 . ;gather all of the patient data
88 . N DGROFDA,DGX
89 . S DGROFDA=$NA(^TMP("DGROFDA",$J)) K @DGROFDA
90 . D DIQ^DGROHLU(.DGROFDA,2,DGDFN,.DGQRY)
91 . ;
92 . ;build FDA segment
93 . K DGSEGSTR
94 . D FDA^DGROHLU1(DGROFDA,.DGSEGSTR)
95 . K @DGROFDA
96 . ;
97 . Q:'$D(DGSEGSTR)
98 . S DGX=0 F S DGX=$O(DGSEGSTR(DGX)) Q:'DGX D
99 . . S @DGROOT@(DGCNT+DGX)=DGSEGSTR(DGX)
100 . ;
101 . S DGRSLT=1
102 Q DGRSLT
Note: See TracBrowser for help on using the repository browser.