LRPXCHKA ;VA/SLC/STAFF - Lab PXRMINDX Index Validation AP ; 17-Oct-2014 09:22 ; MKK
;;5.2;LAB SERVICE;**1030,1034**;NOV 01, 1997;Build 88
;;5.2;LAB SERVICE;**295**;Sep 27, 1994;Build 5
;
AP(DFN,LRDFN) ; from LRPXCHK
N DATE,LRIDT,SUB,ZERO
F SUB="CY","EM","SP" D
. S LRIDT=0
. F S LRIDT=$O(^TMP("LRPXCHK",$J,"LR",LRDFN,SUB,LRIDT)) Q:LRIDT<1 D
.. S ZERO=$G(^TMP("LRPXCHK",$J,"LR",LRDFN,SUB,LRIDT,0))
.. S DATE=$$LRIDT^LRPXAPIU(LRIDT) I 'DATE Q
.. I '$P(ZERO,U,3) Q
.. I '$P(ZERO,U,11) Q
.. D CYEMSP(LRDFN,DFN,LRIDT,DATE,SUB) ; cyto, electron micro, surg path
I $D(^TMP("LRPXCHK",$J,"LR",LRDFN,"AU")) D AUTOPSY(DFN,LRDFN)
Q
;
AUTOPSY(DFN,LRDFN) ;
N DATE,ETIOL,I,II,III,ICD,ICDX,ITEM,NODE,ORGAN,SNOMED,SPEC,SUB,SUBS
I '($P(^TMP("LRPXCHK",$J,"LR",LRDFN,"AU"),U,3)&($P(^("AU"),U,15))) Q
S DATE=$$DOD^LRPXAPIU(DFN) I 'DATE Q
S SPEC=0
F S SPEC=$O(^TMP("LRPXCHK",$J,"LR",LRDFN,33,SPEC)) Q:SPEC<1 D
. I '$L($P($G(^TMP("LRPXCHK",$J,"LR",LRDFN,33,SPEC,0)),U)) Q
. S ITEM="A;S;1."_$$UP^XLFSTR($P(^TMP("LRPXCHK",$J,"LR",LRDFN,33,SPEC,0),U))
. S NODE=LRDFN_";33;"_SPEC_";0"
. D TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
S ICD=0
F S ICD=$O(^TMP("LRPXCHK",$J,"LR",LRDFN,80,ICD)) Q:ICD<1 D
. S ICDX=+$G(^TMP("LRPXCHK",$J,"LR",LRDFN,80,ICD,0))
. I 'ICDX Q
. S ITEM="A;I;"_ICDX
. S NODE=LRDFN_";80;"_ICD_";0"
. D TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
S I=0
F S I=$O(^TMP("LRPXCHK",$J,"LR",LRDFN,"AY",I)) Q:I<1 D
. S ORGAN=+$G(^TMP("LRPXCHK",$J,"LR",LRDFN,"AY",I,0))
. I 'ORGAN Q
. S ITEM="A;O;"_ORGAN
. S NODE=LRDFN_";AY;"_I_";0"
. D TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
. F SUBS="1D","2M","3F","4P" D
.. S SUB=+SUBS
.. S II=0
.. F S II=$O(^TMP("LRPXCHK",$J,"LR",LRDFN,"AY",I,SUB,II)) Q:II<1 D
... S SNOMED=+$G(^TMP("LRPXCHK",$J,"LR",LRDFN,"AY",I,SUB,II,0))
... I 'SNOMED Q
... S ITEM="A;"_$E(SUBS,2)_";"_SNOMED
... S NODE=LRDFN_";AY;"_I_";"_SUB_";"_II_";0"
... D TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
... I SUB'=2 Q
... S III=0
... F S III=$O(^TMP("LRPXCHK",$J,"LR",LRDFN,"AY",I,SUB,II,1,III)) Q:III<1 D
.... S ETIOL=+$G(^TMP("LRPXCHK",$J,"LR",LRDFN,"AY",I,SUB,II,1,III,0))
.... I 'ETIOL Q
.... S ITEM="A;E;"_ETIOL
.... S NODE=LRDFN_";AY;"_I_";"_SUB_";"_II_";1;"_III_";0"
.... D TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
Q
;
CYEMSP(LRDFN,DFN,LRIDT,DATE,SUB) ;
N ACC,I,ICD,ICDX,ITEM,NODE,ORGAN,PREP,SPEC,TEST,TESTS K TESTS
I '$D(^TMP("LRPXCHK",$J,"LR",LRDFN,SUB,0)) Q
S SPEC=0
F S SPEC=$O(^TMP("LRPXCHK",$J,"LR",LRDFN,SUB,LRIDT,.1,SPEC)) Q:SPEC<1 D
. I '$L($P($G(^TMP("LRPXCHK",$J,"LR",LRDFN,SUB,LRIDT,.1,SPEC,0)),U)) Q
. S ITEM="A;S;1."_$$UP^XLFSTR($P(^TMP("LRPXCHK",$J,"LR",LRDFN,SUB,LRIDT,.1,SPEC,0),U))
. S NODE=LRDFN_";"_SUB_";"_LRIDT_";.1;"_SPEC_";0"
. D TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
. S PREP=0
. F S PREP=$O(^TMP("LRPXCHK",$J,"LR",LRDFN,SUB,LRIDT,.1,SPEC,1,PREP)) Q:PREP<1 D
.. S TEST=0
.. F S TEST=$O(^TMP("LRPXCHK",$J,"LR",LRDFN,SUB,LRIDT,.1,SPEC,1,PREP,1,TEST)) Q:TEST<1 D
... S TEST=+$G(^TMP("LRPXCHK",$J,"LR",LRDFN,SUB,LRIDT,.1,SPEC,1,PREP,1,TEST,0))
... I 'TEST Q
... S ITEM="A;T;"_TEST
... S NODE=LRDFN_";"_SUB_";"_LRIDT_";.1;"_SPEC_";1;"_PREP_";1;"_TEST_";0"
... D TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
; S ACC=$P(^TMP("LRPXCHK",$J,"LR",LRDFN,SUB,LRIDT,0),U,6) ; do not use tests on acc
; I $L(ACC) D
; . S NODE=LRDFN_";"_SUB_";"_LRIDT_";0"
; . D ACCY^LRPXAPI(.TESTS,ACC,DATE)
; . I $O(TESTS(0)) D
; .. S TEST=0
; .. F S TEST=+$O(TESTS(TEST)) Q:TEST<1 D
; ... S ITEM="A;T;"_TEST
; ... D TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
S ICD=0
F S ICD=$O(^TMP("LRPXCHK",$J,"LR",LRDFN,SUB,LRIDT,3,ICD)) Q:ICD<1 D
. S ICDX=+$G(^TMP("LRPXCHK",$J,"LR",LRDFN,SUB,LRIDT,3,ICD,0))
. I 'ICDX Q
. S ITEM="A;I;"_ICDX
. S NODE=LRDFN_";"_SUB_";"_LRIDT_";3;"_ICD_";0"
. D TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
S I=0
F S I=$O(^TMP("LRPXCHK",$J,"LR",LRDFN,SUB,LRIDT,2,I)) Q:I<1 D
. S ORGAN=+$G(^TMP("LRPXCHK",$J,"LR",LRDFN,SUB,LRIDT,2,I,0))
. I 'ORGAN Q
. S ITEM="A;O;"_ORGAN
. S NODE=LRDFN_";"_SUB_";"_LRIDT_";2;"_I_";0"
. D TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
. D SNOMED(LRDFN,LRIDT,SUB,I)
Q
;
SNOMED(LRDFN,LRIDT,APSUB,I) ;
N ETIOL,II,III,ITEM,NODE,SNOMED,SUB,SUBS
F SUBS="1D","2M","3F","4P" D
. S SUB=+SUBS
. S II=0
. F S II=$O(^TMP("LRPXCHK",$J,"LR",LRDFN,APSUB,LRIDT,2,I,SUB,II)) Q:II<1 D
.. S SNOMED=+$G(^TMP("LRPXCHK",$J,"LR",LRDFN,APSUB,LRIDT,2,I,SUB,II,0))
.. I 'SNOMED Q
.. S ITEM="A;"_$E(SUBS,2)_";"_SNOMED
.. S NODE=LRDFN_";"_APSUB_";"_LRIDT_";2;"_I_";"_SUB_";"_II_";0"
.. D TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
.. I SUB'=2 Q
.. S III=0
.. F S III=$O(^TMP("LRPXCHK",$J,"LR",LRDFN,APSUB,LRIDT,2,I,SUB,II,1,III)) Q:III<1 D
... S ETIOL=+$G(^TMP("LRPXCHK",$J,"LR",LRDFN,APSUB,LRIDT,2,I,SUB,II,1,III,0))
... I 'ETIOL Q
... S ITEM="A;E;"_ETIOL
... S NODE=LRDFN_";"_APSUB_";"_LRIDT_";2;"_I_";"_SUB_";"_II_";1;"_III_";0"
... D TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
Q
;
LRPXCHKA ;VA/SLC/STAFF - Lab PXRMINDX Index Validation AP ; 17-Oct-2014 09:22 ; MKK
+1 ;;5.2;LAB SERVICE;**1030,1034**;NOV 01, 1997;Build 88
+2 ;;5.2;LAB SERVICE;**295**;Sep 27, 1994;Build 5
+3 ;
AP(DFN,LRDFN) ; from LRPXCHK
+1 NEW DATE,LRIDT,SUB,ZERO
+2 FOR SUB="CY","EM","SP"
Begin DoDot:1
+3 SET LRIDT=0
+4 FOR
SET LRIDT=$ORDER(^TMP("LRPXCHK",$JOB,"LR",LRDFN,SUB,LRIDT))
IF LRIDT<1
QUIT
Begin DoDot:2
+5 SET ZERO=$GET(^TMP("LRPXCHK",$JOB,"LR",LRDFN,SUB,LRIDT,0))
+6 SET DATE=$$LRIDT^LRPXAPIU(LRIDT)
IF 'DATE
QUIT
+7 IF '$PIECE(ZERO,U,3)
QUIT
+8 IF '$PIECE(ZERO,U,11)
QUIT
+9 ; cyto, electron micro, surg path
DO CYEMSP(LRDFN,DFN,LRIDT,DATE,SUB)
End DoDot:2
End DoDot:1
+10 IF $DATA(^TMP("LRPXCHK",$JOB,"LR",LRDFN,"AU"))
DO AUTOPSY(DFN,LRDFN)
+11 QUIT
+12 ;
AUTOPSY(DFN,LRDFN) ;
+1 NEW DATE,ETIOL,I,II,III,ICD,ICDX,ITEM,NODE,ORGAN,SNOMED,SPEC,SUB,SUBS
+2 IF '($PIECE(^TMP("LRPXCHK",$JOB,"LR",LRDFN,"AU"),U,3)&($PIECE(^("AU"),U,15)))
QUIT
+3 SET DATE=$$DOD^LRPXAPIU(DFN)
IF 'DATE
QUIT
+4 SET SPEC=0
+5 FOR
SET SPEC=$ORDER(^TMP("LRPXCHK",$JOB,"LR",LRDFN,33,SPEC))
IF SPEC<1
QUIT
Begin DoDot:1
+6 IF '$LENGTH($PIECE($GET(^TMP("LRPXCHK",$JOB,"LR",LRDFN,33,SPEC,0)),U))
QUIT
+7 SET ITEM="A;S;1."_$$UP^XLFSTR($PIECE(^TMP("LRPXCHK",$JOB,"LR",LRDFN,33,SPEC,0),U))
+8 SET NODE=LRDFN_";33;"_SPEC_";0"
+9 DO TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
End DoDot:1
+10 SET ICD=0
+11 FOR
SET ICD=$ORDER(^TMP("LRPXCHK",$JOB,"LR",LRDFN,80,ICD))
IF ICD<1
QUIT
Begin DoDot:1
+12 SET ICDX=+$GET(^TMP("LRPXCHK",$JOB,"LR",LRDFN,80,ICD,0))
+13 IF 'ICDX
QUIT
+14 SET ITEM="A;I;"_ICDX
+15 SET NODE=LRDFN_";80;"_ICD_";0"
+16 DO TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
End DoDot:1
+17 SET I=0
+18 FOR
SET I=$ORDER(^TMP("LRPXCHK",$JOB,"LR",LRDFN,"AY",I))
IF I<1
QUIT
Begin DoDot:1
+19 SET ORGAN=+$GET(^TMP("LRPXCHK",$JOB,"LR",LRDFN,"AY",I,0))
+20 IF 'ORGAN
QUIT
+21 SET ITEM="A;O;"_ORGAN
+22 SET NODE=LRDFN_";AY;"_I_";0"
+23 DO TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
+24 FOR SUBS="1D","2M","3F","4P"
Begin DoDot:2
+25 SET SUB=+SUBS
+26 SET II=0
+27 FOR
SET II=$ORDER(^TMP("LRPXCHK",$JOB,"LR",LRDFN,"AY",I,SUB,II))
IF II<1
QUIT
Begin DoDot:3
+28 SET SNOMED=+$GET(^TMP("LRPXCHK",$JOB,"LR",LRDFN,"AY",I,SUB,II,0))
+29 IF 'SNOMED
QUIT
+30 SET ITEM="A;"_$EXTRACT(SUBS,2)_";"_SNOMED
+31 SET NODE=LRDFN_";AY;"_I_";"_SUB_";"_II_";0"
+32 DO TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
+33 IF SUB'=2
QUIT
+34 SET III=0
+35 FOR
SET III=$ORDER(^TMP("LRPXCHK",$JOB,"LR",LRDFN,"AY",I,SUB,II,1,III))
IF III<1
QUIT
Begin DoDot:4
+36 SET ETIOL=+$GET(^TMP("LRPXCHK",$JOB,"LR",LRDFN,"AY",I,SUB,II,1,III,0))
+37 IF 'ETIOL
QUIT
+38 SET ITEM="A;E;"_ETIOL
+39 SET NODE=LRDFN_";AY;"_I_";"_SUB_";"_II_";1;"_III_";0"
+40 DO TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+41 QUIT
+42 ;
CYEMSP(LRDFN,DFN,LRIDT,DATE,SUB) ;
+1 NEW ACC,I,ICD,ICDX,ITEM,NODE,ORGAN,PREP,SPEC,TEST,TESTS
KILL TESTS
+2 IF '$DATA(^TMP("LRPXCHK",$JOB,"LR",LRDFN,SUB,0))
QUIT
+3 SET SPEC=0
+4 FOR
SET SPEC=$ORDER(^TMP("LRPXCHK",$JOB,"LR",LRDFN,SUB,LRIDT,.1,SPEC))
IF SPEC<1
QUIT
Begin DoDot:1
+5 IF '$LENGTH($PIECE($GET(^TMP("LRPXCHK",$JOB,"LR",LRDFN,SUB,LRIDT,.1,SPEC,0)),U))
QUIT
+6 SET ITEM="A;S;1."_$$UP^XLFSTR($PIECE(^TMP("LRPXCHK",$JOB,"LR",LRDFN,SUB,LRIDT,.1,SPEC,0),U))
+7 SET NODE=LRDFN_";"_SUB_";"_LRIDT_";.1;"_SPEC_";0"
+8 DO TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
+9 SET PREP=0
+10 FOR
SET PREP=$ORDER(^TMP("LRPXCHK",$JOB,"LR",LRDFN,SUB,LRIDT,.1,SPEC,1,PREP))
IF PREP<1
QUIT
Begin DoDot:2
+11 SET TEST=0
+12 FOR
SET TEST=$ORDER(^TMP("LRPXCHK",$JOB,"LR",LRDFN,SUB,LRIDT,.1,SPEC,1,PREP,1,TEST))
IF TEST<1
QUIT
Begin DoDot:3
+13 SET TEST=+$GET(^TMP("LRPXCHK",$JOB,"LR",LRDFN,SUB,LRIDT,.1,SPEC,1,PREP,1,TEST,0))
+14 IF 'TEST
QUIT
+15 SET ITEM="A;T;"_TEST
+16 SET NODE=LRDFN_";"_SUB_";"_LRIDT_";.1;"_SPEC_";1;"_PREP_";1;"_TEST_";0"
+17 DO TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
End DoDot:3
End DoDot:2
End DoDot:1
+18 ; S ACC=$P(^TMP("LRPXCHK",$J,"LR",LRDFN,SUB,LRIDT,0),U,6) ; do not use tests on acc
+19 ; I $L(ACC) D
+20 ; . S NODE=LRDFN_";"_SUB_";"_LRIDT_";0"
+21 ; . D ACCY^LRPXAPI(.TESTS,ACC,DATE)
+22 ; . I $O(TESTS(0)) D
+23 ; .. S TEST=0
+24 ; .. F S TEST=+$O(TESTS(TEST)) Q:TEST<1 D
+25 ; ... S ITEM="A;T;"_TEST
+26 ; ... D TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
+27 SET ICD=0
+28 FOR
SET ICD=$ORDER(^TMP("LRPXCHK",$JOB,"LR",LRDFN,SUB,LRIDT,3,ICD))
IF ICD<1
QUIT
Begin DoDot:1
+29 SET ICDX=+$GET(^TMP("LRPXCHK",$JOB,"LR",LRDFN,SUB,LRIDT,3,ICD,0))
+30 IF 'ICDX
QUIT
+31 SET ITEM="A;I;"_ICDX
+32 SET NODE=LRDFN_";"_SUB_";"_LRIDT_";3;"_ICD_";0"
+33 DO TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
End DoDot:1
+34 SET I=0
+35 FOR
SET I=$ORDER(^TMP("LRPXCHK",$JOB,"LR",LRDFN,SUB,LRIDT,2,I))
IF I<1
QUIT
Begin DoDot:1
+36 SET ORGAN=+$GET(^TMP("LRPXCHK",$JOB,"LR",LRDFN,SUB,LRIDT,2,I,0))
+37 IF 'ORGAN
QUIT
+38 SET ITEM="A;O;"_ORGAN
+39 SET NODE=LRDFN_";"_SUB_";"_LRIDT_";2;"_I_";0"
+40 DO TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
+41 DO SNOMED(LRDFN,LRIDT,SUB,I)
End DoDot:1
+42 QUIT
+43 ;
SNOMED(LRDFN,LRIDT,APSUB,I) ;
+1 NEW ETIOL,II,III,ITEM,NODE,SNOMED,SUB,SUBS
+2 FOR SUBS="1D","2M","3F","4P"
Begin DoDot:1
+3 SET SUB=+SUBS
+4 SET II=0
+5 FOR
SET II=$ORDER(^TMP("LRPXCHK",$JOB,"LR",LRDFN,APSUB,LRIDT,2,I,SUB,II))
IF II<1
QUIT
Begin DoDot:2
+6 SET SNOMED=+$GET(^TMP("LRPXCHK",$JOB,"LR",LRDFN,APSUB,LRIDT,2,I,SUB,II,0))
+7 IF 'SNOMED
QUIT
+8 SET ITEM="A;"_$EXTRACT(SUBS,2)_";"_SNOMED
+9 SET NODE=LRDFN_";"_APSUB_";"_LRIDT_";2;"_I_";"_SUB_";"_II_";0"
+10 DO TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
+11 IF SUB'=2
QUIT
+12 SET III=0
+13 FOR
SET III=$ORDER(^TMP("LRPXCHK",$JOB,"LR",LRDFN,APSUB,LRIDT,2,I,SUB,II,1,III))
IF III<1
QUIT
Begin DoDot:3
+14 SET ETIOL=+$GET(^TMP("LRPXCHK",$JOB,"LR",LRDFN,APSUB,LRIDT,2,I,SUB,II,1,III,0))
+15 IF 'ETIOL
QUIT
+16 SET ITEM="A;E;"_ETIOL
+17 SET NODE=LRDFN_";"_APSUB_";"_LRIDT_";2;"_I_";"_SUB_";"_II_";1;"_III_";0"
+18 DO TMPCHK^LRPXCHK(DFN,DATE,ITEM,NODE)
End DoDot:3
End DoDot:2
End DoDot:1
+19 QUIT
+20 ;