source: WorldVistAEHR/trunk/r/RADIOLOGY_NUCLEAR_MEDICINE-RA/RARECOV.m@ 1154

Last change on this file since 1154 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 5.7 KB
Line 
1RARECOV ;HISC/SWM-Recover Purged Rad/NM Report/Exam only ;4/17/03 09:39
2 ;;5.0;Radiology/Nuclear Medicine;**34**;Mar 16, 1998
3 ;
4 S:'$D(DTIME) DTIME=9999
5 I $D(^XTMP("RARECOV")) W !,"^XTMP(""RARECOV"") exists, you must delete this before",!,"you can run another recovery.",!! G NOTDONE
6 S RACRT=$E($G(IOST),1,2)="C-"
7 F I=1:1:21 W !,$P($T(INSTRC+I),";;",2)
8 R !,"Press return key to continue, or ""^"" to exit: ",X:DTIME
9 G:X="^" Q
10 ;Select Imaging type(s)
11 ;Return RAPUR array = RAPUR(ien)="", where ien = entry in 79.2
12 S (I,J,CNT)=0 K RAPUR
13 W !!?12,"IMAGING TYPES",!?12,"-------------",!
14 F S I=$O(^RA(79.2,"B",I)) Q:I="" F S J=$O(^RA(79.2,"B",I,J)) Q:'J S CNT=CNT+1 W !?3,CNT,") ",I S RAX(CNT)=J
15 W ! S DIR(0)="L^1:"_CNT,DIR("A")="Select Imaging Type(s) to recover purged data",DIR("?")="Select by number, one or more imaging types to be purged" D ^DIR K DIR I $D(DIRUT) G Q
16 S I="" F J=1:1 S I=$P(Y,",",J) Q:'I S RAPUR(RAX(I))=""
17 G Q:'$O(RAPUR(0))
18 ;
19 ;Select what to recover: exams, reports, or both
20 S DIR(0)="S^E:Exam data;R:Report data;B:Both;",DIR("?")="Do you want to recover purged Exams, Reports, or Both exams and reports"
21 S DIR("A")="Enter type of data to recover",DIR("B")="Report data"
22 D ^DIR K DIR
23 ;REGET70=0 means don't recover file 70 data
24 S RAGET70=$S(Y="E":1,Y="B":1,1:0)
25 S RAGET74=$S(Y="R":1,Y="B":1,1:0)
26 ;
27 S (RADT,RAIEN)=0
28 F S RAIEN=$O(RAPUR(RAIEN)) Q:'RAIEN D ASKDT Q:RAX=""!(CNT<4)
29 G:RAX=""!(CNT<4) NOTDONE
30 W !
31 S DIR(0)="Y",DIR("A")="Do you want to proceed "
32 S DIR("B")="NO" D ^DIR
33 I 'Y G NOTDONE
34 ;
35EXAM ;Copy backup exam/report data
36 D NOW^%DTC S RANOW=%,X1=RANOW,X2=60 D C^%DTC
37 S ^XTMP("RARECOV",0)=X_"^"_RANOW_"^"_"RARECOV"
38 W !!,"Recovering ",$S(RAGET70&RAGET74:"Exam and Report",RAGET70:"Exam",RAGET74:"Report",1:"?")," data from backup to ^XTMP(""RARECOV"".",!
39 F RADTE=0:0 S RADTE=$O(^RADPT("AR",RADTE)) Q:RADTE'>0!(RADTE>RADT) S RADTI=9999999.9999-RADTE F RADFN=0:0 S RADFN=$O(^RADPT("AR",RADTE,RADFN)) Q:RADFN'>0 D
40 .F RACN=0:0 S RACN=$O(^RADPT(RADFN,"DT",RADTI,"P","B",RACN)) Q:RACN'>0 S RACNI=+$O(^(RACN,0)),RA0=$G(^RADPT(RADFN,"DT",RADTI,"P",RACNI,0)),RARPT=+$P(RA0,"^",17) D
41 ..S RAIMAG=+$P($G(^RAMIS(71,+$P(RA0,"^",2),0)),"^",12) Q:'$D(RAPUR(RAIMAG)) W:RACRT "."
42 ..K RARP S RARPTNP=$G(^RARPT(RARPT,"NOPURGE")) I RAGET74 D
43 ... Q:+$O(^RARPT(RARPT,"ERR",0)) ; quit if report amended
44 ...I $P(RAPUR(RAIMAG),"^",2)>RADTE,$D(^RARPT(RARPT,"R")) M ^XTMP("RARECOV","RPT",RARPT,"R")=^RARPT(RARPT,"R") S RARP=""
45 ...I $P(RAPUR(RAIMAG),"^")>RADTE,$D(^RARPT(RARPT,"L")) M ^XTMP("RARECOV","RPT",RARPT,"L")=^RARPT(RARPT,"L") S RARP=""
46 ...I $P(RAPUR(RAIMAG),"^",3)>RADTE,$D(^RARPT(RARPT,"H")) M ^XTMP("RARECOV","RPT",RARPT,"H")=^RARPT(RARPT,"H") S RARP=""
47 ..I $D(RARP) S ^XTMP("RARECOV","RPT",RARPT,"PURGE")=^RARPT(RARPT,"PURGE"),$P(RAPUR(RAIMAG),"^",7)=$P(RAPUR(RAIMAG),"^",7)+1
48 ..K RAEX I RAGET70 D
49 ...I $P(RAPUR(RAIMAG),"^")>RADTE,$D(^RADPT(RADFN,"DT",RADTI,"P",RACNI,"L")) M ^XTMP("RARECOV","DPT",RADFN,RADTI,RACNI,"L")=^RADPT(RADFN,"DT",RADTI,"P",RACNI,"L") S RAEX=""
50 ...I $P(RAPUR(RAIMAG),"^",3)>RADTE,$D(^RADPT(RADFN,"DT",RADTI,"P",RACNI,"H")) M ^XTMP("RARECOV","DPT",RADFN,RADTI,RACNI,"H")=^RADPT(RADFN,"DT",RADTI,"P",RACNI,"H") S RAEX=""
51 ...I $P(RAPUR(RAIMAG),"^",4)>RADTE,$D(^RADPT(RADFN,"DT",RADTI,"P",RACNI,"T")) M ^XTMP("RARECOV","DPT",RADFN,RADTI,RACNI,"T")=^RADPT(RADFN,"DT",RADTI,"P",RACNI,"T") S RAEX=""
52 ..I $D(RAEX) S ^XTMP("RARECOV","DPT",RADFN,RADTI,RACNI,"PURGE")=^RADPT(RADFN,"DT",RADTI,"P",RACNI,"PURGE"),$P(RAPUR(RAIMAG),"^",6)=$P(RAPUR(RAIMAG),"^",6)+1
53 ;
54 D TOTALS G Q
55INSTRC ;
56 ;;Instructions for recovering purged exam and/or report data
57 ;; Step 0.
58 ;; Find out:
59 ;; 1 - the DATE that the purge was done
60 ;; 2 - how many DAYS back from that date was used as cut-off
61 ;; ie., what was entered as "ddd" in "T-ddd" ?
62 ;; Step 1. From the Backup Volume:
63 ;; D ^RARECOV
64 ;; enter cut-off dates that you had used in the purge function
65 ;; Step 2. From the Backup Volume:
66 ;; D ^%GTO (or your system's global copy out utility)
67 ;; enter output file name
68 ;; enter ^XTMP("RARECOV"
69 ;; Step 3. From the Production volume that holds ^XTMP:
70 ;; D ^%GTI (or your system's global restore utility)
71 ;; enter the file name from step 2
72 ;; Step 4. From the Production volume:
73 ;; D ^RARESTOR
74 ;; routine will automatically read from ^XTMP("RARECOV"
75 ;; and copy data back into ^RADPT and/or ^RARPT
76 ;;
77NOTDONE W !!,"-- Nothing Done --"
78Q ;K CNT,I,J,RADD,RADT,RAGET70,RAGET74,RAI,RAIEN,RAPRMPT,RAPUR,RAX
79 Q
80TOTALS ;
81 S RAIEN=0
82 F S RAIEN=$O(RAPUR(RAIEN)) Q:'RAIEN D
83 . W !!,"Imaging Type: ",$P($G(^RA(79.2,RAIEN,0)),"^"),!
84 . W !?5,"No. of exam records recovered : ",$P(RAPUR(RAIEN),"^",6)
85 . W !?5,"No. of reports recovered : ",$P(RAPUR(RAIEN),"^",7)
86 . S ^XTMP("RARECOV",RAIEN)=RAPUR(RAIEN)
87 Q
88 ;Select Cut-off date for the various data fields
89ASKDT S RAX="",CNT=0
90 K RACUTDT W !!?7,"Cut-off Date Selection **** ",$P(^RA(79.2,RAIEN,0),"^")," ****"
91 K X,%DT S %DT="APEX" W !
92 S %DT("A")="Enter date that the Radiology Purge was done : " D ^%DT
93 G:'Y Q G:Y'?.7N Q S RADTDONE=Y
94 R !!,"Enter number of days subtracted from that date as cut-off : ",RANUM:DTIME
95 G:'RANUM Q
96 S ^XTMP("RARECOV",0,RAIEN)=RADTDONE_"^"_RANUM
97 S X1=RADTDONE,X2=-RANUM D C^%DTC S Y=X D DD^%DT S %DT("B")=Y
98 W !?7,"The default value can be changed as needed."
99 K RADD
100 S RAPRMPT="Cut-off Date for "
101 ; define field names, because the backup volume doesn't have ^DD
102 S RADD(.11)="ACTIVITY LOG CUT-OFF"
103 S RADD(.12)="REPORT CUT-OFF"
104 S RADD(.13)="CLINICAL HISTORY CUT-OFF"
105 S RADD(.14)="TRACKING TIME CUT-OFF"
106 F RAI=.11:.01:.14 S CNT=CNT+1 D Q:Y<0
107 . W ! S %DT("A")=RAPRMPT_$P(RADD(RAI),"^")_" : " D ^%DT Q:Y<0 S $P(RAX,"^",CNT)=Y S:Y>RADT RADT=Y
108 G:RAX="" Q G:CNT<4 Q
109 S RAPUR(RAIEN)=RAX
110 Q
Note: See TracBrowser for help on using the repository browser.