LA7SMU ;VA/DALOI/JMC - Shipping Manifest Utility ;JUL 06, 2010 3:14 PM;
;;5.2;AUTOMATED LAB INSTRUMENTS;**27,46,64,1027**;NOV 01, 1997
Q
;
CHKSM(X) ; Shipping manifest status check
; Call with X = ien of file #62.9 LAB SHIPPING CONFIGURATION
; Returns -1 = error^reason
; 0 = no active shipping manifest exists
; >0 = ien of active shipping manifest in file #62.8, LAB SHIPPING MANIFEST
;
; No value passed
I '$G(X) Q "-1^No configuration passed"
; Bad pointer passed
I '$D(^LAHM(62.9,X,0)) Q "-1^Bad configuration pointer"
; Get ien of active shipping manifest.
S Y=+$O(^LAHM(62.8,"AC1",X,0))
I Y S Y=Y_"^"_$P(^LAHM(62.8,Y,0),"^")
Q Y
;
;
CSM(LA7SCFG) ; Creates a new shipping manifest
; Call with X = ien of file #62.9 LAB SHIPPING CONFIGURATION
; Returns -1 = error^reason
; 0 = no active shipping manifest exists
; >0 = ien of active shipping manifest in file #62.8, LAB SHIPPING MANIFEST
;
N DATA,FDA,I,LA7CF,LA7DIE,LA7DT,LA7IEN,LA7SM,X,X4
;
; No value passed
I '$G(LA7SCFG) Q "-1^No configuration passed"
;
; Bad pointer passed
I '$D(^LAHM(62.9,LA7SCFG,0)) Q "-1^Bad configuration pointer"
;
S LA7SCFG(0)=$G(^LAHM(62.9,LA7SCFG,0))
; ien of collecting facility
S LA7CF=$P(LA7SCFG(0),"^",2)
; file #4 INSTITUTION information
F I=.01,.05,99 S X4(I)=$$GET1^DIQ(4,LA7CF_",",I)
;
; Get station number else use short name
S LA7SM=""
I $L(X4(99)) S LA7SM=X4(99)
E S LA7SM=X4(.05)
; Failsafe value
I LA7SM="" S LA7SM="INST:"_LA7CF
S DT=$$DT^XLFDT,LA7DT=$E($$FMTHL7^XLFDT(DT),1,8)
S LA7SM=LA7SM_"-"_LA7DT_"-"
;
L +^LAHM(62.8,0):5 ; Set lock
I '$T Q "-1^Unable to obtain lock on file LAB SHIPPING MANIFEST #62.8"
S X=0
F S X=X+1 Q:'$D(^LAHM(62.8,"B",LA7SM_X))
S LA7SM=LA7SM_X
;
S FDA(1,62.8,"+1,",.01)=LA7SM
S FDA(1,62.8,"+1,",.02)=LA7SCFG
S FDA(1,62.8,"+1,",.03)=1
I $P(LA7SCFG(0),"^",8) S FDA(1,62.8,"+1,",.04)=$P(LA7SCFG(0),"^",8)
S FDA(1,62.8,"+1,",.05)=+$P(LA7SCFG(0),"^",15)
S FDA(1,62.8,"+1,",.06)=+$P(LA7SCFG(0),"^",16)
D UPDATE^DIE("","FDA(1)","LA7IEN","LA7DIE(1)")
D RECALL^DILFD(62.8,LA7IEN(1)_",",DUZ)
;
S DATA="SM01^"_$$NOW^XLFDT
D SEUP(LA7SM,1,DATA)
;
S DATA="SM02^"_$$NOW^XLFDT
D SEUP(LA7SM,1,DATA)
;
; Release lock
L -^LAHM(62.8,0)
Q LA7IEN(1)_"^"_LA7SM
;
;
SMSUP(LA7SM,LA7ST,LA7EVNC) ; Shipping manifest status update.
; Call with LA7SM = ien of entry in file #62.8 LAB SHIPPING MAINFEST^.01 field
; LA7ST = status to update
; LA7EVNC = event code^event date/time (default=NOW)
;
N DATA,FDA,LA7IEN
;
S LA7IEN(1)=+LA7SM
S FDA(2,62.8,+LA7SM_",",.03)=LA7ST
D UPDATE^DIE("","FDA(2)","LA7IEN","LA7DIE(2)")
S DATA=$P(LA7EVNC,"^")_"^"_$S($P(LA7EVNC,"^",2):$P(LA7EVNC,"^",2),1:$$NOW^XLFDT)
D SEUP($P(LA7SM,"^",2),1,DATA)
Q
;
;
STSUP(LA7SM,LA762801,LA7DATA) ; Shipping test status update
; Call with LA7SM = ien of shipping manifest (#62.8)
; LA762801 = ien of test entry on shipping manifest
; LA7DATA = data to be filed
N FDA
S LA762801=LA762801_","_+LA7SM_","
S FDA(62.8,62.801,LA762801,.08)=LA7DATA
D FILE^DIE("","FDA(62.8)","LA7DIE(2)")
Q
;
;
SEUP(LA7ID,LA7EVN,LA7DATA) ; Shipping event update
; Call with LA7ID = shipping identifier (manifest invoice # or UID)
; LA7EVN = event type (1=shipping manifest/2=test)
; LA7DATA = data to be filed
N FDA,I,LA7IEN,X
L +^LAHM(62.85,0) ; Set lock
S FDA(3,62.85,"+1,",.01)=LA7ID
S FDA(3,62.85,"+1,",.02)=$S($G(DUZ)>0:DUZ,1:.5)
S FDA(3,62.85,"+1,",.03)=$$NOW^XLFDT
S FDA(3,62.85,"+1,",.04)=LA7EVN
I $L($P(LA7DATA,"^")) D
. S X=$$EVNC($P(LA7DATA,"^"))
. I X S FDA(3,62.85,"+1,",.05)=+X
F I=2:1:4 I $L($P(LA7DATA,"^",I)) S FDA(3,62.85,"+1,",$P("^.07^.08^.09","^",I))=$P(LA7DATA,"^",I)
;
; Add event to lab shipping event.
D UPDATE^DIE("","FDA(3)","LA7IEN","LA7DIE(3)")
; Release lock
L -^LAHM(62.85,0)
;
Q
;
;
ACCSUP(LA7UID,LA760,LA7DATA) ; Accession status update
; Call with LA7UID = UID of accession to update
; LA7DATA = value to update (pointer to file #62.8, LAB SHIPPING MANIFEST or "@" to delete
;
N FDA,LA7AA,LA7AD,LA7AN,LA7CAD,LA768,X
S X=$Q(^LRO(68,"C",LA7UID))
S LA7AA=$QS(X,4),LA7AD=$QS(X,5),LA7AN=$QS(X,6)
S LA7CAD=$$AD^LA7SUTL(LA7AA) ; Get current accession date for this accession area.
S LA7AD=LA7AD-.000000001
F S LA7AD=$O(^LRO(68,LA7AA,1,LA7AD)) Q:'LA7AD!(LA7AD>LA7CAD) D
. I '$D(^LRO(68,LA7AA,1,LA7AD,1,LA7AN)) Q
. I $P($G(^LRO(68,LA7AA,1,LA7AD,1,LA7AN,.3)),"^")'=LA7UID Q
. I '$D(^LRO(68,LA7AA,1,LA7AD,1,LA7AN,4,LA760)) Q ; Test not on accession.
. S LA768=LA760_","_LA7AN_","_LA7AD_","_LA7AA_","
. S FDA(68,68.04,LA768,9)=LA7DATA
. D FILE^DIE("","FDA(68)","LA7DIE(68)")
Q
;
;
SELSM(LA7SCFG,LA7SCR) ; Select shipping manifest
; Call with LA7SCFG = ien of file #62.9 LAB SHIPPING CONFIGURATION
; LA7SCR = comma delimited list of status screen - only allow selection of manifests with matching status
; Returns LA7Y = pointer to shipping manifest or error
N D,DIC,DTOUT,DUOUT,LA7Y,X,Y
S DIC="^LAHM(62.8,",DIC(0)="AEQ",DIC("A")="Select Shipping Manifest: "
S DIC("S")="I $P(^LAHM(62.8,Y,0),U,2)=LA7SCFG"
S DIC("W")="D SMW^LA7SMU1(Y)"
I $G(LA7SCR)'="" S DIC("S")=DIC("S")_","""_LA7SCR_"""[$P(^LAHM(62.8,Y,0),U,3)"
S D="C"
D MIX^DIC1
I Y<1 S LA7Y="-1^"
E S LA7Y=Y
Q LA7Y
;
;
SMED(LA7SM,LA7EVC) ; Determine shipping manifest's event date
; Call with LA7SM = ien of entry in file #62.8 LAB SHIPPING MANIFEST
; LA7EVC = event type code
; Returns LA7Y = internal event date^external event date
N LA7I,LA7X,LA7Y
I '$G(LA7SM) Q "-1^No shipping manifest passed"
S LA7SM(0)=$G(^LAHM(62.8,+LA7SM,0))
S LA7EV=+$$EVNC(LA7EVC)
I LA7EVC="SM05",$P(LA7SM(0),"^",3)'>2 Q "0^Shipping manifest has not been shipped"
S LA7I=0,LA7Y=""
F S LA7I=$O(^LAHM(62.85,"B",$P(LA7SM(0),"^"),LA7I)) Q:'LA7I D Q:$L(LA7Y)
. I $P($G(^LAHM(62.85,LA7I,0)),"^",5)'=LA7EV Q
. S LA7Y=$P(^LAHM(62.85,LA7I,0),"^",7)_"^"_$$FMTE^XLFDT($P(^LAHM(62.85,LA7I,0),"^",7),"M") ; Event date/time
I $G(LA7Y)="" S LA7Y="-2^No event date found"
Q LA7Y
;
;
EVNC(LA7EVC) ; Resolve an event code to it's pointer/text(.01) value
; Call with LA7EVC = Code to lookup, i.e. SM01, SM50
; Returns Y = ien of code in file #64.061, LAB ELECTRONIC CODES.
N X,Y
S (X,Y)=0
F S X=$O(^LAB(64.061,"F",LA7EVC,X)) Q:'X D Q:Y
. S X(0)=$G(^LAB(64.061,X,0))
. I $P(X(0),"^",7)="E" S Y=X_"^"_$P(X(0),"^")
I 'Y S Y="0^Code not on file"
Q Y
;
;
CHKTST(LA7SM,LA762801) ; Check and update if test is still valid.
; Call with LA7SM = ien of shipping manifest in file #62.8
; LA762801 = ien of entry on test multiple in file #62.8
;
; Returns LA7SKIP = 0 (Test still on accession).
; 1 (Test not on accession).
; 2 (Accession deleted/purged).
; 3 (Test not on accession - already shipped)
; 4 (Accession deleted/purged - already shipped)
;
N LA7AA,LA7AD,LA7AN,LA7DATA,LA7SKIP,LA7UID,X,Y
S LA7SKIP=0
S LA7SM(0)=$G(^LAHM(62.8,+LA7SM,0))
S LA762801(0)=$G(^LAHM(62.8,+LA7SM,10,+LA762801,0))
S LA7UID=$P(LA762801(0),"^",5)
S X=$Q(^LRO(68,"C",LA7UID))
S LA7AA=+$QS(X,4),LA7AD=+$QS(X,5),LA7AN=+$QS(X,6)
;
; Test found.
I $D(^LRO(68,LA7AA,1,LA7AD,1,LA7AN,4,+$P(LA762801(0),"^",2),0)) Q LA7SKIP
; Accession missing.
I '$D(^LRO(68,LA7AA,1,LA7AD,1,LA7AN,0)) D
. ; Already shipped
. I $P(LA7SM(0),"^",3)>4 S LA7SKIP=4 Q
. S LA7SKIP=2,LA7DATA="SM62"
;
; Test missing.
I 'LA7SKIP,'$D(^LRO(68,LA7AA,1,LA7AD,1,LA7AN,4,+$P(LA762801(0),"^",2),0)) D
. ; Already shipped
. I $P(LA7SM(0),"^",3)>4 S LA7SKIP=3 Q
. S LA7SKIP=1,LA7DATA="SM61"
;
; Update manifest/event file if test has not shipped.
I LA7SKIP,LA7SKIP<3 D
. ; Update test on manifest
. D STSUP^LA7SMU(+LA7SM,LA762801,0)
. ; Update event file
. S LA7DATA=LA7DATA_"^"_$$NOW^XLFDT_"^"_$P(LA762801(0),"^",2)_"^"_$P(LA7SM(0),"^")
. D SEUP^LA7SMU(LA7UID,2,LA7DATA)
Q LA7SKIP
LA7SMU ;VA/DALOI/JMC - Shipping Manifest Utility ;JUL 06, 2010 3:14 PM;
+1 ;;5.2;AUTOMATED LAB INSTRUMENTS;**27,46,64,1027**;NOV 01, 1997
+2 QUIT
+3 ;
CHKSM(X) ; Shipping manifest status check
+1 ; Call with X = ien of file #62.9 LAB SHIPPING CONFIGURATION
+2 ; Returns -1 = error^reason
+3 ; 0 = no active shipping manifest exists
+4 ; >0 = ien of active shipping manifest in file #62.8, LAB SHIPPING MANIFEST
+5 ;
+6 ; No value passed
+7 IF '$GET(X)
QUIT "-1^No configuration passed"
+8 ; Bad pointer passed
+9 IF '$DATA(^LAHM(62.9,X,0))
QUIT "-1^Bad configuration pointer"
+10 ; Get ien of active shipping manifest.
+11 SET Y=+$ORDER(^LAHM(62.8,"AC1",X,0))
+12 IF Y
SET Y=Y_"^"_$PIECE(^LAHM(62.8,Y,0),"^")
+13 QUIT Y
+14 ;
+15 ;
CSM(LA7SCFG) ; Creates a new shipping manifest
+1 ; Call with X = ien of file #62.9 LAB SHIPPING CONFIGURATION
+2 ; Returns -1 = error^reason
+3 ; 0 = no active shipping manifest exists
+4 ; >0 = ien of active shipping manifest in file #62.8, LAB SHIPPING MANIFEST
+5 ;
+6 NEW DATA,FDA,I,LA7CF,LA7DIE,LA7DT,LA7IEN,LA7SM,X,X4
+7 ;
+8 ; No value passed
+9 IF '$GET(LA7SCFG)
QUIT "-1^No configuration passed"
+10 ;
+11 ; Bad pointer passed
+12 IF '$DATA(^LAHM(62.9,LA7SCFG,0))
QUIT "-1^Bad configuration pointer"
+13 ;
+14 SET LA7SCFG(0)=$GET(^LAHM(62.9,LA7SCFG,0))
+15 ; ien of collecting facility
+16 SET LA7CF=$PIECE(LA7SCFG(0),"^",2)
+17 ; file #4 INSTITUTION information
+18 FOR I=.01,.05,99
SET X4(I)=$$GET1^DIQ(4,LA7CF_",",I)
+19 ;
+20 ; Get station number else use short name
+21 SET LA7SM=""
+22 IF $LENGTH(X4(99))
SET LA7SM=X4(99)
+23 IF '$TEST
SET LA7SM=X4(.05)
+24 ; Failsafe value
+25 IF LA7SM=""
SET LA7SM="INST:"_LA7CF
+26 SET DT=$$DT^XLFDT
SET LA7DT=$EXTRACT($$FMTHL7^XLFDT(DT),1,8)
+27 SET LA7SM=LA7SM_"-"_LA7DT_"-"
+28 ;
+29 ; Set lock
LOCK +^LAHM(62.8,0):5
+30 IF '$TEST
QUIT "-1^Unable to obtain lock on file LAB SHIPPING MANIFEST #62.8"
+31 SET X=0
+32 FOR
SET X=X+1
IF '$DATA(^LAHM(62.8,"B",LA7SM_X))
QUIT
+33 SET LA7SM=LA7SM_X
+34 ;
+35 SET FDA(1,62.8,"+1,",.01)=LA7SM
+36 SET FDA(1,62.8,"+1,",.02)=LA7SCFG
+37 SET FDA(1,62.8,"+1,",.03)=1
+38 IF $PIECE(LA7SCFG(0),"^",8)
SET FDA(1,62.8,"+1,",.04)=$PIECE(LA7SCFG(0),"^",8)
+39 SET FDA(1,62.8,"+1,",.05)=+$PIECE(LA7SCFG(0),"^",15)
+40 SET FDA(1,62.8,"+1,",.06)=+$PIECE(LA7SCFG(0),"^",16)
+41 DO UPDATE^DIE("","FDA(1)","LA7IEN","LA7DIE(1)")
+42 DO RECALL^DILFD(62.8,LA7IEN(1)_",",DUZ)
+43 ;
+44 SET DATA="SM01^"_$$NOW^XLFDT
+45 DO SEUP(LA7SM,1,DATA)
+46 ;
+47 SET DATA="SM02^"_$$NOW^XLFDT
+48 DO SEUP(LA7SM,1,DATA)
+49 ;
+50 ; Release lock
+51 LOCK -^LAHM(62.8,0)
+52 QUIT LA7IEN(1)_"^"_LA7SM
+53 ;
+54 ;
SMSUP(LA7SM,LA7ST,LA7EVNC) ; Shipping manifest status update.
+1 ; Call with LA7SM = ien of entry in file #62.8 LAB SHIPPING MAINFEST^.01 field
+2 ; LA7ST = status to update
+3 ; LA7EVNC = event code^event date/time (default=NOW)
+4 ;
+5 NEW DATA,FDA,LA7IEN
+6 ;
+7 SET LA7IEN(1)=+LA7SM
+8 SET FDA(2,62.8,+LA7SM_",",.03)=LA7ST
+9 DO UPDATE^DIE("","FDA(2)","LA7IEN","LA7DIE(2)")
+10 SET DATA=$PIECE(LA7EVNC,"^")_"^"_$SELECT($PIECE(LA7EVNC,"^",2):$PIECE(LA7EVNC,"^",2),1:$$NOW^XLFDT)
+11 DO SEUP($PIECE(LA7SM,"^",2),1,DATA)
+12 QUIT
+13 ;
+14 ;
STSUP(LA7SM,LA762801,LA7DATA) ; Shipping test status update
+1 ; Call with LA7SM = ien of shipping manifest (#62.8)
+2 ; LA762801 = ien of test entry on shipping manifest
+3 ; LA7DATA = data to be filed
+4 NEW FDA
+5 SET LA762801=LA762801_","_+LA7SM_","
+6 SET FDA(62.8,62.801,LA762801,.08)=LA7DATA
+7 DO FILE^DIE("","FDA(62.8)","LA7DIE(2)")
+8 QUIT
+9 ;
+10 ;
SEUP(LA7ID,LA7EVN,LA7DATA) ; Shipping event update
+1 ; Call with LA7ID = shipping identifier (manifest invoice # or UID)
+2 ; LA7EVN = event type (1=shipping manifest/2=test)
+3 ; LA7DATA = data to be filed
+4 NEW FDA,I,LA7IEN,X
+5 ; Set lock
LOCK +^LAHM(62.85,0)
+6 SET FDA(3,62.85,"+1,",.01)=LA7ID
+7 SET FDA(3,62.85,"+1,",.02)=$SELECT($GET(DUZ)>0:DUZ,1:.5)
+8 SET FDA(3,62.85,"+1,",.03)=$$NOW^XLFDT
+9 SET FDA(3,62.85,"+1,",.04)=LA7EVN
+10 IF $LENGTH($PIECE(LA7DATA,"^"))
Begin DoDot:1
+11 SET X=$$EVNC($PIECE(LA7DATA,"^"))
+12 IF X
SET FDA(3,62.85,"+1,",.05)=+X
End DoDot:1
+13 FOR I=2:1:4
IF $LENGTH($PIECE(LA7DATA,"^",I))
SET FDA(3,62.85,"+1,",$PIECE("^.07^.08^.09","^",I))=$PIECE(LA7DATA,"^",I)
+14 ;
+15 ; Add event to lab shipping event.
+16 DO UPDATE^DIE("","FDA(3)","LA7IEN","LA7DIE(3)")
+17 ; Release lock
+18 LOCK -^LAHM(62.85,0)
+19 ;
+20 QUIT
+21 ;
+22 ;
ACCSUP(LA7UID,LA760,LA7DATA) ; Accession status update
+1 ; Call with LA7UID = UID of accession to update
+2 ; LA7DATA = value to update (pointer to file #62.8, LAB SHIPPING MANIFEST or "@" to delete
+3 ;
+4 NEW FDA,LA7AA,LA7AD,LA7AN,LA7CAD,LA768,X
+5 SET X=$QUERY(^LRO(68,"C",LA7UID))
+6 SET LA7AA=$QSUBSCRIPT(X,4)
SET LA7AD=$QSUBSCRIPT(X,5)
SET LA7AN=$QSUBSCRIPT(X,6)
+7 ; Get current accession date for this accession area.
SET LA7CAD=$$AD^LA7SUTL(LA7AA)
+8 SET LA7AD=LA7AD-.000000001
+9 FOR
SET LA7AD=$ORDER(^LRO(68,LA7AA,1,LA7AD))
IF 'LA7AD!(LA7AD>LA7CAD)
QUIT
Begin DoDot:1
+10 IF '$DATA(^LRO(68,LA7AA,1,LA7AD,1,LA7AN))
QUIT
+11 IF $PIECE($GET(^LRO(68,LA7AA,1,LA7AD,1,LA7AN,.3)),"^")'=LA7UID
QUIT
+12 ; Test not on accession.
IF '$DATA(^LRO(68,LA7AA,1,LA7AD,1,LA7AN,4,LA760))
QUIT
+13 SET LA768=LA760_","_LA7AN_","_LA7AD_","_LA7AA_","
+14 SET FDA(68,68.04,LA768,9)=LA7DATA
+15 DO FILE^DIE("","FDA(68)","LA7DIE(68)")
End DoDot:1
+16 QUIT
+17 ;
+18 ;
SELSM(LA7SCFG,LA7SCR) ; Select shipping manifest
+1 ; Call with LA7SCFG = ien of file #62.9 LAB SHIPPING CONFIGURATION
+2 ; LA7SCR = comma delimited list of status screen - only allow selection of manifests with matching status
+3 ; Returns LA7Y = pointer to shipping manifest or error
+4 NEW D,DIC,DTOUT,DUOUT,LA7Y,X,Y
+5 SET DIC="^LAHM(62.8,"
SET DIC(0)="AEQ"
SET DIC("A")="Select Shipping Manifest: "
+6 SET DIC("S")="I $P(^LAHM(62.8,Y,0),U,2)=LA7SCFG"
+7 SET DIC("W")="D SMW^LA7SMU1(Y)"
+8 IF $GET(LA7SCR)'=""
SET DIC("S")=DIC("S")_","""_LA7SCR_"""[$P(^LAHM(62.8,Y,0),U,3)"
+9 SET D="C"
+10 DO MIX^DIC1
+11 IF Y<1
SET LA7Y="-1^"
+12 IF '$TEST
SET LA7Y=Y
+13 QUIT LA7Y
+14 ;
+15 ;
SMED(LA7SM,LA7EVC) ; Determine shipping manifest's event date
+1 ; Call with LA7SM = ien of entry in file #62.8 LAB SHIPPING MANIFEST
+2 ; LA7EVC = event type code
+3 ; Returns LA7Y = internal event date^external event date
+4 NEW LA7I,LA7X,LA7Y
+5 IF '$GET(LA7SM)
QUIT "-1^No shipping manifest passed"
+6 SET LA7SM(0)=$GET(^LAHM(62.8,+LA7SM,0))
+7 SET LA7EV=+$$EVNC(LA7EVC)
+8 IF LA7EVC="SM05"
IF $PIECE(LA7SM(0),"^",3)'>2
QUIT "0^Shipping manifest has not been shipped"
+9 SET LA7I=0
SET LA7Y=""
+10 FOR
SET LA7I=$ORDER(^LAHM(62.85,"B",$PIECE(LA7SM(0),"^"),LA7I))
IF 'LA7I
QUIT
Begin DoDot:1
+11 IF $PIECE($GET(^LAHM(62.85,LA7I,0)),"^",5)'=LA7EV
QUIT
+12 ; Event date/time
SET LA7Y=$PIECE(^LAHM(62.85,LA7I,0),"^",7)_"^"_$$FMTE^XLFDT($PIECE(^LAHM(62.85,LA7I,0),"^",7),"M")
End DoDot:1
IF $LENGTH(LA7Y)
QUIT
+13 IF $GET(LA7Y)=""
SET LA7Y="-2^No event date found"
+14 QUIT LA7Y
+15 ;
+16 ;
EVNC(LA7EVC) ; Resolve an event code to it's pointer/text(.01) value
+1 ; Call with LA7EVC = Code to lookup, i.e. SM01, SM50
+2 ; Returns Y = ien of code in file #64.061, LAB ELECTRONIC CODES.
+3 NEW X,Y
+4 SET (X,Y)=0
+5 FOR
SET X=$ORDER(^LAB(64.061,"F",LA7EVC,X))
IF 'X
QUIT
Begin DoDot:1
+6 SET X(0)=$GET(^LAB(64.061,X,0))
+7 IF $PIECE(X(0),"^",7)="E"
SET Y=X_"^"_$PIECE(X(0),"^")
End DoDot:1
IF Y
QUIT
+8 IF 'Y
SET Y="0^Code not on file"
+9 QUIT Y
+10 ;
+11 ;
CHKTST(LA7SM,LA762801) ; Check and update if test is still valid.
+1 ; Call with LA7SM = ien of shipping manifest in file #62.8
+2 ; LA762801 = ien of entry on test multiple in file #62.8
+3 ;
+4 ; Returns LA7SKIP = 0 (Test still on accession).
+5 ; 1 (Test not on accession).
+6 ; 2 (Accession deleted/purged).
+7 ; 3 (Test not on accession - already shipped)
+8 ; 4 (Accession deleted/purged - already shipped)
+9 ;
+10 NEW LA7AA,LA7AD,LA7AN,LA7DATA,LA7SKIP,LA7UID,X,Y
+11 SET LA7SKIP=0
+12 SET LA7SM(0)=$GET(^LAHM(62.8,+LA7SM,0))
+13 SET LA762801(0)=$GET(^LAHM(62.8,+LA7SM,10,+LA762801,0))
+14 SET LA7UID=$PIECE(LA762801(0),"^",5)
+15 SET X=$QUERY(^LRO(68,"C",LA7UID))
+16 SET LA7AA=+$QSUBSCRIPT(X,4)
SET LA7AD=+$QSUBSCRIPT(X,5)
SET LA7AN=+$QSUBSCRIPT(X,6)
+17 ;
+18 ; Test found.
+19 IF $DATA(^LRO(68,LA7AA,1,LA7AD,1,LA7AN,4,+$PIECE(LA762801(0),"^",2),0))
QUIT LA7SKIP
+20 ; Accession missing.
+21 IF '$DATA(^LRO(68,LA7AA,1,LA7AD,1,LA7AN,0))
Begin DoDot:1
+22 ; Already shipped
+23 IF $PIECE(LA7SM(0),"^",3)>4
SET LA7SKIP=4
QUIT
+24 SET LA7SKIP=2
SET LA7DATA="SM62"
End DoDot:1
+25 ;
+26 ; Test missing.
+27 IF 'LA7SKIP
IF '$DATA(^LRO(68,LA7AA,1,LA7AD,1,LA7AN,4,+$PIECE(LA762801(0),"^",2),0))
Begin DoDot:1
+28 ; Already shipped
+29 IF $PIECE(LA7SM(0),"^",3)>4
SET LA7SKIP=3
QUIT
+30 SET LA7SKIP=1
SET LA7DATA="SM61"
End DoDot:1
+31 ;
+32 ; Update manifest/event file if test has not shipped.
+33 IF LA7SKIP
IF LA7SKIP<3
Begin DoDot:1
+34 ; Update test on manifest
+35 DO STSUP^LA7SMU(+LA7SM,LA762801,0)
+36 ; Update event file
+37 SET LA7DATA=LA7DATA_"^"_$$NOW^XLFDT_"^"_$P(LA762801(0),"^",2)_"^"_$PIECE(LA7SM(0),"^")
+38 DO SEUP^LA7SMU(LA7UID,2,LA7DATA)
End DoDot:1
+39 QUIT LA7SKIP