source: WorldVistAEHR/trunk/r/LAB_SERVICE-LR-LS/LRTT5P1.m@ 1006

Last change on this file since 1006 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 4.6 KB
Line 
1LRTT5P1 ;DALOI/FHS-LAB URGENCY TURNAROUND TIMES PROCESSOR ;12/3/1997
2 ;;5.2;LAB SERVICE;**153,221,263,274,358**;Sep 27, 1994
3ONE ; from LRTT5
4 ; return for reg & irreg: # tests, total time, bad turnaround time
5 ; input:
6 ; ^TMP("LRTT5",$J,"TESTS",tests)=test names
7 ; LRPQ("URGENCY",urgencies)=urgency names
8 ; LRSDT, LREDT, LRPDET
9 ; output:
10 ; ^TMP("LR",$J,"REG")=#tests^total time
11 ; ^TMP("LR",$J,"REG",TAT,#)=acc^test^in^out
12 ; ^TMP("LR",$J,"REGT",test)=#tests^total time
13 ; ^TMP("LR",$J,"IRREG")=#tests^total time
14 ; ^TMP("LR",$J,"IRREG",TAT,#)=acc^test^in^out
15 ; ^TMP("LR",$J,"IRREGT",test)=#tests^total time
16 ; ^TMP("LR",$J,"BAD",TAT,#)=acc^test^in^out
17 ;
18START ; go thru tests
19 S LRSDT=$P(LRSDT,"."),LREDT=$P(LREDT,".")
20 I LRSDT>LREDT S X=LRSDT,LRSDT=LREDT,LREDT=X
21 S LRPSDT=LRSDT,LRPEDT=LREDT
22 S LRTEST=0 F S LRTEST=$O(^TMP("LRTT5",$J,"TESTS",LRTEST)) Q:LRTEST<1 D
23 .; get acc areas for tests
24 . S LRPN=0 F S LRPN=$O(^LAB(60,LRTEST,8,LRPN)) Q:LRPN<1 I $D(^(LRPN,0)) S LRAA=+$P(^(0),U,2) I $D(^LRO(68,LRAA,0)) S LRAA(LRAA)=""
25 ; go thru valid accession areas, get accession type - daily, yearly, etc
26 S (LRPN,LRAA)=0 F S LRAA=$O(LRAA(LRAA)) Q:LRAA<1 I $D(^LRO(68,LRAA,0)) S LRAAT=$P(^(0),U,3) D
27 . ; go thru accession dates, start using appropriate acc type
28 . S LRSDT=LRPSDT,LREDT=$P(LRPEDT,".")_".24"
29 . S LRAD=$S(LRAAT="D":LRSDT,LRAAT="M":LRSDT\100*100,1:LRSDT\10000*10000)-.000001
30 . F S LRAD=$O(^LRO(68,LRAA,1,LRAD)) Q:LRAD<1!(LRAD>(LREDT)) D
31 . . ; go thru accession #s
32 . . S LRAN=0 F S LRAN=$O(^LRO(68,LRAA,1,LRAD,1,LRAN)) Q:LRAN<1 S LRDPF=$P($G(^(LRAN,0)),U,2) D
33 . . . Q:$S('LRDPF:1,LRDPF=2:0,LRDPF=67:0,1:1)
34 . . . ; check lab arrival time, must be >= begin time and <= end time
35 . . . Q:'$D(^LRO(68,LRAA,1,LRAD,1,LRAN,3)) S LRPLRRX1=$P(^(3),U,3) Q:LRPLRRX1<LRSDT Q:LRPLRRX1>(LREDT)
36 . . . I $G(^LRO(68,LRAA,1,LRAD,1,LRAN,.4)),$O(LRLLOC(0)),'$D(LRLLOC(+$G(^(.4)))) Q
37 . . . ; go thru tests on accession, if valid urgency get date reported
38 . . . S LRTEST=0 F S LRTEST=$O(^TMP("LRTT5",$J,"TESTS",LRTEST)) Q:LRTEST<1 I $D(^LRO(68,LRAA,1,LRAD,1,LRAN,4,LRTEST,0)),$D(LRPQ("URGENCY",+$P(^(0),U,2))),$P(^(0),U,8)'="" S LRPLRRX2=+$P(^(0),U,5) D
39 . . . . Q:'$P(^LRO(68,LRAA,1,LRAD,1,LRAN,4,LRTEST,0),U,4) ;Must be verified and have suffix code.
40 . . . . ; increment sequence number
41 . . . . S LRPN=LRPN+1
42 . . . . ; no report date, set to zero TAT save as bad and quit
43 . . . . I 'LRPLRRX2 S LRPLRRX2=LRPLRRX1 D SAVE("BAD") Q
44 . . . . ; if negative times save as bad and quit
45 . . . . I LRPLRRX1>LRPLRRX2 D SAVE("BAD") Q
46 . . . . ; if time is not regular (7am-5pm) then save as irregular and quit
47 . . . . S LRPRX1T="."_$P(LRPLRRX1,".",2) I LRPRX1T<.07!(LRPRX1T>.17) D SAVE("IRREG") Q
48 . . . . ; if Sunday or Saturday save as irregular and quit
49 . . . . S (LRPRX1D,X)=LRPLRRX1\1 D H^%DTC I %Y=0!(%Y=6) D SAVE("IRREG") Q
50 . . . . ; if holiday save as irregular and quit
51 . . . . I $D(^HOLIDAY("B",LRPRX1D)) D SAVE("IRREG") Q
52 . . . . ; otherwise save as regular and quit
53 . . . . D SAVE("REG")
54 ; go thru reg & irreg
55 F LRPTYPE="REG","IRREG" D
56 . ; go thru TATs
57 . S (LRPNN,LRPNT)=0,LRPDIFF="" F S LRPDIFF=$O(^TMP("LR",$J,LRPTYPE,LRPDIFF)) Q:LRPDIFF="" D
58 . . ; go thru each reg & irreg TAT, count # and total
59 . . S LRPN="" F S LRPN=$O(^TMP("LR",$J,LRPTYPE,LRPDIFF,LRPN)) Q:LRPN="" S LRPNN=LRPNN+1,LRPNT=LRPNT+LRPDIFF
60 . ; store reg data
61 . S ^TMP("LR",$J,LRPTYPE)=LRPNN_U_LRPNT
62CLEAN K %Y,LRAA,LRAAT,LRAN,LRPDIFF,LRAD,LRPLRRX1,LRPLRRX2,LRPN,LRPNN,LRPNT,LRPRX1D,LRPRX1T,LRTEST,LRTESTN,LRPTYPE,X
63 Q
64SAVE(LRPUTYPE) ; collect reg, irreg, and bad
65 N LRUID
66 S LRUID=$G(^LRO(68,LRAA,1,LRAD,1,LRAN,.3))
67 S LRPDIFF=$$DIFF(LRPLRRX2,LRPLRRX1),LRTESTN=$P(^LAB(60,LRTEST,0),U)
68 I LRPUTYPE="BAD"!('$L(LRUID)) S ^TMP("LR",$J,"BAD",-LRPDIFF,LRPN)=$G(^LRO(68,LRAA,1,LRAD,1,LRAN,.2))_U_LRTESTN_U_LRPLRRX1_U_$S(LRPLRRX2=LRPLRRX1:"",1:LRPLRRX2) Q
69 Q:$D(^TMP("LR",$J,LRPUTYPE,+LRPDIFF,LRTESTN_LRUID))#2
70 S ^TMP("LR",$J,LRPUTYPE,+LRPDIFF,LRTESTN_LRUID)=$G(^LRO(68,LRAA,1,LRAD,1,LRAN,.2))_U_LRTESTN_U_LRPLRRX1_U_LRPLRRX2
71 S $P(^(LRTESTN),U)=$P($G(^TMP("LR",$J,LRPUTYPE_"T",LRTESTN)),U)+1,$P(^(LRTESTN),U,2)=$P($G(^(LRTESTN)),U,2)+LRPDIFF
72 Q
73DIFF(LRPUT1,LRPUT2) ; $$(time1,time2) -> difference in min
74 N LRPUDIFF,X1,X2,LRPUX1M,LRPUX2M,LRPUX1H,LRPUX2H,LRPUX1TH,LRPUX2TH,LRPUX1TM,LRPUX2TM,LRPUXMI
75 S X1=$P(LRPUT1,"."),X2=$P(LRPUT2,"."),LRPUX1TH=$E(LRPUT1,9),LRPUX2TH=$E(LRPUT2,9),LRPUX1H=$E(LRPUT1,10),LRPUX2H=$E(LRPUT2,10),LRPUX1TM=$E(LRPUT1,11),LRPUX2TM=$E(LRPUT2,11),LRPUX1M=$E(LRPUT1,12),LRPUX2M=$E(LRPUT2,12)
76 D ^%DTC S LRPUXMI=X*1440+(LRPUX1M+(LRPUX1TM*10)+(LRPUX1TH*600)+(LRPUX1H*60))-(LRPUX2M+(LRPUX2TM*10)+(LRPUX2TH*600)+(LRPUX2H*60)),LRPUDIFF=LRPUXMI S:LRPUXMI<0 LRPUDIFF=-LRPUXMI
77 Q LRPUDIFF
Note: See TracBrowser for help on using the repository browser.