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

ACHSXREF.m

Go to the documentation of this file.
ACHSXREF ; IHS/ITSC/PMF - UNDOCUMENTED X-REF FIX FOR CHS FACILITY FILE  [ 10/16/2001   8:16 AM ]
 ;;3.1;CONTRACT HEALTH MGMT SYSTEM;;JUN 11, 2001
 ;
 S U="^"
 S $ZT="ERROR^"_$ZN
 S %H=$H D YX^%DTC S NOW=Y
 I $G(ACHSVERS)="" S ACHSVERS="V3.1T1"
 ;
 S ^ACHSINST(ACHSVERS,$ZN,"ENTERED")=NOW
 ;
 S ACHSYAYA="" F  S ACHSYAYA=$O(^ACHSXREF(ACHSYAYA)) Q:ACHSYAYA=""  K ^(ACHSYAYA) ;RESET GLOBAL COUNTER
 K ACHSYAYA
 ;
 D EOBD
 D EOBP
 D EOBR
 D ES
 D PB
 D TB
 D VB
 D AC
 ;
 ;OKAY NOW LETS SEE IF ANY DANGLING XREFS FOUND ARE NOT IN THE
 ;SAVED FILE
 ;D COMPARE     ;WILL NOT BE OF USE UNLESS 'ARCHIVE' FILE IS STILL AROUND
 D CLEANUP
 ;
 S %H=$H D YX^%DTC S NOW=Y
 S ^ACHSINST(ACHSVERS,$ZN,"FINISHED")=NOW
 ;
 Q
 ;
EOBD ;
 S XREF="EOBD"
 S TOTALMIS=0
 S FACILITY=0
 W !!,"CHECKING EOBD X-REFS...."
 W !,"CROSS REFERENCE BY FUNKY DATE, DOCUMENT IEN, TRANSACTION IEN"
 F  S FACILITY=$O(^ACHSF(FACILITY)) Q:+FACILITY=0  D
 .S FUNKYDT=0
 .F  S FUNKYDT=$O(^ACHSF(FACILITY,"EOBD",FUNKYDT)) Q:+FUNKYDT=0  D
 ..S DOCNUM=0
 ..F  S DOCNUM=$O(^ACHSF(FACILITY,"EOBD",FUNKYDT,DOCNUM)) Q:+DOCNUM=0  D
 ...S TRANNUM=0
 ...F  S TRANNUM=$O(^ACHSF(FACILITY,"EOBD",FUNKYDT,DOCNUM,TRANNUM)) Q:+TRANNUM=0  D
 ....D DOCSUM,TRANSUM
 ...I KILLIT K ^ACHSF(FACILITY,"EOBD",FUNKYDT,DOCNUM) W !,"KILLING ^ACHSF("_FACILITY_","_XREF_","_FUNKYDT_","_DOCNUM_")"
 ;
 W !,"TOTAL MISSING: ",TOTALMIS
 Q
 ;
 ;
EOBP ;
 S XREF="EOBP"
 S TOTALMIS=0
 S FACILITY=0
 W !!,"CHECKING EOBP X-REFS...."
 W !,"CROSS REFERENCE BY PATEINT DFN , DOCUMENT IEN, TRANSACTION IEN"
 F  S FACILITY=$O(^ACHSF(FACILITY)) Q:+FACILITY=0  D
 .S PATNUM=0
 .F  S PATNUM=$O(^ACHSF(FACILITY,"EOBP",PATNUM)) Q:+PATNUM=0  D
 ..S DOCNUM=0
 ..F  S DOCNUM=$O(^ACHSF(FACILITY,"EOBP",PATNUM,DOCNUM)) Q:+DOCNUM=0  D
 ...S TRANNUM=0
 ...F  S TRANNUM=$O(^ACHSF(FACILITY,"EOBP",PATNUM,DOCNUM,TRANNUM)) Q:+TRANNUM=0  D
 ....D DOCSUM,TRANSUM
 ...I KILLIT K ^ACHSF(FACILITY,"EOBP",PATNUM,DOCNUM) W !,"KILLING ^ACHSF("_FACILITY_","_XREF_","_PATNUM_","_DOCNUM_")"
 ;
 W !,"TOTAL MISSING: ",TOTALMIS
 Q
 ;
