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

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

initial load of FOIAVistA 6/30/08 version

File size: 5.7 KB
Line 
1VAFHLIN1 ;ALB/KCL/SCK/PHH - CREATE HL7 INSURANCE (IN1) SEGMENT ; 02/09/2007
2 ;;5.3;Registration;**122,190,670,740**;Aug 13, 1993;Build 2
3 ;
4 ;
5 ; This generic function was designed to return the HL7 IN1 (Insurance)
6 ; segment. This segment contains VA-specific patient insurance
7 ; information. (All active insurance data for a patient including
8 ; those insurance carriers that do not reimburse the VA i.e Medicare)
9 ;
10 ; SCK - modified for Insurance Encapsulation API
11 ; 1. The Insurance API does not currently support the Pre-Certification flag
12 ; in the IN1 segment, Field 28. No value will be returned for field 28.
13 ; 2. The Insurance API does not support Line 2 or Line 3 of the address.
14 ; The API returns a single address line.
15 ;
16EN(DFN,VAFSTR,VAFHLQ,VAFHLFS,VAFARRY) ; --
17 ; Entry point to return HL7 IN1 segments.
18 ;
19 ; Input:
20 ; DFN - internal entry number of the PATIENT (#2) file.
21 ; VAFSTR - (optional) string of fields requested seperated
22 ; by commas. If not passed, return all data fields.
23 ; VAFHLQ - (optional) HL7 null variable.
24 ; VAFHLFS - (optional) HL7 field separator.
25 ; VAFARRY - (optional) user-supplied array name which will hold
26 ; HL7 IN1 segments. Otherwise, ^TMP("VAFIN1",$J) will
27 ; be used.
28 ;
29 ; Output:
30 ; Array of HL7 IN1 segments
31 ;
32 N VAFGRP,VAFI,VAFIDX,VAFINS,VAFNODE,VAFPHN,VAFY,VAF36,X,VAFX,VAFTMP
33 S VAFARRY=$G(VAFARRY),VAFIDX=0
34 ;
35 ; if VAFARRY not defined, use ^TMP("VAFIN1",$J)
36 S:(VAFARRY="") VAFARRY="^TMP(""VAFIN1"",$J)"
37 ;
38 ; if VAFHLQ or VAFHLFS not passed, use default HL7 variables
39 S VAFHLQ=$S($D(VAFHLQ):VAFHLQ,1:$G(HLQ)),VAFHLFS=$S($D(VAFHLFS):VAFHLFS,1:$G(HLFS))
40 ;
41 ; if DFN not passed, exit
42 I '$G(DFN) S @VAFARRY@(1,0)="IN1"_VAFHLFS_1 G ENQ
43 ;
44 ; find all insurance data for a patient (IB SUPPORTED CALL)
45 ; This uses the Encapsulated Insurance API to retrieve data into an array
46 ; See IB*2*267 Release Notes v1.0 for flags and array ID's
47 S VAFX=$$INSUR^IBBAPI(DFN,,"R",.VAFTMP,"*")
48 ;
49 ; if no active insurance on file for patient, build IN1
50 I VAFX'=1 D
51 .; Build a null array if no insurance data returned
52 . F VAFI=1:1:22 S VAFINS(1,VAFI)=""
53 .; Merge array to remove first two nodes to simplify handling
54 E M VAFINS=VAFTMP("IBBAPI","INSUR")
55 ;
56ALL ; get all active insurance for patient
57 F VAFI=0:0 S VAFI=$O(VAFINS(VAFI)) Q:'VAFI D
58 .D BUILD
59 ;
60ENQ Q
61 ;
62 ;
63BUILD ; Build array of HL7 (IN1) segments
64 S $P(VAFY,VAFHLFS,36)="",VAFIDX=VAFIDX+1
65 ;
66 ; if VAFSTR not passed, return all data fields
67 I $G(VAFSTR)']"" S VAFSTR="4,5,7,8,9,12,13,15,16,17,28,36"
68 S VAFSTR=","_VAFSTR_","
69 ;
70 ; sequential number (required field)
71 S $P(VAFY,VAFHLFS,1)=VAFIDX
72 ;
73 ; build HL7 (IN1) segment fields
74 I VAFSTR[",3," S $P(VAFY,VAFHLFS,3)=+$P(VAFINS(VAFI,1),U) ;Insurance company IEN (P-190)
75 I VAFSTR[",4," S $P(VAFY,VAFHLFS,4)=$S($P(VAFINS(VAFI,1),U,2)]"":$P(VAFINS(VAFI,1),U,2),1:VAFHLQ) ; Insurance Carrier Name
76 I VAFSTR[",5," S X=$$ADDR1(VAFI) S $P(VAFY,VAFHLFS,5)=$S(+X>0:X,1:VAFHLQ)
77 I VAFSTR[",7," S X=$$HLPHONE^HLFNC(VAFINS(VAFI,6)) S $P(VAFY,VAFHLFS,7)=$S(X]"":X,1:VAFHLQ) ; Insurance Co. Phone Number
78 I VAFSTR[",8," S $P(VAFY,VAFHLFS,8)=$S(VAFINS(VAFI,18)]"":VAFINS(VAFI,18),1:VAFHLQ) ; Group Number
79 I VAFSTR[",9," S $P(VAFY,VAFHLFS,9)=$S($P(VAFINS(VAFI,8),U,2)]"":$P(VAFINS(VAFI,8),U,2),1:VAFHLQ) ; Group Name ** The Insurance Encapsulation API doesnot return a "Group" Name, this field will display the Policy Name returned by the API
80 I VAFSTR[",12," S X=$$HLDATE^HLFNC(VAFINS(VAFI,10)) S $P(VAFY,VAFHLFS,12)=$S(X]"":X,1:VAFHLQ) ; Policy Effective Date
81 I VAFSTR[",13," S X=$$HLDATE^HLFNC(VAFINS(VAFI,11)) S $P(VAFY,VAFHLFS,13)=$S(X]"":X,1:VAFHLQ) ; Policy Expiration Date
82 I VAFSTR[",15," S $P(VAFY,VAFHLFS,15)=$S(+$P($G(VAFINS(VAFI,21)),"^")>0:+$P(VAFINS(VAFI,21),"^"),1:VAFHLQ) ; Plan Type (ptr. to Type of Plan (#355.1) file)
83 I VAFSTR[",16," S $P(VAFY,VAFHLFS,16)=$S(VAFINS(VAFI,13)]"":VAFINS(VAFI,13),1:VAFHLQ) ; Name of Insured
84 I VAFSTR[",17," S X=$$WHOSE($P(VAFINS(VAFI,12),U)) S $P(VAFY,VAFHLFS,17)=$S(X]"":X,1:VAFHLQ) ; Whose Insurance
85 ;I VAFSTR[",28," S $P(VAFY,VAFHLFS,28)=VAFHLQ ; $S($P(VAFGRP,"^",6)]"":$P(VAFGRP,"^",6),1:VAFHLQ) ; Is Pre-Certification Required?
86 I VAFSTR[",36," S $P(VAFY,VAFHLFS,36)=$S(VAFINS(VAFI,14)]"":VAFINS(VAFI,14),1:VAFHLQ) ; Subscriber ID
87 ;
88 ; set all active insurance policies into array
89 S @VAFARRY@(VAFIDX,0)="IN1"_VAFHLFS_$G(VAFY)
90 Q
91 ;
92WHOSE(VAFWHO) ; Format Subscriber relationship for HL7 conversion
93 ;
94 ; Input: Subscriber relationship from Insurance API, ID=12
95 ; P - Patient
96 ; S - Spouse
97 ; O - Other
98 ;
99 ; Output:
100 ; v - Veteran
101 ; s - Spouse
102 ; o - Other
103 ;
104 S:VAFWHO["P" VAFWHO="V"
105 Q $$LOW^XLFSTR(VAFWHO)
106 ;
107ADDR1(VAFI) ; Format insurance company address from Insurance API for HL7 conversion.
108 ;
109 ; Input:
110 ; Index number for Insurance API array
111 ;
112 ; Output:
113 ; String in the form of the HL7 address field
114 ;
115 N VAFAD,VAFGL
116 S VAFAD=VAFINS(VAFI,2)
117 S VAFGL=VAFINS(VAFI,3)_"^"_$P(VAFINS(VAFI,4),U)_"^"_VAFINS(VAFI,5)
118 ;
119 ; convert DHCP address to HL7 format using HL7 utility
120 Q $$HLADDR^HLFNC(VAFAD,VAFGL)
121 ;
122ADDR(VAFPTR) ; Format insurance company address for HL7 conversion
123 ; Retained for backword compatibility
124 ;
125 ; Input:
126 ; VAFPTR - pointer to Insurance Co. (#36) file
127 ;
128 ; Output:
129 ; String in the form of the HL7 address field
130 ;
131 N VAFAD,VAFADDR,VAFGL,VAFST
132 S VAFAD=""
133 ;
134 ; get (.11) node of Insurance Co. (#36) file
135 S VAFADDR=$G(^DIC(36,+VAFPTR,.11))
136 ;
137 ; 1st & 2nd street address lines
138 F VAFST=1,2 S VAFAD=VAFAD_"^"_$P(VAFADDR,"^",VAFST)
139 S VAFAD=$P(VAFAD,"^",2,99)
140 S VAFGL=$P(VAFADDR,"^",4) ; city
141 S VAFGL=VAFGL_"^"_$P(VAFADDR,"^",5) ; state
142 S VAFGL=VAFGL_"^"_$P(VAFADDR,"^",6) ; zip
143 ;
144 ; convert DHCP address to HL7 format using HL7 utility
145 Q $$HLADDR^HLFNC(VAFAD,VAFGL)
Note: See TracBrowser for help on using the repository browser.