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

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

initial load of FOIAVistA 6/30/08 version

File size: 3.9 KB
Line 
1VAFCADT4 ;ALB/RJS - HL7 ADT BREAKOUT OF VAFCADT1 - APRIL 13,1995
2 ;;5.3;Registration;**91**;Jun 06, 1996
3 ;
4 ;This routine was broken out of routine VAFCADT1 and
5 ;contains numerous functions and procedures used by that routine
6 ;
7INSERT(DFN,EVENT,VAFHDT,PIVOT) ;
8 I $$LASTONE(VAFHDT) D BLDMSG^VAFCADT2(DFN,EVENT,VAFHDT,"05","",PIVOT) Q
9 D BLDMSG^VAFCADT2(DFN,EVENT,VAFHDT,"04","",PIVOT)
10 I $$RECORD(VAFHDT)["ADMISSION" D BOTH(DFN,VAFHDT,PIVOT) Q
11 I $$RECORD(VAFHDT)["TRANSFER"&($$RECORD(VAFHDT)["SPECIALTY") D BOTH(DFN,VAFHDT,PIVOT) Q
12 I $$RECORD(VAFHDT)["TRANSFER" D TRANSFER(DFN,VAFHDT,PIVOT) Q
13 I $$RECORD(VAFHDT)["SPECIALTY" D SPECLTY(DFN,VAFHDT,PIVOT)
14 Q
15 ;
16 ;
17DELETE(DFN,EVENT,VAFHDT,PIVOT,EVTYPE) ;
18 I $$LASTONE(VAFHDT) D BLDMSG^VAFCADT2(DFN,EVENT,VAFHDT,"05","",PIVOT) Q
19 D BLDMSG^VAFCADT2(DFN,EVENT,VAFHDT,"04","",PIVOT)
20 I EVTYPE=2.2 D BOTH(DFN,VAFHDT,PIVOT) Q
21 I EVTYPE=2.6 D SPECLTY(DFN,VAFHDT,PIVOT) Q
22 I EVTYPE=3.2 D BOTH(DFN,VAFHDT,PIVOT) Q
23 I EVTYPE=3.6 D SPECLTY(DFN,VAFHDT,PIVOT) Q
24 Q
25 ;
26 ;
27BOTH(DFN,VAFHDT,PIVOT) ;
28 N FINISHED,FOUND1,FOUND2,RECORD
29 S (FINISHED,FOUND1,FOUND2)=0
30 F S VAFHDT=$O(HISTORY(VAFHDT)) Q:VAFHDT=""!(FINISHED) D
31 . S IEN=""
32 . F S IEN=$O(HISTORY(VAFHDT,IEN)) Q:IEN=""!(FINISHED) D
33 . . S RECORD=HISTORY(VAFHDT,IEN)
34 . . I RECORD["TRANSFER" S FOUND1=1
35 . . I RECORD["SPECIALTY" S FOUND2=1
36 . . I FOUND1&(FOUND2) S FINISHED=1 Q
37 . . I (RECORD["LASTONE") D BLDMSG^VAFCADT2(DFN,"A08",VAFHDT,"05",IEN,PIVOT) S FINISHED=1 Q
38 . . D BLDMSG^VAFCADT2(DFN,"A08",VAFHDT,"04","",PIVOT)
39 Q
40 ;
41 ;
42TRANSFER(DFN,VAFHDT,PIVOT) ;
43 N FINISHED,RECORD S FINISHED=0
44 F S VAFHDT=$O(HISTORY(VAFHDT)) Q:VAFHDT=""!(FINISHED) D
45 . S IEN=""
46 . F S IEN=$O(HISTORY(VAFHDT,IEN)) Q:IEN=""!(FINISHED) D
47 . . S RECORD=HISTORY(VAFHDT,IEN)
48 . . I RECORD["TRANSFER" S FINISHED=1 Q
49 . . I (RECORD["LASTONE") D BLDMSG^VAFCADT2(DFN,"A08",VAFHDT,"05",IEN,PIVOT) S FINISHED=1 Q
50 . . D BLDMSG^VAFCADT2(DFN,"A08",VAFHDT,"04","",PIVOT)
51 Q
52 ;
53 ;
54SPECLTY(DFN,VAFHDT,PIVOT) ;
55 N FINISHED,RECORD S FINISHED=0
56 F S VAFHDT=$O(HISTORY(VAFHDT)) Q:VAFHDT=""!(FINISHED) D
57 . S IEN=""
58 . F S IEN=$O(HISTORY(VAFHDT,IEN)) Q:IEN=""!(FINISHED) D
59 . . S RECORD=HISTORY(VAFHDT,IEN)
60 . . I RECORD["SPECIALTY" S FINISHED=1 Q
61 . . I (RECORD["LASTONE") D BLDMSG^VAFCADT2(DFN,"A08",VAFHDT,"05",IEN,PIVOT) S FINISHED=1 Q
62 . . D BLDMSG^VAFCADT2(DFN,"A08",VAFHDT,"04","",PIVOT)
63 Q
64 ;
65ENTIRE(PIVOT) ;
66 N VAFHDT,IEN,RECORD
67 S VAFHDT=""
68 F S VAFHDT=$O(HISTORY(VAFHDT)) Q:VAFHDT="" D
69 . S IEN="",EVCODE="04"
70 . F S IEN=$O(HISTORY(VAFHDT,IEN)) Q:IEN="" D
71 . . S RECORD=HISTORY(VAFHDT,IEN)
72 . . I RECORD["LASTONE" S EVCODE="05"
73 . . I RECORD["ADMISSION" D BLDMSG^VAFCADT2(DFN,"A01",VAFHDT,"05","",PIVOT) Q
74 . . I RECORD["TRANSFER" D BLDMSG^VAFCADT2(DFN,"A02",VAFHDT,EVCODE,"",PIVOT) Q
75 . . I RECORD["SPECIALTY" D BLDMSG^VAFCADT2(DFN,"A08",VAFHDT,EVCODE,"",PIVOT) Q
76 . . I RECORD["DISCHARGE" D BLDMSG^VAFCADT2(DFN,"A03",VAFHDT,EVCODE,IEN,PIVOT) Q
77 Q
78 ;
79 ;
80LASTONE(VAFHDT) ;
81 N IEN,RESULT,NEXTDATE S RESULT=0
82 S NEXTDATE=$O(HISTORY(VAFHDT))
83 I $G(NEXTDATE)="" S RESULT=1 G LASTEND
84 S IEN=$O(HISTORY(VAFHDT,""))
85 I $G(IEN)'="" D
86 . I HISTORY(VAFHDT,IEN)["LASTONE" S RESULT=1
87LASTEND ;
88 Q RESULT
89 ;
90 ;
91RECORD(VAFHDT) ;
92 N IEN
93 S IEN=$O(HISTORY(VAFHDT,""))
94 Q HISTORY(VAFHDT,IEN)
95 ;
96 ;
97ADMDATE(IEN) ;
98 N RESULT
99 S RESULT=$P($G(^DGPM(IEN,0)),"^",1)
100 Q:$G(RESULT)="" 0
101 Q RESULT
102HISTORY ;
103 N VAFHDT,IEN
104 S VAFHDT=""
105 F S VAFHDT=$O(HISTORY(VAFHDT)) Q:VAFHDT="" D
106 . S IEN=""
107 . F S IEN=$O(HISTORY(VAFHDT,IEN)) Q:IEN="" D
108 . . W !,VAFHDT," ---> ",HISTORY(VAFHDT,IEN)
109 Q
110 ;
111ADDING(DFN,EVENT,VAFHDT,PIVOT,PIVCHK) ;
112 I PIVCHK'>0 D ENTIRE(PIVOT) Q
113 D INSERT(DFN,EVENT,VAFHDT,PIVOT)
114 Q
115 ;
116PIVINIT(DFN,VAFHDATE,ADMSSN) ;
117 S PIVCHK=$$PIVCHK^VAFHPIVT(DFN,VAFHDATE,1,ADMSSN_";DGPM(")
118 S PIVOT=$$PIVNW^VAFHPIVT(DFN,VAFHDATE,1,ADMSSN_";DGPM(")
119 Q
120 ;
121SETVARS(NODE,DGPMDA) ;
122 S TYPE=$P(NODE,"^",2),VAFHDT=$P(NODE,"^",1),ADMSSN=$P(NODE,"^",14),IEN=DGPMDA Q
123 ;
124MOVETYPE(NODE) ;
125 N TYPE
126 S TYPE=$P(NODE,"^",18)
127 I TYPE>0 Q TYPE
128 Q 0
Note: See TracBrowser for help on using the repository browser.