LA7SRR ;VA/DALOI/JMC - Select Accessions for Resending LEDI Results ;JUL 06, 2010 3:14 PM
;;5.2;AUTOMATED LAB INSTRUMENTS;**46,64,1027**;NOV 01, 1997
;
EN ; Select Accessions to resend.
;
; Housekeeping before we start.
D EXIT
;
S (LA7CNT,LA7QUIT)=0
;
S DIR(0)="SO^1:Range of Accessions;2:Selected Accessions"
S DIR("A")="Selection Method",DIR("B")=1
D ^DIR
I $D(DIRUT) D EXIT Q
S LA7TYPE=+Y
;
; Get list of accession numbers, set flags used by LRWU4.
S LRACC=1,LREXMPT=1
I LA7TYPE=1 D
. D ^LRWU4
. I LRAN<1 S LA7QUIT=1 Q
. S FIRST=LRAN,X=$O(^LRO(68,LRAA,1,LRAD,1,":"),-1)
. S DIR(0)="NO^"_LRAN_":"_X_":0",DIR("B")=LRAN
. S DIR("A",1)="",DIR("A")="Download from "_LRAN_" to"
. D ^DIR K DIR
. I $D(DIRUT) S LA7QUIT=1 Q
. S LRAN=FIRST-1,LAST=Y
. F S LRAN=$O(^LRO(68,LRAA,1,LRAD,1,LRAN)) Q:'LRAN!(LRAN>LAST) D SETTMP
I LA7TYPE=2 F D Q:LA7QUIT!(LRAN<1)
. D ^LRWU4
. I $D(DTOUT)!($D(DUOUT)) S LA7QUIT=1 Q
. I LRAN<1 S:'$D(^TMP("LA7S-RTM",$J)) LA7QUIT=1 Q
. D SETTMP
I LA7QUIT D EXIT Q
;
I '$D(^TMP("LA7S-RTM",$J)) D Q
. S DIR("A",1)="No accessions found to retransmit."
. S DIR("A")="Enter RETURN to continue or '^' to exit"
. S DIR(0)="E"
. D ^DIR,EXIT
;
S DIR("A")="Ready to retransmit"
S DIR("A",1)="Found "_LA7CNT_" accessions that can be retransmitted."
S DIR(0)="YO",DIR("B")="NO"
D ^DIR K DIR
I Y'=1 D EXIT Q
D EN^DDIOL("Working","","!")
S LA7CNT=0,LA7UID=""
F S LA7UID=$O(^TMP("LA7S-RTM",$J,LA7UID)) Q:LA7UID="" D
. K LA7X
. S LA7X=^TMP("LA7S-RTM",$J,LA7UID)
. S LA7NLT="",LA7CNT=LA7CNT+1
. F S LA7NLT=$O(^TMP("LA7S-RTM",$J,LA7UID,LA7NLT)) Q:LA7NLT="" D
. . S LA764=$$FIND1^DIC(64,"","MX",LA7NLT,"C")
. . I 'LA764 Q
. . S LA7NLTN=$$GET1^DIQ(64,LA764_",",.01)
. . K LA7Y
. . M LA7Y=^TMP("LA7S-RTM",$J,LA7UID,LA7NLT)
. . D SET^LA7VMSG($P(LA7X,"^"),$P(LA7X,"^",2),$P(LA7X,"^",3),$P(LA7X,"^",4),LA7NLTN,LA7NLT,$P(LA7X,"^",5),$P(LA7X,"^",6),$P(LA7X,"^",7),$P(LA7X,"^",8),.LA7Y,"ORU")
;
; Task background job to create messages
S ZTIO="",ZTRTN="ORU^LA7VMSG",ZTDTH=$H
S ZTDESC="Resend Lab LEDI HL7 Result Message"
D ^%ZTLOAD
;
K LA7X
S LA7X(1)="...Done",LA7X(1,"F")=""
I $G(ZTSK) D
. S LA7X(2)=LA7CNT_" accession"_$S(LA7CNT>1:"s",1:"")_" scheduled for retransmitting of results!"
. S LA7X(3)="Task# "_ZTSK_" queued for processing"
E S LA7X(2)="*** Tasking of retransmission failed ***"
D EN^DDIOL(.LA7X),EXIT
;
Q
;
;
SETTMP ; Setup TMP global with accession to resend.
;
N LA763,LA768,LA7I,LA7X,LA7Y,LR60,LR61,LRDFN,LRIDT,LRODT,LRSB,LRSS
;
S LRSS=$P(^LRO(68,LRAA,0),"^",2)
F LA7I=0,.2,.3,3 S LA768(LA7I)=$G(^LRO(68,LRAA,1,LRAD,1,LRAN,LA7I))
S LA7UID=$P(LA768(.3),"^")
;
; Not a LEDI specimen
I '$P(LA768(.3),"^",2),'$P(LA768(.3),"^",3) D Q
. N LA7X
. S LA7X="Not a LEDI specimen - Accession "_$P(LA768(.2),"^")_" ("_LA7UID_") skipped"
. D EN^DDIOL(LA7X,"","!")
;
I "CHMICYEMSP"'[LRSS!(LRSS="") D
. N LA7X
. S LA7X(1)=$$GET1^DIQ(68,LRAA_",",.02)_" subscript NOT supported at this time"
. S LA7X(2)="Accession "_$P(LA768(.2),"^")_" ("_LA7UID_") skipped"
. D EN^DDIOL(.LA7X)
;
; Check file #63 for order codes and results
; If no order NLT code found then use default NLT
; Check if test has been added to order then report results using NLT
; code of the added test.
S LRDFN=$P(LA768(0),"^"),LRODT=$P(LA768(0),"^",4),LRIDT=$P(LA768(3),"^",5)
; Check for date report completed.
I '$P(^LR(LRDFN,LRSS,LRIDT,0),"^",3) D Q
. N LA7X
. S LA7X="No date report completed - Accession "_$P(LA768(.2),"^")_" ("_LA7UID_") skipped"
. D EN^DDIOL(LA7X,"","!")
;
I LRSS="CH" D
. S LRSB=1
. F S LRSB=$O(^LR(LRDFN,LRSS,LRIDT,LRSB)) Q:'LRSB D
. . S X=^LR(LRDFN,LRSS,LRIDT,LRSB)
. . S LA7NLT=$P($P(X,"^",3),"!")
. . I LA7NLT'="" S LA7Y(LA7NLT,LRSB)="" Q
. . S LR61=+$P(^LR(LRDFN,LRSS,LRIDT,0),"^",5)
. . S LA7NLT=$P($$DEFCODE^LA7VHLU5(LRSS,LRSB,$P(X,"^",3),LR61),"!")
. . I LA7NLT'="" S LA7Y(LA7NLT,LRSB)=""
;
I LRSS="MI" D
. S LR60=0
. F S LR60=$O(^LRO(68,LRAA,1,LRAD,1,LRAN,4,LR60)) Q:'LR60 D
. . S LA764=$P($G(^LAB(60,LR60,64)),"^")
. . S LA7NLT=$$GET1^DIQ(64,LA764_",",1)
. . I LA7NLT'="" S LA7Y(LA7NLT)=""
;
I LRSS="SP" S LA7Y("88515.0000")=""
I LRSS="CY" S LA7Y("88593.0000")=""
I LRSS="EM" S LA7Y("88597.0000")=""
I LRSS="AU" S LA7Y("88533.0000")=""
;
I LA7UID'="",$D(LA7Y) D
. S LA7CNT=LA7CNT+1
. S X=$P(LA768(.3),"^",1)_"^"_$P(LA768(.3),"^",2)_"^"_$P(LA768(.3),"^",5)_"^"_$P(LA768(.3),"^",3)_"^"_LRIDT_"^"_LRSS_"^"_LRDFN_"^"_LRODT
. S ^TMP("LA7S-RTM",$J,LA7UID)=X
. S LA7I=""
. F S LA7I=$O(LA7Y(LA7I)) Q:LA7I="" M ^TMP("LA7S-RTM",$J,LA7UID,LA7I)=LA7Y(LA7I)
Q
;
;
EXIT ; Housekeeping - clean up.
K ^TMP("LA7S-RTM",$J)
K LA764,LA7CNT,LA7NLT,LA7NLTN,LA7QUIT,LA7TYPE,LA7UID,LA7X,LA7Y
K LRAA,LRACC,LRAD,LRAN,LREXMPT,LRIDIV,LRSS,LRX
K %DT,DA,DIC,DIR,DIRUT,DTOUT,DUOUT,FIRST,LAST,X,Y
K ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
Q
LA7SRR ;VA/DALOI/JMC - Select Accessions for Resending LEDI Results ;JUL 06, 2010 3:14 PM
+1 ;;5.2;AUTOMATED LAB INSTRUMENTS;**46,64,1027**;NOV 01, 1997
+2 ;
EN ; Select Accessions to resend.
+1 ;
+2 ; Housekeeping before we start.
+3 DO EXIT
+4 ;
+5 SET (LA7CNT,LA7QUIT)=0
+6 ;
+7 SET DIR(0)="SO^1:Range of Accessions;2:Selected Accessions"
+8 SET DIR("A")="Selection Method"
SET DIR("B")=1
+9 DO ^DIR
+10 IF $DATA(DIRUT)
DO EXIT
QUIT
+11 SET LA7TYPE=+Y
+12 ;
+13 ; Get list of accession numbers, set flags used by LRWU4.
+14 SET LRACC=1
SET LREXMPT=1
+15 IF LA7TYPE=1
Begin DoDot:1
+16 DO ^LRWU4
+17 IF LRAN<1
SET LA7QUIT=1
QUIT
+18 SET FIRST=LRAN
SET X=$ORDER(^LRO(68,LRAA,1,LRAD,1,":"),-1)
+19 SET DIR(0)="NO^"_LRAN_":"_X_":0"
SET DIR("B")=LRAN
+20 SET DIR("A",1)=""
SET DIR("A")="Download from "_LRAN_" to"
+21 DO ^DIR
KILL DIR
+22 IF $DATA(DIRUT)
SET LA7QUIT=1
QUIT
+23 SET LRAN=FIRST-1
SET LAST=Y
+24 FOR
SET LRAN=$ORDER(^LRO(68,LRAA,1,LRAD,1,LRAN))
IF 'LRAN!(LRAN>LAST)
QUIT
DO SETTMP
End DoDot:1
+25 IF LA7TYPE=2
FOR
Begin DoDot:1
+26 DO ^LRWU4
+27 IF $DATA(DTOUT)!($DATA(DUOUT))
SET LA7QUIT=1
QUIT
+28 IF LRAN<1
IF '$DATA(^TMP("LA7S-RTM",$JOB))
SET LA7QUIT=1
QUIT
+29 DO SETTMP
End DoDot:1
IF LA7QUIT!(LRAN<1)
QUIT
+30 IF LA7QUIT
DO EXIT
QUIT
+31 ;
+32 IF '$DATA(^TMP("LA7S-RTM",$JOB))
Begin DoDot:1
+33 SET DIR("A",1)="No accessions found to retransmit."
+34 SET DIR("A")="Enter RETURN to continue or '^' to exit"
+35 SET DIR(0)="E"
+36 DO ^DIR
DO EXIT
End DoDot:1
QUIT
+37 ;
+38 SET DIR("A")="Ready to retransmit"
+39 SET DIR("A",1)="Found "_LA7CNT_" accessions that can be retransmitted."
+40 SET DIR(0)="YO"
SET DIR("B")="NO"
+41 DO ^DIR
KILL DIR
+42 IF Y'=1
DO EXIT
QUIT
+43 DO EN^DDIOL("Working","","!")
+44 SET LA7CNT=0
SET LA7UID=""
+45 FOR
SET LA7UID=$ORDER(^TMP("LA7S-RTM",$JOB,LA7UID))
IF LA7UID=""
QUIT
Begin DoDot:1
+46 KILL LA7X
+47 SET LA7X=^TMP("LA7S-RTM",$JOB,LA7UID)
+48 SET LA7NLT=""
SET LA7CNT=LA7CNT+1
+49 FOR
SET LA7NLT=$ORDER(^TMP("LA7S-RTM",$JOB,LA7UID,LA7NLT))
IF LA7NLT=""
QUIT
Begin DoDot:2
+50 SET LA764=$$FIND1^DIC(64,"","MX",LA7NLT,"C")
+51 IF 'LA764
QUIT
+52 SET LA7NLTN=$$GET1^DIQ(64,LA764_",",.01)
+53 KILL LA7Y
+54 MERGE LA7Y=^TMP("LA7S-RTM",$JOB,LA7UID,LA7NLT)
+55 DO SET^LA7VMSG($PIECE(LA7X,"^"),$PIECE(LA7X,"^",2),$PIECE(LA7X,"^",3),$PIECE(LA7X,"^",4),LA7NLTN,LA7NLT,$PIECE(LA7X,"^",5),$PIECE(LA7X,"^",6),$PIECE(LA7X,"^",7),$PIECE(LA7X,"^",8),.LA7Y,"ORU")
End DoDot:2
End DoDot:1
+56 ;
+57 ; Task background job to create messages
+58 SET ZTIO=""
SET ZTRTN="ORU^LA7VMSG"
SET ZTDTH=$HOROLOG
+59 SET ZTDESC="Resend Lab LEDI HL7 Result Message"
+60 DO ^%ZTLOAD
+61 ;
+62 KILL LA7X
+63 SET LA7X(1)="...Done"
SET LA7X(1,"F")=""
+64 IF $GET(ZTSK)
Begin DoDot:1
+65 SET LA7X(2)=LA7CNT_" accession"_$SELECT(LA7CNT>1:"s",1:"")_" scheduled for retransmitting of results!"
+66 SET LA7X(3)="Task# "_ZTSK_" queued for processing"
End DoDot:1
+67 IF '$TEST
SET LA7X(2)="*** Tasking of retransmission failed ***"
+68 DO EN^DDIOL(.LA7X)
DO EXIT
+69 ;
+70 QUIT
+71 ;
+72 ;
SETTMP ; Setup TMP global with accession to resend.
+1 ;
+2 NEW LA763,LA768,LA7I,LA7X,LA7Y,LR60,LR61,LRDFN,LRIDT,LRODT,LRSB,LRSS
+3 ;
+4 SET LRSS=$PIECE(^LRO(68,LRAA,0),"^",2)
+5 FOR LA7I=0,.2,.3,3
SET LA768(LA7I)=$GET(^LRO(68,LRAA,1,LRAD,1,LRAN,LA7I))
+6 SET LA7UID=$PIECE(LA768(.3),"^")
+7 ;
+8 ; Not a LEDI specimen
+9 IF '$PIECE(LA768(.3),"^",2)
IF '$PIECE(LA768(.3),"^",3)
Begin DoDot:1
+10 NEW LA7X
+11 SET LA7X="Not a LEDI specimen - Accession "_$PIECE(LA768(.2),"^")_" ("_LA7UID_") skipped"
+12 DO EN^DDIOL(LA7X,"","!")
End DoDot:1
QUIT
+13 ;
+14 IF "CHMICYEMSP"'[LRSS!(LRSS="")
Begin DoDot:1
+15 NEW LA7X
+16 SET LA7X(1)=$$GET1^DIQ(68,LRAA_",",.02)_" subscript NOT supported at this time"
+17 SET LA7X(2)="Accession "_$PIECE(LA768(.2),"^")_" ("_LA7UID_") skipped"
+18 DO EN^DDIOL(.LA7X)
End DoDot:1
+19 ;
+20 ; Check file #63 for order codes and results
+21 ; If no order NLT code found then use default NLT
+22 ; Check if test has been added to order then report results using NLT
+23 ; code of the added test.
+24 SET LRDFN=$PIECE(LA768(0),"^")
SET LRODT=$PIECE(LA768(0),"^",4)
SET LRIDT=$PIECE(LA768(3),"^",5)
+25 ; Check for date report completed.
+26 IF '$PIECE(^LR(LRDFN,LRSS,LRIDT,0),"^",3)
Begin DoDot:1
+27 NEW LA7X
+28 SET LA7X="No date report completed - Accession "_$PIECE(LA768(.2),"^")_" ("_LA7UID_") skipped"
+29 DO EN^DDIOL(LA7X,"","!")
End DoDot:1
QUIT
+30 ;
+31 IF LRSS="CH"
Begin DoDot:1
+32 SET LRSB=1
+33 FOR
SET LRSB=$ORDER(^LR(LRDFN,LRSS,LRIDT,LRSB))
IF 'LRSB
QUIT
Begin DoDot:2
+34 SET X=^LR(LRDFN,LRSS,LRIDT,LRSB)
+35 SET LA7NLT=$PIECE($PIECE(X,"^",3),"!")
+36 IF LA7NLT'=""
SET LA7Y(LA7NLT,LRSB)=""
QUIT
+37 SET LR61=+$PIECE(^LR(LRDFN,LRSS,LRIDT,0),"^",5)
+38 SET LA7NLT=$PIECE($$DEFCODE^LA7VHLU5(LRSS,LRSB,$PIECE(X,"^",3),LR61),"!")
+39 IF LA7NLT'=""
SET LA7Y(LA7NLT,LRSB)=""
End DoDot:2
End DoDot:1
+40 ;
+41 IF LRSS="MI"
Begin DoDot:1
+42 SET LR60=0
+43 FOR
SET LR60=$ORDER(^LRO(68,LRAA,1,LRAD,1,LRAN,4,LR60))
IF 'LR60
QUIT
Begin DoDot:2
+44 SET LA764=$PIECE($GET(^LAB(60,LR60,64)),"^")
+45 SET LA7NLT=$$GET1^DIQ(64,LA764_",",1)
+46 IF LA7NLT'=""
SET LA7Y(LA7NLT)=""
End DoDot:2
End DoDot:1
+47 ;
+48 IF LRSS="SP"
SET LA7Y("88515.0000")=""
+49 IF LRSS="CY"
SET LA7Y("88593.0000")=""
+50 IF LRSS="EM"
SET LA7Y("88597.0000")=""
+51 IF LRSS="AU"
SET LA7Y("88533.0000")=""
+52 ;
+53 IF LA7UID'=""
IF $DATA(LA7Y)
Begin DoDot:1
+54 SET LA7CNT=LA7CNT+1
+55 SET X=$PIECE(LA768(.3),"^",1)_"^"_$PIECE(LA768(.3),"^",2)_"^"_$PIECE(LA768(.3),"^",5)_"^"_$PIECE(LA768(.3),"^",3)_"^"_LRIDT_"^"_LRSS_"^"_LRDFN_"^"_LRODT
+56 SET ^TMP("LA7S-RTM",$JOB,LA7UID)=X
+57 SET LA7I=""
+58 FOR
SET LA7I=$ORDER(LA7Y(LA7I))
IF LA7I=""
QUIT
MERGE ^TMP("LA7S-RTM",$JOB,LA7UID,LA7I)=LA7Y(LA7I)
End DoDot:1
+59 QUIT
+60 ;
+61 ;
EXIT ; Housekeeping - clean up.
+1 KILL ^TMP("LA7S-RTM",$JOB)
+2 KILL LA764,LA7CNT,LA7NLT,LA7NLTN,LA7QUIT,LA7TYPE,LA7UID,LA7X,LA7Y
+3 KILL LRAA,LRACC,LRAD,LRAN,LREXMPT,LRIDIV,LRSS,LRX
+4 KILL %DT,DA,DIC,DIR,DIRUT,DTOUT,DUOUT,FIRST,LAST,X,Y
+5 KILL ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
+6 QUIT