Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: LA7ADL

LA7ADL.m

Go to the documentation of this file.
  1. LA7ADL ;VA/DALOI/JMC - Automatic Download of Test Orders; 1/30/95 09:00
  1. ;;5.2;AUTOMATED LAB INSTRUMENTS;**1001,1030**;NOV 01, 1997
  1. ;;5.2;AUTOMATED LAB INSTRUMENTS;**17,25,23,57**;Sep 27, 1994
  1. ;
  1. ; This routine will monitor the ^LA("ADL") node to check for accessions which are to have test orders automatically
  1. ; downloaded to another computer system. All entries in the auto instrument file which are flagged for automatic downloading
  1. ; will be checked to see if they contain any tests on the accession. If tests are found then the appropiate download message
  1. ; is constructed and sent.
  1. ;
  1. ;
  1. EN(LA7UID) ; Set flag to check accession for downloading, start background job if needed.
  1. ; Called by LR7OMERG, LRCONJAM, LRTSTSET, LRWLST1.
  1. ;
  1. ; No UID passed to routine.
  1. I $G(LA7UID)="" Q
  1. ;
  1. ; No instrument flagged for auto downloading.
  1. I '$D(^LAB(62.4,"AE")) Q
  1. ;
  1. ; Quit if "Don't Start/Collect" flag set.
  1. I +$G(^LA("ADL","STOP"),0)=3 Q
  1. ;
  1. ; Lock node in case already downloading this accession, wait until downloading finished.
  1. L +^LA("ADL","Q",LA7UID):60
  1. ;
  1. ; Set flag to check this accession for auto downloading.
  1. S ^LA("ADL","Q",LA7UID)=""
  1. ;
  1. ; Release lock.
  1. L -^LA("ADL","Q",LA7UID)
  1. ;
  1. ; Quit if "Don't Start" flag set.
  1. I +$G(^LA("ADL","STOP"),0)=2 Q
  1. ;
  1. ; Lock zeroth node.
  1. ; Quit if another process has lock
  1. ; - either another job setting node or the background job.
  1. L +^LA("ADL",0):1
  1. I '$T Q
  1. ;
  1. ; Task background job to run.
  1. N ZTSK
  1. D ZTSK
  1. ;
  1. ; Unlock node.
  1. L -^LA("ADL",0)
  1. ;
  1. Q
  1. ;
  1. ;
  1. DQ ; Entry point from Taskman.
  1. ;
  1. ; Set flag for taskman to cleanup task.
  1. I $D(ZTQUEUED) S ZTREQ="@"
  1. ;
  1. ; Wait for a little while in case another job checking for background job has lock.
  1. L +^LA("ADL",0):10
  1. ; Another process has lock, only want one at a time.
  1. I '$T Q
  1. ;
  1. ; No instrument flagged for auto downloading.
  1. I '$D(^LAB(62.4,"AE")) D EXIT Q
  1. ;
  1. ; Quit if "Don't Start/Collect" flags set.
  1. I +$G(^LA("ADL","STOP"),0)>1 Q
  1. ;
  1. D BUILD
  1. ;
  1. F D UID Q:TOUT>60
  1. D EXIT
  1. Q
  1. ;
  1. ;
  1. UID ; Start loop to monitor for accessions to download.
  1. ;
  1. S LA7UID="",(TOUT,ZTSTOP)=0
  1. ;
  1. ; Flag set to "Rebuild".
  1. I +$G(^LA("ADL","STOP"))=1,'ZTSTOP D BUILD
  1. ;
  1. F S LA7UID=$O(^LA("ADL","Q",LA7UID)) Q:LA7UID=""!(ZTSTOP)!(TOUT) D
  1. . I +$G(^LA("ADL","STOP"))>0 S TOUT=61 Q
  1. . I $$S^%ZTLOAD S ZTSTOP=1,TOUT=61 Q
  1. . ; Lock this UID, synch setting/deleting when another job is attempting to set node.
  1. . L +^LA("ADL","Q",LA7UID):1
  1. . ; Unable to get lock, go on to next UID, check again on next go around.
  1. . I '$T Q
  1. . ; Get accession info from ^LRO(68,"C").
  1. . S X=$Q(^LRO(68,"C",LA7UID))
  1. . ; Quit - UID does not match.
  1. . I $QS(X,3)'=LA7UID D CLEANUP Q
  1. . ; Setup accession variables for auto downloading.
  1. . S LRAA=+$QS(X,4),LRAD=+$QS(X,5),LRAN=+$QS(X,6)
  1. . ; ----- BEGIN IHS/OIT/MKK - LR*5.2*1030
  1. . I +$O(^LRO(68,LRAA,1,LRAD,1,LRAN,5,0))<1 D MAILALRT D CLEANUP Q
  1. . ; ----- END IHS/OIT/MKK - LR*5.2*1030
  1. . D BLDTST
  1. . S LA7INST=0
  1. . F S LA7INST=$O(LA7AUTO(LA7INST)) Q:'LA7INST D
  1. . . D CHKTEST
  1. . . ; No tests on instrument list for this accession.
  1. . . I '$D(LA7ACC) Q
  1. . . S LRINST=LA7INST,LRAUTO=LA7AUTO(LA7INST)
  1. . . N LA7UID
  1. . . ; File build (entry^routine) from fields #93 and #94 in file #62.4.
  1. . . D @$P(LA7AUTO(LA7INST,9),"^",3,4)
  1. . D CLEANUP
  1. ;
  1. F D Q:$O(^LA("ADL","Q",""))'="" Q:TOUT>60
  1. . I $G(^LA("ADL","STOP"))>1 S TOUT=61 Q
  1. . ; Task has been requested to stop.
  1. . I $$S^%ZTLOAD S TOUT=61,ZTSTOP=1 Q
  1. . S TOUT=TOUT+1 H 5
  1. ;
  1. Q
  1. ;
  1. ;
  1. BLDTST ; Build array of tests on accession to check for downloading
  1. ;
  1. N X,LA760,LA7PCNT
  1. ;
  1. K LA7TREE
  1. S LA760=0
  1. F S LA760=$O(^LRO(68,LRAA,1,LRAD,1,LRAN,4,LA760)) Q:'LA760 D
  1. . ; Quit if test has been removed from accession.
  1. . S X=$G(^LRO(68,LRAA,1,LRAD,1,LRAN,4,LA760,0),0) Q:'X
  1. . ; If test completed (#4, COMPLETE DATE entered), don't download.
  1. . I $P(X,"^",5) Q
  1. . ; Build array of atomic tests on accession with urgency.
  1. . S LA7PCNT=0
  1. . D UNWIND^LA7ADL1(LA760,$P(X,"^",2),0)
  1. ;
  1. Q
  1. ;
  1. ;
  1. CHKTEST ; Check tests to determine if they should build in message.
  1. ; Array LA7ACC returned with tests to send in message
  1. ;
  1. N LA760,LA761,LA76205,LA768,LA7I,LRDPF,X
  1. ;
  1. K LA7ACC
  1. ;
  1. ; Quit - specimen uncollected & don't download uncollected flag set.
  1. ; controls exempted.
  1. S LRDPF=$P($G(^LRO(68,LRAA,1,LRAD,1,LRAN,0)),"^",2)
  1. S X=$G(^LRO(68,LRAA,1,LRAD,1,LRAN,3))
  1. I LRDPF'=62.3,'$P(X,"^",3),'$P(^TMP("LA7-INST",$J,LA7INST),"^") Q
  1. ;
  1. S X=$O(^LRO(68,LRAA,1,LRAD,1,LRAN,5,0))
  1. ;
  1. Q:+$G(X)<1 ; If no SITE/SPECIMEN, Quit -- IHS/OIT/MKK - LR*5.2*1030
  1. ;
  1. S LA761=$P(^LRO(68,LRAA,1,LRAD,1,LRAN,5,X,0),"^")
  1. S LA760=0
  1. F S LA760=$O(LA7TREE(LA760)) Q:'LA760 D
  1. . I '$D(^TMP("LA7-INST",$J,LA7INST,LA760)) Q
  1. . S LA7I=0
  1. . F S LA7I=$O(^TMP("LA7-INST",$J,LA7INST,LA760,LA7I)) Q:'LA7I D
  1. . . S LA76205=+$P(LA7TREE(LA760),"^")
  1. . . D CHKMASK
  1. ;
  1. Q
  1. ;
  1. CHKMASK ; Check pattern mask for tests that match download pattern mask
  1. ;
  1. ; Any accession area, specimen, urgency
  1. I $D(^TMP("LA7-INST",$J,LA7INST,LA760,LA7I,0,0,0)) D ADD Q
  1. ;
  1. ; Specific accession area, any specimen/urgency
  1. I $D(^TMP("LA7-INST",$J,LA7INST,LA760,LA7I,LRAA,0,0)) D ADD Q
  1. ;
  1. ; Specific specimen, any accession area/urgency
  1. I $D(^TMP("LA7-INST",$J,LA7INST,LA760,LA7I,0,LA761,0)) D ADD Q
  1. ;
  1. ; Specific urgency, any accession area/specimen
  1. I $D(^TMP("LA7-INST",$J,LA7INST,LA760,LA7I,0,0,LA76205)) D ADD Q
  1. ;
  1. ; Specific accession/specimen, any urgency
  1. I $D(^TMP("LA7-INST",$J,LA7INST,LA760,LA7I,LRAA,LA761,0)) D ADD Q
  1. ;
  1. ; Specific specimen/urgency, any accession area
  1. I $D(^TMP("LA7-INST",$J,LA7INST,LA760,LA7I,0,LA761,LA76205)) D ADD Q
  1. ;
  1. ; Specific accession/specimen/urgency
  1. I $D(^TMP("LA7-INST",$J,LA7INST,LA760,LA7I,LRAA,LA761,LA76205)) D ADD Q
  1. ;
  1. Q
  1. ;
  1. ADD ; Add to list of tests to download
  1. ;
  1. S LA7ACC(LA7I)=LA760_"^"_LA7TREE(LA760)
  1. Q
  1. ;
  1. ;
  1. CLEANUP ; Delete flag after accession has been checked.
  1. ; NOTE: Lock previously set above.
  1. ;
  1. K ^LA("ADL","Q",LA7UID)
  1. ;
  1. ; Release lock on this UID.
  1. L -^LA("ADL","Q",LA7UID)
  1. ;
  1. Q
  1. ;
  1. ;
  1. ZTSK ; Task background job to run.
  1. ;
  1. N ZTDESC,ZTSAVE,ZTDTH,ZTIO,ZTRTN
  1. ;
  1. ; Task background job if not running.
  1. S ZTRTN="DQ^LA7ADL",ZTDESC="Lab Auto Download",ZTIO="",ZTDTH=$H
  1. D ^%ZTLOAD
  1. ;
  1. Q
  1. ;
  1. ;
  1. BUILD ; Build TMP global with list of tests for instruments flagged for auto download.
  1. D BUILD^LA7ADL1
  1. ;
  1. ; Set flag to "Running".
  1. D SETSTOP^LA7ADL1(0,$G(DUZ))
  1. ;
  1. Q
  1. ;
  1. ;
  1. EXIT ; Exit and cleanup.
  1. ;
  1. ; Release lock on LA("ADL") global.
  1. L -^LA("ADL",0)
  1. ;
  1. K ^TMP("LA7",$J),^TMP($J)
  1. K LA7ADL
  1. K LRAA,LRAD,LRAN
  1. K TOUT
  1. ;
  1. ; Clear flag if normal shutdown, no new accessions.
  1. I +$G(^LA("ADL","STOP"))<2 K ^LA("ADL","STOP")
  1. ;
  1. Q
  1. ;
  1. ; ----- BEGIN IHS/OIT/MKK - LR*5.2*1030
  1. ; Only sent if the ACCESSION has no SPECIMEN node.
  1. ; Issue first surfaced at Chinle post Patch 1027 Install.
  1. MAILALRT ; Send mail message alert
  1. N J,LRCNT,LRMTXT,X,XMINSTR,XMSUB,XMTO
  1. ;
  1. S LRMTXT(1)=" This is from routine LA7ADL."
  1. S LRMTXT(2)=" "
  1. S LRMTXT(3)=" This message was generated during the donwloading of"
  1. S LRMTXT(4)=" information. The SPECIMEN node of this Accessions is"
  1. S LRMTXT(5)=" NULL. This is an error."
  1. S LRMTXT(6)=" "
  1. S LRMTXT(7)=" The following *debugging* information is provided to"
  1. S LRMTXT(8)=" assist support staff in resolving this error."
  1. S LRMTXT(9)=" "
  1. S LRCNT=9
  1. ;
  1. F J="LA7UID","LRAA","LRAD","LRAN","LRDFN" D
  1. . S X=$G(@J)
  1. . I $L(X) S LRCNT=LRCNT+1,LRMTXT(LRCNT)=J_"="_X
  1. . F S J=$Q(@J) Q:J="" S LRCNT=LRCNT+1,LRMTXT(LRCNT)=J_"="_@J
  1. ;
  1. S XMSUB="ACCESSION has no SPECIMEN node."
  1. S XMTO("G.LMI")=""
  1. S XMINSTR("FROM")="Lab Routine LA7ADL"
  1. S XMINSTR("ADDR FLAGS")="R"
  1. D SENDMSG^XMXAPI(DUZ,XMSUB,"LRMTXT",.XMTO,.XMINSTR)
  1. Q
  1. ;
  1. ; ----- END IHS/OIT/MKK - LR*5.2*1030