TIUDSCNV ; SLC/JER - Discharge Summary Conversion routine
;;1.0;TEXT INTEGRATION UTILITIES;**9**;Jun 20, 1997
MAIN ; Control branching
N GMRDA,TIUOK,TIUQUEUE,TIURUN,GMRDSTOP
I +$P($G(^AUPNPAT(0)),U,3)'=+$P($G(^DPT(0)),U,3),'$D(^GMR(128,"CNV","PXPTPOST")) D Q:+TIUOK'>0
. N TIUPRMT
. W !!,"The IHS Patient file appears to be out of synchrony with File #2."
. W !,"Before continuing, you must run a program to synchronize these files."
. W !,"It may take a few minutes.",!
. S TIUPRMT="Would you like me to run that program now"
. S TIUOK=$$READ^TIUU("Y",TIUPRMT,"NO")
. I +TIUOK'>0 W !,"Okay, hurry back!" Q
. I +TIUOK>0 D QUE^PXPTPOST S ^GMR(128,"CNV","PXPTPOST")=1
W !!?9,"***************************************************************"
W !?9,"* This option will convert your Discharge Summary version 1.0 *"
W !?9,"* Database in preparation for implementation of Discharge *"
W !?9,"* Summary under Text Integration Utilities... *"
W !?9,"* Although the process is NOT irreversible, we recommend you *"
W !?9,"* be certain you are prepared to implement before invoking *"
W !?9,"* this process! *"
W !?9,"***************************************************************",!
S TIUOK=$$READ^TIUU("Y"," ... Are you sure","NO")
I +TIUOK'>0 W !!?9,$C(7),"Very well, no damage done!" Q
I +$G(^GMR(128,"CNV","T0")),'+$G(^GMR(128,"CNV","T1")) D Q:+$G(TIURUN)
. W !!,"The DISCHARGE SUMMARY CONVERSION is either still running in another partition,"
. W !,"or it has been interrupted...",!
. S TIURUN=+$$RUNNING
. I +TIURUN W !!,$C(7),"CONVERSION STILL RUNNING IN ANOTHER PARTITION."
. E W !!,"No other instance of the conversion could be detected...You're free to RESTART."
I +$P($G(^TIU(8925.97,1,0)),U,2),'+$P($G(^TIU(8925.97,1,0)),U,3) D Q:+$G(TIURUN)
. W !!,"The PROGRESS NOTES CONVERSION is either still running in another partition,"
. W !,"or it has been interrupted...",!
. S TIURUN=+$$PNRUN
. I +TIURUN W !!,$C(7),"PROGRESS NOTES CONVERSION STILL RUNNING IN ANOTHER PARTITION."
. E W !!,"PN CONVERSION is NOT currently running...You're free to begin."
S GMRDA=+$G(^GMR(128,"CNV","CHKPNT"))
S GMRDSTOP=+$G(^GMR(128,"CNV","STOP #"))
I GMRDSTOP'>0 D
. S GMRDSTOP=+$P($G(^GMR(128,0)),U,3),^GMR(128,"CNV","STOP #")=GMRDSTOP
I +GMRDSTOP'>0 W !!,$C(7),"NO DISCHARGE SUMMARIES TO CONVERT...Bye!",! Q
I +GMRDA>0 D
. W !!,"CONVERSION HAS ALREADY BEEN RUN..."
. W !,"Checkpoint is Record #",GMRDA
. I +GMRDSTOP'=+$P($G(^GMR(128,0)),U,3) D
. . S GMRDSTOP=+$P(^GMR(128,0),U,3)
. . S ^GMR(128,"CNV","STOP #")=GMRDSTOP
. W !,"Conversion will stop after record #",GMRDSTOP
. S TIUOK=$$READ^TIUU("Y"," Do You Wish to Continue","NO")
I +TIUOK'>0 W !!?5,"Very well, no damage done!" Q
S TIUQUEUE=$$READ^TIUU("Y","Would you like to QUEUE this Process","NO")
I +TIUQUEUE'>0 D Q
. W !!?9,$C(7),"Discharge Summary Conversion Running in Foreground"
. D ENQ
D QUEUE
Q
QUEUE ; Call Task Manager to process conversion
N %,ZTDTH,ZTDESC,ZTIO,ZTSAVE,ZTSK,ZTRTN
S ZTRTN="ENQ^TIUDSCNV"
S ZTSAVE("GMRDA")="",ZTSAVE("DUZ(")="",ZTSAVE("GMRDSTOP")=""
S:'$D(ZTDESC) ZTDESC="TIU DISCHARGE SUMMARY CONVERSION" S ZTIO=""
D ^%ZTLOAD W !,$S($D(ZTSK):"Request Queued!",1:"Request Cancelled!")
D ^%ZISC
Q
ENQ ; Where the work happens
N GMRDCNT,GMRDTOTL
S:+$G(GMRDA)'>0 GMRDA=+$G(^GMR(128,"CNV","CHKPNT"))
S GMRDCNT=+$G(^GMR(128,"CNV","CNT"))
S GMRDTOTL=+$P($G(^GMR(128,0)),U,3)
; --- Get records from file #128 ---
S:'$D(^GMR(128,"CNV","T0")) ^GMR(128,"CNV","T0")=$$NOW^TIULC
I '$D(ZTQUEUED) D PROGBAR
F S GMRDA=$O(^GMR(128,GMRDA)) Q:(+GMRDA'>0)!(+GMRDA>+GMRDSTOP)!+$G(ZTSTOP) D
. D CONVERT(GMRDA) S GMRDCNT=+$G(GMRDCNT)+1
. I '$D(ZTQUEUED) D PROGRESS(GMRDCNT,GMRDTOTL)
. S ^GMR(128,"CNV","CNT")=GMRDCNT
. I $$S^%ZTLOAD S ZTSTOP=1
Q:+$G(ZTSTOP)
S ^GMR(128,"CNV","CNT")=GMRDCNT
S ^GMR(128,"CNV","T1")=$$NOW^TIULC
D BULLETIN ; Send Conversion Bulletin
Q
BULLETIN ; Send Bulletins on completion
N TIUCNVCT,TIUMISCT,TIUADMCT,TIUFAIL,TIUBDT,TIUEDT,XMY,XMB,XMDUZ
S TIUCNVCT=+$G(^GMR(128,"CNV","SUCCEED"))
S TIUMISCT=+$G(^GMR(128,"CNV","FAIL",0))
S TIUADMCT=+$P($G(^GMR(128,"CNV","FAIL",0)),U,2)
S TIUFAIL=+$G(TIUMISCT)+$G(TIUADMCT)
S TIUBDT=$$DATE^TIULS(+$G(^GMR(128,"CNV","T0")),"MM/DD/YY HR:MIN")
S TIUEDT=$$DATE^TIULS(+$G(^GMR(128,"CNV","T1")),"MM/DD/YY HR:MIN")
S XMY(+$G(DUZ))=""
S XMB="TIU DS CONVERSION "_$S(+TIUFAIL>0:"ERRORS",1:"CLEAN")
S XMDUZ="TIU DISCHARGE SUMMARY CONVERSION"
S XMB(1)=TIUBDT,XMB(2)=TIUEDT,XMB(3)=TIUCNVCT
I +TIUFAIL>0 S XMB(4)=TIUFAIL,XMB(5)=TIUMISCT,XMB(6)=TIUADMCT
D ^XMB,KILL^XM
Q
PROGBAR ; Write a Progress Bar
K LAST
; I '$D(IOINORM) S X="IOINORM;IORVON;IORVOFF" D ENDR^%ZISS
W !!,$$CENTER^TIULS("Discharge Summary Conversion in Progress...")
W !,$$CENTER^TIULS("Percent Complete")
W !,$$CENTER^TIULS("0 10 20 30 40 50 60 70 80 90 100")
W !?12,"|"
Q
PROGRESS(COUNT,TOTAL) ; Indicate Progress
N PCT,INCR,BAR S PCT=(COUNT/TOTAL)*100
S INCR=PCT\2
I +$G(LAST)'=$J(INCR,0,0) D
. S $P(BAR,"|",(INCR-+$G(LAST))+1)=""
. W BAR S LAST=$J(INCR,0,0)
I COUNT=TOTAL W "|",!!?20,"DISCHARGE SUMMARY CONVERSION COMPLETE!"
Q
CONVERT(GMRDA,TIUSNGL) ; "Turn or burn!"
N GMRD0,GMRDACT,DOCTYP,DFN,GMRDADT,GMRDLDT,TNEW,TIU,TIUTYP,TIUDA,TIUDAD
S GMRD0=$G(^GMR(128,+GMRDA,0)),GMRDACT=$G(^GMR(128,+GMRDA,"ACT"))
I GMRD0']"" D Q
. N TIUCRCT
. S ^GMR(128,"CNV","FAIL",GMRDA)="MISSING INFORMATION"
. S TIUCRCT=+$G(^GMR(128,"CNV","FAIL",0))+1
. S $P(^GMR(128,"CNV","FAIL",0),U)=TIUCRCT
D ALERTDEL^GMRDALRT(GMRDA)
S DOCTYP=$S(+$P(GMRD0,U,6):"ADDENDUM",1:"DISCHARGE SUMMARY")
S TIUTYP(1)=1_U_+$$WHATITLE^TIUPUTU(DOCTYP)_U_DOCTYP
S DFN=+$P(GMRD0,U,2),GMRDADT=$P(GMRD0,U,7)
S GMRDLDT=$S($L(GMRDADT,".")=2:$$FMADD^XLFDT(GMRDADT,"","","",1),1:$$FMADD^XLFDT(GMRDADT,1))
D MAIN^TIUMOVE(.TIU,.DFN,"",GMRDADT,GMRDLDT,1,"LAST",0)
I +$G(TIU("AD#"))'>0 D Q
. N TIUNOVCT
. S ^GMR(128,"CNV","FAIL",GMRDA)="NO ADMISSION FOUND"
. S TIUNOVCT=+$P($G(^GMR(128,"CNV","FAIL",0)),U,2)+1
. S $P(^GMR(128,"CNV","FAIL",0),U,2)=TIUNOVCT
I DOCTYP="DISCHARGE SUMMARY" D
. S TIUDA=$$GETREC^TIUEDI1(DFN,.TIU,1,.TNEW)
. I +$G(TIU("VSTR")) D POST^TIUPXAP1(.TIU,DFN,TIUDA)
. D STUFREC^TIUDSCN1(TIUDA,"",GMRD0,GMRDACT)
I DOCTYP="ADDENDUM" D
. S TIUDA=$$MAKEADD^TIUPUTU
. I +$G(TIU("VSTR")) D POST^TIUPXAP1(.TIU,DFN,TIUDA)
. S TIUDAD=$$FINDAD(DFN,.TIU,+$P(TIUTYP(1),U,2))
. I +TIUDAD'>0 D DELETE^TIUDSCN1(TIUDA),ADDFAIL^TIUDSCN1(GMRDA) Q
. D STUFREC^TIUDSCN1(TIUDA,TIUDAD,GMRD0,GMRDACT)
D SEND^TIUALRT(TIUDA)
D AUDIT^TIUEDI1(TIUDA,0,$$CHKSUM^TIULC("^TIU(8925,"_+TIUDA_",""TEXT"")"))
S:'+$G(TIUSNGL) ^GMR(128,"CNV","CHKPNT")=GMRDA_U_TIUDA
S ^GMR(128,"CNV","SUCCEED")=+$G(^GMR(128,"CNV","SUCCEED"))+1
S ^GMR(128,"CNV","SUCCEED",GMRDA)=TIUDA
Q
RUNNING() ; Evaluate whether conversion is running in another partition
N TIUCKP0,TIUCKP1,TIUI,TIUY
W !,"Attempting to determine whether conversion has crashed,"
W !,"or is still running in another partition..."
S TIUCKP0=+$G(^GMR(128,"CNV","CHKPNT")),TIUY=0
F TIUI=1:1:1000 D Q:+TIUY
. W:'(TIUI#10) "."
. S TIUCKP1=+$G(^GMR(128,"CNV","CHKPNT"))
. I TIUCKP1'=TIUCKP0 S TIUY=1
Q +$G(TIUY)
PNRUN() ; Evaluate whether PN conversion is running in another partition
N TIUCKP0,TIUCKP1,TIUI,TIUY
W !,"Attempting to determine whether PN conversion has crashed,"
W !,"or is still running in another partition..."
S TIUCKP0=+$P($G(^TIU(8925.97,1,0)),U,5),TIUY=0
F TIUI=1:1:1000 D Q:+TIUY
. W:'(TIUI#10) "."
. S TIUCKP1=+$P($G(^TIU(8925.97,1,0)),U,5)
. I TIUCKP1'=TIUCKP0 S TIUY=1
Q +$G(TIUY)
FINDAD(DFN,TIU,TIUTYPE) ; Find original record for an addendum
N TIUY
S TIUY=+$O(^TIU(8925,"AV",DFN,1,+$G(TIU("VISIT")),0))
I +TIUY'>0 S TIUY=+$O(^TIU(8925,"APTLD",DFN,1,$G(TIU("VSTR")),0))
Q TIUY
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HTIUDSCNV 7984 printed Dec 13, 2024@02:39:51 Page 2
TIUDSCNV ; SLC/JER - Discharge Summary Conversion routine
+1 ;;1.0;TEXT INTEGRATION UTILITIES;**9**;Jun 20, 1997
MAIN ; Control branching
+1 NEW GMRDA,TIUOK,TIUQUEUE,TIURUN,GMRDSTOP
+2 IF +$PIECE($GET(^AUPNPAT(0)),U,3)'=+$PIECE($GET(^DPT(0)),U,3)
IF '$DATA(^GMR(128,"CNV","PXPTPOST"))
Begin DoDot:1
+3 NEW TIUPRMT
+4 WRITE !!,"The IHS Patient file appears to be out of synchrony with File #2."
+5 WRITE !,"Before continuing, you must run a program to synchronize these files."
+6 WRITE !,"It may take a few minutes.",!
+7 SET TIUPRMT="Would you like me to run that program now"
+8 SET TIUOK=$$READ^TIUU("Y",TIUPRMT,"NO")
+9 IF +TIUOK'>0
WRITE !,"Okay, hurry back!"
QUIT
+10 IF +TIUOK>0
DO QUE^PXPTPOST
SET ^GMR(128,"CNV","PXPTPOST")=1
End DoDot:1
if +TIUOK'>0
QUIT
+11 WRITE !!?9,"***************************************************************"
+12 WRITE !?9,"* This option will convert your Discharge Summary version 1.0 *"
+13 WRITE !?9,"* Database in preparation for implementation of Discharge *"
+14 WRITE !?9,"* Summary under Text Integration Utilities... *"
+15 WRITE !?9,"* Although the process is NOT irreversible, we recommend you *"
+16 WRITE !?9,"* be certain you are prepared to implement before invoking *"
+17 WRITE !?9,"* this process! *"
+18 WRITE !?9,"***************************************************************",!
+19 SET TIUOK=$$READ^TIUU("Y"," ... Are you sure","NO")
+20 IF +TIUOK'>0
WRITE !!?9,$CHAR(7),"Very well, no damage done!"
QUIT
+21 IF +$GET(^GMR(128,"CNV","T0"))
IF '+$GET(^GMR(128,"CNV","T1"))
Begin DoDot:1
+22 WRITE !!,"The DISCHARGE SUMMARY CONVERSION is either still running in another partition,"
+23 WRITE !,"or it has been interrupted...",!
+24 SET TIURUN=+$$RUNNING
+25 IF +TIURUN
WRITE !!,$CHAR(7),"CONVERSION STILL RUNNING IN ANOTHER PARTITION."
+26 IF '$TEST
WRITE !!,"No other instance of the conversion could be detected...You're free to RESTART."
End DoDot:1
if +$GET(TIURUN)
QUIT
+27 IF +$PIECE($GET(^TIU(8925.97,1,0)),U,2)
IF '+$PIECE($GET(^TIU(8925.97,1,0)),U,3)
Begin DoDot:1
+28 WRITE !!,"The PROGRESS NOTES CONVERSION is either still running in another partition,"
+29 WRITE !,"or it has been interrupted...",!
+30 SET TIURUN=+$$PNRUN
+31 IF +TIURUN
WRITE !!,$CHAR(7),"PROGRESS NOTES CONVERSION STILL RUNNING IN ANOTHER PARTITION."
+32 IF '$TEST
WRITE !!,"PN CONVERSION is NOT currently running...You're free to begin."
End DoDot:1
if +$GET(TIURUN)
QUIT
+33 SET GMRDA=+$GET(^GMR(128,"CNV","CHKPNT"))
+34 SET GMRDSTOP=+$GET(^GMR(128,"CNV","STOP #"))
+35 IF GMRDSTOP'>0
Begin DoDot:1
+36 SET GMRDSTOP=+$PIECE($GET(^GMR(128,0)),U,3)
SET ^GMR(128,"CNV","STOP #")=GMRDSTOP
End DoDot:1
+37 IF +GMRDSTOP'>0
WRITE !!,$CHAR(7),"NO DISCHARGE SUMMARIES TO CONVERT...Bye!",!
QUIT
+38 IF +GMRDA>0
Begin DoDot:1
+39 WRITE !!,"CONVERSION HAS ALREADY BEEN RUN..."
+40 WRITE !,"Checkpoint is Record #",GMRDA
+41 IF +GMRDSTOP'=+$PIECE($GET(^GMR(128,0)),U,3)
Begin DoDot:2
+42 SET GMRDSTOP=+$PIECE(^GMR(128,0),U,3)
+43 SET ^GMR(128,"CNV","STOP #")=GMRDSTOP
End DoDot:2
+44 WRITE !,"Conversion will stop after record #",GMRDSTOP
+45 SET TIUOK=$$READ^TIUU("Y"," Do You Wish to Continue","NO")
End DoDot:1
+46 IF +TIUOK'>0
WRITE !!?5,"Very well, no damage done!"
QUIT
+47 SET TIUQUEUE=$$READ^TIUU("Y","Would you like to QUEUE this Process","NO")
+48 IF +TIUQUEUE'>0
Begin DoDot:1
+49 WRITE !!?9,$CHAR(7),"Discharge Summary Conversion Running in Foreground"
+50 DO ENQ
End DoDot:1
QUIT
+51 DO QUEUE
+52 QUIT
QUEUE ; Call Task Manager to process conversion
+1 NEW %,ZTDTH,ZTDESC,ZTIO,ZTSAVE,ZTSK,ZTRTN
+2 SET ZTRTN="ENQ^TIUDSCNV"
+3 SET ZTSAVE("GMRDA")=""
SET ZTSAVE("DUZ(")=""
SET ZTSAVE("GMRDSTOP")=""
+4 if '$DATA(ZTDESC)
SET ZTDESC="TIU DISCHARGE SUMMARY CONVERSION"
SET ZTIO=""
+5 DO ^%ZTLOAD
WRITE !,$SELECT($DATA(ZTSK):"Request Queued!",1:"Request Cancelled!")
+6 DO ^%ZISC
+7 QUIT
ENQ ; Where the work happens
+1 NEW GMRDCNT,GMRDTOTL
+2 if +$GET(GMRDA)'>0
SET GMRDA=+$GET(^GMR(128,"CNV","CHKPNT"))
+3 SET GMRDCNT=+$GET(^GMR(128,"CNV","CNT"))
+4 SET GMRDTOTL=+$PIECE($GET(^GMR(128,0)),U,3)
+5 ; --- Get records from file #128 ---
+6 if '$DATA(^GMR(128,"CNV","T0"))
SET ^GMR(128,"CNV","T0")=$$NOW^TIULC
+7 IF '$DATA(ZTQUEUED)
DO PROGBAR
+8 FOR
SET GMRDA=$ORDER(^GMR(128,GMRDA))
if (+GMRDA'>0)!(+GMRDA>+GMRDSTOP)!+$GET(ZTSTOP)
QUIT
Begin DoDot:1
+9 DO CONVERT(GMRDA)
SET GMRDCNT=+$GET(GMRDCNT)+1
+10 IF '$DATA(ZTQUEUED)
DO PROGRESS(GMRDCNT,GMRDTOTL)
+11 SET ^GMR(128,"CNV","CNT")=GMRDCNT
+12 IF $$S^%ZTLOAD
SET ZTSTOP=1
End DoDot:1
+13 if +$GET(ZTSTOP)
QUIT
+14 SET ^GMR(128,"CNV","CNT")=GMRDCNT
+15 SET ^GMR(128,"CNV","T1")=$$NOW^TIULC
+16 ; Send Conversion Bulletin
DO BULLETIN
+17 QUIT
BULLETIN ; Send Bulletins on completion
+1 NEW TIUCNVCT,TIUMISCT,TIUADMCT,TIUFAIL,TIUBDT,TIUEDT,XMY,XMB,XMDUZ
+2 SET TIUCNVCT=+$GET(^GMR(128,"CNV","SUCCEED"))
+3 SET TIUMISCT=+$GET(^GMR(128,"CNV","FAIL",0))
+4 SET TIUADMCT=+$PIECE($GET(^GMR(128,"CNV","FAIL",0)),U,2)
+5 SET TIUFAIL=+$GET(TIUMISCT)+$GET(TIUADMCT)
+6 SET TIUBDT=$$DATE^TIULS(+$GET(^GMR(128,"CNV","T0")),"MM/DD/YY HR:MIN")
+7 SET TIUEDT=$$DATE^TIULS(+$GET(^GMR(128,"CNV","T1")),"MM/DD/YY HR:MIN")
+8 SET XMY(+$GET(DUZ))=""
+9 SET XMB="TIU DS CONVERSION "_$SELECT(+TIUFAIL>0:"ERRORS",1:"CLEAN")
+10 SET XMDUZ="TIU DISCHARGE SUMMARY CONVERSION"
+11 SET XMB(1)=TIUBDT
SET XMB(2)=TIUEDT
SET XMB(3)=TIUCNVCT
+12 IF +TIUFAIL>0
SET XMB(4)=TIUFAIL
SET XMB(5)=TIUMISCT
SET XMB(6)=TIUADMCT
+13 DO ^XMB
DO KILL^XM
+14 QUIT
PROGBAR ; Write a Progress Bar
+1 KILL LAST
+2 ; I '$D(IOINORM) S X="IOINORM;IORVON;IORVOFF" D ENDR^%ZISS
+3 WRITE !!,$$CENTER^TIULS("Discharge Summary Conversion in Progress...")
+4 WRITE !,$$CENTER^TIULS("Percent Complete")
+5 WRITE !,$$CENTER^TIULS("0 10 20 30 40 50 60 70 80 90 100")
+6 WRITE !?12,"|"
+7 QUIT
PROGRESS(COUNT,TOTAL) ; Indicate Progress
+1 NEW PCT,INCR,BAR
SET PCT=(COUNT/TOTAL)*100
+2 SET INCR=PCT\2
+3 IF +$GET(LAST)'=$JUSTIFY(INCR,0,0)
Begin DoDot:1
+4 SET $PIECE(BAR,"|",(INCR-+$GET(LAST))+1)=""
+5 WRITE BAR
SET LAST=$JUSTIFY(INCR,0,0)
End DoDot:1
+6 IF COUNT=TOTAL
WRITE "|",!!?20,"DISCHARGE SUMMARY CONVERSION COMPLETE!"
+7 QUIT
CONVERT(GMRDA,TIUSNGL) ; "Turn or burn!"
+1 NEW GMRD0,GMRDACT,DOCTYP,DFN,GMRDADT,GMRDLDT,TNEW,TIU,TIUTYP,TIUDA,TIUDAD
+2 SET GMRD0=$GET(^GMR(128,+GMRDA,0))
SET GMRDACT=$GET(^GMR(128,+GMRDA,"ACT"))
+3 IF GMRD0']""
Begin DoDot:1
+4 NEW TIUCRCT
+5 SET ^GMR(128,"CNV","FAIL",GMRDA)="MISSING INFORMATION"
+6 SET TIUCRCT=+$GET(^GMR(128,"CNV","FAIL",0))+1
+7 SET $PIECE(^GMR(128,"CNV","FAIL",0),U)=TIUCRCT
End DoDot:1
QUIT
+8 DO ALERTDEL^GMRDALRT(GMRDA)
+9 SET DOCTYP=$SELECT(+$PIECE(GMRD0,U,6):"ADDENDUM",1:"DISCHARGE SUMMARY")
+10 SET TIUTYP(1)=1_U_+$$WHATITLE^TIUPUTU(DOCTYP)_U_DOCTYP
+11 SET DFN=+$PIECE(GMRD0,U,2)
SET GMRDADT=$PIECE(GMRD0,U,7)
+12 SET GMRDLDT=$SELECT($LENGTH(GMRDADT,".")=2:$$FMADD^XLFDT(GMRDADT,"","","",1),1:$$FMADD^XLFDT(GMRDADT,1))
+13 DO MAIN^TIUMOVE(.TIU,.DFN,"",GMRDADT,GMRDLDT,1,"LAST",0)
+14 IF +$GET(TIU("AD#"))'>0
Begin DoDot:1
+15 NEW TIUNOVCT
+16 SET ^GMR(128,"CNV","FAIL",GMRDA)="NO ADMISSION FOUND"
+17 SET TIUNOVCT=+$PIECE($GET(^GMR(128,"CNV","FAIL",0)),U,2)+1
+18 SET $PIECE(^GMR(128,"CNV","FAIL",0),U,2)=TIUNOVCT
End DoDot:1
QUIT
+19 IF DOCTYP="DISCHARGE SUMMARY"
Begin DoDot:1
+20 SET TIUDA=$$GETREC^TIUEDI1(DFN,.TIU,1,.TNEW)
+21 IF +$GET(TIU("VSTR"))
DO POST^TIUPXAP1(.TIU,DFN,TIUDA)
+22 DO STUFREC^TIUDSCN1(TIUDA,"",GMRD0,GMRDACT)
End DoDot:1
+23 IF DOCTYP="ADDENDUM"
Begin DoDot:1
+24 SET TIUDA=$$MAKEADD^TIUPUTU
+25 IF +$GET(TIU("VSTR"))
DO POST^TIUPXAP1(.TIU,DFN,TIUDA)
+26 SET TIUDAD=$$FINDAD(DFN,.TIU,+$PIECE(TIUTYP(1),U,2))
+27 IF +TIUDAD'>0
DO DELETE^TIUDSCN1(TIUDA)
DO ADDFAIL^TIUDSCN1(GMRDA)
QUIT
+28 DO STUFREC^TIUDSCN1(TIUDA,TIUDAD,GMRD0,GMRDACT)
End DoDot:1
+29 DO SEND^TIUALRT(TIUDA)
+30 DO AUDIT^TIUEDI1(TIUDA,0,$$CHKSUM^TIULC("^TIU(8925,"_+TIUDA_",""TEXT"")"))
+31 if '+$GET(TIUSNGL)
SET ^GMR(128,"CNV","CHKPNT")=GMRDA_U_TIUDA
+32 SET ^GMR(128,"CNV","SUCCEED")=+$GET(^GMR(128,"CNV","SUCCEED"))+1
+33 SET ^GMR(128,"CNV","SUCCEED",GMRDA)=TIUDA
+34 QUIT
RUNNING() ; Evaluate whether conversion is running in another partition
+1 NEW TIUCKP0,TIUCKP1,TIUI,TIUY
+2 WRITE !,"Attempting to determine whether conversion has crashed,"
+3 WRITE !,"or is still running in another partition..."
+4 SET TIUCKP0=+$GET(^GMR(128,"CNV","CHKPNT"))
SET TIUY=0
+5 FOR TIUI=1:1:1000
Begin DoDot:1
+6 if '(TIUI#10)
WRITE "."
+7 SET TIUCKP1=+$GET(^GMR(128,"CNV","CHKPNT"))
+8 IF TIUCKP1'=TIUCKP0
SET TIUY=1
End DoDot:1
if +TIUY
QUIT
+9 QUIT +$GET(TIUY)
PNRUN() ; Evaluate whether PN conversion is running in another partition
+1 NEW TIUCKP0,TIUCKP1,TIUI,TIUY
+2 WRITE !,"Attempting to determine whether PN conversion has crashed,"
+3 WRITE !,"or is still running in another partition..."
+4 SET TIUCKP0=+$PIECE($GET(^TIU(8925.97,1,0)),U,5)
SET TIUY=0
+5 FOR TIUI=1:1:1000
Begin DoDot:1
+6 if '(TIUI#10)
WRITE "."
+7 SET TIUCKP1=+$PIECE($GET(^TIU(8925.97,1,0)),U,5)
+8 IF TIUCKP1'=TIUCKP0
SET TIUY=1
End DoDot:1
if +TIUY
QUIT
+9 QUIT +$GET(TIUY)
FINDAD(DFN,TIU,TIUTYPE) ; Find original record for an addendum
+1 NEW TIUY
+2 SET TIUY=+$ORDER(^TIU(8925,"AV",DFN,1,+$GET(TIU("VISIT")),0))
+3 IF +TIUY'>0
SET TIUY=+$ORDER(^TIU(8925,"APTLD",DFN,1,$GET(TIU("VSTR")),0))
+4 QUIT TIUY