Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: VSITKIL

VSITKIL.m

Go to the documentation of this file.
  1. VSITKIL ;ISL/ARS,JVS - NON INTERACTIVE CHECK DEPENDENT ENTRY COUNT ;May 17, 2017@12:01
  1. ;;1.0;PCE PATIENT CARE ENCOUNTER;**76,204,211**;Aug 12, 1996;Build 454
  1. ; Patch PX*1*76 changes the 2nd line of all VSIT* routines to reflect
  1. ; the incorporation of the module into PCE. For historical reference,
  1. ; the old (VISIT TRACKING) 2nd line is included below to reference VSIT
  1. ; patches.
  1. ;
  1. ;;2.0;VISIT TRACKING;**1,2**;Aug 12, 1996
  1. ;;
  1. KILL(VSITKDFN) ; ENTER THE VSIT YOU WANT CHECKED SET VSITKDFN=IEN
  1. ; VSITKDFN = Vsit Ien REQUIRED
  1. ;
  1. N DIK,VSITKDEC,VSITKND,LOCK,ERROR
  1. S VSITKND=""
  1. G:$G(VSITKDFN)'?1.N XIT
  1. G:$D(^XTMP("AUPNVSIT",VSITKDFN)) XIT
  1. S LOCK=$$LOCK^PXLOCK(VSITKDFN,DUZ,2,.ERROR,"VSITKIL")
  1. G:'LOCK XIT
  1. I '$D(^AUPNVSIT(VSITKDFN,0)) D UNLOCK^PXLOCK(VSITKDFN,DUZ,"VSITKIL") G XIT
  1. ;
  1. S VSITKDEC=$P(^AUPNVSIT(VSITKDFN,0),U,9)
  1. S VSITKND=$$DEC^VSITKIL(VSITKDFN)
  1. I VSITKND'=VSITKDEC S $P(^AUPNVSIT(VSITKDFN,0),U,9)=VSITKND,VSITKDEC=VSITKND
  1. ;Check delete flag and reindex
  1. I VSITKND>0,$P(^AUPNVSIT(VSITKDFN,0),U,11)=1 D
  1. . S $P(^AUPNVSIT(VSITKDFN,0),U,11)=0
  1. . S DA=VSITKDFN
  1. . S DIK="^AUPNVSIT("
  1. . D IX^DIK
  1. . K DIK,DA,DR
  1. I VSITKND=0 D
  1. . S DIK="^AUPNVSIT("
  1. . S DA=VSITKDFN
  1. . D ^DIK
  1. . K DIK,DA
  1. . D UNLOCK^PXLOCK(VSITKDFN,DUZ,"VSITKIL")
  1. . K VSITKDFN
  1. E D UNLOCK^PXLOCK(VSITKDFN,DUZ,"VSITKIL")
  1. XIT ;exit
  1. Q VSITKND
  1. ;
  1. DOC ; This routine checks the dependent entry count of the VISIT file for
  1. ; accuracy. If it is not correct it is replaced with a correct count
  1. ; The count is determined by scanning each of the VISIT related
  1. ; files for entries that point to that VISIT. A count is incremented
  1. ; each time a "hit" is made.
  1. ; The user can enter the visit IEN and if there is not any entries
  1. ; pointing to the entry it is deleted. (not logically but totally)
  1. Q
  1. ;
  1. DEC(VISIT,VISUAL) ;Test looking through DD to find fields pointing to the visit entries.
  1. ; VISIT=Visit ien to looked up and counted
  1. ; VISUAL= Set to 1 if you want and interactive display of what is found
  1. ;
  1. ; Look for file and field
  1. ;
  1. N COUNT,FIELD,FILE,GET,PIECE,PX,REF,SNDPIECE,STOP,SUB,VAUGHN
  1. N VDD,VDDN,VDDR
  1. ;
  1. S FILE=""
  1. F S FILE=$O(^DD(9000010,0,"PT",FILE)) Q:FILE="" D
  1. .S FIELD=""
  1. .F S FIELD=$O(^DD(9000010,0,"PT",FILE,FIELD)) Q:FIELD="" D
  1. ..S VDD(FILE,FIELD)=""
  1. D REF,QUE
  1. K VDDN,VDDR
  1. I $G(VISUAL) W !,"COUNT= "
  1. Q COUNT
  1. ;
  1. REF ;Look for all of the regular cross references and other
  1. ;
  1. S FILE="" F S FILE=$O(VDD(FILE)) Q:FILE="" D
  1. .S FIELD="" F S FIELD=$O(VDD(FILE,FIELD)) Q:FIELD="" D
  1. ..D REG
  1. K VDD
  1. Q
  1. ;
  1. REG ;Look for regular cross references
  1. ;
  1. S STOP=0
  1. I '$D(^DD(FILE,FIELD,1)) S VDDN(FILE,FIELD)="" Q
  1. S SUB=0 F S SUB=$O(^DD(FILE,FIELD,1,SUB)) Q:SUB="" D
  1. .S GET=$G(^DD(FILE,FIELD,1,SUB,0))
  1. .I $P(GET,U,3)']"" S VDDR(FILE,SUB)=FILE_U_FIELD_U_SUB S STOP=1
  1. .E S VDDN(FILE,FIELD)=""
  1. Q
  1. QUE ;CHECK OUT CROSS REFERENCE
  1. ;
  1. S FILE="",FIELD="",COUNT=0
  1. F S FILE=$O(VDDR(FILE)) Q:FILE="" D
  1. .S SUB=0 F S SUB=$O(VDDR(FILE,SUB)) Q:SUB="" S GET=$G(VDDR(FILE,SUB)) D
  1. ..S REF=$G(^DD($P(GET,U,1),$P(GET,U,2),1,$P(GET,U,3),1))
  1. ..I $P(REF,"""",1)["DA(1)" Q
  1. ..S PIECE=$P(REF," ",2)
  1. ..S SNDPIECE=$P(PIECE,"""",1,2)_""""
  1. ..S VAUGHN=$P(PIECE,"""",1,2)_""")"
  1. ..I $D(@VAUGHN) D
  1. ...S PX=SNDPIECE_",VISIT)"
  1. ...I $D(@PX) S COUNT=COUNT+$$COUNT(PX)
  1. Q
  1. ;
  1. COUNT(NPX,UPPER) ;COUNT ENTRIES IN FILES AND SUB-FILES
  1. N LEVEL,TOTAL
  1. I $G(UPPER)'="" S NPX=$P(NPX,")")_","_UPPER_")"
  1. S LEVEL=0 F S LEVEL=$O(@NPX@(LEVEL)) Q:'+LEVEL D
  1. .I $D(@NPX@(LEVEL))>9 S TOTAL=$G(TOTAL)+$$COUNT(NPX,LEVEL)
  1. .I $D(@NPX@(LEVEL))<10 S TOTAL=$G(TOTAL)+1 W:$G(VISUAL) !," ",$P($NA(@NPX),")")_","_LEVEL
  1. Q +$G(TOTAL)
  1. COMP ;COMPARE DEC WITH WHAT UTILITY SAYS
  1. ;Call this entry point to loop through the entire file to see the
  1. ;dependent entry points that aren't accurate
  1. ;
  1. N CNT,DEC,DEC1,KYRON
  1. ;
  1. S CNT=0
  1. S KYRON=0 F S KYRON=$O(^AUPNVSIT(KYRON)) Q:KYRON'>0 D
  1. .S DEC=$P(^AUPNVSIT(KYRON,0),U,9)
  1. .S DEC1=$$DEC^VSITKIL(KYRON,0)
  1. .I DEC="",DEC1=0 ;ok, both are zero
  1. .E I DEC'=DEC1 D
  1. ..W !,"Visit= "_KYRON,?20,"Entry's Dependent Entry Count= "_DEC,?56,"Found= "_DEC1,?68,"BAD"
  1. ..S CNT=CNT+1
  1. ..S DEC1=$$DEC^VSITKIL(KYRON,1)
  1. W !!,"BAD COUNTS "_CNT
  1. Q