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

OR3CONV1.m

Go to the documentation of this file.
  1. OR3CONV1 ;SLC/MLI-Conversion utilities and cleanup ;8/2/97 [5/25/99 9:33am]
  1. ;;3.0;ORDER ENTRY/RESULTS REPORTING;**14,40,296**;Dec 17, 1997;Build 19
  1. ;
  1. ; Continuation calls from OR3CONV - used by OE/RR version 3 conversion
  1. ;
  1. ; Utilities for site to call:
  1. ; RESTART - if process stopped for any reason, this can be used
  1. ; to restart the background portion of the conversion.
  1. ;
  1. ; STATUS - display the status of the conversion via TaskMan and
  1. ; via OE/RR.
  1. ;
  1. STOP ; entry point to stop conversion cleanly
  1. N X
  1. S X=$G(^ORD(100.99,1,"CONV"))
  1. I +X W !,"The conversion has already run to completion." Q
  1. I '$P(X,"^",6) W !,"The background job conversion has not yet started." Q
  1. D STATUS
  1. I $$RUSURE("stop") D SET^OR3CONV(11,1)
  1. Q
  1. ;
  1. RESTART ; entry point to restart conversion
  1. N X
  1. S X=$$CHECK()
  1. I X]"" D Q
  1. . W !,"You can not use the RESTART call at this time."
  1. . W !,X
  1. . W !!,"Call STATUS^OR3CONV1 to get current status of conversion."
  1. D STATUS
  1. I $$RUSURE("restart") D
  1. . S ZTSAVE("ORESTART")=$P(^ORD(100.99,1,"CONV"),"^",9)
  1. . D QUEUE^OR3CONV
  1. Q
  1. ;
  1. CHECK() ; check status to see if restart should be allowed
  1. N X
  1. S X=$G(^ORD(100.99,1,"CONV"))
  1. I +X Q "The conversion has already run to completion."
  1. I '$P(X,"^",6) Q "The background job conversion has not yet started."
  1. S X=+$P(X,"^",10) I X S X=$$ZTSKCHK(X) I '$P(X,"^",2) Q $P(X,"^",1)
  1. Q ""
  1. ;
  1. RUSURE(TEXT) ; return 1 if yes, 0 otherwise
  1. N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
  1. S DIR(0)="YA",DIR("B")="No"
  1. S DIR("A")="Are you sure you want to "_TEXT_" the conversion? "
  1. D ^DIR
  1. Q +Y
  1. ;
  1. STATUS ; get status of conversion
  1. N STAGE,X
  1. S X=$G(^ORD(100.99,1,"CONV"))
  1. I +X W !,"The conversion has already completed!" Q
  1. I $P(X,"^",1)="" W !,"The conversion has not yet started." Q
  1. I $P(X,"^",11) W !,"The background job was requested to stop." Q
  1. I '$P(X,"^",6),'$P(X,"^",10) D Q
  1. . W !,"The background conversion of patient orders has not"
  1. . W !,"started yet. This process is queued to run by the post-"
  1. . W !,"installation process of CPRS. It has not yet been queued."
  1. I $P(X,"^",10) D Q
  1. . W !,"The background conversion of patient orders is running."
  1. . W !,"The task number assigned to the conversion was ",$P(X,"^",10),"."
  1. . W !,"The following is the status of the process according to TaskMan:"
  1. . W !?5,$P($$ZTSKCHK($P(X,"^",10)),"^",1)
  1. . W !
  1. . S STAGE=$$STAGE($P(X,"^",8))
  1. . I +STAGE=0 D Q
  1. . . W !,"The background job is currently populating the list of"
  1. . . W !,"patients that will need to be processed by the conversion."
  1. . . W !,"Last DFN populated: ",$O(^ORD(100.99,1,"PTCONV","A"),-1)
  1. . W !,"The background conversion is currently on stage ",+STAGE,"."
  1. . W !,"This stage converts ",$S(STAGE<7:"patients who ",1:""),$P(STAGE,"^",2),"."
  1. . I $P(X,"^",9) D
  1. . . W !,"It last completed processing "
  1. . . W $P(STAGE,"^",3)," ",$P(X,"^",9),"."
  1. . W !!,"So far, orders for ",+$P(X,"^",12)," patients have converted."
  1. . W !,"There are currently ",+$P(^ORD(100.99,1,"PTCONV",0),"^",4)," patients left to process."
  1. . I +STAGE'=1 Q ; show more info for inpatients
  1. . W !!,"Patients on ward ",$P(X,"^",4)," are currently being processed."
  1. . W !,"The last patient to be converted was DFN #",$P(X,"^",5),"."
  1. Q
  1. ;
  1. ZTSKCHK(ZTSK) ; check status of task via TaskMan utilities
  1. ; return message^flag where flag is 1 to allow requeue...0 otherwise
  1. D STAT^%ZTLOAD
  1. Q $P($T(ZTSKMSG+ZTSK(1)),";;",2)
  1. ;
  1. ZTSKMSG ;;Unable to find task on current volume set^1
  1. ;;Task is scheduled and waiting to run^0
  1. ;;The task is running^0
  1. ;;The task completed^1
  1. ;;The task was created without being scheduled^0
  1. ;;The process stopped for some reason^1
  1. ;;Unable to obtain status from TaskMan^1
  1. ;
  1. STAGE(STAGE) ; return text of what stage does
  1. Q $P($T(STAGETXT+STAGE),";;",2)
  1. ;
  1. ; stages - number^text^up to text
  1. STAGETXT ;;0^populating list of patients to convert
  1. ;;1^are current inpatients^ward
  1. ;;2^have future scheduled admissions on file^scheduled admission date
  1. ;;3^have waiting list file entries^DFN
  1. ;;4^have discharges within last 4 weeks^discharge date
  1. ;;5^have appointments in last 4 or next 4 weeks^hospital location
  1. ;;6^have not already been converted^DFN
  1. ;;7^orders not associated with PATIENT file entries^variable pointer
  1. ;
  1. CLEANUP ; conversion is completed
  1. N X
  1. I '$$FINALCHK() D ERROR Q
  1. D KILL^OR3C101,REQUEUE^ORMTIME(1)
  1. D BADNAMES^PSJIPST3
  1. D MAIL
  1. Q
  1. ;
  1. FINALCHK() ; check to see if every patient converted
  1. N DFN,ERROR
  1. S ERROR=1
  1. F DFN=0:0 S DFN=$O(^ORD(100.99,1,"PTCONV",DFN)) Q:'DFN D Q:ERROR
  1. . S ERROR=$$CONVERT^OR3CONV(DFN,1) ; try again to convert
  1. . I '$$PTDONE^OR3CONV(DFN) S ERROR=0
  1. Q ERROR
  1. ;
  1. MAIL ; send e-mail that the conversion completed
  1. N COUNT,X
  1. S COUNT=0,X=$G(^ORD(100.99,1,"CONV"))
  1. D LINE("The orders conversion has completed")
  1. D LINE(" ")
  1. D LINE("The conversion was first started: "_$$FMTE^XLFDT($P(X,"^",6)))
  1. D LINE("It ran to completion: "_$$FMTE^XLFDT($P(X,"^",7)))
  1. D SEND("OE/RR version 3.0 conversion complete")
  1. Q
  1. ;
  1. ERROR ; create mail message if unconverted patients found
  1. N COUNT
  1. S COUNT=0
  1. D LINE("A problem was encountered in the OE/RR conversion. After")
  1. D LINE("going through all patients, it was still unable to convert")
  1. D LINE("orders for some patients. Please contact the national")
  1. D LINE("customer support help desk for further assistance.")
  1. D SEND("OE/RR version 3.0 conversion encountered problem")
  1. Q
  1. ;
  1. LINE(TEXT) ; store data in array for mail message
  1. S COUNT=COUNT+1
  1. S ORTEXT(COUNT)=TEXT
  1. Q
  1. ;
  1. SEND(SUBJECT) ; define rest of XM variables and fire message off
  1. N DIFROM,XMDUZ,XMSUB,XMTEXT,XMY
  1. S XMSUB=SUBJECT,XMTEXT="ORTEXT("
  1. S XMDUZ="OE/RR CONVERSION"
  1. F I="G.CPRS INSTALLATION@ISC-SLC.VA.GOV",DUZ S XMY(I)=""
  1. D ^XMD
  1. Q
  1. ;
  1. PTCONV ; populate OR3 PATIENTS TO CONVERT multiple...hard set for speed
  1. N COUNT,DFN,LAST
  1. S COUNT=0,LAST=""
  1. F DFN=0:0 S DFN=$O(^DPT(DFN)) Q:'DFN!(DFN'=+DFN) I $D(^(DFN,0)) D
  1. . S LAST=DFN,COUNT=COUNT+1
  1. . I $D(^ORD(100.99,1,"PTCONV",DFN,0)) Q
  1. . S ^ORD(100.99,1,"PTCONV",DFN,0)=DFN,^ORD(100.99,1,"PTCONV","B",DFN,DFN)=""
  1. S ^ORD(100.99,1,"PTCONV",0)="^100.9903PA^"_LAST_"^"_COUNT
  1. Q