source: WorldVistAEHR/trunk/r/TEXT_INTEGRATION_UTILITIES-GMRP-TIU/TIUDSCNV.m@ 1556

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

initial load of WorldVistAEHR

File size: 7.6 KB
Line 
1TIUDSCNV ; SLC/JER - Discharge Summary Conversion routine
2 ;;1.0;TEXT INTEGRATION UTILITIES;**9**;Jun 20, 1997
3MAIN ; Control branching
4 N GMRDA,TIUOK,TIUQUEUE,TIURUN,GMRDSTOP
5 I +$P($G(^AUPNPAT(0)),U,3)'=+$P($G(^DPT(0)),U,3),'$D(^GMR(128,"CNV","PXPTPOST")) D Q:+TIUOK'>0
6 . N TIUPRMT
7 . W !!,"The IHS Patient file appears to be out of synchrony with File #2."
8 . W !,"Before continuing, you must run a program to synchronize these files."
9 . W !,"It may take a few minutes.",!
10 . S TIUPRMT="Would you like me to run that program now"
11 . S TIUOK=$$READ^TIUU("Y",TIUPRMT,"NO")
12 . I +TIUOK'>0 W !,"Okay, hurry back!" Q
13 . I +TIUOK>0 D QUE^PXPTPOST S ^GMR(128,"CNV","PXPTPOST")=1
14 W !!?9,"***************************************************************"
15 W !?9,"* This option will convert your Discharge Summary version 1.0 *"
16 W !?9,"* Database in preparation for implementation of Discharge *"
17 W !?9,"* Summary under Text Integration Utilities... *"
18 W !?9,"* Although the process is NOT irreversible, we recommend you *"
19 W !?9,"* be certain you are prepared to implement before invoking *"
20 W !?9,"* this process! *"
21 W !?9,"***************************************************************",!
22 S TIUOK=$$READ^TIUU("Y"," ... Are you sure","NO")
23 I +TIUOK'>0 W !!?9,$C(7),"Very well, no damage done!" Q
24 I +$G(^GMR(128,"CNV","T0")),'+$G(^GMR(128,"CNV","T1")) D Q:+$G(TIURUN)
25 . W !!,"The DISCHARGE SUMMARY CONVERSION is either still running in another partition,"
26 . W !,"or it has been interrupted...",!
27 . S TIURUN=+$$RUNNING
28 . I +TIURUN W !!,$C(7),"CONVERSION STILL RUNNING IN ANOTHER PARTITION."
29 . E W !!,"No other instance of the conversion could be detected...You're free to RESTART."
30 I +$P($G(^TIU(8925.97,1,0)),U,2),'+$P($G(^TIU(8925.97,1,0)),U,3) D Q:+$G(TIURUN)
31 . W !!,"The PROGRESS NOTES CONVERSION is either still running in another partition,"
32 . W !,"or it has been interrupted...",!
33 . S TIURUN=+$$PNRUN
34 . I +TIURUN W !!,$C(7),"PROGRESS NOTES CONVERSION STILL RUNNING IN ANOTHER PARTITION."
35 . E W !!,"PN CONVERSION is NOT currently running...You're free to begin."
36 S GMRDA=+$G(^GMR(128,"CNV","CHKPNT"))
37 S GMRDSTOP=+$G(^GMR(128,"CNV","STOP #"))
38 I GMRDSTOP'>0 D
39 . S GMRDSTOP=+$P($G(^GMR(128,0)),U,3),^GMR(128,"CNV","STOP #")=GMRDSTOP
40 I +GMRDSTOP'>0 W !!,$C(7),"NO DISCHARGE SUMMARIES TO CONVERT...Bye!",! Q
41 I +GMRDA>0 D
42 . W !!,"CONVERSION HAS ALREADY BEEN RUN..."
43 . W !,"Checkpoint is Record #",GMRDA
44 . I +GMRDSTOP'=+$P($G(^GMR(128,0)),U,3) D
45 . . S GMRDSTOP=+$P(^GMR(128,0),U,3)
46 . . S ^GMR(128,"CNV","STOP #")=GMRDSTOP
47 . W !,"Conversion will stop after record #",GMRDSTOP
48 . S TIUOK=$$READ^TIUU("Y"," Do You Wish to Continue","NO")
49 I +TIUOK'>0 W !!?5,"Very well, no damage done!" Q
50 S TIUQUEUE=$$READ^TIUU("Y","Would you like to QUEUE this Process","NO")
51 I +TIUQUEUE'>0 D Q
52 . W !!?9,$C(7),"Discharge Summary Conversion Running in Foreground"
53 . D ENQ
54 D QUEUE
55 Q
56QUEUE ; Call Task Manager to process conversion
57 N %,ZTDTH,ZTDESC,ZTIO,ZTSAVE,ZTSK,ZTRTN
58 S ZTRTN="ENQ^TIUDSCNV"
59 S ZTSAVE("GMRDA")="",ZTSAVE("DUZ(")="",ZTSAVE("GMRDSTOP")=""
60 S:'$D(ZTDESC) ZTDESC="TIU DISCHARGE SUMMARY CONVERSION" S ZTIO=""
61 D ^%ZTLOAD W !,$S($D(ZTSK):"Request Queued!",1:"Request Cancelled!")
62 D ^%ZISC
63 Q
64ENQ ; Where the work happens
65 N GMRDCNT,GMRDTOTL
66 S:+$G(GMRDA)'>0 GMRDA=+$G(^GMR(128,"CNV","CHKPNT"))
67 S GMRDCNT=+$G(^GMR(128,"CNV","CNT"))
68 S GMRDTOTL=+$P($G(^GMR(128,0)),U,3)
69 ; --- Get records from file #128 ---
70 S:'$D(^GMR(128,"CNV","T0")) ^GMR(128,"CNV","T0")=$$NOW^TIULC
71 I '$D(ZTQUEUED) D PROGBAR
72 F S GMRDA=$O(^GMR(128,GMRDA)) Q:(+GMRDA'>0)!(+GMRDA>+GMRDSTOP)!+$G(ZTSTOP) D
73 . D CONVERT(GMRDA) S GMRDCNT=+$G(GMRDCNT)+1
74 . I '$D(ZTQUEUED) D PROGRESS(GMRDCNT,GMRDTOTL)
75 . S ^GMR(128,"CNV","CNT")=GMRDCNT
76 . I $$S^%ZTLOAD S ZTSTOP=1
77 Q:+$G(ZTSTOP)
78 S ^GMR(128,"CNV","CNT")=GMRDCNT
79 S ^GMR(128,"CNV","T1")=$$NOW^TIULC
80 D BULLETIN ; Send Conversion Bulletin
81 Q
82BULLETIN ; Send Bulletins on completion
83 N TIUCNVCT,TIUMISCT,TIUADMCT,TIUFAIL,TIUBDT,TIUEDT,XMY,XMB,XMDUZ
84 S TIUCNVCT=+$G(^GMR(128,"CNV","SUCCEED"))
85 S TIUMISCT=+$G(^GMR(128,"CNV","FAIL",0))
86 S TIUADMCT=+$P($G(^GMR(128,"CNV","FAIL",0)),U,2)
87 S TIUFAIL=+$G(TIUMISCT)+$G(TIUADMCT)
88 S TIUBDT=$$DATE^TIULS(+$G(^GMR(128,"CNV","T0")),"MM/DD/YY HR:MIN")
89 S TIUEDT=$$DATE^TIULS(+$G(^GMR(128,"CNV","T1")),"MM/DD/YY HR:MIN")
90 S XMY(+$G(DUZ))=""
91 S XMB="TIU DS CONVERSION "_$S(+TIUFAIL>0:"ERRORS",1:"CLEAN")
92 S XMDUZ="TIU DISCHARGE SUMMARY CONVERSION"
93 S XMB(1)=TIUBDT,XMB(2)=TIUEDT,XMB(3)=TIUCNVCT
94 I +TIUFAIL>0 S XMB(4)=TIUFAIL,XMB(5)=TIUMISCT,XMB(6)=TIUADMCT
95 D ^XMB,KILL^XM
96 Q
97PROGBAR ; Write a Progress Bar
98 K LAST
99 ; I '$D(IOINORM) S X="IOINORM;IORVON;IORVOFF" D ENDR^%ZISS
100 W !!,$$CENTER^TIULS("Discharge Summary Conversion in Progress...")
101 W !,$$CENTER^TIULS("Percent Complete")
102 W !,$$CENTER^TIULS("0 10 20 30 40 50 60 70 80 90 100")
103 W !?12,"|"
104 Q
105PROGRESS(COUNT,TOTAL) ; Indicate Progress
106 N PCT,INCR,BAR S PCT=(COUNT/TOTAL)*100
107 S INCR=PCT\2
108 I +$G(LAST)'=$J(INCR,0,0) D
109 . S $P(BAR,"|",(INCR-+$G(LAST))+1)=""
110 . W BAR S LAST=$J(INCR,0,0)
111 I COUNT=TOTAL W "|",!!?20,"DISCHARGE SUMMARY CONVERSION COMPLETE!"
112 Q
113CONVERT(GMRDA,TIUSNGL) ; "Turn or burn!"
114 N GMRD0,GMRDACT,DOCTYP,DFN,GMRDADT,GMRDLDT,TNEW,TIU,TIUTYP,TIUDA,TIUDAD
115 S GMRD0=$G(^GMR(128,+GMRDA,0)),GMRDACT=$G(^GMR(128,+GMRDA,"ACT"))
116 I GMRD0']"" D Q
117 . N TIUCRCT
118 . S ^GMR(128,"CNV","FAIL",GMRDA)="MISSING INFORMATION"
119 . S TIUCRCT=+$G(^GMR(128,"CNV","FAIL",0))+1
120 . S $P(^GMR(128,"CNV","FAIL",0),U)=TIUCRCT
121 D ALERTDEL^GMRDALRT(GMRDA)
122 S DOCTYP=$S(+$P(GMRD0,U,6):"ADDENDUM",1:"DISCHARGE SUMMARY")
123 S TIUTYP(1)=1_U_+$$WHATITLE^TIUPUTU(DOCTYP)_U_DOCTYP
124 S DFN=+$P(GMRD0,U,2),GMRDADT=$P(GMRD0,U,7)
125 S GMRDLDT=$S($L(GMRDADT,".")=2:$$FMADD^XLFDT(GMRDADT,"","","",1),1:$$FMADD^XLFDT(GMRDADT,1))
126 D MAIN^TIUMOVE(.TIU,.DFN,"",GMRDADT,GMRDLDT,1,"LAST",0)
127 I +$G(TIU("AD#"))'>0 D Q
128 . N TIUNOVCT
129 . S ^GMR(128,"CNV","FAIL",GMRDA)="NO ADMISSION FOUND"
130 . S TIUNOVCT=+$P($G(^GMR(128,"CNV","FAIL",0)),U,2)+1
131 . S $P(^GMR(128,"CNV","FAIL",0),U,2)=TIUNOVCT
132 I DOCTYP="DISCHARGE SUMMARY" D
133 . S TIUDA=$$GETREC^TIUEDI1(DFN,.TIU,1,.TNEW)
134 . I +$G(TIU("VSTR")) D POST^TIUPXAP1(.TIU,DFN,TIUDA)
135 . D STUFREC^TIUDSCN1(TIUDA,"",GMRD0,GMRDACT)
136 I DOCTYP="ADDENDUM" D
137 . S TIUDA=$$MAKEADD^TIUPUTU
138 . I +$G(TIU("VSTR")) D POST^TIUPXAP1(.TIU,DFN,TIUDA)
139 . S TIUDAD=$$FINDAD(DFN,.TIU,+$P(TIUTYP(1),U,2))
140 . I +TIUDAD'>0 D DELETE^TIUDSCN1(TIUDA),ADDFAIL^TIUDSCN1(GMRDA) Q
141 . D STUFREC^TIUDSCN1(TIUDA,TIUDAD,GMRD0,GMRDACT)
142 D SEND^TIUALRT(TIUDA)
143 D AUDIT^TIUEDI1(TIUDA,0,$$CHKSUM^TIULC("^TIU(8925,"_+TIUDA_",""TEXT"")"))
144 S:'+$G(TIUSNGL) ^GMR(128,"CNV","CHKPNT")=GMRDA_U_TIUDA
145 S ^GMR(128,"CNV","SUCCEED")=+$G(^GMR(128,"CNV","SUCCEED"))+1
146 S ^GMR(128,"CNV","SUCCEED",GMRDA)=TIUDA
147 Q
148RUNNING() ; Evaluate whether conversion is running in another partition
149 N TIUCKP0,TIUCKP1,TIUI,TIUY
150 W !,"Attempting to determine whether conversion has crashed,"
151 W !,"or is still running in another partition..."
152 S TIUCKP0=+$G(^GMR(128,"CNV","CHKPNT")),TIUY=0
153 F TIUI=1:1:1000 D Q:+TIUY
154 . W:'(TIUI#10) "."
155 . S TIUCKP1=+$G(^GMR(128,"CNV","CHKPNT"))
156 . I TIUCKP1'=TIUCKP0 S TIUY=1
157 Q +$G(TIUY)
158PNRUN() ; Evaluate whether PN conversion is running in another partition
159 N TIUCKP0,TIUCKP1,TIUI,TIUY
160 W !,"Attempting to determine whether PN conversion has crashed,"
161 W !,"or is still running in another partition..."
162 S TIUCKP0=+$P($G(^TIU(8925.97,1,0)),U,5),TIUY=0
163 F TIUI=1:1:1000 D Q:+TIUY
164 . W:'(TIUI#10) "."
165 . S TIUCKP1=+$P($G(^TIU(8925.97,1,0)),U,5)
166 . I TIUCKP1'=TIUCKP0 S TIUY=1
167 Q +$G(TIUY)
168FINDAD(DFN,TIU,TIUTYPE) ; Find original record for an addendum
169 N TIUY
170 S TIUY=+$O(^TIU(8925,"AV",DFN,1,+$G(TIU("VISIT")),0))
171 I +TIUY'>0 S TIUY=+$O(^TIU(8925,"APTLD",DFN,1,$G(TIU("VSTR")),0))
172 Q TIUY
Note: See TracBrowser for help on using the repository browser.