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

LA7ADL1.m

Go to the documentation of this file.
  1. LA7ADL1 ;DALOI/JMC - Automatic Download of Test Orders (Cont'd) ;Aug 14, 2008
  1. ;;5.2;AUTOMATED LAB INSTRUMENTS;**17,23,57,74**;Sep 27, 1994;Build 229
  1. ;
  1. ;
  1. BUILD ; Build test listing for all instruments designated for auto download.
  1. ;
  1. N LA7I,LA7INST,LA7WL
  1. ;
  1. K ^TMP("LA7-INST",$J)
  1. K LA7AUTO
  1. ;
  1. ; Flag used to notify download routines of automatic download (no worklist).
  1. S LA7ADL=1
  1. ;
  1. S LA7INST=0
  1. F S LA7INST=$O(^LAB(62.4,"AE",LA7INST)) Q:'LA7INST D BLDINST(LA7INST,0)
  1. Q
  1. ;
  1. ;
  1. BLDINST(LA7INST,LA7WL) ; Build list of instrument tests
  1. ; Call with LA7INST = ien of entry in file #62.4
  1. ; LA7WL = ien of entry in file #62.8 (optional)
  1. ; will default to list associated with #62.4 entry.
  1. ;
  1. K ^TMP("LA7-INST",$J,LA7INST)
  1. ;
  1. S LA7AUTO(LA7INST)=$G(^LAB(62.4,LA7INST,0))
  1. ; Quit - no zero node in 62.4.
  1. I LA7AUTO(LA7INST)="" K LA7AUTO(LA7INST) Q
  1. ;
  1. S LA7AUTO(LA7INST,9)=$G(^LAB(62.4,LA7INST,9))
  1. ; Quit - no/invalid download routine specified.
  1. I $$CHKRTN Q
  1. ;
  1. ; Worklist pointer
  1. I 'LA7WL S LA7WL=$P(LA7AUTO(LA7INST),"^",4)
  1. ;
  1. ; Store "include uncollected accessions" flag, defaults to 0 (NO)
  1. S ^TMP("LA7-INST",$J,LA7INST)=+$P($G(^LRO(68.2,LA7WL,0)),"^",10)
  1. ;
  1. S LA7I=0
  1. F S LA7I=$O(^LAB(62.4,LA7INST,3,LA7I)) Q:'LA7I D BLDTST
  1. ;
  1. ; No download tests found for this instrument.
  1. I '$O(^TMP("LA7-INST",$J,LA7INST,0)) D
  1. . K LA7AUTO(LA7INST)
  1. . K ^TMP("LA7-INST",$J,LA7INST)
  1. Q
  1. ;
  1. ;
  1. BLDTST ; Build list of test that can be downloaded.
  1. ;
  1. N X,Y
  1. ; Don't download this test.
  1. I $P($G(^LAB(62.4,LA7INST,3,LA7I,2)),"^",4)=0 Q
  1. ;
  1. ; X = Zeroth node of test multiple
  1. ; Y = Screening criteria - accession area, specimen type, urgency
  1. S X=$G(^LAB(62.4,LA7INST,3,LA7I,0))
  1. S Y=$G(^LAB(62.4,LA7INST,3,LA7I,2))
  1. ;
  1. ; Build pattern mask based on file #60, #62.41, #68, #61, #62.05 iens
  1. S ^TMP("LA7-INST",$J,LA7INST,+X,LA7I,+$P(Y,"^",12),+$P(Y,"^",13),+$P(Y,"^",14))=""
  1. ;
  1. ; Build test info
  1. S ^TMP("LA7",$J,LA7INST,LA7I)=X
  1. S $P(^TMP("LA7",$J,LA7INST,LA7I),"^",7)=$P($G(^LAB(60,+X,.2)),"^")
  1. ;
  1. Q
  1. ;
  1. ;
  1. CHKRTN() ; Check if download routine defined and valid
  1. ;
  1. N LA7ERR,X,XQA,XQAMSG
  1. ;
  1. S LA7ERR=0,XQAMSG=""
  1. ;
  1. ; Check if download routine specified
  1. I $P(LA7AUTO(LA7INST,9),"^",4)="" D
  1. . S LA7ERR=1
  1. . S XQAMSG="No download routine (field #94)"
  1. ;
  1. ; Check if download routine valid
  1. I $P(LA7AUTO(LA7INST,9),"^",4)'="" D
  1. . S X=$P(LA7AUTO(LA7INST,9),"^",4) X ^%ZOSF("TEST") Q:$T
  1. . S LA7ERR=1
  1. . S XQAMSG="Invalid download routine (field #94)"
  1. ;
  1. ; Check if routine label valid
  1. I 'LA7ERR,$L($P(LA7AUTO(LA7INST,9),"^",3)) D
  1. . I $L($T(@$P(LA7AUTO(LA7INST,9),"^",3,4))) Q
  1. . S LA7ERR=1
  1. . S XQAMSG="Invalid download routine label (field #93)"
  1. ;
  1. ; If problem send alert and kill array entry
  1. I LA7ERR D
  1. . S XQAMSG=XQAMSG_" specified for AUTO INSTRUMENT: "_$P(LA7AUTO(LA7INST),"^")
  1. . D ERROR^LA7UID
  1. . K LA7AUTO(LA7INST)
  1. ;
  1. Q LA7ERR
  1. ;
  1. ;
  1. UNWIND(LA760,LA7URG,LA7PARNT) ; Unwind profile - set tests into array LA7TREE with urgency.
  1. ;
  1. ; Call with LA760 = file #60 ien
  1. ; LA7URG = file #62.05 ien
  1. ; LA7PARNT = file #60 ien - ordered parent (panel)
  1. ;
  1. ; Recursive panel, caught in a loop.
  1. I $G(LA7PCNT)>50 Q
  1. ;
  1. ; If no urgency, set to routine (9), default value.
  1. I 'LA7URG S LA7URG=9
  1. ;
  1. ; Test does not exist in file 60.
  1. I '$D(^LAB(60,LA760,0)) Q
  1. ;
  1. ; Bypass "workload" type tests.
  1. I $P(^LAB(60,LA760,0),"^",4)="WK" Q
  1. ;
  1. ; Test already listed, check if urgency different.
  1. I $D(LA7TREE(LA760)) D Q
  1. . S LA7PCNT=0
  1. . ; Convert expanded panel test urgency to regular urgency
  1. . I LA7URG>50 S LA7URG=LA7URG-50
  1. . ; Found test with higher urgency, save new urgency.
  1. . I LA7URG<LA7TREE(LA760) S $P(LA7TREE(LA760),"^")=LA7URG
  1. ;
  1. ; Not a panel, list test with urgency.
  1. I '$O(^LAB(60,LA760,2,0)) S LA7TREE(LA760)=LA7URG_"^"_LA7PARNT,LA7PCNT=0 Q
  1. ;
  1. N I
  1. ;
  1. ; Increment panel and test loop counter.
  1. S LA7PCNT=$G(LA7PCNT)+1,I=0
  1. ;
  1. ; Expand test on panel.
  1. F S I=$O(^LAB(60,LA760,2,I)) Q:'I D
  1. . N II
  1. . ; IEN of test on panel.
  1. . S II=+$G(^LAB(60,LA760,2,I,0))
  1. . ; Recursive panel, panel calls itself.
  1. . I II,II=LA760 Q
  1. . I II D UNWIND(II,LA7URG,LA7PARNT)
  1. ;
  1. Q
  1. ;
  1. ;
  1. SETSTOP(FLAG,USER) ; Set "STOP" node in ^LA("ADL") global..
  1. ; Required parameters
  1. ; FLAG - Values passed can be:
  1. ; 0 = Auto download background task running.
  1. ; 1 = Start/Restart background task.
  1. ; 2 = Shutdown auto download background task, don't restart.
  1. ; 3 = Shutdown, don't start auto download task and don't collect accessions for downloading.
  1. ; USER - DUZ of user.
  1. ;
  1. ; Value passed out of range.
  1. I FLAG<0!(FLAG>3) Q
  1. ;
  1. I $G(USER)'>0 S USER="UNKNOWN"
  1. ;
  1. ; Set flag to value passed, user and current time.
  1. S ^LA("ADL","STOP")=FLAG_"^"_$$HTFM^XLFDT($H)_"^"_USER
  1. ;
  1. Q
  1. ;
  1. ;
  1. SHOWST() ; Show status
  1. ;
  1. N X,Y
  1. ;
  1. S X=$G(^LA("ADL","STOP"),-1)
  1. S Y=$P("Not Running^Running^Start/Restart Auto Download Job^Shutdown Auto Download Job^Shutdown Auto Download Job and Stop Collecting Accessions","^",$P(X,"^")+2)
  1. ;
  1. I +X'<0 D
  1. . S $P(Y,"^",2)=$$FMTE^XLFDT($P(X,"^",2))
  1. . I $P(X,"^",3) S $P(Y,"^",3)=$$GET1^DIQ(200,$P(X,"^",3)_",",.01)
  1. . I $P(X,"^",3)="UNKNOWN"!($P(Y,"^",3)="") S $P(Y,"^",3)="UNKNOWN"
  1. ;
  1. Q Y