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

ACHSPRE.m

Go to the documentation of this file.
ACHSPRE ;IHS/ITSC/PMF - ENVIRONMENT CHECK-NAMESPACE CLEANUP ;     [ 11/19/2001  8:18 AM ]
 ;;3.1;CONTRACT HEALTH MGMT SYSTEM;;JUN 11, 2001
 ;
 S $ZT="ERROR"
 S U="^",CM=","
 ;
 I 'XPDENV,$D(^ACHSINST) D
 . M ^ACHSINS1=^ACHSINST
 . S G="" F  S G=$O(^ACHSINST(G)) Q:G=""  K ^ACHSINST(G)
 . Q
 ;
 S ^ACHSINST="",G=$$NOJOURN^ZIBGCHAR("ACHSINIT")
 ;
 S ACHSVERS="V"_$P($T(+2),";",3)
 S $P(LINE,"*",81)=""
 ;
 I $D(^%ZOSF("MAXSIZ")) S X=250 X ^%ZOSF("MAXSIZ")
 ;
 ;GET THE CURRENT VERSION INSTALLED
 S PACKNUM=$O(^DIC(9.4,"B",$P($T(+2),";",4),""))
 I PACKNUM="" D  Q
 .W !,$$C^XBFUNC("THERE IS SOMETHING WRONG WITH YOUR PACKAGE FILE!!")
 .W !,$$C^XBFUNC("THE PACKAGE IEN COULD NOT BE FOUND IN FILE #9.4!")
 .S XPDABORT=1
 .D SORRY
 ;
 S CVERSION=$G(^DIC(9.4,PACKNUM,"VERSION"))
 I CVERSION="" D  Q
 .W !,"THERE IS SOMETHING WRONG WITH YOUR PACKAGE FILE!!"
 .W !,"THE PACKAGE VERSION IN FILE #9.4 COULD NOT BE FOUND!"
 .S XPDABORT=1
 .D SORRY
 ;
 W !,"Checking, please wait..."
 D INT^%SP
 I %FTOTBLK/%TOTBLK*100<2 D  Q
 . W !,"YOU HAVE LESS THAN 2% FREE SPACE.  THIS IS NOT ENOUGH SPACE TO DO THE INSTALL."
 . S XPDABORT=1
 . D SORRY
 . Q
 ;
 W !,"More checking, please wait..."
 S TOTBYT=0,GLOB="^ACHSDEN"
 F  S GLOB=$Q(@GLOB) Q:GLOB=""  S TOTBYT=TOTBYT+$L(GLOB)+$L(@GLOB)
 I TOTBYT*2.5/1012>%FTOTBLK D  Q
 . W !,"YOU DO NOT HAVE ENOUGH FREE SPACE TO RUN THIS INSTALL."
 . S XPDABORT=1
 . D SORRY
 . Q
 ;
 ;if we are doing the initial check prior to installing, it's time
 ;to do the conversion
 I 'XPDENV D CONV
 I $G(STOP) D  Q
 . W !,"THE TRIAL CONVERSION OF THE DENIAL DATA HAS FAILED"
 . S XPDABORT=1 D SORRY
 . Q
 ;
 I 'XPDENV W !!,"THE ENVIRONMENT CHECK WILL BE RUN WHEN THE INSTALL OPTION IS USED!" Q
 ;
 ;END of pre install check
 ;
 S XPDABORT=0
 ;
 I '$G(DUZ) W !,"DUZ UNDEFINED OR 0." S ^ACHSINST(ACHSVERS,"ERROR",$ZN,"DUZ VARIABLES NOT SET")=NOW S XPDABORT=1 D SORRY Q
 I '$L($G(DUZ(0))) W !,"DUZ(0) UNDEFINED OR NULL." S ^ACHSINST(ACHSVERS,"ERROR",$ZN,"DUZ VARIABLES NOT SET")=NOW S XPDABORT=1 D SORRY Q
 S INSTALER=$P($G(^VA(200,DUZ,0)),U)
 I INSTALER="" S %H=$H D YX^%DTC S NOW=Y S ^ACHSINST(ACHSVERS,"ERROR",$ZN,"UNKNOWN INSTALLER")=NOW S XPDABORT=1 D SORRY Q
 ;
