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

ACHSPOST.m

Go to the documentation of this file.
ACHSPOST ; IHS/ITSC/TPF/PMF - POST INIT FOR CHS DENIALS/DEFERRED SVCS ; JUL 10, 2008 
 ;;3.1;CONTRACT HEALTH MGMT SYSTEM;**14**;JUN 11,2001
 ;3.1*14 12.4.2007 IHS/OIT/FCJ ADDED CSV CHANGES
 ;
 S $ZT="ERROR^"_$ZN
 ;
 ;if this is a restart, certain vars won't be set.  we can set
 ;them now, restart or not, and no harm done
 S U="^"
 S ACHSVERS="V"_$P($T(+2),";",3)
 S $P(LINE,"*",81)=""
 ;
 ;set the time, record the start
 S %H=$H D YX^%DTC S NOW=Y
 S ^ACHSINST(ACHSVERS,$ZN,"ENTERED")=NOW
 ;
 I $D(^ACHSINST(ACHSVERS,"ERROR")) S ^ACHSINST(ACHSVERS,"ERROR","PREVIOUS ERRORS HAVE NOT BEEN CLEARED")=NOW S ERROR=1,XPDABORT=1 D START^ACHSPOSM(ERROR) Q
 ;
 ;
 I '$D(^ACHSINST(ACHSVERS,"ACHSPRE","FINISHED")) W !!,"ACHSPOST IS DEPENDENT ON ACHSPRE!!" S XPDABORT=1,ERROR=1,^ACHSINST(ACHSVERS,"ERROR","ATTEMPT VIA "_$ZN,"CHS INSTALL","STATUS")="ACHSPRE NOT RUN"_U_NOW D START^ACHSPOSM(ERROR) Q
 ;
 ;
 N ACHD,ACHDPT,ACHDX,ACHDY,ACHDZ,DA,DIC,DIE,DIK,DD,DO,DR
 ;
 W !!,"Beginning CHS 3.1 Post Init at ",$$FMTE^XLFDT(NOW),!!
 ;
 ;
 ;
 D DIVCHK     ;CHECK ACTIVE DIVISIONS ON THIS SYSTEM
              ;USED LATER TO SET UP DICTIONARY GLOBALS
              ;
 ;
 W !!,LINE
 D DDCHECK    ;CHECK TO SEE IF DENIAL DATA DICTIONARIES WERE INITILAIZED
              ;PROPERLY
 ;
 I ERROR=2 D
 .W !!,"WARNING: The following files may have an error in the zero"
 .W !,"node of the data dictionary entry. Please report this to ITSC"
 .W !!
 .S FILE=""
 .F  S FILE=$O(ERRLIST(FILE)) Q:FILE=""  D
 ..S FILENAME=$O(^DD(FILE,0,"NM",""))
 ..W !?10,FILE,?20,FILENAME
 .D START^ACHSPOSM(ERROR)
 ;
 W !!,LINE
 ;
 ;THE FOLLOWING DATA IS ONLY LOADED IF THE DATA DOES NOT ALREADY EXIST
 ;ON THE INSTALLING SYSTEM. EXCEPT DENIAL REASONS. EXISTING DENIAL
 ;ARE DE-ACTIVATED AND NEW ONES APPROVED BY CHS WORKGROUP ARE ADDED.
 ;
 D ^ACHSPOS1   ;DEFERRED SERVICE LETTER FORCE ENTRY
 ;              DENIAL STATUS FORCE ENTRY
 ;
 D ^ACHSPOS2   ;CALLS ACHSPOS3, DATA FOR DENIAL REASONS
 ;
 D ^ACHSPOS4   ;DATA FOR DENIAL FACILITY FILE
 ;
 D ^ACHSPOS5   ;DATA FOR MEDICAL PRIORITY FILE
 ;
 D ^ACHSPOS6   ; DATA FOR DEFERRED SERVICES CATEGORY FILE 
 ;
 D ^ACHSCONV   ;CONVERT CHS DENIAL DATA TO ACHS DATA STRUCTURE
 ;
 D KEYASS      ;ASSIGN THE 'ACHSZMENU' KEY TO ALL USERS WHO HAVE THE
               ;'ACHSMENU' OPTION
 ;
 ;D PULLCPT     ;PULL ALL CPT ENTRIES IN ALL CHS DOCUMENTS AND DELETE
 ;             ;POINTERS TO CPT ENTRIES WITH "unknown" IN PIECE 2 OF
 ;             ;NODE 1
 ; 
 D ^ACHSXREF    ;LOOK AT DANGLING X-REFS IN DOCUMENT FILE AND DELETE
 ;              ALSO WILL REPORT ON POSSIBLE ENTRIES THAT MAY BE FIXED
 ;
 S %H=$H D YX^%DTC S NOW=Y
 S ^ACHSINST(ACHSVERS,$ZN,"FINISHED")=NOW
 ;
 ;
 ;
 Q
 ;
 ;GET LIST OF ALL DIVISIONS ASSIGNED TO ACTIVE USERS ON THE SYSTEM
