LR7OB63C ;VA/slc/dcm - Get SP,EM,CY data ; 17-Oct-2014 09:22 ; MKK
;;5.2;LAB SERVICE;**1003,121,187,315,1031,1034**;NOV 01, 1997;Build 188
;
SS(LRSS) ;Process SP,CY,EM data
N IFN,IFN1,IFN2,X0,X1,X2,X3,X4,X5,Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y18,CTR1,PATH,SUB,NNN,NN1
Q:'$G(IVDT)
S NNN=$S(LRSS="SP":"",LRSS="CY":9,LRSS="EM":2,1:""),NN1=+("63."_$S(LRSS="SP":8,1:NNN)_19)
Q:'$D(^LR(LRDFN,LRSS,IVDT)) S X0=^(IVDT,0),Y6=$S(+$G(CORRECT):"C",$P(X0,"^",11):"F",$P(X0,"^",3):"R",1:"I"),CTR1=0
S:+X0 $P(^TMP("LRX",$J,69,CTR,68),"^",4)=+X0 ;DT Specimen Taken
S:$P(X0,"^",10) $P(^TMP("LRX",$J,69,CTR,68),"^",5)=$P(X0,"^",10) ;DT Received
S:$P(X0,"^",3) $P(^TMP("LRX",$J,69,CTR,68),"^",6)=$P(X0,"^",3) ;DT Completed
S PATH=$P(X0,"^",2) ;Pathologist
S Y18=";CH;"_IVDT
S CTR1=CTR1+1,^TMP("LRX",$J,69,CTR,68,CTR1)=$S($D(^TMP("LRX",$J,69,1)):$P(^TMP("LRX",$J,69,1),"^"),1:"")_"^^"_PATH_"^"_$P(X0,"^",3)
D WP(.1,"SPECIMEN","","ST")
D WP(.2,"BRIEF CLINICAL HISTORY","","TX")
D WP(.3,"PREOPERATIVE DIAGNOSIS","","TX")
D WP(.4,"OPERATIVE FINDINGS","","TX")
D WP(.5,"POSTOPERATIVE DIAGNOSIS","","TX")
D WP(1,"GROSS DESCRIPTION","&GDT","TX"),MOD(7,"MODIFIED GROSS DESCRIPTION")
D WP(1.1,"MICROSCOPIC DESCRIPTION","&MDT","TX"),MOD(4,"MODIFIED MICROSCOPIC DESCRIPTION")
D WP(1.3,"FROZEN SECTION","","TX"),MOD(6,"MODIFIED FROZEN SECTION")
D WP(1.4,"DIAGNOSIS","","TX"),MOD(5,"MODIFIED DIAGNOSIS")
S IFN=0 N X1
F S IFN=$O(^LR(LRDFN,LRSS,IVDT,1.2,IFN)) Q:IFN<1 S X=^(IFN,0),IFN1=0 D
. F S IFN1=$O(^LR(LRDFN,LRSS,IVDT,1.2,IFN,1,IFN1)) Q:IFN1<1 S CTR1=CTR1+1,X1=^(IFN1,0),^TMP("LRX",$J,69,CTR,63,CTR1)="SUPPLEMENTARY REPORT~"_+X_"^"_X1_"^^^^"_Y6_"^^TX^^^^^^^SUPPLEMNT RPT^^^"_Y18
S IFN=0,SUB=0
F S IFN=$O(^LR(LRDFN,LRSS,IVDT,2,IFN)) Q:IFN<1 S X=^(IFN,0) D
. S SUB=SUB+1,CTR1=CTR1+1,^TMP("LRX",$J,69,CTR,63,CTR1)="ORGAN/TISSUE^"_$$POINTER^LR7OB63(+("63."_NNN_12),.01,+X)_"^^^^"_Y6_"^"_SUB_"^CE^"_$P($G(^LAB(61,+X,0)),"^",2)_"^SNM^&ANT^^^^ORG/TISS^^^"_Y18
. D PTR(1,"DISEASE",+("63."_NNN_15),.01,61.4,"")
. S IFN1=0
. F S IFN1=$O(^LR(LRDFN,LRSS,IVDT,2,IFN,2,IFN1)) Q:IFN1<1 S X=^(IFN1,0) D
.. S CTR1=CTR1+1,^TMP("LRX",$J,69,CTR,63,CTR1)="MORPHOLOGY"_"^"_$$POINTER^LR7OB63(+("63."_NNN_16),.01,+X)_"^^^^"_Y6_"^"_SUB_"^CE^"_$P($G(^LAB(61.1,+X,0)),"^",2)_"^SNM^&IMP^^^^_MORPH^^^"_Y18
.. S IFN2=0
.. F S IFN2=$O(^LR(LRDFN,LRSS,IVDT,2,IFN,2,IFN1,1,IFN2)) Q:IFN2<1 S X=^(IFN2,0) D
... S CTR1=CTR1+1,^TMP("LRX",$J,69,CTR,63,CTR1)="ETIOLOGY^"_$$POINTER^LR7OB63(+("63."_NNN_17),.01,+X)_"^^^^"_Y6_"^"_SUB_"^CE^"_$P($G(^LAB(61.2,+X,0)),"^",2)_"^SNM^^^^^ETIOLOGY^^^"_Y18
. D PTR(3,"FUNCTION",+("63."_NNN_85),.01,61.3,"")
. D PTR(4,"PROCEDURE",+("63."_NNN_82),.01,61.5,"&CNP")
. S IFN1=0 F S IFN1=$O(^LR(LRDFN,LRSS,IVDT,2,IFN,5,IFN1)) Q:IFN1<1 S X=^(IFN1,0),IFN2=0 F S IFN2=$O(^LR(LRDFN,LRSS,IVDT,2,IFN,5,IFN1,1,IFN2)) Q:IFN2<1 S X1=^(IFN2,0) D
.. S CTR1=CTR1+1,^TMP("LRX",$J,69,CTR,3,CTR1)="SPECIAL STUDIES "_$$SET^LR7OB63(NN1,.01,$P(X,"^"))_"~"_$P(X,"^",2)_"^"_X1_"^^^^^^TX^^^^^^^SPEC STUDIES"_$$SET^LR7OB63(NN1,.01,$P(X,"^"))_"~"_$P(X,"^",2)_"^^^"_Y18
S IFN=0 F S IFN=$O(^LR(LRDFN,LRSS,IVDT,3,IFN)) Q:IFN<1 D
. N LRX,LRTMP
. ; S LRX=^(IFN,0),LRX=$$ICDDX^ICDCODE(+LRX,,,1)
. S LRX=^(IFN,0),LRX=$$ICDDX^ICDEX(+LRX,,,"I") ; IHS/MSC/MKK - LR*5.2*1034
. S CTR1=CTR1+1,LRTMP="ICD DIAGNOSIS^"
. S LRTMP=LRTMP_$P(LRX,"^",4)_"^^^^"_Y6_"^^CE^"_$P(LRX,"^",2)
. S LRTMP=LRTMP_"^ICD9^&IMP^^^^^ICD DIAG^^^"_Y18
. S ^TMP("LRX",$J,69,CTR,63,CTR1)=LRTMP
. Q
Q
WP(I,NAME,ID,VALTYP) ;Store word processing fields
;I=Node at ^LR(LRDFN,LRSS,IVDT,I)
;NAME= Field name
;ID=Coded HL7 ID
;VALTYP="TX" for text, "CE" for Coded
N IFN,IFN1,X
Q:'I Q:'$L(NAME)
S IFN=0 F S IFN=$O(^LR(LRDFN,LRSS,IVDT,I,IFN)) Q:IFN<1 S X=^(IFN,0) D SPLIT^LR7OU1(X,"^TMP(""LRX"",$J,69,CTR,63)",.CTR1,80,NAME_"^","^^^^"_Y6_"^^"_VALTYP_"^^^"_ID_"^^^^"_NAME_"^^^"_Y18)
Q
PTR(I,NAME,FILE,FIELD,SNMFILE,ID) ;Store ptr fields for ORGAN/TISSUE multiple
;I=Node at ^LR(LRDFN,LRSS,IVDT,2,IFN,I)
;NAME=Field name
;FILE=File #
;FIELD=Field #
;SNMFILE=Snomed file # for coded entry
;ID=Procedure ID Natl
N IFN1
Q:'I Q:'$L(NAME)
S IFN1=0
F S IFN1=$O(^LR(LRDFN,LRSS,IVDT,2,IFN,I,IFN1)) Q:IFN1<1 S X=^(IFN1,0) D
. S CTR1=CTR1+1,^TMP("LRX",$J,69,CTR,63,CTR1)=NAME_"^"_$$POINTER^LR7OB63(FILE,FIELD,+X)_"^^^^"_Y6_"^"_SUB_"^CE^"_$P($G(@("^LAB("_SNMFILE_","_+X_",0)")),"^",2)_"^SNM^"_ID_"^^^^"_NAME_"^^^"_Y18
Q
MOD(IFN,FLDNM) ;Process Modified text fields
;IFN=Internal # of modified node
;FLDNM=Field name
Q:'$D(^LR(LRDFN,LRSS,IVDT,+IFN)) S IFN1=0
N X,X1
F S IFN1=$O(^LR(LRDFN,LRSS,IVDT,+IFN,IFN1)) Q:IFN1<1 S X=^(IFN1,0),IFN2=0 D
. F S IFN2=$O(^LR(LRDFN,LRSS,IVDT,+IFN,IFN1,1,IFN2)) Q:IFN2<1 S X1=^(IFN2,0),CTR1=CTR1+1,^TMP("LRX",$J,69,CTR,63,CTR1)=FLDNM_"~"_+X_"^"_X1_"^^^^"_Y6_"^^TX^^^^^^^"_FLDNM_"^^^"_Y18
Q
LR7OB63C ;VA/slc/dcm - Get SP,EM,CY data ; 17-Oct-2014 09:22 ; MKK
+1 ;;5.2;LAB SERVICE;**1003,121,187,315,1031,1034**;NOV 01, 1997;Build 188
+2 ;
SS(LRSS) ;Process SP,CY,EM data
+1 NEW IFN,IFN1,IFN2,X0,X1,X2,X3,X4,X5,Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y18,CTR1,PATH,SUB,NNN,NN1
+2 IF '$GET(IVDT)
QUIT
+3 SET NNN=$SELECT(LRSS="SP":"",LRSS="CY":9,LRSS="EM":2,1:"")
SET NN1=+("63."_$SELECT(LRSS="SP":8,1:NNN)_19)
+4 IF '$DATA(^LR(LRDFN,LRSS,IVDT))
QUIT
SET X0=^(IVDT,0)
SET Y6=$SELECT(+$GET(CORRECT):"C",$PIECE(X0,"^",11):"F",$PIECE(X0,"^",3):"R",1:"I")
SET CTR1=0
+5 ;DT Specimen Taken
IF +X0
SET $PIECE(^TMP("LRX",$JOB,69,CTR,68),"^",4)=+X0
+6 ;DT Received
IF $PIECE(X0,"^",10)
SET $PIECE(^TMP("LRX",$JOB,69,CTR,68),"^",5)=$PIECE(X0,"^",10)
+7 ;DT Completed
IF $PIECE(X0,"^",3)
SET $PIECE(^TMP("LRX",$JOB,69,CTR,68),"^",6)=$PIECE(X0,"^",3)
+8 ;Pathologist
SET PATH=$PIECE(X0,"^",2)
+9 SET Y18=";CH;"_IVDT
+10 SET CTR1=CTR1+1
SET ^TMP("LRX",$JOB,69,CTR,68,CTR1)=$SELECT($DATA(^TMP("LRX",$JOB,69,1)):$PIECE(^TMP("LRX",$JOB,69,1),"^"),1:"")_"^^"_PATH_"^"_$PIECE(X0,"^",3)
+11 DO WP(.1,"SPECIMEN","","ST")
+12 DO WP(.2,"BRIEF CLINICAL HISTORY","","TX")
+13 DO WP(.3,"PREOPERATIVE DIAGNOSIS","","TX")
+14 DO WP(.4,"OPERATIVE FINDINGS","","TX")
+15 DO WP(.5,"POSTOPERATIVE DIAGNOSIS","","TX")
+16 DO WP(1,"GROSS DESCRIPTION","&GDT","TX")
DO MOD(7,"MODIFIED GROSS DESCRIPTION")
+17 DO WP(1.1,"MICROSCOPIC DESCRIPTION","&MDT","TX")
DO MOD(4,"MODIFIED MICROSCOPIC DESCRIPTION")
+18 DO WP(1.3,"FROZEN SECTION","","TX")
DO MOD(6,"MODIFIED FROZEN SECTION")
+19 DO WP(1.4,"DIAGNOSIS","","TX")
DO MOD(5,"MODIFIED DIAGNOSIS")
+20 SET IFN=0
NEW X1
+21 FOR
SET IFN=$ORDER(^LR(LRDFN,LRSS,IVDT,1.2,IFN))
IF IFN<1
QUIT
SET X=^(IFN,0)
SET IFN1=0
Begin DoDot:1
+22 FOR
SET IFN1=$ORDER(^LR(LRDFN,LRSS,IVDT,1.2,IFN,1,IFN1))
IF IFN1<1
QUIT
SET CTR1=CTR1+1
SET X1=^(IFN1,0)
SET ^TMP("LRX",$JOB,69,CTR,63,CTR1)="SUPPLEMENTARY REPORT~"_+X_"^"_X1_"^^^^"_Y6_"^^TX^^^^^^^SUPPLEMNT RPT^^^"_Y18
End DoDot:1
+23 SET IFN=0
SET SUB=0
+24 FOR
SET IFN=$ORDER(^LR(LRDFN,LRSS,IVDT,2,IFN))
IF IFN<1
QUIT
SET X=^(IFN,0)
Begin DoDot:1
+25 SET SUB=SUB+1
SET CTR1=CTR1+1
SET ^TMP("LRX",$JOB,69,CTR,63,CTR1)="ORGAN/TISSUE^"_$$POINTER^LR7OB63(+("63."_NNN_12),.01,+X)_"^^^^"_Y6_"^"_SUB_"^CE^"_$PIECE($GET(^LAB(61,+X,0)),"^",2)_"^SNM^&ANT^^^^ORG/TISS^^^"_Y18
+26 DO PTR(1,"DISEASE",+("63."_NNN_15),.01,61.4,"")
+27 SET IFN1=0
+28 FOR
SET IFN1=$ORDER(^LR(LRDFN,LRSS,IVDT,2,IFN,2,IFN1))
IF IFN1<1
QUIT
SET X=^(IFN1,0)
Begin DoDot:2
+29 SET CTR1=CTR1+1
SET ^TMP("LRX",$JOB,69,CTR,63,CTR1)="MORPHOLOGY"_"^"_$$POINTER^LR7OB63(+("63."_NNN_16),.01,+X)_"^^^^"_Y6_"^"_SUB_"^CE^"_$PIECE($GET(^LAB(61.1,+X,0)),"^",2)_"^SNM^&IMP^^^^_MORPH^^^"_Y18
+30 SET IFN2=0
+31 FOR
SET IFN2=$ORDER(^LR(LRDFN,LRSS,IVDT,2,IFN,2,IFN1,1,IFN2))
IF IFN2<1
QUIT
SET X=^(IFN2,0)
Begin DoDot:3
+32 SET CTR1=CTR1+1
SET ^TMP("LRX",$JOB,69,CTR,63,CTR1)="ETIOLOGY^"_$$POINTER^LR7OB63(+("63."_NNN_17),.01,+X)_"^^^^"_Y6_"^"_SUB_"^CE^"_$PIECE($GET(^LAB(61.2,+X,0)),"^",2)_"^SNM^^^^^ETIOLOGY^^^"_Y18
End DoDot:3
End DoDot:2
+33 DO PTR(3,"FUNCTION",+("63."_NNN_85),.01,61.3,"")
+34 DO PTR(4,"PROCEDURE",+("63."_NNN_82),.01,61.5,"&CNP")
+35 SET IFN1=0
FOR
SET IFN1=$ORDER(^LR(LRDFN,LRSS,IVDT,2,IFN,5,IFN1))
IF IFN1<1
QUIT
SET X=^(IFN1,0)
SET IFN2=0
FOR
SET IFN2=$ORDER(^LR(LRDFN,LRSS,IVDT,2,IFN,5,IFN1,1,IFN2))
IF IFN2<1
QUIT
SET X1=^(IFN2,0)
Begin DoDot:2
+36 SET CTR1=CTR1+1
SET ^TMP("LRX",$JOB,69,CTR,3,CTR1)="SPECIAL STUDIES "_$$SET^LR7OB63(NN1,.01,$PIECE(X,"^"))_"~"_$PIECE(X,"^",2)_"^"_X1_"^^^^^^TX^^^^^^^SPEC STUDIES"_$$SET^LR7OB63(NN1,.01,$PIECE(X,"^"))_"~"_$PIECE(X,"^",2)_"^^^"_Y18
End DoDot:2
End DoDot:1
+37 SET IFN=0
FOR
SET IFN=$ORDER(^LR(LRDFN,LRSS,IVDT,3,IFN))
IF IFN<1
QUIT
Begin DoDot:1
+38 NEW LRX,LRTMP
+39 ; S LRX=^(IFN,0),LRX=$$ICDDX^ICDCODE(+LRX,,,1)
+40 ; IHS/MSC/MKK - LR*5.2*1034
SET LRX=^(IFN,0)
SET LRX=$$ICDDX^ICDEX(+LRX,,,"I")
+41 SET CTR1=CTR1+1
SET LRTMP="ICD DIAGNOSIS^"
+42 SET LRTMP=LRTMP_$PIECE(LRX,"^",4)_"^^^^"_Y6_"^^CE^"_$PIECE(LRX,"^",2)
+43 SET LRTMP=LRTMP_"^ICD9^&IMP^^^^^ICD DIAG^^^"_Y18
+44 SET ^TMP("LRX",$JOB,69,CTR,63,CTR1)=LRTMP
+45 QUIT
End DoDot:1
+46 QUIT
WP(I,NAME,ID,VALTYP) ;Store word processing fields
+1 ;I=Node at ^LR(LRDFN,LRSS,IVDT,I)
+2 ;NAME= Field name
+3 ;ID=Coded HL7 ID
+4 ;VALTYP="TX" for text, "CE" for Coded
+5 NEW IFN,IFN1,X
+6 IF 'I
QUIT
IF '$LENGTH(NAME)
QUIT
+7 SET IFN=0
FOR
SET IFN=$ORDER(^LR(LRDFN,LRSS,IVDT,I,IFN))
IF IFN<1
QUIT
SET X=^(IFN,0)
DO SPLIT^LR7OU1(X,"^TMP(""LRX"",$J,69,CTR,63)",.CTR1,80,NAME_"^","^^^^"_Y6_"^^"_VALTYP_"^^^"_ID_"^^^^"_NAME_"^^^"_Y18)
+8 QUIT
PTR(I,NAME,FILE,FIELD,SNMFILE,ID) ;Store ptr fields for ORGAN/TISSUE multiple
+1 ;I=Node at ^LR(LRDFN,LRSS,IVDT,2,IFN,I)
+2 ;NAME=Field name
+3 ;FILE=File #
+4 ;FIELD=Field #
+5 ;SNMFILE=Snomed file # for coded entry
+6 ;ID=Procedure ID Natl
+7 NEW IFN1
+8 IF 'I
QUIT
IF '$LENGTH(NAME)
QUIT
+9 SET IFN1=0
+10 FOR
SET IFN1=$ORDER(^LR(LRDFN,LRSS,IVDT,2,IFN,I,IFN1))
IF IFN1<1
QUIT
SET X=^(IFN1,0)
Begin DoDot:1
+11 SET CTR1=CTR1+1
SET ^TMP("LRX",$JOB,69,CTR,63,CTR1)=NAME_"^"_$$POINTER^LR7OB63(FILE,FIELD,+X)_"^^^^"_Y6_"^"_SUB_"^CE^"_$PIECE($GET(@("^LAB("_SNMFILE_","_+X_",0)")),"^",2)_"^SNM^"_ID_"^^^^"_NAME_"^^^"_Y18
End DoDot:1
+12 QUIT
MOD(IFN,FLDNM) ;Process Modified text fields
+1 ;IFN=Internal # of modified node
+2 ;FLDNM=Field name
+3 IF '$DATA(^LR(LRDFN,LRSS,IVDT,+IFN))
QUIT
SET IFN1=0
+4 NEW X,X1
+5 FOR
SET IFN1=$ORDER(^LR(LRDFN,LRSS,IVDT,+IFN,IFN1))
IF IFN1<1
QUIT
SET X=^(IFN1,0)
SET IFN2=0
Begin DoDot:1
+6 FOR
SET IFN2=$ORDER(^LR(LRDFN,LRSS,IVDT,+IFN,IFN1,1,IFN2))
IF IFN2<1
QUIT
SET X1=^(IFN2,0)
SET CTR1=CTR1+1
SET ^TMP("LRX",$JOB,69,CTR,63,CTR1)=FLDNM_"~"_+X_"^"_X1_"^^^^"_Y6_"^^TX^^^^^^^"_FLDNM_"^^^"_Y18
End DoDot:1
+7 QUIT