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

BVCONV.m

Go to the documentation of this file.
  1. BVCONV ; IHS/ITSC/JDH - interface to PCC conversion routine [ 03/29/2002 4:14 PM ]
  1. ;;2.0;IHS V FILES 200 CONVERSION;;MAR 29, 2002
  1. ;
  1. W !!,"This routine can't be called from the top" D EXIT Q
  1. ;
  1. EN ;EP
  1. N BVCPRCP,BVCABRT,BVCRUN,BVCONV,BVCRCNT,BVCNCNT,BVCFCNT,X,X1,D,BVCDFDC,BVCQ,DIR,DIC,Y
  1. D ^XUP ; get DUZ and system variables
  1. ; prr conversion checks
  1. I '$G(DUZ) W !,"Your DUZ must be defined." D EXIT Q ; check to see if the conversion can be run
  1. I DUZ(0)'["@" W !,"You must have fileman programmer access to run this routine." D EXIT Q
  1. I $D(^BVCONV(1,"RUNNING")) D ABORT("5^The conversion is already running.") G EXIT ; make sure no runs twice at a time
  1. S BVCPRCP=0
  1. I '$D(^BVCHK(1,"OK")) D ABORT("6^Routine EN^BVCHK must run clean before procedding.") G EXIT ; make sure navigation and fields are ok
  1. I '$L($T(^BVCONV1)) D ABORT("0^The conversion appears to have been run.") G EXIT ; the conversion routine is automatically deleted when conversion of all files is complete.
  1. D ELEMLST(1) ; check all fields, targeted for conversion, for file 200 pointers
  1. S X=$G(^BVCONV1(BVCPRCP,"RUN TIMES")) ; run time node of conversion control file
  1. I 'X,$D(BVCONV(1,1)) D ABORT("1^Some conversion fields do not use file 200 datatypes.") G EXIT ;The conversion may have been run
  1. I $P(X,U,2) D ABORT("2^The conversion stop flag is recorded") G EXIT
  1. ; not yet converted or the software has been reloaded
  1. S BVCRUN=X
  1. S X1=$G(^BVCHK(1,"PCC CONV FLAG")) ; flag to indicate one time load (set by package post-init)
  1. I X1'=887700,'X D ABORT("3^no 1 time load flag and no start time recorded for the conversion.") G EXIT
  1. ; end pre-lim checks
  1. D SPLASH
  1. ;
  1. PR ;EP get a default provider
  1. W !!,"In case a provider file pointer can not be resolved to a file "
  1. W "200 pointer, a default provider must determined for use."
  1. S DIC(0)="AEQ",D="AK.PROVIDER",DIC=200,DIC("A")="Please enter a default provider: "
  1. S DIC("S")="I '$P($G(^(""PS"")),U,4)" D IX^DIC G:Y<0 EXIT
  1. S BVCDFDC=+Y
  1. ;
  1. S BVCABRT=0
  1. I 'BVCPRCP D G:BVCABRT EXIT
  1. .W !!,"Taskman must be shutdown during the conversion process"
  1. .D:'$$TASKCHK STOP^ZTMKU
  1. .I '$$TASKCHK W !!,"TASKMAN AND SERVERS ARE NOT SHUT DOWN." S BVCABRT=1 Q:BVCABRT
  1. .W !!,"Install PCC data dictionaries with file 200 pointers"
  1. .I 'BVCRUN D ^BVCINIT ; load PCC data dictionaries changed to file 200 pointers and clear conversion control global
  1. .; check to be sure fields targeted for conversion are defined as file 200 pointers. and build conversion elements table
  1. .D ELEMLST(0)
  1. .I $D(BVCONV(1,0)) D ABORT("4^Not all conversion fields point to file 200.") S BVCABRT=1
  1. ;
  1. S DIR(0)="Y",DIR("B")="NO"
  1. S DIR("A")="Do you want to put this conversion "_$S(BVCPRCP:"check ",1:"")_" into a seperate process?"
  1. D ^DIR G:$D(DIRUT) EXIT S BVCQ=Y
  1. ;
  1. G EXIT:$$ZIS ;get device;
  1. ; save variables for the new job
  1. K ^BVCONV(1,"VARS")
  1. I BVCQ D D HOME^%ZIS
  1. .F I="BVCPRCP","BVCDFDC","BVCQ","IOT","IOP","DUZ","DUZ(0)","IOPAR" S ^BVCONV(1,"VARS",I)=@I
  1. .S:$D(DUZ(2)) ^BVCONV(1,"VARS","DUZ(2)")=DUZ(2)
  1. ;
  1. ; run the conversion and complete
  1. O W !!,"The conversion "_$S(BVCPRCP:"check ",1:"")_"process was "_$S('BVCRUN:"re",1:"")_" started at"_$$HTE^XLFDT($H)
  1. S ^BVCONV(1,"RUNNING")="" X:'BVCPRCP ^%ZOSF("NBRK") ; turn break off
  1. I 'BVCQ D
  1. .D EN^BVCONV1 ; run the conversion
  1. E J EN^BVCONV1 ; IHS SAC exemption date 5/10/00
  1. X:BVCPRCP ^%ZOSF("BRK") ;turn break back on
  1. Q
  1. ;
  1. TASKCHK() ; check if taskman and servers are down
  1. Q ('$D(^%ZTSCH("RUN"))&$D(^%ZTSCH("STOP")))
  1. ;
  1. EXIT W !!,"EXITING" Q
  1. ;
  1. XMD(BVCST,BVCCVTM) ;EP send a mail message of abort or completion
  1. N BVCONV,XMDUZ,XMTEXT,XMSUB,XMY,BVCNUMB
  1. S XMDUZ=.5,XMTEXT="BVCONV(",XMSUB="Notice of PCC 200 file conversion "_$S(BVCST=2:"check ",1:"")_$S(BVCST:"completion",1:"failure")
  1. S BVCONV(1)="The repointing of PCC data elements from file 6 to 200 "_$S(BVCST=1:"is complete",BVCST=2:"has been checked",1:"has aborted")_"."
  1. I BVCST D
  1. .S BVCONV(2)="",X=$G(^BVCONV1(BVCPRCP,"RUN TIMES"))
  1. .S BVCONV(3)="The conversion "_$S(BVCST=2:"check",1:"")_" started "_$$HTE^XLFDT($P(X,U))_" and completed "_$$HTE^XLFDT($P(X,U,2))
  1. .S BVCONV(3.1)=""
  1. .S BVCONV(3.2)="The compile "_$S(BVCST=2:"will take approximately ",1:"process took ")_BVCCVTM_" hours."
  1. .S BVCONV(4)=""
  1. .S BVCNUMB=90000
  1. .F I=5:1 S BVCNUMB=$O(^BVCONV1(BVCPRCP,BVCNUMB)) Q:'BVCNUMB D
  1. ..S BVCONV(I)="",X=^BVCONV1(BVCPRCP,BVCNUMB)
  1. ..S BVCONV(I_.1)=$FN(+$P(X,U,4),",")_" pointers "_$S(BVCST=2:"will be",1:"were")_" repointed in the "_$P(^DIC(BVCNUMB,0),U)_" file, "
  1. ..S BVCONV(I_.2)=$FN(+$P(X,U,5),",")_" pointer fields "_$S(BVCST=2:"have",1:"had")_" no data to convert."
  1. ..S BVCONV(I_.3)=$FN(+$P(X,U,6),",")_" pointer fields "_$S(BVCST=2:"will be",1:"were")_" repointed to the chosen default provider "_$P(^VA(200,BVCDFDC,0),U)
  1. E D
  1. .S BVCONV(1.1)="The error is recorded in the error trap and the FILE 200 CONVERSION ERROR file."
  1. .S BVCONV(1.2)="PLEASE CALL THE ITSC HELP DESK."
  1. S:$G(DUZ) XMY(DUZ)="" S XMY(.5)=""
  1. D ^XMD
  1. Q
  1. ELEM ; conversion element records in the format
  1. ; file number^file root^direct set (flag);field number;node;piece^..
  1. ;;9000001^AUPNPAT(^0;.14;0;14
  1. ;;9000007^AUPNFSE(^1;.06;0;6^1;.08;0;8
  1. ;;9000010.06^AUPNVPRV(^0;.01;0;1
  1. ;;9000010.08^AUPNVPRC(^0;.11;0;11^1;.12;0;12
  1. ;;9000010.09^AUPNVLAB(^1;.07;0;7^0;1202;12;2^1;1204;12;4
  1. ;;9000010.14^AUPNVMED(^1;1202;12;2^1;1204;12;4
  1. ;;9000010.15^AUPNVTRT(^1;.05;0;5
  1. ;;9000010.16^AUPNVPED(^1;.05;0;5
  1. ;;9000010.21^AUPNVDXP(^1;1202;12;2^1;1204;12;4
  1. ;;9000010.22^AUPNVRAD(^1;1202;12;2^1;1204;12;4
  1. ;;9000010.23^AUPNVHF(^1;.05;0;5
  1. ;;9000010.25^AUPNVMIC(^0;1202;12;2^1;1204;12;4
  1. ;;9000010.31^AUPNVBB(^0;1202;12;2^1;1204;12;4
  1. ;;END
  1. ;
  1. FM(BVCNUMB,BVCFLD) ; function to determine whether fileman must be used
  1. ; must use fileman when field has cross references or an audit node not
  1. ; equal to n
  1. N X
  1. S X=$O(^DD(BVCNUMB,BVCFLD,1,0)) ; cross reference check
  1. I 'X S X=$G(^DD(BVCNUMB,BVCFLD,"AUDIT")) S:$L(X) X="ey"[X
  1. Q +X
  1. ;
  1. ELEMLST(BVCFLG) ;EP get list of conversion elements
  1. ; If BVCFLG=0 check to for file 200 pointers (an indication the
  1. ; conversion has been started or complete)
  1. ; If BVCFLG=1 build conversion table
  1. ;
  1. K BVCONV
  1. N BVCNUMB,BVCREC,BVCELM,BVCELMS,BVCFLD,BVCROOT
  1. S (BVCRCNT,BVCFCNT,BVCNCNT)=0
  1. F I=2:1 S BVCREC=$P($T(ELEM+I),";;",2) Q:BVCREC="END" D
  1. .S BVCNUMB=+BVCREC,BVCELMS=""
  1. .F J=3:1 S BVCELM=$P(BVCREC,U,J) Q:'$L(BVCELM) D
  1. ..S BVCFLD=$P(BVCELM,";",2),BVCFCNT=BVCFCNT+1 D Q:'BVCFLG
  1. ...S BVCONV(1,$P(^DD(BVCNUMB,BVCFLD,0),U,3)="VA(200,",BVCNUMB,BVCFLD)="",BVCNCNT=BVCNCNT+1
  1. ..S $P(BVCELM,";")='$$FM(BVCNUMB,BVCFLD) S BVCELMS=BVCELMS_U_BVCELM ; tag FM may override direct set flag
  1. ..S BVCROOT=$P(BVCREC,U,2),BVCONV(BVCNUMB)=BVCROOT_BVCELMS,BVCRCNT=BVCRCNT+$P(@(U_BVCROOT_"0)"),U,4)
  1. Q
  1. ;
  1. SPLASH ; splash screen message
  1. W !!,"This program will repoint field values, that currently point to file 6, to file",!,"200. and change targeted AUPN* file data dictionaries to file 200 versus 6"
  1. W !,"pointer datatypes. If a field value (provider pointer) can not be resolved to a",!,"corresponding file 200 entry, the default provider you supply will be used. "
  1. W !,"You have "_$FN(BVCRCNT,",")_" records to repoint, and this process will take between",!,"3 to 8 hours, depending on your system. It is imperative to permit this process"
  1. W !,"to complete. Please turn off journalling until you are notified the conversion",!,"is complete. A notification of completion will be sent to your's and the"
  1. W !,"postmaster's mailbox. Exceptions are recorded in the FILE 200 CONVERSION ERROR",!,"FILE file."
  1. W !!,"If you have any questions, please call the Help Desk desk",!
  1. Q
  1. ;
  1. ZIS() ; get device variables
  1. N %ZIS S %ZIS="M" S:BVCQ %ZIS=%ZIS_"N" D ^%ZIS
  1. S:'POP IOP=ION_";"_IOM_";"_IOSL
  1. Q POP
  1. ;
  1. ABORT(BVCFLG) ;
  1. N BVCNUMB,BVCFLD
  1. W !!,"The conversion of PCC data to file 200 pointers is being aborted."
  1. W:+BVCFLG<5 !,"The conversion appears to have been previously completed."
  1. W !,"Condition flag: "_$P(BVCFLG,U,2,99)
  1. I +BVCFLG=1!(+BVCFLG=4) D
  1. .F I=0:1:1 I $D(BVCONV(1,I)) D
  1. ..W !!,"The following fields are "_$S(I:"",1:"not ")_"defined to use file 200 datatypes.",!
  1. ..S (BVCNUMB,BVCFLD)=0
  1. ..F S BVCNUMB=$O(BVCONV(1,I,BVCNUMB)) Q:'BVCNUMB D
  1. ...F S BVCFLD=$O(BVCONV(1,I,BVCNUMB,BVCFLD)) Q:'BVCFLD D
  1. ....W !,"Field "_BVCFLD_" of file "_BVCNUMB_"."
  1. W !!,"If you need assistance, call the Help Desk."
  1. Q
  1. ;
  1. ;
  1. DELETE ;EP delete conversion routine
  1. N BVCTMP,X,I
  1. F X="BVCONVT1","AUMCUTL","AUMCUTL1","AUMCUTL2","BVCENV","BVCINIS","BVCINIT" X ^%ZOSF("DEL") ; delete conversion routines ;TASSC/MFD removed "BVCONV1", because generated NOROUTINE error with Cache, but added BVCONVT1
  1. F I=1:1:5 S X="BVCINIT"_I X ^%ZOSF("DEL") ;TASSC/MFD added T to BVCINI
  1. F I=1:1:9 S X="BVCIN00"_I X ^%ZOSF("DEL") ;TASSC/MFD added N to BVCI00
  1. F I=65:1:77 S X="BVCIN00"_$C(I) X ^%ZOSF("DEL") ;TASSC/MFD added N to BVCI00, changed 76 to 77 to catch M routine
  1. Q
  1. ;
  1. RESTRT ;EP; call here to restart the conversion
  1. W !!,"*** RESTART OF THE PCC CONVERSION ***",!!
  1. N POP S POP=0
  1. I $D(^BVCONV(1,"RUNNING")) D Q:POP'=1
  1. .W !!,"The conversion may already be running.","Are you sure you wish to continue with a",!,"restart?"
  1. .N % S %=2 D YN^DICN S POP=%
  1. K ^BVCONV(1,"RUNNING")
  1. G EN
  1. Q
  1. ;
  1. EXEC ;EP; call here to see whether the completion is complete
  1. W !,"The conversion is "_$S($L($T(^BVCONV1)):"not",1:"")_" complete.",!
  1. Q