VistA-FOIAVistA/r/TEXT_INTEGRATION_UTILITIES-.../TIUPNCV.m

151 lines
6.0 KiB
Mathematica

TIUPNCV ;SLC/DJP-SF/JLI ;3/3/98 14:00
;;1.0;TEXT INTEGRATION UTILITIES;**9**;Jun 20, 1997
;
DRIVER ;Entry point; initializes counters
S TIUFPRIV=1
S:'$D(U) U="^" S (GMRPCTR,TIUCTR,ERRCTR)=0 S:'$D(GMRPST) GMRPST=0
;above- if not a Restart, initializes counter
S $P(^TIU(8925.97,1,0),U,2)=$$NOW^XLFDT
S GMRPFINI=$P($G(^TIU(8925.97,1,0)),U,8)
S TIUSTRT=$$DATE^TIULS($$NOW^TIULC,"MM/DD/YY HR:MIN")
;
RESTART ;Restarts Progress Note conversion
S GMRPIFN=GMRPST
F S GMRPIFN=$O(^GMR(121,GMRPIFN)) Q:'GMRPIFN Q:GMRPIFN=$G(GMRPFINI) D
. D MAIN
S TIUEND=$$DATE^TIULS($$NOW^TIULC,"MM/DD/YY HR:MIN")
;
CLEANUP ;Releases Bulletin & kills variables and scratch files
W !!?20,"***** CONVERSION HAS FINISHED *****",!
STOP D REPORT^TIUPNCV4
K GMRPCTR,TIUCTR,GMRPST,GMRPIFN,GMRPFL,TIUFPRIV
K ^TMP("TIUIFN")
I $P($G(^TIU(8925.97,1,2)),U,3)'>0
I S $P(^TIU(8925.97,1,0),U,3)=$$NOW^XLFDT
S $P(^TIU(8925.97,1,2),U,3)=0
Q
;
MAIN ;Main loop for each record
I $P($G(^TIU(8925.97,1,2)),U,3)>0
I S TIUEND=$$DATE^TIULS($$NOW^TIULC,"MM/DD/YY HR:MIN") G STOP
N PN S GMRPCTR=GMRPCTR+1
;
MAIN1 ;
Q:'+$P($G(^GMR(121,GMRPIFN,1)),U,3)
Q:$P($G(^GMR(121,GMRPIFN,5)),U)="1"
;do not convert unsigned/uncosigned notes
;
;ignore if test patient note
Q:$E($P($G(^DPT(+$P($G(^GMR(121,GMRPIFN,0)),U,2),0)),U,9),1,5)="00000"
;
Q:$D(^GMR(121,"CNV",GMRPIFN)) ;already converted
;
S GMR0=$G(^GMR(121,GMRPIFN,0)) ;using naked ref below
S GMR1=$G(^(1)),GMR5=$G(^(5)),GMR9=$G(^(9)),GMR100=$G(^(100))
F I=1,2,3,5,6 S PN($P(".01^.02^.03^.04^.05^.06",U,I))=$P(GMR0,U,I)
F I=1:1:5 S PN($P("1^2^3^4^4.1",U,I))=$P(GMR1,U,I)
F I=1:1:4 S PN($P("5^6^7^7.1",U,I))=$P(GMR5,U,I)
S PN(9)=$P(GMR9,U)
S PN(100)=$P(GMR100,U)
I (PN(.02)="")!(PN(.03)="")!(PN(.05)="")!(PN(1)="")!(PN(2)="") D Q
. S PROBLEM="Progress Note - IFN #"_GMRPIFN_" is incomplete."
. D ERRORLOG^TIUPNCV3 K BADREC,PN,PROBLEM Q
I PN(100),'$D(^GMR(121,"CNV",PN(100))) D Q
. S PROBLEM="Progress note - IFN # "_GMRPIFN_", addendum to unconverted parent note IFN # "_PN(100)
. D ERRORLOG^TIUPNCV3 K BADREC,PN,PROBLEM Q
;
D TIUFLDS
;
D TITLE^TIUPNCV3 I $D(BADREC) D CLEANREC Q
;
D RTNODE I $D(TIU("BAD")) D CLEANREC Q
;
D SETFIELD^TIUPNCV1 I $D(BADREC) D WIPEOUT Q
;
;Builds the TIU record
S DIE="^TIU(8925,",DA=TIUIFN D COPY I $D(BADREC) D WIPEOUT Q
D TEXT
D SIGSET ; D:TIU(1505)'="" SIGSET D:TIU(1511)'="" COSET
D ^TIUPNCVX ;*** May uncomment for direct X-ref set ***
;S DA=TIUIFN,DIK="^TIU(8925," D IX1^DIK ; DO SETS ON X-REFS FOR ENTRY
S $P(^TIU(8925.97,1,0),U,5)=GMRPIFN ;last PN successfully processed
S $P(^TIU(8925.97,1,2),U,2)=TIUIFN ;last IEN used within ^TIU(8925,
I TIUCTR=1 S $P(^TIU(8925.97,1,2),U,1)=TIUIFN ;first IEN in ^TIU(8925,
S TIUCTR=TIUCTR+1
S $P(^TIU(8925.97,1,0),U,6)=TIUCTR ;records # of TIU documents built
S ^GMR(121,"CNV",GMRPIFN)=TIUIFN
I '(TIUIFN#500) W "."
D CLEANREC
Q
;
CLEANREC ;Cleans partition after entry of record
K TIU,ESIG,PN,ATH,P1,P2,P3,P4,P5,C1,C2,C3,PNT,BADREC,TIUD,TIUNM,TIUT
K TMSG,TYP,COSIGN,TIUCOMPO,TIUCTYP,TYPE
K ^TMP("TIUBRK",GMRPIFN)
Q
;
WIPEOUT ;Clears ^TIU(8925 if record is found to be incomplete
S DIK="^TIU(8925,",DA=TIUIFN D ^DIK
K ^TMP("TIUIFN",GMRPIFN)
I $G(TIU(.03)) S X=TIU(.03) D SUB^AUPNVSIT
D CLEANREC
Q
;
TIUFLDS ;Sets TIU variables with PN data
;
; TIU(.01) SET IN TITLESET TIUPNCV3
S TIU(.02)=PN(.02) ; .02 PATIENT - .02 PATIENT
; TIU(.03) SET IN VISIT TIUPNCV1
; TIU(.04) SET IN TITLESET TIUPNCV3
; TIU(.05) SET IN SIGVAR/COSVAR TIUPNCV1
S TIU(.06)=$S(+PN(100):$G(^GMR(121,"CNV",+PN(100))),1:"")
S TIU(.07)=PN(.03) ; USE DATE/TIME OF NOTE FOR EPISODE DATE TIME
S TIU(.13)="E"
S TIU(1201)=PN(.01) ; 1201 ENTRY DATE/TIME - .01 FILE ENTRY DATE
S (TIU(1202),TIU(1204))=PN(2) ; 1202 AUTHOR/DICTATOR - 2 AUTHOR
; expected signer 1204 in TIU is PN(2)- AUTHOR in GMR
S (TIU(1205),TIU(1211))=PN(9) ; 1205 HOSPITAL LOCATION - 9 LOCATION
S TIU(1301)=PN(.03) ; 1301 REFERENCE DATE - .03 DATE/TIME OF PROG NOTE
S TIU(1302)=PN(.05) ; 1302 ENTERED BY - .05 TRANSCRIBER
S TIU(1303)="C"
S TIU(1501)=PN(4) ; 1501 SIGNATURE DATE/TIME - 4 DATE/TIME SIGNED
S TIU(1502)=PN(3) ; 1502 SIGNED BY - 3 E-SIG (AUTHOR)
S (TIU(1503),TIU(1504),TIU(1505))=""
S TIU(1506)=PN(5) ; 1506 COSIGNATURE NEEDED - 5 COSIGNATURE REQUIRED
S TIU(1507)=PN(7) ; 1507 COSIGNATURE DATE/TIME - 7 DATE/TIME COSIGNED
S (TIU(1208),TIU(1508))=PN(6) ; 1508 COSIGNED BY - 6 COSIGNER
S (TIU(1509),TIU(1510),TIU(1511))=""
S (TIU(1512),TIU("SIGCHART"))=PN(4.1) ;1512 - 4.1 SIGNATURE IN CHART
S (TIU(1513),TIU("COSCHART"))=PN(7.1) ;1513 - 7.1 COSIGNATURE IN CHART
S TIU("MHCONV")=PN(.06)
S TIU("PARENT")=$S(+PN(100):$G(^GMR(121,"CNV",+PN(100))),1:"")
S TIU("SPECDT")=$P(TIU(1201),".",1)
S TIU("TITLE")=PN(1)
Q
;
RTNODE ;Sets 0 Node for TIU record
S TIUFPRIV=1
S (DIC,DLAYGO)=8925,DIC(0)="LN",X=""""_"`"_TIU(.01)_""""
D ^DIC I +Y<1 S TIU("BAD")=1 Q
S TIUIFN=+Y,^TMP("TIUIFN",GMRPIFN)=TIUIFN
Q
;
COPY ;Writes data from ^GMR(121,GMRPIFN --> ^TIU(8925,TIUIFN
S ^TIU(8925,TIUIFN,0)=TIU(.01)_U_TIU(.02)_U_TIU(.03)_U_TIU(.04)_U_TIU(.05)_U_TIU(.06)_U_TIU(.07)_U_U_U_U_U_U_TIU(.13)
S ^TIU(8925,TIUIFN,12)=TIU(1201)_U_TIU(1202)_U_U_TIU(1204)_U_TIU(1205)_U_U_U_TIU(1208)_U_U_U_TIU(1211)
S ^TIU(8925,TIUIFN,13)=TIU(1301)_U_TIU(1302)_U_TIU(1303)
I $D(TIUNEWTY) S DR=".01////"_TIUNEWTY D ^DIE K TIUNEWTY
Q
;
TEXT ;Copies text
I $D(^TMP("TIUHOLD",GMRPIFN)) M ^TIU(8925,TIUIFN,"TEXT")=^TMP("TIUHOLD",GMRPIFN,10) K ^TMP("TIUHOLD",GMRPIFN),^TMP("TIUMERGE",GMRPIFN) Q
Q
;
SIGSET ;Sets ^TIU(8925 signature fields
N X
I TIU(1502)>0 S TIU(1503)=$$ENCRYPT^TIULC1(TIU(1503),1,$$CHKSUM^TIULC("^TIU(8925,"_TIUIFN_",""TEXT"")")),TIU(1504)=$$ENCRYPT^TIULC1(TIU(1504),1,$$CHKSUM^TIULC("^TIU(8925,"_TIUIFN_",""TEXT"")"))
I TIU(1508)>0 S TIU(1509)=$$ENCRYPT^TIULC1(TIU(1509),1,$$CHKSUM^TIULC("^TIU(8925,"_TIUIFN_",""TEXT"")")),TIU(1510)=$$ENCRYPT^TIULC1(TIU(1510),1,$$CHKSUM^TIULC("^TIU(8925,"_TIUIFN_",""TEXT"")"))
S X=TIU(1501)_U_TIU(1502)_U_TIU(1503)_U_TIU(1504)_U_TIU(1505)
S ^TIU(8925,TIUIFN,15)=X_U_TIU(1506)_U_TIU(1507)_U_TIU(1508)_U_TIU(1509)_U_TIU(1510)_U_TIU(1511)_U_TIU(1512)_U_TIU(1513)
Q