ASKBACK ;
 S DIR(0)="Y^^"
 S DIR("A")="Has a SYSTEM BACKUP been successfully performed?"
 S DIR("B")="NO"
 S DIR("?")="Answer YES if backups were successfully performed."
 D ^DIR
 I $D(DUOUT) W !,"User initiated abort!",!,"Aborting installation!" S ERROR=1,XPDABORT=1 S ^ACHSINST(ACHSVERS,"ERROR",$ZN,"USER INITIATED ABORT!")=NOW Q
 I 'Y W !!,"Aborting installation!!" S ERROR=1,XPDABORT=1 S:Y="" ^ACHSINST(ACHSVERS,"ERROR",$ZN,"PROMPT TIMED OUT!")=NOW Q
ASKCAPT ;
 S DIR(0)="Y^^"
 S DIR("A")="Has the 'Capture to file' option been turned on?"
 S DIR("B")="NO"
 S DIR("?")="Answer YES if the 'Capture to file' option is ON."
 D ^DIR
 I $D(DUOUT) W !,"User initiated abort!",!,"Aborting installation!!" S ERROR=1,XPDABORT=1 S ^ACHSINST(ACHSVERS,"ERROR",$ZN,"USER INITIATED ABORT!")=NOW Q
 I 'Y W !!,"Aborting installation!!" S ERROR=1,XPDABORT=1 S:Y="" ^ACHSINST(ACHSVERS,"ERROR",$ZN,"PROMPT TIMED OUT!")=NOW Q
 ;
 ;
 D HOME^%ZIS,DT^DICRW
 S %H=$H D YX^%DTC S NOW=Y
 S ^ACHSINST(ACHSVERS,"CHS INSTALL","STATUS","INSTALL BEGUN")=NOW
 S ^ACHSINST(ACHSVERS,$ZN,"ENTERED")=NOW
 W !,LINE
 W !,$$C^XBFUNC("Hello, "_$P(INSTALER,CM,2)_" "_$P(INSTALER,CM)),!!,$$C^XBFUNC("Checking Environment for Installation of")
 W !,$$C^XBFUNC("VERSION "_$P($T(+2),";",3)_" of "_$P($T(+2),";",4)_".")
 S X=$G(^DD("VERSION"))
 ;
 W !!,"Need at least FileMan 21.....FileMan "_X_" Present"
 I X<21 S ^ACHSINST(ACHSVERS,"ERROR","ONLY HAVE FILEMAN "_X)=NOW W "  Not Present!" D SORRY Q
 S X=$G(^DIC(9.4,$O(^DIC(9.4,"C","XU",0)),"VERSION"))
 W !!,"Need at least Kernel 7.1.....Kernel "_X_" Present"
 I X<7.1 S ^ACHSINST(ACHSVERS,"ERROR","ONLY HAVE KERNEL "_X)=NOW W "  Not Present!" D SORRY Q
 W !!,"Need HFS interface to Kernel (^%ZISH)....."
 S ACHS=1
 S ACHSRCHK="'$L($T(@X"_$S($G(^%ZOSF("OS"))["UNIX":"^%ZISH",1:"^ZISHMSMD")_"))"
 F X="OPEN","DEL","SEND","LIST","STATUS" I @ACHSRCHK W !,$J("",20)_X_"^%ZISH not Present" S ACHS=0
 I 'ACHS S ^ACHSINST(ACHSVERS,"ERROR","NEED HFS INTERFACE ^%ZISH ROUTINES")=NOW D SORRY Q
 ;
 S X=$G(^DIC(9.4,$O(^DIC(9.4,"C","XB",0)),"VERSION"))
 W !!,"Need XB/ZIB, v 3.0.....XB/ZIB "_X_" Present"
 I X<3 S ^ACHSINST(ACHSVERS,"ERROR","NEED XB/ZIB INSTALLED")=NOW W "  Not Present!" D SORRY Q
 ;
 S X=$P($T(+2^AUTTVLK),";",3)
 S X=$S(X<89:"20"_X,1:"19"_X)
 S X=$S(X>1998:"Looks OK...",1:"")
 W !!,"Need AUT IHS Standard Data Dictionaries, at least v 98.1 ...."_X
 I '$L(X) S ^ACHSINST(ACHSVERS,"ERROR","NEED AUTT VERSION 98.1")=NOW S XPDABORT=1 W "  Not OK!" D SORRY Q
 S X=$P($T(+2^AUPNPAT),";",3)
 S X=$S(X<89:"20"_X,1:"19"_X)
 S X=$S(X>1999:"Looks OK...",1:"")
 W !!,"Need AUPN, at least v 99.1 ...."_X
 I '$L(X) S ^ACHSINST(ACHSVERS,"ERROR","NEED AUPN VERSION 99.1")=NOW S XPDABORT=1 W "  Not OK!" D SORRY Q
 K ^TMP("ACHSPOST",$J)
 ;
 ;check conversion finished node
 S RUNTIME="" F  S RUNTIME=$O(^ACHS("V3.1","denial conversion","AMOCK",RUNTIME)) Q:RUNTIME=""  I +$G(^(RUNTIME)) Q
 ;
 ;10/31/01  pmf  only check for the conversion if they are
 ;not already 3.1. replace one line
 ;I RUNTIME="" D  Q
 I RUNTIME="",(CVERSION<3.1) D  Q
 . W !!,"CONVERSION OF DENIAL DATA NOT FOUND"
 . S ^ACHSINST(ACHSVERS,"ERROR","CONVERSION NOT COMPLETE"_X)=NOW D SORRY
 . Q
 ;
 W !!,$$C^XBFUNC("ENVIRONMENT OK.")
 W !,LINE
 S %H=$H D YX^%DTC S NOW=Y
 S ^ACHSINST(ACHSVERS,$ZN,"ENVIRONMENT CHECK OK")=NOW
 ;
 S %H=$H D YMD^%DTC
 D DELDD
 ;
 W !!,"CHS DICTIONARIES FROM PREVIOUS VERSION HAVE BEEN DELETED!"
 D DELRTN
 S ^ACHSINST(ACHSVERS,$ZN,"CHS NAMESPACE DELETIONS FINISHED")=NOW
 W !!,"CHS ROUTINES FROM PREVIOUS VERSION HAVE BEEN DELETED!"
 W !!,LINE
 K ^TMP("ACHSPOST")
 Q
 ;
SORRY ;
 K DIFQ
 W *7,!!!,$$C^XBFUNC("Sorry....something is wrong with your environment")
 W !,$$C^XBFUNC("Aborting Contract Health System install!")
 W !,$$C^XBFUNC("Please print/capture this screen and notify")
 W !,$$C^XBFUNC("the Support Team")
 W !!,LINE
 S %H=$H D YX^%DTC S NOW=Y
 S XPDABORT=1
 ;
 S ^ACHSINST(ACHSVERS,$ZN,"ENVIRONMENT CHECK FAILED")=NOW
 S ^ACHSINST(ACHSVERS,$ZN,"ABORTED")=NOW
 ;
 S Y=$$DIR^XBDIR("E","Press RETURN To Continue...","","","",1) X ^%ZOSF("TRMRD")
 Q
 ;
DELRTN ;
 S XPDIDTOT=384,XPDIDVT=10,XGCURATR=10,IOBM=10
 D INIT^XPDID
 D TITLE^XPDID("DELETING OLD CHS ROUTINES")
 D SAY^XGF(10,10,"DELETING CHS ROUTINES.....")
 S %H=$H D YX^%DTC S NOW=Y
 S ^ACHSINST(ACHSVERS,"DELRTN^"_$ZN,"ENTERED")=NOW
 S %RN="ACHRZZZ" F COUNT=1:1 S %RN=$O(^(%RN)) Q:%RN'[("ACH")&(%RN'[("AZZZE"))  D
 .S $P(FILLER," ",IOM-$L(%RN))=""
 .D SAY^XGF(12,10,"DELETING "_%RN_"....."_FILLER)
 .X "ZR  ZS @%RN"
 .D UPDATE^XPDID(COUNT)
 S %H=$H D YX^%DTC S NOW=Y
 S ^ACHSINST(ACHSVERS,"DELRTN^"_$ZN,"FINISHED")=NOW
 D UPDATE^XPDID(0)
 D EXIT^XPDID("FINISHED WITH CHS ROUTINE DELETE!")
 Q
 ;
DELDD ;
 S XPDIDTOT=20,XPDIDVT=10,XGCURATR=10,IOBM=10
 D INIT^XPDID,TITLE^XPDID("DELETING OLD CHS DATA DICTIONARIES")
 S %H=$H D YX^%DTC S NOW=Y
 S ^ACHSINST(ACHSVERS,"DELDD^"_$ZN,"ENTERED")=NOW
 F GLO="^DIC(","^DD(" D
 .S FILENUM=9002060.999999
 .F COUNT=1:1  S FILENUM=$O(@(GLO_FILENUM_")")) Q:FILENUM>9002080.999999  D
 ..S GLOBAL=GLO_FILENUM_")"
 ..I '$D(@GLOBAL) D SAY^XGF(12,10,GLOBAL_" NOT FOUND ON THIS SYSTEM!") Q
 ..D UPDATE^XPDID(COUNT)
 ..D SAY^XGF(12,10,"KILLING GLOBAL "_GLOBAL_"  ..........")
 ..K @GLOBAL
 S TMP=$O(^DIC("B","CHS DEFERRED SERVICES CATEGORY",""))
 K:TMP=9002068 ^DIC("B","CHS DEFERRED SERVICES CATEGORY",9002068)
 S %H=$H D YX^%DTC S NOW=Y
 S ^ACHSINST(ACHSVERS,"DELDD^"_$ZN,"FINISHED")=NOW
 D UPDATE^XPDID(0)
 D EXIT^XPDID("FINISHED WITH CHS DATA DICTIONARY DELETE!")
 Q
 ;
CONV ; CONVERT CHS DENIAL DATA FROM OLD TO NEW STRUCTURE
 ;
 S %H=$H D YX^%DTC S NOW=Y,RUNTIME=Y
 I '$G(CVERSION) S ^ACHSINST(ACHSVERS,$ZN,"CONVERSION NOT DONE, FIRST TIME INSTALL")=NOW Q
 ;
 I +CVERSION>3 W !!,"THE CURRENT VERSION OF CHS IS HIGER THAN 3.0",!,"CONVERSION PROCESS WILL BE BYPASSED!" S ^ACHSINST(ACHSVERS,$ZN,"CONVERSION BYPASSED DUE TO HIGH VERSION")=NOW Q
 ;
 S LINE=$G(LINE)
 W !!,LINE,!!,"Starting trial conversion, please be patient"
 S ^ACHSINST(ACHSVERS,"CONV^"_$ZN,"ENTERED")=NOW
 ;
 S (NUMENTRY,NUMERR,STOP)=0,QT=""""
 ;
 ;S NODE=$G(^ACHSINST(VERS,"CONVERSION",MOCK,"LAST NODE"))
 S NODE=""
 I NODE="" S NODE="^ACHSDEN"
 ;
 ;stop journaling on the globals, if they exist
 S G=$$NOJOURN^ZIBGCHAR("ACHSDEN")
 I $D(^ACHSDENY) S G=$$NOJOURN^ZIBGCHAR("ACHSDENY")
 I $D(^ACHSDENZ) S G=$$NOJOURN^ZIBGCHAR("ACHSDENZ")
 ;
 ;kill off globals one and two, just in case they exist
 S G="" F  S G=$O(^ACHSDENY(G)) Q:G=""  K ^(G)
 S G="" F  S G=$O(^ACHSDENZ(G)) Q:G=""  K ^(G)
 ;
 ;establish top node of globals one and two
 S ^ACHSDENY="",^ACHSDENZ=""
 ;stop journaling on the globals again, now that we know they exist
 S G=$$NOJOURN^ZIBGCHAR("ACHSDEN"),G=$$NOJOURN^ZIBGCHAR("ACHSDENY"),G=$$NOJOURN^ZIBGCHAR("ACHSDENZ")
 ;
 M ^ACHSDENZ=^ACHSDEN
 S NEWNODE="^ACHSDENY("
 ;
 D LOOP1
 I 'STOP D SET1
 I 'STOP D LOOP2
 ;
 S %H=$H D YX^%DTC
 S ^ACHS("V3.1","denial conversion","AMOCK",RUNTIME)='STOP_U_Y
 ;
 S %H=$H D YX^%DTC S NOW=Y
 S ^ACHSINST(ACHSVERS,"CONV^"_$ZN,"FINISHED")=NOW
 ;
 Q
 ;
LOOP1 ;
 S $ZT="ERRORCN"
 ;
 F  S NODE=$Q(@NODE) Q:NODE=""!(STOP)  D
 . ;
 . ;SKIP X-REFS WE DO NOT NEED TO CONVERT THESE.
 . S FIRSTSUB=$P($P(NODE,CM),"(",2)
 . I FIRSTSUB?1""""1A.E1"""" Q
 . ;
 . ;check for alpha subscripts, indicating a cross reference
 . ;do not process these
 . S FOUND=0 F XXI=3:1:99 S XXS=$P($P(NODE,"(",2),CM,XXI) Q:XXS=""  I XXS?1""""1A.E1"""" S FOUND=1 Q
 . K XXI,XXS I FOUND Q
 . K FOUND
 . ;CHECK FOR NEW DATA STRUCTURE MIXED WITH OLD, copy new data as is
 . I NODE[("""D""") D ASIS Q
 . I NODE[(",0)"),$L(NODE,CM)=2 D REC0 Q
 . I NODE[(",10)") D REC10 Q
 . I NODE[(",100)") D REC100 Q
 . I NODE[(",200,") D REC200 Q
 . I NODE[(",210,") D REC210 Q
 . I NODE[(",290)") D REC290 Q
 . I NODE[(",300,") D REC300 Q
 . I NODE[(",400)") D REC400 Q
 . I NODE[(",500,") D REC500 Q
 . I NODE[(",600,") D REC600 Q
 . I NODE[(",650)") D REC650 Q
 . I NODE[(",700,") D REC700 Q
 . Q
 ;
 ;that ends the main loop of the conversion
 Q
 ;
SET1 ;
 S NEWNODE="^ACHSDENY(0)"
 S @NEWNODE="CHS DENIAL DATA^9002071I"_U_$S($G(ISSUEFAC)="":0,1:ISSUEFAC)_U_$S($G(NUMENTRY)="":0,1:NUMENTRY)
 ;
 ;DO COUNTS OF FACILITIES AND ITEMS WITHIN FACILITY
 S FAC=0 F CNT=1:1 S FAC=$O(^ACHSDENY(FAC)) Q:+FAC=0  D
 . S ITEM=0 F CNT2=1:1 S ITEM=$O(^ACHSDENY(FAC,"D",ITEM)) Q:+ITEM=0  D
 .. S NEWNODE="^ACHSDENY("_FAC_CM_QT_"D"_QT_CM_"0)"
 .. S @NEWNODE=U_"9002071.01A"_U_ITEM_U_CNT2
 .. Q
 . Q
 ;
 Q
 ;
LOOP2 ;
 ;the data is now converted and sitting in ^ACHSDENY.
 ;here we set up the cross references for it.
 W !!!,"Re-indexing new Denial file..."
 ;
 S FAC=0 F  S FAC=$O(^ACHSDENY(FAC)) Q:'+FAC  Q:STOP  S DEN=0 D LOOP2A
 Q
 ;
LOOP2A ;
 ;note start of new error trap
 S $ZT="ERRORXR"
 ;
 F  S DEN=$O(^ACHSDENY(FAC,"D",DEN)) Q:'+DEN  Q:STOP  D
 . S DAT=$G(^ACHSDENY(FAC,"D",DEN,0))
 . I DAT="" Q
 . S NODE="^ACHSDENY("_FAC_CM_QT_"D"_QT_CM_DEN
 . S DENIAL=$P(DAT,U,1),AISSUE=$P(DAT,U,2),ES=$P(DAT,U,4)
 . I AISSUE'="" S ^ACHSDENY(FAC,"D","AISSUE",AISSUE,DEN)=""
 . I DENIAL'="" S ^ACHSDENY(FAC,"D","B",DENIAL,DEN)=""
 . I ES'="" S ^ACHSDENY(FAC,"D","ES",ES,DEN)=""
 . Q
 Q
 ;
 W !,"Denial Updates Completed at ",$$FMTE^XLFDT(%)
 S ^ACHSINST(ACHSVERS,"REINDEX^"_$ZN,"FINISHED")=NOW
 ;
 Q
 ;
ASIS ;
 ;COPY AS IS THIS IS THE NEW DATA STRUCTURE
 S RECORD=$G(@NODE)
 S SUB1=$P(NODE,"(",2,299)
 S ASISNODE="^ACHSDEN("_SUB1
 S @ASISNODE=RECORD
 ;
 Q
 ;
REC0 ;
 ;GET THE ZERO NODE AND REARRANGE THE PIECES
 S NUMENTRY=NUMENTRY+1
 I NUMENTRY#100=0 W !,?18,NUMENTRY," denials examined so far"
 S REC0=$G(@NODE)
 S DENIAL=$P(REC0,U)
 S ISSUEDT=$P(REC0,U,2)
 S SERVDT=$P(REC0,U,3)
 S ISREG=$P(REC0,U,4)
 S PAT=$P(REC0,U,5)
 S ISSUEBY=$P(REC0,U,6)
 S REQDT=$P(REC0,U,7)
 S ISSUEFAC=$P(REC0,U,8)
 ;
 I ISSUEFAC="" S ISSUEFAC=$O(^ACHSF("B",0))
 ;
 S ENTRYNUM=$P($P(NODE,","),"(",2)
 ;
 ;CHECK FOR EXISTING ENTRIES HERE (THIS SHOULD ONLY HAPPEN IN SITES WITH
 ;THE OLD STRUCTURE MIXED WITH THE NEW)
 I $D(^ACHSDEN(ISSUEFAC,"D",ENTRYNUM)) W !,"ENTRY "_ENTRYNUM_" ALREADY EXISTS FOR THIS "_ISSUEFAC_"!" S ENTRYNUM=$O(^ACHSDEN(ISSUEFAC,"D","A"),-1)+1
 ;
 S NEWNODE="^ACHSDENY("_ISSUEFAC
 ;
 S @(NEWNODE_",0)")=ISSUEFAC
 S NODE0=NEWNODE_",""D"","_ENTRYNUM_",0)"
 S @NODE0=DENIAL_U_ISSUEDT_U_ISSUEBY_U_SERVDT_U_REQDT_U_ISREG_U_PAT
 ;
 Q
REC10 ;EP
 S REC10=$G(@NODE)     ;NO CHANGE IN PIECES
 S NODE10=NEWNODE_",""D"","_ENTRYNUM_",10)"
 S @NODE10=REC10
 Q
REC100 ;EP
 S REC100=$G(@NODE)   ;NO CHANGE IN PIECES
 S NODE100=NEWNODE_",""D"","_ENTRYNUM_",100)"
 S @NODE100=REC100
 Q
REC200 ;EP
 S REC200=$G(@NODE)
 I $P(REC200,U,2)="9002071.01PA" S $P(REC200,U,2)="9002071.02PA"
 S NODE200=NEWNODE_",""D"","_ENTRYNUM_",200"_$S(ENTRYNUM=200:$P(NODE,"200,200",2,99),1:$P(NODE,",200",2,99))
 S @NODE200=REC200
 Q
REC210 ;EP
 S REC210=$G(@NODE)   ;NO CHANGE IN PIECES
 I $P(REC210,U,2)="9002071.05A" S $P(REC210,U,2)="9002071.03A"
 S NODE210=NEWNODE_",""D"","_ENTRYNUM_",210"_$S(ENTRYNUM=210:$P(NODE,"210,210",2,99),1:$P(NODE,",210",2,99))
 S @NODE210=REC210
 Q
REC290 ;EP
 S REC290=$G(@NODE)   ;CHANGE TO NODE 250 SAME PIECE
 S NODE250=NEWNODE_",""D"","_ENTRYNUM_",250)"
 S @NODE250=REC290
 Q
REC300 ;EP
 S REC300=$G(@NODE)     ;NO CHANGE IN PIECES
 I $P(REC300,U,2)="9002071.02PA" S $P(REC300,U,2)="9002071.04PA"
 S NODE300=NEWNODE_",""D"","_ENTRYNUM_",300"_$S(ENTRYNUM=300:$P(NODE,"300,300",2,99),1:$P(NODE,",300",2,99))
 S @NODE300=REC300
 Q
REC400 ;EP
 S REC400=$G(@NODE)     ;PIECES CHANGE
 S DEFSER=$P(REC400,U)
 S PRICAT=$P(REC400,U,4)
 S MPRICAT=""
 S:PRICAT'="" MPRICAT=$O(^ACHSMPRI("B",PRICAT,MPRICAT))
 S APPEAL=$P(REC400,U,5)
 S NREC400=DEFSER_U_MPRICAT_U_APPEAL
 S NODE400=NEWNODE_",""D"","_ENTRYNUM_",400)"
 S @NODE400=NREC400
 Q
REC500 ;EP
 S REC500=$G(@NODE)
 I $P(REC500,U,2)="9002071.03PA" S $P(REC500,U,2)="9002071.05PA"
 S NODE500=NEWNODE_",""D"","_ENTRYNUM_",500"_$S(ENTRYNUM=500:$P(NODE,"500,500",2,99),1:$P(NODE,",500",2,99))
 S @NODE500=REC500
 Q
REC600 ;EP
 S REC600=$G(@NODE)
 I $P(REC600,U,2)="9002071.04PA" S $P(REC600,U,2)="9002071.06PA"
 S NODE600=NEWNODE_",""D"","_ENTRYNUM_",600"_$S(ENTRYNUM=600:$P(NODE,"600,600",2,99),1:$P(NODE,",600",2,99))
 S @NODE600=REC600
 Q
REC650 ;EP
 S REC650=$G(@NODE)
 S NODE500=NEWNODE_",""D"","_ENTRYNUM_",500,1,0)"
 I $D(@NODE500) D
 .S COM500=NEWNODE_",""D"","_ENTRYNUM_",500,1,1,0)"
 .S COM500C=NEWNODE_",""D"","_ENTRYNUM_",500,1,1,1,0)"
 .S @COM500=U_"9002071.53^1^1"
 .S @COM500C=REC650
 S NODE600=NEWNODE_",""D"","_ENTRYNUM_",600,1,0)"
 I $D(@NODE600) D
 .S COM600=NEWNODE_",""D"","_ENTRYNUM_",600,1,1,0)"
 .S COM600C=NEWNODE_",""D"","_ENTRYNUM_",600,1,1,1,0)"
 .S @COM600=U_"9002071.63^1^1"
 .S @COM600C=REC650
 Q
 ;
REC700 ;EP
 S REC700=$G(@NODE)     ;CHANGE FROM 700 TO 800 FIELD GROUP
 I $P(REC700,U,2)="9002071.06A" S $P(REC700,U,2)="9002071.08PA"
 S NODE800=NEWNODE_",""D"","_ENTRYNUM_",800"_$S(ENTRYNUM=700:$P(NODE,"700,700",2,99),1:$P(NODE,",700",2,99))
 S @NODE800=REC700
 ;OLD PIECE ONE IS A FREE TEXT ENTRY AND MUST BE CHANGED TO A POINTER
 S OLDFREE=$P(@NODE800,U)
 ;FIND POSSIBLE INSURER USING OLD FREE TEXT ENTRY
 S NEWPTR="",NAME=""
 F  S NAME=$O(^AUTNINS("B",NAME)) Q:NAME=""  I NAME=OLDFREE S NEWPTR=NAME Q
 I NEWPTR'="" S $P(@NODE800,U)=NEWPTR
 Q
 ;
ERROR ;
 S $ZT="ERRORH"
 S ^ACHSINST(ACHSVERS,"ERROR",$ZN,"ERROR TRAP CALLED")=NOW
 S XPDABORT=1
 G ^%ET
 ;
ERRORCN ;
 S $ZT="ERRORH"
 D ERRREC
 ;
 I NEWNODE[(QT_"D"_QT),($P(NEWNODE,CM,3)'="") S NEWNEW=$P(NEWNODE,CM,1,3)_")" I NEWNEW'="" K @NEWNEW
 S REC=$P($P(NODE,"(",2),CM,1)
 S NODE="^ACHSDEN("_(REC+1)_")"
 G LOOP1
 ;
ERRORXR ;
 ;we get here if there is an error in creating the x-refs.
 S $ZT="ERRORH"
 D ERRREC
 ;
 G LOOP2A
 ;
ERRREC ;
 ;record some info about this error before going on
 S ERRNUM=+$O(^ACHSINST(ACHSVERS,"denial conversion","ERRORS",RUNTIME,""),-1)+1
 S ^ACHSINST(ACHSVERS,"denial conversion","ERRORS",RUNTIME,ERRNUM,"$ZE")=$ZE
 S ^ACHSINST(ACHSVERS,"denial conversion","ERRORS",RUNTIME,ERRNUM,"NODE")=$G(NODE)
 S ^ACHSINST(ACHSVERS,"denial conversion","ERRORS",RUNTIME,ERRNUM,"NEWNODE")=$G(NEWNODE)
 ;
 S NUMERR=NUMERR+1
 I NUMERR>500!(NUMENTRY>1000&(NUMERR/NUMENTRY*100>5)) S STOP=1
 Q
 ;
ERRORH ;
 G ^XUSCLEAN
 ;