LRMITSPO ; IHS/DIR/FJE - MICRO TREND PROCESS ORGANISMS 14:54 ;
;;5.2;LR;**1013**;JUL 15, 2002
;
;;5.2;LAB SERVICE;**96,116**;Sep 27, 1994
; from LRMITSPE
;
; bacteria
I $D(LROTYPE("B")),+$G(^LR(LRDFN,"MI",LRIDT,1)),$O(^(3,0)) S LROTYPE="B" D
.S LRSUBN=0 F S LRSUBN=$O(^LR(LRDFN,"MI",LRIDT,3,LRSUBN)) Q:LRSUBN="" S LRORGN=+^(LRSUBN,0) D
..; if specific organisms required and not valid quit
..I $D(LRSORG),'$D(LRSORG(LROTYPE,LRORGN)) Q
..S LRORGNM=$E($P($G(^LAB(61.2,+LRORGN,0)),U),1,30) I '$L(LRORGNM) S LRORGNM=LRUNK
..; if antibiotic pattern required and not valid quit
..I $D(LRAP) S LROK=1 D Q:'LROK
...S LRDN=0 F S LRDN=$O(LRAP(LRDN)) Q:LRDN="" S LRX=$G(^LR(LRDFN,"MI",LRIDT,3,LRSUBN,LRDN)) D Q:'LROK
....S LRX=$$SENS(LRDN,LRX)
....I '$L(LRX) S LROK=0 Q
....I LRX=LRAP(LRDN) Q
....I LRX'=LRAP(LRDN) S LROK=0
..K LRANTIM S LRDN=0 F S LRDN=$O(^LR(LRDFN,"MI",LRIDT,3,LRSUBN,LRDN)) Q:LRDN="" S LRX=$G(^(LRDN)) I $L(LRX) D
...S LRINTERP=$$SENS(LRDN,LRX) I $L(LRINTERP) S LRANTIM(LRDN)=LRINTERP_U_LRX
..S LRORGNM="("_LROTYPE_") "_LRORGNM D ^LRMITSPS
K LRANTIM
; fungus
I $D(LROTYPE("F")),+$G(^LR(LRDFN,"MI",LRIDT,8)),$O(^(9,0)) S LROTYPE="F" D
.S LRSUBN=0 F S LRSUBN=$O(^LR(LRDFN,"MI",LRIDT,9,LRSUBN)) Q:LRSUBN<1 S LRORGN=+^(LRSUBN,0) D SETUP
; mycobacteria
I $D(LROTYPE("M")),+$G(^LR(LRDFN,"MI",LRIDT,11)),$O(^(12,0)) S LROTYPE="M" D
.S LRSUBN=0 F S LRSUBN=$O(^LR(LRDFN,"MI",LRIDT,12,LRSUBN)) Q:LRSUBN<1 S LRORGN=+^(LRSUBN,0) D
..K LRTB S LRDN=2 F S LRDN=$O(^LR(LRDFN,"MI",LRIDT,12,LRSUBN,LRDN)) Q:LRDN="" S LRTB(LRDN)=$P(^(LRDN),U)
..D SETUP
K LRTB
; parasite
I $D(LROTYPE("P")),+$G(^LR(LRDFN,"MI",LRIDT,5)),$O(^(6,0)) S LROTYPE="P" D
.S LRSUBN=0 F S LRSUBN=$O(^LR(LRDFN,"MI",LRIDT,6,LRSUBN)) Q:LRSUBN<1 S LRORGN=+^(LRSUBN,0) D SETUP
; virus
I $D(LROTYPE("V")),+$G(^LR(LRDFN,"MI",LRIDT,16)),$O(^(17,0)) S LROTYPE="V" D
.S LRSUBN=0 F S LRSUBN=$O(^LR(LRDFN,"MI",LRIDT,17,LRSUBN)) Q:LRSUBN<1 S LRORGN=+^(LRSUBN,0) D SETUP
; Expanded Search
I '$D(LROTYPE("B")),+$G(^LR(LRDFN,"MI",LRIDT,0)),$O(^(3,0)) D
.S LROTYPE=$S($D(LROTYPE("V")):"V",$D(LROTYPE("P")):"P",$D(LROTYPE("F")):"F",$D(LROTYPE("M")):"M",1:"")
.Q:LROTYPE=""
.S LRSUBN=0 F S LRSUBN=$O(^LR(LRDFN,"MI",LRIDT,3,LRSUBN)) Q:LRSUBN<1 S LRORGN=+^(LRSUBN,0) D:LROTYPE=$P(^LAB(61.2,+LRORGN,0),U,5) SETUP
Q
SETUP ; if specific organisms are required, do not setup unless valid organism
I $D(LRSORG),'$D(LRSORG(LROTYPE,LRORGN)) Q
S LRORGNM=$E($P($G(^LAB(61.2,+LRORGN,0)),U),1,30) I '$L(LRORGNM) S LRORGNM=LRUNK
S LRORGNM="("_LROTYPE_") "_LRORGNM
; setup data on isolate
D ^LRMITSPS
Q
SENS(DRUGNODE,VALUES) ; $$(antibiotic,susceptibility) -> "S","R" or ""
N INTERP,RESULT
S INTERP=$P(VALUES,U,2),RESULT=$P(VALUES,U)
I '$L(INTERP),$L(RESULT) S INTERP=$G(^LAB(62.06,"AI",DRUGNODE,RESULT))
I '$L(INTERP) S INTERP=RESULT
I '$L(INTERP) Q ""
I $D(LRSUSS(INTERP)) Q "S"
I $D(LRSUSR(INTERP)) Q "R"
I INTERP["S" Q "S"
Q ""
LRMITSPO ; IHS/DIR/FJE - MICRO TREND PROCESS ORGANISMS 14:54 ;
+1 ;;5.2;LR;**1013**;JUL 15, 2002
+2 ;
+3 ;;5.2;LAB SERVICE;**96,116**;Sep 27, 1994
+4 ; from LRMITSPE
+5 ;
+6 ; bacteria
+7 IF $DATA(LROTYPE("B"))
IF +$GET(^LR(LRDFN,"MI",LRIDT,1))
IF $ORDER(^(3,0))
SET LROTYPE="B"
Begin DoDot:1
+8 SET LRSUBN=0
FOR
SET LRSUBN=$ORDER(^LR(LRDFN,"MI",LRIDT,3,LRSUBN))
IF LRSUBN=""
QUIT
SET LRORGN=+^(LRSUBN,0)
Begin DoDot:2
+9 ; if specific organisms required and not valid quit
+10 IF $DATA(LRSORG)
IF '$DATA(LRSORG(LROTYPE,LRORGN))
QUIT
+11 SET LRORGNM=$EXTRACT($PIECE($GET(^LAB(61.2,+LRORGN,0)),U),1,30)
IF '$LENGTH(LRORGNM)
SET LRORGNM=LRUNK
+12 ; if antibiotic pattern required and not valid quit
+13 IF $DATA(LRAP)
SET LROK=1
Begin DoDot:3
+14 SET LRDN=0
FOR
SET LRDN=$ORDER(LRAP(LRDN))
IF LRDN=""
QUIT
SET LRX=$GET(^LR(LRDFN,"MI",LRIDT,3,LRSUBN,LRDN))
Begin DoDot:4
+15 SET LRX=$$SENS(LRDN,LRX)
+16 IF '$LENGTH(LRX)
SET LROK=0
QUIT
+17 IF LRX=LRAP(LRDN)
QUIT
+18 IF LRX'=LRAP(LRDN)
SET LROK=0
End DoDot:4
IF 'LROK
QUIT
End DoDot:3
IF 'LROK
QUIT
+19 KILL LRANTIM
SET LRDN=0
FOR
SET LRDN=$ORDER(^LR(LRDFN,"MI",LRIDT,3,LRSUBN,LRDN))
IF LRDN=""
QUIT
SET LRX=$GET(^(LRDN))
IF $LENGTH(LRX)
Begin DoDot:3
+20 SET LRINTERP=$$SENS(LRDN,LRX)
IF $LENGTH(LRINTERP)
SET LRANTIM(LRDN)=LRINTERP_U_LRX
End DoDot:3
+21 SET LRORGNM="("_LROTYPE_") "_LRORGNM
DO ^LRMITSPS
End DoDot:2
End DoDot:1
+22 KILL LRANTIM
+23 ; fungus
+24 IF $DATA(LROTYPE("F"))
IF +$GET(^LR(LRDFN,"MI",LRIDT,8))
IF $ORDER(^(9,0))
SET LROTYPE="F"
Begin DoDot:1
+25 SET LRSUBN=0
FOR
SET LRSUBN=$ORDER(^LR(LRDFN,"MI",LRIDT,9,LRSUBN))
IF LRSUBN<1
QUIT
SET LRORGN=+^(LRSUBN,0)
DO SETUP
End DoDot:1
+26 ; mycobacteria
+27 IF $DATA(LROTYPE("M"))
IF +$GET(^LR(LRDFN,"MI",LRIDT,11))
IF $ORDER(^(12,0))
SET LROTYPE="M"
Begin DoDot:1
+28 SET LRSUBN=0
FOR
SET LRSUBN=$ORDER(^LR(LRDFN,"MI",LRIDT,12,LRSUBN))
IF LRSUBN<1
QUIT
SET LRORGN=+^(LRSUBN,0)
Begin DoDot:2
+29 KILL LRTB
SET LRDN=2
FOR
SET LRDN=$ORDER(^LR(LRDFN,"MI",LRIDT,12,LRSUBN,LRDN))
IF LRDN=""
QUIT
SET LRTB(LRDN)=$PIECE(^(LRDN),U)
+30 DO SETUP
End DoDot:2
End DoDot:1
+31 KILL LRTB
+32 ; parasite
+33 IF $DATA(LROTYPE("P"))
IF +$GET(^LR(LRDFN,"MI",LRIDT,5))
IF $ORDER(^(6,0))
SET LROTYPE="P"
Begin DoDot:1
+34 SET LRSUBN=0
FOR
SET LRSUBN=$ORDER(^LR(LRDFN,"MI",LRIDT,6,LRSUBN))
IF LRSUBN<1
QUIT
SET LRORGN=+^(LRSUBN,0)
DO SETUP
End DoDot:1
+35 ; virus
+36 IF $DATA(LROTYPE("V"))
IF +$GET(^LR(LRDFN,"MI",LRIDT,16))
IF $ORDER(^(17,0))
SET LROTYPE="V"
Begin DoDot:1
+37 SET LRSUBN=0
FOR
SET LRSUBN=$ORDER(^LR(LRDFN,"MI",LRIDT,17,LRSUBN))
IF LRSUBN<1
QUIT
SET LRORGN=+^(LRSUBN,0)
DO SETUP
End DoDot:1
+38 ; Expanded Search
+39 IF '$DATA(LROTYPE("B"))
IF +$GET(^LR(LRDFN,"MI",LRIDT,0))
IF $ORDER(^(3,0))
Begin DoDot:1
+40 SET LROTYPE=$SELECT($DATA(LROTYPE("V")):"V",$DATA(LROTYPE("P")):"P",$DATA(LROTYPE("F")):"F",$DATA(LROTYPE("M")):"M",1:"")
+41 IF LROTYPE=""
QUIT
+42 SET LRSUBN=0
FOR
SET LRSUBN=$ORDER(^LR(LRDFN,"MI",LRIDT,3,LRSUBN))
IF LRSUBN<1
QUIT
SET LRORGN=+^(LRSUBN,0)
IF LROTYPE=$PIECE(^LAB(61.2,+LRORGN,0),U,5)
DO SETUP
End DoDot:1
+43 QUIT
SETUP ; if specific organisms are required, do not setup unless valid organism
+1 IF $DATA(LRSORG)
IF '$DATA(LRSORG(LROTYPE,LRORGN))
QUIT
+2 SET LRORGNM=$EXTRACT($PIECE($GET(^LAB(61.2,+LRORGN,0)),U),1,30)
IF '$LENGTH(LRORGNM)
SET LRORGNM=LRUNK
+3 SET LRORGNM="("_LROTYPE_") "_LRORGNM
+4 ; setup data on isolate
+5 DO ^LRMITSPS
+6 QUIT
SENS(DRUGNODE,VALUES) ; $$(antibiotic,susceptibility) -> "S","R" or ""
+1 NEW INTERP,RESULT
+2 SET INTERP=$PIECE(VALUES,U,2)
SET RESULT=$PIECE(VALUES,U)
+3 IF '$LENGTH(INTERP)
IF $LENGTH(RESULT)
SET INTERP=$GET(^LAB(62.06,"AI",DRUGNODE,RESULT))
+4 IF '$LENGTH(INTERP)
SET INTERP=RESULT
+5 IF '$LENGTH(INTERP)
QUIT ""
+6 IF $DATA(LRSUSS(INTERP))
QUIT "S"
+7 IF $DATA(LRSUSR(INTERP))
QUIT "R"
+8 IF INTERP["S"
QUIT "S"
+9 QUIT ""