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

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

initial load of WorldVistAEHR

File size: 3.2 KB
Line 
1VAFHLOBX ;ALB/SCK-Create generic OBX segment ; 22 Jan 2002 10:27 AM
2 ;;5.3;Registration;**189,149,494**;Aug 13, 1993
3 ;
4 ; This routine returns the HL7 defined OBX segment
5 ;
6EN(VAFARRY,VAFNUM,VAFSTR) ; Returns OBX segment
7 ;
8 ; Input - VAFARRY Array of data fields from calling application for building into OBX segment fields
9 ; Data to be included is expected to be in the following format:
10 ; VAFARRY(Field Number) = Field Value
11 ;
12 ; - Dates to be in internal FM format
13 ; - Provider name to be in external format
14 ; VAFNUM (optional) as sequential number for SET ID (default=1)
15 ; VAFSTR (Optional) as string of fields requested separated by commas. Build all if not passed in.
16 ;
17 ; **** Assumes all HL7 variables are defined ****
18 ;
19 ; Output - String of data forming the OBX segment
20 ;
21 N VAFY,X1
22 ;
23 ;; Check initial values, set defaults as needed
24 ;; Quit on empty array
25 I ($O(VAFARRY(""))="") S VAFY=1 G QUIT
26 S VAFNUM=$S($G(VAFNUM):VAFNUM,1:1)
27 I $G(VAFSTR)']"" S VAFSTR="2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17"
28 ;
29 ;; Initialize the output string
30 S $P(VAFY,HLFS,17)="",VAFSTR=","_VAFSTR_","
31 S $P(VAFY,HLFS,1)=VAFNUM ; Required field
32 ;
33 ;;Check required OBX fields
34 I $G(VAFARRY(11))=""!($L($G(VAFARRY(11)))>1) S VAFY=1 G QUIT ; obs result status
35 I $G(VAFARRY(3))="" S VAFY=1 G QUIT ; obs ID
36 I $G(VAFARRY(11))'="X",$G(VAFARRY(2))']"" S VAFY=1 G QUIT ; Value Type
37 ;
38 ;;Build segment fields
39 I VAFSTR[",2," S $P(VAFY,HLFS,2)=$S($G(VAFARRY(2))]"":VAFARRY(2),1:HLQ) ; Value Type
40 I VAFSTR[",3," S $P(VAFY,HLFS,3)=$G(VAFARRY(3)) ; Observation Identifier
41 I VAFSTR[",4," S $P(VAFY,HLFS,4)=$S($G(VAFARRY(4))]"":VAFARRY(4),1:HLQ) ; Observation Sub ID
42 I VAFSTR[",5," S $P(VAFY,HLFS,5)=$S($G(VAFARRY(5))]"":VAFARRY(5),1:HLQ) ; Observation Value
43 I VAFSTR[",6," S $P(VAFY,HLFS,6)=$S($G(VAFARRY(6))]"":VAFARRY(6),1:HLQ) ; Units
44 I VAFSTR[",7," S $P(VAFY,HLFS,7)=$S($G(VAFARRY(7))]"":VAFARRY(7),1:HLQ) ; Reference Range
45 I VAFSTR[",8," S $P(VAFY,HLFS,8)=$S($G(VAFARRY(8))]"":VAFARRY(8),1:HLQ) ; Abnormal flags
46 I VAFSTR[",9," S $P(VAFY,HLFS,9)=$S($G(VAFARRY(9))]"":VAFARRY(9),1:HLQ) ; Probability
47 I VAFSTR[",10," S $P(VAFY,HLFS,10)=$S($G(VAFARRY(10))]"":VAFARRY(10),1:HLQ) ; Nature of Abnormal Test
48 I VAFSTR[",11," S $P(VAFY,HLFS,11)=$G(VAFARRY(11)) ; Observation Result Status
49 I VAFSTR[",12," S X1=$$HLDATE^HLFNC($G(VAFARRY(12))),$P(VAFY,HLFS,12)=$S(X1]"":X1,1:HLQ) ; Date of last OBS Normal Values
50 I VAFSTR[",13," S $P(VAFY,HLFS,13)=$S($G(VAFARRY(13))]"":VAFARRY(13),1:HLQ) ; User Defined Access Checks
51 I VAFSTR[",14," S X1=$$HLDATE^HLFNC($G(VAFARRY(14))),$P(VAFY,HLFS,14)=$S(X1]"":X1,1:HLQ) ; DT of Observation
52 I VAFSTR[",15," S $P(VAFY,HLFS,15)=$S($G(VAFARRY(15))]"":VAFARRY(15),1:HLQ) ; Producer's ID
53 I VAFSTR[",16," D S $P(VAFY,HLFS,16)=$S(X1]"":X1,1:HLQ)
54 . S DIC="^VA(200,",DIC(0)="MZO",X="`"_$G(VAFARRY(16)) D ^DIC
55 . I VAFARRY(16)]"",Y>0 D
56 .. N DGNAME S DGNAME("FILE")=200,DGNAME("IENS")=VAFARRY(16),DGNAME("FIELD")=.01
57 .. S X1=$$HLNAME^XLFNAME(.DGNAME,"S",$E($G(HLECH))),X1=$G(VAFARRY(16))_$E(HLECH,1)_X1
58 . E D
59 .. S X1=""
60 ;
61 I VAFSTR[",17," S $P(VAFY,HLFS,17)=$S($G(VAFARRY(17))]"":VAFARRY(17),1:HLQ) ; OBS. Method
62 ;
63 ;
64QUIT Q "OBX"_HLFS_$G(VAFY)
Note: See TracBrowser for help on using the repository browser.