EOBR ;
 S XREF="EOBR"
 W !!,"CHECKING EOBR X-REFS....."
 W !,"CROSS REFERENCE BY DOCUMENT IEN, TRANSACTION IEN, FUNKYDATE"
 S TOTALMIS=0
 S FACILITY=0
 F  S FACILITY=$O(^ACHSF(FACILITY)) Q:+FACILITY=0  D
 .S DOCNUM=0
 .F  S DOCNUM=$O(^ACHSF(FACILITY,"EOBR",DOCNUM)) Q:+DOCNUM=0  D
 ..S TRANNUM=0
 ..F  S TRANNUM=$O(^ACHSF(FACILITY,"EOBR",DOCNUM,TRANNUM)) Q:+TRANNUM=0  D
 ...D DOCSUM,TRANSUM
 ..I KILLIT K ^ACHSF(FACILITY,"EOBR",DOCNUM) W !,"KILLING ^ACHSF("_FACILITY_","_XREF_","_DOCNUM_")"
 ;
 W !,"TOTAL MISSING: ",TOTALMIS
 Q
 ;
ES ;
 S XREF="ES"
 S TOTALMIS=0
 S FACILITY=0
 W !!,"CHECKING ES X-REFS...."
 W !,"CROSS REFERENCE BY FUNKY DATE , DOCUMENT IEN"
 F  S FACILITY=$O(^ACHSF(FACILITY)) Q:+FACILITY=0  D
 .S FUNKYDT=0
 .F  S FUNKYDT=$O(^ACHSF(FACILITY,"ES",FUNKYDT)) Q:+FUNKYDT=0  D
 ..S DOCNUM=0
 ..F  S DOCNUM=$O(^ACHSF(FACILITY,"ES",FUNKYDT,DOCNUM)) Q:+DOCNUM=0  D
 ...D DOCSUM
 ...I KILLIT K ^ACHSF(FACILITY,"ES",FUNKYDT,DOCNUM) W !,"KILLING ^ACHSF("_FACILITY_","_XREF_","_FUNKYDT_","_DOCNUM_")"
 ;
 W !,"TOTAL MISSING: ",TOTALMIS
 Q
 ;
PB ;
 S XREF="PB"
 W !!,"CHECKING PB X-REFS....."
 W !,"CROSS REFERENCE BY PATIENT DFN, DOCUMENT IEN, TRANSACTION IEN"
 S TOTALMIS=0
 S FACILITY=0
 F  S FACILITY=$O(^ACHSF(FACILITY)) Q:+FACILITY=0  D
 .S DFN=0
 .F  S DFN=$O(^ACHSF(FACILITY,"PB",DFN)) Q:+DFN=0  D
 ..S DOCNUM=0
 ..F  S DOCNUM=$O(^ACHSF(FACILITY,"PB",DFN,DOCNUM)) Q:+DOCNUM=0  D
 ...S TRANNUM=0
 ...F  S TRANNUM=$O(^ACHSF(FACILITY,"PB",DFN,DOCNUM,TRANNUM)) Q:+TRANNUM=0  D
 ....D DOCSUM,TRANSUM
 ....I KILLIT K ^ACHSF(FACILITY,"PB",DFN,DOCNUM,TRANNUM) W !,"KILLING ^ACHSF("_FACILITY_","_XREF_","_DFN_","_DOCNUM_")"
 ;
 W !,"TOTAL MISSING: ",TOTALMIS
 Q
 ;
TB ;
 S XREF="TB"
 W !!,"CHECKING TB X-REFS....."
 W !,"CROSS REFERENCE BY DATE, TRANSACTION TYPE, DOCUMENT IEN, TRANSACTION IEN"
 S TOTALMIS=0
 S FACILITY=0
 F  S FACILITY=$O(^ACHSF(FACILITY)) Q:+FACILITY=0  D
 .S DATE=0
 .F  S DATE=$O(^ACHSF(FACILITY,"TB",DATE)) Q:+DATE=0  D
 ..S TRANTYPE=""
 ..F  S TRANTYPE=$O(^ACHSF(FACILITY,"TB",DATE,TRANTYPE)) Q:TRANTYPE=""  D
 ...S DOCNUM=0
 ...F  S DOCNUM=$O(^ACHSF(FACILITY,"TB",DATE,TRANTYPE,DOCNUM)) Q:+DOCNUM=0  D
 ....S TRANNUM=0
 ....F  S TRANNUM=$O(^ACHSF(FACILITY,"TB",DATE,TRANTYPE,DOCNUM,TRANNUM)) Q:+TRANNUM=0  D
 .....D DOCSUM,TRANSUM
 ...I KILLIT K ^ACHSF(FACILITY,"TB",DATE,TRANTYPE,DOCNUM) W !,"KILLING ^ACHSF("_FACILITY_","_XREF_","_DATE_","_TRANTYPE_","_DOCNUM_")"
 ;
 W !,"TOTAL MISSING: ",TOTALMIS
 Q
 ;
