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

ACHSYCX.m

Go to the documentation of this file.
  1. ACHSYCX ; IHS/ITSC/PMF - CROSS REFERENCE CLEANUP FOR CHS FACILITY FILE ; [ 04/19/2002 12:14 PM ]
  1. ;;3.1;CONTRACT HEALTH MGMT SYSTEM;**4**;JUN 11, 2001
  1. ;ACHS*3.1*4 whole routine is new
  1. ;
  1. ;look for cross references to documents that are not there and
  1. ;kill them. this utility does not check xrefs down to the trans
  1. ;level, just the doc level. So if a xref points to a doc that
  1. ;is there and a transaction that is not there, nothing is done.
  1. ;
  1. ;the xrefs all have their name, i.e., TB, in subscript 2 except
  1. ;for AC, where it is ss 1, and B, where it is ss 2. the routine
  1. ;is generic enough to handle that
  1. ;
  1. ;EOBR has the document pointer in position 3
  1. ;B and TB have doc pointer in position 5
  1. ;the rest have doc pointer in position 4
  1. ;
  1. ;if the flag MOCK is set, it means we've entered from another
  1. ;routine and we will not kill anything, just find the buggers
  1. ;
  1. S DOLH=$H,DOLH=$TR(DOLH,",","_")
  1. S MOCK=$G(MOCK)
  1. K COUNT
  1. ;
  1. ;before we get started, clean up anything this util stored
  1. ;in ^TEMP more than 90 days ago
  1. S XDOLH="" F S XDOLH=$O(^TEMP("ACHSCLXR",XDOLH)) Q:XDOLH="" Q:((XDOLH+3)>+DOLH) K ^TEMP("ACHSCLXR",XDOLH)
  1. ;
  1. F XREF="AC","B","EOBD","EOBP","EOBR","ES","PB","PDOS","TB","VB" D CLEAN
  1. ;
  1. I MOCK W !!!,"This was a trial run and no actual changes were made",!,"These numbers are counts only"
  1. W !!!,"Number of cross references examined:",?50,+$G(COUNT("TOTCHK"))
  1. W !!,"Total number of cross references removed:",?50,+$G(COUNT("KILL"))
  1. W !
  1. F XREF="AC","B","EOBD","EOBP","EOBR","ES","PB","PDOS","TB","VB" W !,"For cross reference ",XREF,":",?50,+$G(COUNT(XREF))
  1. W !!
  1. S ^TEMP("ACHSCLXR",DOLH)=$H
  1. ;
  1. K COUNT,DOLH,FAC,MOCK,SS1,SS2,SS3,SS4,SS5,XREF,XDOLH
  1. Q
  1. ;
  1. CLEAN ;
  1. ;handle AC as a special case, since it appears in the first
  1. ;subscript position
  1. I XREF="AC" S SS1="AC" D CLEAN2 Q
  1. S SS1=0 F S SS1=$O(^ACHSF(SS1)) Q:'SS1 D CLEAN2
  1. Q
  1. ;
  1. CLEAN2 ;
  1. I XREF="B" S SS2="D" D CLEAN3 Q
  1. I XREF'="AC" S SS2=XREF D CLEAN3 Q
  1. S SS2="" F S SS2=$O(^ACHSF(SS1,SS2)) Q:SS2="" D CLEAN3
  1. Q
  1. ;
  1. CLEAN3 ;
  1. I XREF="B" S SS3=XREF D CLEAN4 Q
  1. S SS3="" F S SS3=$O(^ACHSF(SS1,SS2,SS3)) Q:SS3="" D CLEAN4
  1. Q
  1. ;
  1. CLEAN4 ;
  1. ;we can now identify the facility code. It's in subscript 1
  1. ;unless the cross reference is AC, then it's in ss 3.
  1. ;
  1. I XREF="AC" S FAC=SS3
  1. E S FAC=SS1
  1. ;
  1. ;for cross reference EOBR, doc pointer is in ss3, so we are
  1. ;ready to test
  1. I XREF="EOBR" D Q
  1. . S COUNT("TOTCHK")=$G(COUNT("TOTCHK"))+1 I COUNT("TOTCHK")#500=0 W " ."
  1. . I $D(^ACHSF(FAC,"D",SS3)) Q
  1. . M ^TEMP("ACHSCLXR",DOLH,SS1,SS2,SS3)=^ACHSF(SS1,SS2,SS3)
  1. . S COUNT("KILL")=$G(COUNT("KILL"))+1
  1. . S COUNT(XREF)=$G(COUNT(XREF))+1
  1. . I MOCK Q
  1. . K ^ACHSF(SS1,SS2,SS3)
  1. . Q
  1. S SS4="" F S SS4=$O(^ACHSF(SS1,SS2,SS3,SS4)) Q:SS4="" D CLEAN5
  1. Q
  1. ;
  1. CLEAN5 ;
  1. ;all of the cross references have the doc pointer in ss4, except
  1. ;EOBR, which is already done, and TB and B, which are handled as
  1. ;exceptions
  1. ;
  1. I XREF'="TB",(XREF'="B") D Q
  1. . S COUNT("TOTCHK")=$G(COUNT("TOTCHK"))+1 I COUNT("TOTCHK")#500=0 W " ."
  1. . I $D(^ACHSF(FAC,"D",SS4)) Q
  1. . M ^TEMP("ACHSCLXR",DOLH,SS1,SS2,SS3,SS4)=^ACHSF(SS1,SS2,SS3,SS4)
  1. . S COUNT("KILL")=$G(COUNT("KILL"))+1
  1. . S COUNT(XREF)=$G(COUNT(XREF))+1
  1. . I MOCK Q
  1. . K ^ACHSF(SS1,SS2,SS3,SS4)
  1. . Q
  1. S SS5="" F S SS5=$O(^ACHSF(SS1,SS2,SS3,SS4,SS5)) Q:SS5="" D CLEAN6
  1. Q
  1. ;
  1. CLEAN6 ;
  1. S COUNT("TOTCHK")=$G(COUNT("TOTCHK"))+1 I COUNT("TOTCHK")#500=0 W " ."
  1. I $D(^ACHSF(FAC,"D",SS5)) Q
  1. M ^TEMP("ACHSCLXR",DOLH,SS1,SS2,SS3,SS4,SS5)=^ACHSF(SS1,SS2,SS3,SS4,SS5)
  1. S COUNT("KILL")=$G(COUNT("KILL"))+1
  1. S COUNT(XREF)=$G(COUNT(XREF))+1
  1. I MOCK Q
  1. K ^ACHSF(SS1,SS2,SS3,SS4,SS5)
  1. Q