DIVCHK ;EP from ACHSPOS4
 S %H=$H D YX^%DTC S NOW=Y
 S ^ACHSINST(ACHSVERS,"DIVCHK^"_$ZN,"ENTERED")=NOW
 ;
 ;
 W !!,LINE
 W !!,"The following is a list of active facilities that have been"
 W !,"assigned to active users. You may want to review this list"
 W !,"to determine whether these are correct or not."
 ;
 W !!,"If the 'CHS DENIAL FACILITY' file does NOT exist, the install"
 W !,"will create an entry in the 'CHS DENIAL FACILITY' file so"
 W !,"denials can be entered for these facilities. Otherwise the"
 W !,"Site Manager will have to enter new denial facilities as"
 W !,"required."
 W !!
 S ACHSPERS=0
 F  S ACHSPERS=$O(^VA(200,ACHSPERS)) Q:+ACHSPERS=0  D
 .Q:$P($G(^VA(200,ACHSPERS,0)),U,11)'=""    ;TERMINATION DATE
 .Q:$P($G(^VA(200,ACHSPERS,"PS")),U,4)'=""  ;INACTIVE DATE
 .S ACHSDIV=0
 .F  S ACHSDIV=$O(^VA(200,ACHSPERS,2,ACHSDIV)) Q:+ACHSDIV=0  D
 ..;IS THE 'INACTIVE FACILITY FLAG' SET?
 ..Q:$P($G(^DIC(4,ACHSDIV,99)),U,4)="Y"!($P($G(^DIC(4,ACHSDIV,99)),U,4)="y")
 ..S ^ACHSINST(ACHSVERS,$ZN,"ACTIVE FACILITIES",ACHSDIV)=$P($G(^DIC(4,ACHSDIV,0)),U)
 ;FOLLOWING JUST FOR TESTING
 W !!,"FACILITY IEN",?15,"FACILITY NAME"
 W !,"------------",?15,"-------------"
 S ACHSDIV=""
 F  S ACHSDIV=$O(^ACHSINST(ACHSVERS,$ZN,"ACTIVE FACILITIES",ACHSDIV)) Q:ACHSDIV=""  D
 .S ACHSDNM=$P($G(^DIC(4,ACHSDIV,0),"UNDEFINED"),U)
 .W !,ACHSDIV,?15,ACHSDNM
 ;
 W !!,LINE
 S %H=$H D YX^%DTC S NOW=Y
 S ^ACHSINST(ACHSVERS,"DIVCHK^"_$ZN,"FINISHED")=NOW
 Q
 ;
 ;ASSIGN 'ACHSZMENU' KEY TO 'ACHSMENU' OPTION HOLDERS