VB ;
 S XREF="VB"
 W !!,"CHECKING VB X-REF....."
 W !,"CROSS REFERENCE BY PROVIDER IEN, DOCUMENT IEN, TRANSACTION IEN"
 S TOTALMIS=0
 S FACILITY=0
 F  S FACILITY=$O(^ACHSF(FACILITY)) Q:+FACILITY=0  D
 .S PROVNUM=0
 .F  S PROVNUM=$O(^ACHSF(FACILITY,"VB",PROVNUM)) Q:+PROVNUM=0  D
 ..S DOCNUM=0
 ..F  S DOCNUM=$O(^ACHSF(FACILITY,"VB",PROVNUM,DOCNUM)) Q:+DOCNUM=0  D
 ...S TRANNUM=0
 ...F  S TRANNUM=$O(^ACHSF(FACILITY,"VB",PROVNUM,DOCNUM,TRANNUM)) Q:+TRANNUM=0  D
 ....D DOCSUM,TRANSUM
 ...I KILLIT K ^ACHSF(FACILITY,"VB",PROVNUM,DOCNUM) W !,"KILLING ^ACHSF("_FACILITY_","_XREF_","_PROVNUM_","_DOCNUM_")"
 ;
 W !,"TOTAL MISSING: ",TOTALMIS
 Q
 ;
AC ;
 S XREF="AC"
 W !!,"CHECKING AC X-REF...."
 W !,"CROSS REFERENCE BY PROVIDER IEN, DOCUMENT IEN, TRANSACTION IEN"
 S TOTALMIS=0
 S PATNUM=0
 F  S PATNUM=$O(^ACHSF("AC",PATNUM)) Q:+PATNUM=0  D
 .S FACILITY=0
 .F  S FACILITY=$O(^ACHSF("AC",PATNUM,FACILITY)) Q:+FACILITY=0  D
 ..S DOCNUM=0
 ..F  S DOCNUM=$O(^ACHSF("AC",PATNUM,FACILITY,DOCNUM)) Q:+DOCNUM=0  D
 ...S TRANNUM=0
 ...F  S TRANNUM=$O(^ACHSF("AC",PATNUM,FACILITY,DOCNUM,TRANNUM)) Q:+TRANNUM=0  D
 ....D DOCSUM,TRANSUM
 ....I KILLIT K ^ACHSF("AC",PATNUM,FACILITY,DOCNUM) W !,"KILLING ^ACHSF("_XREF_","_PATNUM_","_FACILITY_","_DOCNUM_")"
 W !,"TOTAL MISSING: ",TOTALMIS
 Q
 ;
DOCSUM ;
 S KILLIT=0
 Q:$D(^ACHSF(FACILITY,"D",DOCNUM,0))
 S TOTALMIS=TOTALMIS+1
 S ^ACHSXREF(FACILITY,DOCNUM,XREF)=$G(^ACHSXREF(FACILITY,DOCNUM,XREF))+1
 ;W !!,"FAC: ",FACILITY
 ;W !,"DOC: ",DOCNUM
 D DOCALL(FACILITY,DOCNUM)      ;CHECK FOR INFO IN OTHER DOCUMENT NODES
 I 'BARE W !,"DATA WAS FOUND IN OTHER NODES FOR DOCUMENT "_DOCNUM_" IN FACILITY "_FACILITY_" . INVESTIGATION NEEDED!" Q
 ;
 ;IF WE DON'T HAVE A ZERO NODE AND WE CAN'T FIND ANY OTHER NODES
 ;ITS OBVIOUSLY A ROGUE POINTER
 S KILLIT=1
 Q
 ;
