source: FOIAVistA/trunk/r/PCE_PATIENT_CARE_ENCOUNTER-AUTN-EFDP-PX-VSIT--PXRM/VSITKIL.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.7 KB
Line 
1VSITKIL ;ISL/ARS,JVS - NON INTERACTIVE CHECK DEPENDENT ENTRY COUNT ;8/15/97
2 ;;1.0;PCE PATIENT CARE ENCOUNTER;**76**;Aug 12, 1996
3 ; Patch PX*1*76 changes the 2nd line of all VSIT* routines to reflect
4 ; the incorporation of the module into PCE. For historical reference,
5 ; the old (VISIT TRACKING) 2nd line is included below to reference VSIT
6 ; patches.
7 ;
8 ;;2.0;VISIT TRACKING;**1,2**;Aug 12, 1996
9 ;;
10KILL(VSITKDFN) ; ENTER THE VSIT YOU WANT CHECKED SET VSITKDFN=IEN
11 ; VSITKDFN = Vsit Ien REQUIRED
12 ;
13 N DIK,VSITKDEC,VSITKND
14 S VSITKND=""
15 ;
16 G:VSITKDFN'=+VSITKDFN!(VSITKDFN="") XIT
17 G:'$D(^AUPNVSIT(VSITKDFN,0)) XIT
18 ;
19 L +^AUPNVSIT(VSITKDFN):45
20 S VSITKDEC=$P(^AUPNVSIT(VSITKDFN,0),"^",9)
21 S VSITKND=$$DEC^VSITKIL(VSITKDFN)
22 I VSITKND'=VSITKDEC,VSITKND'=$P(^AUPNVSIT(VSITKDFN,0),"^",9) S $P(^AUPNVSIT(VSITKDFN,0),"^",9)=VSITKND
23 ;Check delete flag and reindex
24 I VSITKND>0,$P(^AUPNVSIT(VSITKDFN,0),"^",11)=1 D
25 . S $P(^AUPNVSIT(VSITKDFN,0),"^",11)=0
26 . S DA=VSITKDFN
27 . S DIK="^AUPNVSIT("
28 . D IX^DIK
29 . K DIK,DA,DR
30 I VSITKND=0 D
31 . S DIK="^AUPNVSIT("
32 . S DA=VSITKDFN
33 . D ^DIK
34 . K DIK,DA
35 . L -^AUPNVSIT(VSITKDFN)
36 . K VSITKDFN
37 E L -^AUPNVSIT(VSITKDFN)
38XIT ;exit
39 Q VSITKND
40 ;
41DOC ; This routine checks the dependent entry count of the VISIT file for
42 ; accuracy. If it is not correct it is replaced with a correct count
43 ; The count is determined by scanning each of the VISIT related
44 ; files for entries that point to that VISIT. A count is incremented
45 ; each time a "hit" is made.
46 ; The user can enter the visit IEN and if there is not any entries
47 ; pointing to the entry it is deleted. (not logically but totally)
48 Q
49 ;
50DEC(VISIT,VISUAL) ;Test looking through DD to find fields pointing to the visit entries.
51 ; VISIT=Visit ien to looked up and counted
52 ; VISUAL= Set to 1 if you want and interactive display of what is found
53 ;
54 ; Look for file and field
55 ;
56 N BECKY,COUNT,FIELD,FILE,GET,PIECE,PX,REF,SNDPIECE,STOP,SUB,VAUGHN
57 N VDD,VDDN,VDDR
58 ;
59 S FILE=""
60 F S FILE=$O(^DD(9000010,0,"PT",FILE)) Q:FILE="" D
61 .S FIELD=""
62 .F S FIELD=$O(^DD(9000010,0,"PT",FILE,FIELD)) Q:FIELD="" D
63 ..S VDD(FILE,FIELD)=""
64 D REF,QUE
65 K VDDN,VDDR
66 I $G(VISUAL) W !,"COUNT= "
67 Q COUNT
68 ;
69REF ;Look for all of the regular cross references and other
70 ;
71 S FILE="" F S FILE=$O(VDD(FILE)) Q:FILE="" D
72 .S FIELD="" F S FIELD=$O(VDD(FILE,FIELD)) Q:FIELD="" D
73 ..D REG
74 K VDD
75 Q
76 ;
77REG ;Look for regular cross references
78 ;
79 S STOP=0
80 I '$D(^DD(FILE,FIELD,1)) S VDDN(FILE,FIELD)="" Q
81 S SUB=0 F S SUB=$O(^DD(FILE,FIELD,1,SUB)) Q:SUB="" D
82 .S GET=$G(^DD(FILE,FIELD,1,SUB,0))
83 .I $P(GET,"^",3)']"" S VDDR(FILE,SUB)=FILE_"^"_FIELD_"^"_SUB S STOP=1
84 .E S VDDN(FILE,FIELD)=""
85 Q
86QUE ;CHECK OUT CROSS REFERENCE
87 ;
88 S FILE="",FIELD="",STOP="",COUNT=0
89 F S FILE=$O(VDDR(FILE)) Q:FILE="" D
90 .S SUB=0,STOP="" F S SUB=$O(VDDR(FILE,SUB)) Q:SUB="" Q:STOP=1 S GET=$G(VDDR(FILE,SUB)) D
91 ..S REF=$G(^DD($P(GET,"^",1),$P(GET,"^",2),1,$P(GET,"^",3),1))
92 ..I $P(REF,"""",1)["DA(1)" Q
93 ..S PIECE=$P(REF," ",2)
94 ..S SNDPIECE=$P(PIECE,"""",1,2)_""""
95 ..S VAUGHN=$P(PIECE,"""",1,2)_""")"
96 ..I $D(@VAUGHN) D S STOP=1
97 ...S PX=SNDPIECE_",VISIT)"
98 ...I $D(@PX) D
99 ....S BECKY=0 F S BECKY=$O(@PX@(BECKY)) Q:BECKY="" S COUNT=COUNT+1 W:$G(VISUAL) !," ",SNDPIECE_","_VISIT_","_BECKY
100 Q
101 ;
102COMP ;COMPARE DEC WITH WHAT UTILITY SAYS
103 ;Call this entry point to loop through the entire file to see the
104 ;dependent entry points that aren't accurate
105 ;
106 N CNT,DEC,DEC1,KYRON
107 ;
108 S CNT=0
109 S KYRON=0 F S KYRON=$O(^AUPNVSIT(KYRON)) Q:KYRON'>0 D
110 .S DEC=$P(^AUPNVSIT(KYRON,0),"^",9)
111 .S DEC1=$$DEC^VSITKIL(KYRON,0)
112 .I DEC="",DEC1=0 ;ok, both are zero
113 .E I DEC'=DEC1 D
114 ..W !,"Visit= "_KYRON,?20,"Entry's Dependent Entry Count= "_DEC,?56,"Found= "_DEC1,?68,"BAD"
115 ..S CNT=CNT+1
116 ..S DEC1=$$DEC^VSITKIL(KYRON,1)
117 W !!,"BAD COUNTS "_CNT
118 Q
Note: See TracBrowser for help on using the repository browser.