KEYASS ;
 S %H=$H D YX^%DTC S NOW=Y
 S CURDATE=X
 S OKEYNUM=$O(^DIC(19.1,"B","ACHSZMENU",""))  ;GET IEN OF OLD MENU KEY
 ;
 S NKEYNUM=$O(^DIC(19.1,"B","ACHSZDEFDENMENU",""))  ;NEW KEY NUMBER
 Q:NKEYNUM=""
 S PERSIEN=0
 F  S PERSIEN=$O(^VA(200,PERSIEN)) Q:+PERSIEN=0  D
 .;QUIT IF THE PERSON DOESN'T HAVE EITHER OF THE NEW OR OLD KEYS
 .Q:'$D(^VA(200,PERSIEN,51,"B",OKEYNUM))&('$D(^VA(200,PERSIEN,51,"B",OKEYNUM)))
 .W !!,"PERSON CURRENTLY HAS NEW OR OLD KEY: ",!,$P($G(^VA(200,PERSIEN,0)),U)
 .S TERMDT=$P($G(^VA(200,PERSIEN,0)),U,11)
 .S:TERMDT="" TERMDT=9999999
 .;
 .I TERMDT<CURDATE!(TERMDT=CURDATE) W !,"PERSON DEACTIVATED! KEY NOT ADDED" Q
 .I $D(^VA(200,PERSIEN,51,"B",NKEYNUM)) S X="ACHSZMENU",DA(1)=PERSIEN,DIC(0)="L",DIC="^VA(200,"_DA(1)_",51,",DLAYGO=200 D ^DIC W !,"PERSON ALREADY HAS NEW KEY! ASSIGNING OLD KEY"
 .I $D(^VA(200,PERSIEN,51,"B",OKEYNUM)) S X="ACHSZDEFDENMENU",DA(1)=PERSIEN,DIC(0)="L",DIC="^VA(200,"_DA(1)_",51,",DLAYGO=200 D ^DIC W !,"PERSON ALREADY HAS NEW KEY! ASSIGNING OLD KEY"
 .;
 .S ^ACHSINST(ACHSVERS,$ZN,"KEY ASSIGNMENTS",PERSIEN)=$P($G(^VA(200,PERSIEN,0)),U)
 .W ?50,"KEY ADDED TO ACTIVE USER"
 ;
 Q
 ;CHECK DENIAL DATA DICTIONARIES  - JUST A WARNING
DDCHECK ;
 S ERROR=0
 S ERRLIST=""
 I $P($G(^DD(9002061,0)),U,4)'=2 D SET(9002061) S ERROR=2,ERRLIST(9002061)=""
 I $P($G(^DD(9002062,0)),U,4)'=5 D SET(9002062) S ERROR=2,ERRLIST(9002062)=""
 I $P($G(^DD(9002063,0)),U,4)'=2 D SET(9002063) S ERROR=2,ERRLIST(9002063)=""
 I $P($G(^DD(9002064,0)),U,4)'=6 D SET(9002064) S ERROR=2,ERRLIST(9002064)=""
 I $P($G(^DD(9002064.1,0)),U,4)'=2 D SET(9002064.1) S ERROR=2,ERRLIST(9002064.1)=""
 I $P($G(^DD(9002065,0)),U,4)'=42 D SET(9002065) S ERROR=2,ERRLIST(9002065)=""
 I $P($G(^DD(9002066,0)),U,4)'=4 D SET(9002066) S ERROR=2,ERRLIST(9002066)=""
 I $P($G(^DD(9002066.5,0)),U,4)'=4 D SET(9002066.5) S ERROR=2,ERRLIST(9002066.5)=""
 I $P($G(^DD(9002067,0)),U,4)'=3 D SET(9002067) S ERROR=2,ERRLIST(90020667)=""
 I $P($G(^DD(9002068,0)),U,4)'=2 D SET(9002068) S ERROR=2,ERRLIST(9002068)=""
 I $P($G(^DD(9002069,0)),U,4)'=14 D SET(9002069) S ERROR=2,ERRLIST(9002069)=""
 I $P($G(^DD(9002070,0)),U,4)'=2 D SET(9002070) S ERROR=2,ERRLIST(9002070)=""
 I $P($G(^DD(9002071,0)),U,4)'=2 D SET(9002071) S ERROR=2,ERRLIST(9002071)=""
 I $P($G(^DD(9002072,0)),U,4)'=33 D SET(9002072) S ERROR=2,ERRLIST(9002072)=""
 I $P($G(^DD(9002072.1,0)),U,4)'=9 D SET(9002072.1) S ERROR=2,ERRLIST(9002072.1)=""
 I $P($G(^DD(9002073,0)),U,4)'=5 D SET(9002073) S ERROR=2,ERRLIST(9002073)=""
 I $P($G(^DD(9002073.1,0)),U,4)'=5 D SET(9002073.1) S ERROR=2,ERRLIST(9002073.1)=""
 I $P($G(^DD(9002074,0)),U,4)'=3 D SET(9002074) S ERROR=2,ERRLIST(9002074)=""
 I $P($G(^DD(9002075,0)),U,4)'=2 D SET(9002075) S ERROR=2,ERRLIST(9002075)=""
 I $P($G(^DD(9002076,0)),U,4)'=3 D SET(9002076) S ERROR=2,ERRLIST(9002076)=""
 I $P($G(^DD(9002077,0)),U,4)'=2 D SET(9002077) S ERROR=2,ERRLIST(9002077)=""
 I $P($G(^DD(9002078,0)),U,4)'=2 D SET(9002078) S ERROR=2,ERRLIST(9002078)=""
 I $P($G(^DD(9002079,0)),U,4)'=15 D SET(9002079) S ERROR=2,ERRLIST(9002079)=""
 I $P($G(^DD(9002080,0)),U,4)'=50 D SET(9002080) S ERROR=2,ERRLIST(9002080)=""
 Q
 ;
 ;SET INSTALL GLOBAL WITH INFO