TRANSUM ;
 S KILLIT=0
 Q:$D(^ACHSF(FACILITY,"D",DOCNUM,"T",TRANNUM,0))
 S TOTALMIS=TOTALMIS+1
 S ^ACHSXREF(FACILITY,DOCNUM,TRANNUM,XREF)=$G(^ACHSXREF(FACILITY,DOCNUM,TRANNUM,XREF))+1
 ;W !!,"FAC: ",FACILITY
 ;W !,"DOC: ",DOCNUM
 ;W !,"TRAN:",TRANNUM
 D DOCALL(FACILITY,DOCNUM)          ;CHECK IF IT HAS OTHER NODES DEFINED
 I 'BARE W !,"DATA FOUND IN OTHER NODES. INVESTIGATION NEEDED!" Q
 S KILLIT=1
 ;
 Q
 ;
 ;WHAT IF THE DOCUMENT DOESN'T HAVE A ZERO NODE BUT IT HAS OTHER NODES?
 ;
DOCALL(FACILITY,DOCNUM) ;
 S BARE=1      ;ASSUME IT DOESN'T HAVE DATA
 F SUB=1:1:11 D
 .I $D(^ACHSF(FACILITY,"D",DOCNUM,SUB)) D
 ..;W !,"DATA IN NODE: ",SUB
 ..S BARE=0
 Q
 ;CHECK DANGLING XREFS TO DOCUMENTS IN
 ;SAVED FILE /usr/spool/uucppublic/ ACHSF.SAV
COMPARE ;
 ;FORM OF THE COMMAND
 ;grep "\^ACHSF(4,\"D\",62,0)" /usr/spool/uucppublic/ACHSF.SAV
 ;LETS SEE IF THE SO CALLED "ARCHIVE" FILE IS OUT THERE.
 S NOTOPEN=$$OPEN^%ZISH("/usr/spool/uucppublic/","ACHSF.SAV","R")
 ;
 ;5/2/01   pmf   don't write this message out, it looks bad.
 ;record it, though.  the message is worded to fall between
 ;the ENTERED message and the FINISHED message.
 ;I NOTOPEN W !!!,"CANNOT FIND FILE" Q
 I NOTOPEN S ^ACHSINST(ACHSVERS,$ZN,"FIND ARCHIVE NEGATIVE")=NOW
 ;
 S FILENAME="/usr/spool/uucppublic/ACHSF.SAV"
 W !!,"SEARCHING TARGET FILE...."
 S FACILITY=0
 F FACCNT=1:1 S FACILITY=$O(^ACHSXREF(FACILITY)) Q:+FACILITY=0  D
 .S DOCUMENT=""
 .F DOCCNT=1:1 S DOCUMENT=$O(^ACHSXREF(FACILITY,DOCUMENT)) Q:DOCUMENT=""  D
 ..W:DOCCNT#100 "."
 ..;IS ^ACHSF(FACILITY,"D",DOCUMENT,0) IN THE FILE?
 ..S TARGET="""\^ACHSF("_FACILITY_",\""D\"","_DOCUMENT_",0)"""
 ..S HOSTCMD="grep "_TARGET_" "_FILENAME
 ..S X=$$TERMINAL^%HOSTCMD(HOSTCMD)
 ..I X=0 S ^ACHSXREF("D",FACILITY,DOCUMENT)=""
 ..;
 ..S TRANNUM=""
 ..F TRANCNT=1:1 S TRANNUM=$O(^ACHSXREF(FACILITY,DOCUMENT,TRANNUM)) Q:TRANNUM=""  D
 ...;IS ^ACHSF(FACILITY,"D",DOCUMENT,"T",TRANSACTION NUMBER,0) IN FILE?
 ...S TARGET="""\^ACHSF("_FACILITY_",\""D\"","_DOCUMENT_",\""T\"","_TRANNUM_",0)"""
 ...S HOSTCMD="grep "_TARGET_" "_FILENAME
 ...S X=$$TERMINAL^%HOSTCMD(HOSTCMD)
 ...I X=0 S ^ACHSXREF("T",FACILITY,DOCUMENT,TRANNUM)=""
 ;
 Q
 ;
ERROR ;
 I $G(ACHSVERS)="" S ACHSVERS="V3.1T1"
 S ^ACHSINST(ACHSVERS,"ERROR",$ZN,"ERROR TRAP CALLED")=""
 G ^%ET
 Q
 ;
 ;CLEANUP
CLEANUP ;
 K ACHSYAYA,DATE,DFN,DOCCNT,DOCNUM,DOCUMENT,FACCNT,FACILITY,FILENAME,FUNKYDT,HOSTCMD,NOTOPEN,PATNUM,PROVNUM,SUB,TARGET,TOTALMIS,TRANCNT,TRANNUM,TRANTYPE,X,XREF
 Q