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

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

initial load of WorldVistAEHR

File size: 5.5 KB
Line 
1VAFHLPV1 ;ALB/CM/ESD HL7 PV1 SEGMENT BUILDING ;06/08/00
2 ;;5.3;Registration;**94,106,151,298,617**;Aug 13, 1993
3 ;
4 ;This routine will build an HL7 PV1 segment for an inpatient or
5 ;outpatient event depending on the entry point used.
6 ;Use IN for inpatient
7 ;Use OUT for outpatient
8 ;
9IN(DFN,VAFHDT,VAFSTR,IEN,PIVOT,SETID,VAFDIAG) ;
10 N RESULT
11 S RESULT=$$EN^VAFHAPV1(DFN,VAFHDT,VAFSTR,IEN,PIVOT,SETID,.VAFDIAG)
12 Q $G(RESULT)
13 ;
14OUT(DFN,EVT,EVDTS,VPTR,STRP,NUMP) ;
15 ;DFN - Patient File
16 ;EVT - event number from pivot file
17 ;EVDTS - event date/time in FileMan format
18 ;VPTR - variable pointer
19 ;STRP - string of fields (if null - required fields, if "A" - supported
20 ;fields, or string of fields seperated by commas")
21 ;NUMP - ID # (optional)
22 ;
23 N ERR
24 I '$D(NUMP) S NUMP=1
25 S ERR=$$OPV1^VAFHCPV($G(DFN),$G(EVT),$G(EVDTS),$G(VPTR),$G(STRP),NUMP)
26 Q ERR
27KVAR ;
28 K VAFHLPV1
29 Q
30 ;
31EN(VAFENC,VAFDENC,VAFSTR,VAFNUM,VAFHLQ,VAFHLFS) ;
32 ; Entry point for Ambulatory Care Database Project
33 ;
34 ; Entry point to return the HL7 PV1 (Patient Visit) segment
35 ;
36 ; Input: VAFENC - Outpatient Encounter IEN (pointer to Outpatient
37 ; Encounter file #409.68)
38 ;
39 ; VAFDENC - Deleted Outpatient Encounter IEN (pointer to
40 ; Deleted Outpatient Encounter file #409.74)
41 ;
42 ; VAFSTR - String of fields requested separated by commas
43 ;
44 ; VAFNUM - Set ID (sequential number - default=1)
45 ;
46 ; VAFHLQ - Optional HL7 null variable. If not there, use
47 ; default HL7 variable.
48 ;
49 ; VAFHLFS - Optional HL7 field separator. If not there, use
50 ; default HL7 variable.
51 ;
52 ; Output: String containing desired components of the PV1 segment
53 ;
54 ; NOTE: Data for the PV1 segment will be retrieved from either the
55 ; Outpatient Encounter file (#409.68) or Deleted Outpatient
56 ; Encounter (#409.74) based on the pointer parameter passed in.
57 ;
58 ;06/08/2000 ACS - AMBCARE PV1 CHANGES:
59 ; 1. SET UP HL7 DEFAULT VARIABLES AT BEGINNING OF SUBROUTINE.
60 ; 2. VALIDATE EXISTENCE OF AMBCARE ENCOUNTER.
61 ; 3. ALWAYS RETURN PATIENT CLASS IN SEGMENT.
62 ;
63 ;
64 N VAFAPTYP,VAFCLIN,VAFDAT,VAFDFN,VAFFLG,VAFNODE,VAFNODE1,VAFORIG,VAFPTCL,VAFY,X,VAINVENC,VAFPSTAT,VAFPIN
65 ;
66 ; - If VAFHLQ or VAFHLFS aren't passed in, use default HL7 variables.
67 S VAFHLQ=$S($D(VAFHLQ):VAFHLQ,1:$G(HLQ)),VAFHLFS=$S($D(VAFHLFS):VAFHLFS,1:$G(HLFS))
68 ;
69 ;- Sequential Number
70 S $P(VAFY,VAFHLFS,1)=$S($G(VAFNUM):VAFNUM,1:1)
71 ;
72 S VAFPTCL="O" ; Patient Class = Outpatient
73 ;
74 ;- Set patient class in segment
75 S $P(VAFY,VAFHLFS,2)=VAFPTCL
76 ;
77 ;- If encounter or variable string missing, pass back incomplete segment
78 I ($G(VAFENC)=""&($G(VAFDENC)=""))!($G(VAFSTR)="") G ENQ
79 ;
80 ; - If regular encounter doesn't exist, pass back incomplete segment
81 I $G(VAFENC) D G:$G(VAINVENC) ENQ
82 . I '$D(^SCE($G(VAFENC))) S VAINVENC=1
83 ;
84 ; - If deleted encounter doesn't exist, pass back incomplete segment
85 I $G(VAFDENC) D G:$G(VAINVENC) ENQ
86 . I '$D(^SD(409.74,$G(VAFDENC))) S VAINVENC=1
87 ;
88 S VAFENC=+$G(VAFENC),VAFDENC=+$G(VAFDENC)
89 S $P(VAFY,VAFHLFS,50)="",VAFSTR=","_VAFSTR_","
90 ;
91 ; - Set flag to indicate whether Outpatient Encounter ("E") or Deleted
92 ; Outpatient Encounter ("D").
93 S VAFFLG=$S(VAFENC:"E",1:"D")
94 ;
95 I VAFFLG="E" S VAFNODE=$$SCE^DGSDU(VAFENC)
96 ;
97 ; - VAFNODE1 = old encounter zero node for deleted encounter
98 I VAFFLG="D" D
99 . S VAFNODE=$G(^SD(409.74,VAFDENC,0))
100 . S VAFNODE1=$G(^SD(409.74,VAFDENC,1))
101 ;
102 ;- Reset patient class/status if Inpatient
103 S VAFPSTAT=$$INPATENC^SCDXUTL($S(VAFFLG="E":VAFENC,1:VAFDENC),$S(VAFFLG="E":1,1:2))
104 I VAFPSTAT S VAFPTCL="I" S $P(VAFY,VAFHLFS,2)=VAFPTCL
105 ;
106 ;- Purpose of Visit
107 I VAFSTR[",4," D
108 . S VAFDAT=$P(VAFNODE,"^"),VAFDFN=$P(VAFNODE,"^",2)
109 . S VAFCLIN=$S(VAFFLG="E":$P(VAFNODE,"^",4),1:$P(VAFNODE1,"^",4))
110 . S VAFAPTYP=$S(VAFFLG="E":$P(VAFNODE,"^",10),1:$P(VAFNODE1,"^",10))
111 . S X=$$POV^SCDXUTL0(VAFDFN,VAFDAT,VAFCLIN,VAFAPTYP)
112 . I X="" D
113 .. S VAFORIG=$S(VAFFLG="E":$P(VAFNODE,"^",8),1:$P(VAFNODE1,"^",8))
114 .. S X=$S(VAFORIG=2:"04"_$S($L(VAFAPTYP)=1:"0"_VAFAPTYP,1:VAFAPTYP),VAFORIG=3:"02"_$S($L(VAFAPTYP)=1:"0"_VAFAPTYP,1:VAFAPTYP),1:"")
115 . S $P(VAFY,VAFHLFS,4)=$S(X]"":X,1:VAFHLQ)
116 ;
117 ;- Location of Visit
118 I VAFSTR[",14," D
119 . S VAFCLIN=$S(VAFFLG="E":$P(VAFNODE,"^",4),1:$P(VAFNODE1,"^",4))
120 . S X=$P($G(^SC(+VAFCLIN,0)),"^",19),X=$S(X="Y":1,X="N":6,1:"")
121 . I X="" S VAFORIG=$S(VAFFLG="E":$P(VAFNODE,"^",8),1:$P(VAFNODE1,"^",8)),X=$S(VAFORIG=2!(VAFORIG=3):1,1:"")
122 . S $P(VAFY,VAFHLFS,14)=$S(X]"":X,1:VAFHLQ)
123 ;
124 ;- Outpatient Encounter IEN (not passed for deleted outpat encounter)
125 I VAFSTR[",19," S $P(VAFY,VAFHLFS,19)=$S(VAFFLG="E":VAFENC,1:VAFHLQ)
126 ;
127 ;- Facility Number and Suffix
128 I VAFSTR[",39," D
129 . ; add division parameter to $$SITE^VASITE call ; abr
130 . S X=$S(VAFFLG="E":$$SITE^VASITE($P(VAFNODE,"^"),$P(VAFNODE,"^",11)),1:$$SITE^VASITE($P(VAFNODE1,"^"),$P(VAFNODE1,"^",11)))
131 . S X=$P(X,"^",3)
132 . S $P(VAFY,VAFHLFS,39)=$S(X]"":X,1:VAFHLQ)
133 ;
134 ;- Encounter Date/Time for Outpatients & Admission Date for Inpatients
135 I VAFSTR[",44," D
136 . N DFN,VAIN
137 . S VAFPIN=0
138 . I VAFPSTAT S VAFPIN=$S(VAFFLG="E":$P(VAFNODE,"^",2),1:$P(VAFNODE1,"^",2)) I VAFPIN S DFN=VAFPIN D INP^VADPT S X=$P(VAIN(7),"^") I 'X S VAFPIN=0
139 . I 'VAFPIN S X=$S(VAFFLG="E":$P(VAFNODE,"^"),1:$P(VAFNODE1,"^"))
140 . S X=$$HLDATE^HLFNC(X)
141 . S $P(VAFY,VAFHLFS,44)=$S(X]"":X,1:VAFHLQ)
142 ;
143 ;- Unique Identifier (PCE)
144 I VAFSTR[",50," D
145 . S X=$S(VAFFLG="E":$P(VAFNODE,"^",20),1:$P(VAFNODE1,"^",20))
146 . S $P(VAFY,VAFHLFS,50)=$S(X]"":X,1:VAFHLQ)
147 ;
148ENQ Q "PV1"_VAFHLFS_$G(VAFY)
Note: See TracBrowser for help on using the repository browser.