SET(NUM) ;
 S %H=$H D YX^%DTC S NOW=Y
 S ^ACHSINST(ACHSVERS,"WARNING",$ZN,"CHS BAD DD INSTALL",NUM)=NOW
 Q
END ;
 ;
 D KTMP,NOW^%DTC
 W !!,"CHS 3.1 Post-Init Complete ",$$FMTE^XLFDT(%)
 S %H=$H D YX^%DTC S NOW=Y
 S ^ACHSINST(ACHSVERS,"CHS INSTALL","STATUS","INSTALL FINISHED")=NOW
 ;
MAIL ;
 S ERROR=0
 D START^ACHSPOSM(ERROR)    ;NO ERROR
 Q
 ;
 ;KILL TEMP DATA GLOBALS
KTMP ;
 K ^TMP($J,"DEN"),^TMP($J,"FAC"),^TMP($J,"DEF"),^TMP($J,"MPRI")
 Q
 ;
ERROR S ^ACHSINST(ACHSVERS,"ERROR",$ZN,"ERROR TRAP CALLED")=""
 G ^%ET
 Q
 ;
 ;GO THRU ACHS FILES AND PULL CPT POINTERS. DELETE THOSE THAT POINT TO
 ;CPT ENTRIES WITH THE SECOND PIECE OF THE ZERO NODE ="unknown"
PULLCPT ;
 S ACHSVERS="V"_$P($T(+2),";",3)
 S U="^"
 D DOCCPT    ;PULL CPTs FROM 'CHS FACILITY'
 D DENCPT    ;PULL CPTs FROM 'CHS DENIAL DATA'
 D DEFCPT    ;PULL CPTs FROM 'CHS DEFERRED SERVICES DATA'
 ;D CLEANUP   ;CLEANUP ENTRIES IN ^ICPT WITH "unknown" IN SECOND
 ;            PIECE OFNODE 0
 Q
 ;
 ;GO THROUGH 'CHS FACILITY' FILE AND PULL CPT POINTERS
DOCCPT ;
 S %H=$H D YX^%DTC S NOW=Y
 S ^ACHSINST(ACHSVERS,"DOCCPT^"_$ZN,"ENTERED")=NOW
 ;
 S CPTCNT=0
 S FACILITY=0
 F  S FACILITY=$O(^ACHSF(FACILITY)) Q:+FACILITY=0  D
 .;
 .S DOCUMENT=0
 .F DOCCNT=1:1 S DOCUMENT=$O(^ACHSF(FACILITY,"D",DOCUMENT)) Q:+DOCUMENT=0  D
 ..;W !,DOCUMENT
 ..S CPTMULT=0
 ..F  S CPTMULT=$O(^ACHSF(FACILITY,"D",DOCUMENT,11,CPTMULT)) Q:+CPTMULT=0  D
 ...S CPTINFO=$G(^ACHSF(FACILITY,"D",DOCUMENT,11,CPTMULT,0))
 ...Q:CPTINFO=""!(CPTINFO'[("ICPT("))
 ...S CODE=$P($P(CPTINFO,";"),U)
 ...;
 ...;IS THIS A BAD CHS CPT ENTRY?
 ...;3.1*14 12.4.2007 IHS/OIT/FCJ ADDED CSV CHANGES NXT 2 LINES
 ...;Q:$P($G(^ICPT(CODE,0)),U,2)'="unknown"   ;NO THEN QUIT
 ...Q:$P($$CPT^ICPTCOD(CODE),U,3)'="unknown"   ;NO THEN QUIT
 ...S CPTCNT=CPTCNT+1   ;NUMBER OF CPT ENTRIES IN THE CHS GLOBAL
 ...S DA(2)=FACILITY
 ...S DA(1)=DOCUMENT
 ...S DA=CPTMULT
 ...S DIK="^ACHSF("_FACILITY_",""D"","_DA(1)_",11,"
 ...D ^DIK
 ...;K ^ACHSF(FACILITY,"D",DOCUMENT,11,CPTMULT)
 ...;K ^ACHSF(FACILITY,"D",DOCUMENT,11,"B",$P(CPTINFO,U))
 ...;S NUMENTRY=$P($G(^ACHSF(FACILITY,"D",DOCUMENT,11,0)),U,4)
 ...;S NUMENTRY=NUMENTRY-1
 ...;S $P(^ACHSF(FACILITY,"D",DOCUMENT,11,0),U,4)=NUMENTRY 
 ;
 ;
 S %H=$H D YX^%DTC S NOW=Y
 S ^ACHSINST(ACHSVERS,"DOCCPT^"_$ZN,"FINISHED")=NOW
 S ^ACHSINST(ACHSVERS,"DOCCPT^"_$ZN,"BAD CPT IN ^ACHSF")=CPTCNT
 ;
 Q
 ;
 ;NOW GET CPTs FROM 'CHS DEFERRED SERVICES DATA'
 ;
DEFCPT ;
 ;
 S %H=$H D YX^%DTC S NOW=Y
 S ^ACHSINST(ACHSVERS,"DEFCPT^"_$ZN,"ENTERED")=NOW
 ;
 S DEFCNT=0
 S FACILITY=0
 F  S FACILITY=$O(^ACHSDEF(FACILITY)) Q:+FACILITY=0  D
 .S DEFDOC=0
 .F  S DEFDOC=$O(^ACHSDEF(FACILITY,"D",DEFDOC)) Q:+DEFDOC=0  D
 ..S MULT=0
 ..F  S MULT=$O(^ACHSDEF(FACILITY,"D",DEFDOC,300,MULT)) Q:+MULT=0  D
 ...S DEFCPT=$P($G(^ACHSDEF(FACILITY,"D",DEFDOC,300,MULT,0)),U)
 ...Q:DEFCPT=""
 ...;IS THIS POINTING TO A BAD CHS CPT ENTRY?
 ...;3.1*14 12.4.2007 IHS/OIT/FCJ ADDED CSV CHANGES NXT 2 LINES
 ...;Q:$P($G(^ICPT(DEFCPT,0)),U,2)'="unknown"
 ...Q:$P($$CPT^ICPTCOD(DEFCPT),U,3)'="unknown"
 ...S DEFCNT=DEFCNT+1
 ...S DA(2)=FACILITY
 ...S DA(1)=DEFDOC
 ...S DA=MULT
 ...S DIK="^ACHSF("_FACILITY_",""D"","_DA(1)_",300,"
 ...D ^DIK
 ...;K ^ACHSDEF(FACILITY,"D",DEFDOC,300,MULT)
 ...;K ^ACHSDEF(FACILITY,"D",DEFDOC,300,"B",DEFCPT)
 ...;S NUMENTRY=$P($G(^ACHSDEF(FACILITY,"D",DEFDOC,300,0)),U,4)
 ...;S NUMENTRY=NUMENTRY-1
 ...;S $P(^ACHSDEF(FACILITY,"D",DEFDOC,300,0),U,4)=NUMENTRY 
 ;
 S %H=$H D YX^%DTC S NOW=Y
 S ^ACHSINST(ACHSVERS,"DEFCPT^"_$ZN,"FINISHED")=NOW
 S ^ACHSINST(ACHSVERS,"DEFCPT^"_$ZN,"BAD CPT IN ^ACHSDEF")=DEFCNT
 ;
 Q
 ;
 ;NOW GET CPTs FROM 'CHS DENIAL DATA' FILE
DENCPT ;
 ;
 S %H=$H D YX^%DTC S NOW=Y
 S ^ACHSINST(ACHSVERS,"DENCPT^"_$ZN,"ENTERED")=NOW
 ;
 S DENCNT=0
 S FACILITY=0
 F  S FACILITY=$O(^ACHSDEN(FACILITY)) Q:+FACILITY=0  D
 .S DENDOC=0
 .F  S DENDOC=$O(^ACHSDEN(FACILITY,"D",DENDOC)) Q:+DENDOC=0  D
 ..S MULT=0
 ..F  S MULT=$O(^ACHSDEN(FACILITY,"D",DENDOC,MULT)) Q:+MULT=0  D
 ...S DENCPT=$P($G(^ACHSDEN(FACILITY,"D",DENDOC,700,MULT,0)),U)
 ...Q:DENCPT=""
 ...;
 ...;IS THIS A BAD CHS CPT ENTRY?
 ...;3.1*14 12.4.2007 IHS/OIT/FCJ ADDED CSV CHANGES NXT 2 LINES
 ...;Q:$P($G(^ICPT(DENCPT,0)),U,2)'="unknown"
 ...Q:$P($$CPT^ICPTCOD(DENCPT),U,3)'="unknown"
 ...S DENCNT=DENCNT+1
 ...S DA(2)=FACILITY
 ...S DA(1)=DENDOC
 ...S DA=MULT
 ...S DIK="^ACHSF("_FACILITY_",""D"","_DA(1)_",700,"
 ...D ^DIK
 ...;K ^ACHSDEN(FACILITY,"D",DENDOC,700,MULT)
 ...;K ^ACHSDEN(FACILITY,"D",DENDOC,700,"B",DENCPT)
 ...;S NUMENTRY=$P($G(^ACHSDEN(FACILITY,"D",DENDOC,700,0)),U,4)
 ...;S NUMENTRY=NUMENTRY-1
 ...;S $P(^ACHSDEN(FACILITY,"D",DENDOC,700,0),U,4)=NUMENTRY 
 ;
 S %H=$H D YX^%DTC S NOW=Y
 S ^ACHSINST(ACHSVERS,"DENCPT^"_$ZN,"FINISHED")=NOW
 S ^ACHSINST(ACHSVERS,"DENCPT^"_$ZN,"BAD CPT IN ^ACHSDEN")=DENCNT
 ;
 Q
 ;
 ;CLEANUP CPT "unknown" ENTRIES
CLEANUP ;
 ;
 S CPTCODE=0
 F  S CPTCODE=$O(^ICPT(CPTCODE)) Q:+CPTCODE=0  D
 .;3.1*14 12.4.2007 IHS/OIT/FCJ ADDED CSV CHANGES NXT 2 LINES
 .;Q:$P($G(^ICPT(CPTCODE,0)),U,2)'="unknown"
 .Q:$P($$CPT^ICPTCOD(CPTCODE),U,3)'="unknown"
 .S DIK="^ICPT("
 .S DA=CPTCODE
 .D ^DIK
 .;
 Q
 ;
OPTS ;
 ;;ACHSDENADD
 ;;ACHSDENDELETE
 ;;ACHSDENDOCUMENT
 ;;ACHSDENEDIT
 ;;ACHSDENLETTER
 ;;ACHSDENMENU
 ;;ACHSDENPARM
 ;;ACHSDENPARMADDREA
 ;;ACHSDENPARMAMT
 ;;ACHSDENPARMBOT
 ;;ACHSDENPARMFAC
 ;;ACHSDENPARMHEAD
 ;;ACHSDENPARMLOF
 ;;ACHSDENPARMMID
 ;;ACHSDENPARMNUMS
 ;;ACHSDENPARMREA
 ;;ACHSDENPARMSIG
 ;;ACHSDENPARMUNMET
 ;;ACHSDENPVDRLIST
 ;;ACHSDENPVDRLISTNOT
 ;;ACHSDENREASONS
 ;;ACHSDENREP1
 ;;ACHSDENREPMENU
 ;;ACHSDENRPTHQ1
 ;;ACHSDENSTATS
 ;;ACHSDENUNMET