LRAPSNMD ;VA/DALOI/WTY - Display/print SNOMED codes;08/06/01
;;5.2;LAB SERVICE;**1030,1031**;NOV 01, 1997
;
;;VA LR Patch(s): 259
;
Q
INIT(LRDFN,LRSS,LRI,LRSF,LRAA,LRAN,LRAD,LRDEM,LRDEV) ;
; This routine displays SNOMED codes and their description for the
; given record in the LAB DATA (#63) file.
;
; LRDFN - IEN of the patient's record in the LAB DATA file (#63)
; LRSS - Anatomic Pathology section (i.e. "SP" for Surgical Pathology)
; LRI - Inverse date/time specimen taken
; LRSF - Anatomic Pathology sub-file number (i.e. 63.08 for Surg Path)
; LRAA - IEN of the accession area in the ACCESSION (#68) file
; LRAN - Accession Number
; LRAD - Accession Date
; LRDEM - Demographics Array. The following are used in the header
; code but are not required:
; LRDEM("PNM") - Patient Name
; LRDEM("PRO") - Provider
; LRDEM("AUDT") - Autopsy Date
; LRDEM("AUTYP") - Autopsy Type
; LRDEM("DTH") - Date of Death
; LRDEM("SSN") - Social Security Number
; LRDEM("SEX") - Sex
; LRDEM("AGE") - Age (or Age at Death for AU)
; LRDEM("DOB") - Date of Birth
; LRDEV - 1 indicates use device handling in this routine
; 0 indicates use device handling of calling application
;
N LRAU,LRQUIT,LRL
Q:'$D(LRSS)!('$D(LRDFN))!('$D(LRSF))!('$D(LRAA))!('+$G(LRAN))
Q:'+$G(LRAD)
S $P(LRL,"-",79)=""
S LRAU=$S(LRSS'="AU":0,1:1)
Q:'LRAU&('$D(LRI))
MAIN ;
S LRQUIT=0,LRDEV=+$G(LRDEV)
D:LRDEV ASKDEV
I $G(POP)!(LRQUIT) D END Q
D REPORT
D END
Q
CHECK ;
N LRSB
I LRAU D Q
.S LRSB=$Q(^LR(LRDFN,"AY",0))
.I $QS(LRSB,2)'="AY" D
..W !!,"No SNOMED codes found."
..S LRQUIT=1
S LRSB=$Q(^LR(LRDFN,LRSS,LRI,2,0))
I $QS(LRSB,4)'=2 D
.W !!,"No SNOMED codes found."
.S LRQUIT=1
Q
ASKDEV ;
W !
S %ZIS="Q" D ^%ZIS
I POP W ! S LRQUIT=1 Q
I $D(IO("Q")) D
.S ZTDESC="LIST OF SNOMED CODES FOR AN ACCESSION"
.S ZTSAVE("LR*")="",ZTRTN="REPORT^LRAPSNMD"
.D ^%ZTLOAD W:$D(ZTSK) !,"Request Queued, #",ZTSK W !
.K ZTSK,IO("Q") D HOME^%ZIS
.S LRQUIT=1
Q
REPORT ;
U IO W:IOST["C-" @IOF
N LRFILE,LRFILE1,LRFILE2,LRFILE3,LRCASE,LRX
N LRA,LRA1,LRA2,LRIENS,LRIENS1,LRIENS2,LRIENS3
N LRP1,LRP2,LRP3,LRP4,LRP5,LRDFP,LRPRFX,LRPG,LRACC,LRSEC
S LRIENS=LRAN_","_LRAD_","_LRAA_","
S LRACC=$$GET1^DIQ(68.02,LRIENS,15,"E")
S LRSEC=$$GET1^DIQ(68,LRAA_",",.01)
S (LRQUIT,LRPG)=0
D HDR
;Print Specimens
I 'LRAU D Q:LRQUIT
.W !,"Tissue Specimen(s): ",!
.S LRX=0
.F S LRX=$O(^LR(LRDFN,LRSS,LRI,.1,LRX)) Q:LRX'>0!(LRQUIT) D
..I $Y>(IOSL-5) D HDR Q:LRQUIT
..W ?5,$P($G(^LR(LRDFN,LRSS,LRI,.1,LRX,0)),U),!
D CHECK
Q:LRQUIT
I LRAU D
.S LRFILE="^LR(LRDFN,""AY"",",LRFILE1=63.2,LRIENS=LRDFN_",",LRCASE=1
I 'LRAU D
.S LRFILE="^LR(LRDFN,LRSS,LRI,2,"
.S LRFILE1=+$$GET1^DID(LRSF,10,"","SPECIFIER")
.S LRIENS=LRI_","_LRDFN_","
.S LRCASE=+$$GET1^DIQ(69.2,LRAA_",",.05,"I")
S LRA=0 F S LRA=$O(@(LRFILE_"LRA)")) Q:LRA'>0!(LRQUIT) D
.;Topography
.S LRIENS1=LRA_","_LRIENS
.D WRITE(LRFILE1,LRIENS1,LRCASE,"T",0)
.;Morphology
.S LRA1=0
.F S LRA1=$O(@(LRFILE_"LRA,2,LRA1)")) Q:LRA1'>0!(LRQUIT) D
..S LRFILE2=+$$GET1^DID(LRFILE1,4,"","SPECIFIER")
..S LRIENS2=LRA1_","_LRIENS1
..D WRITE(LRFILE2,LRIENS2,LRCASE,"M",5)
..;Etiology
..S LRA2=0
..F S LRA2=$O(@(LRFILE_"LRA,2,LRA1,1,LRA2)")) Q:LRA2'>0!(LRQUIT) D
...S LRFILE3=+$$GET1^DID(LRFILE2,1,"","SPECIFIER")
...S LRIENS3=LRA2_","_LRIENS2
...D WRITE(LRFILE3,LRIENS3,LRCASE,"E",10)
.;Disease,Function,Procedure
.F LRDFP="1;3","3;1","4;1.5" D
..S LRDFP(1)=$P(LRDFP,";"),LRDFP(2)=$P(LRDFP,";",2),LRA1=0
..F S LRA1=$O(@(LRFILE_"LRA,LRDFP(1),LRA1)")) Q:LRA1'>0!(LRQUIT) D
...S LRFILE2=+$$GET1^DID(LRFILE1,LRDFP(2),"","SPECIFIER")
...S LRIENS2=LRA1_","_LRIENS1
...S LRPRFX=$S(LRDFP(1)=1:"D",LRDFP(1)=3:"F",1:"P")
...D WRITE(LRFILE2,LRIENS2,LRCASE,LRPRFX,5)
Q:LRQUIT
W !!,$$CJ^XLFSTR("(End of Report)",IOM)
Q
WRITE(LRP1,LRP2,LRP3,LRP4,LRP5) ;
;LRP1=File number
;LRP2=IEN string
;LRP3=Case (Upper or Lower)
;LRP4=Prefix
;LRP5=Tab position
N LRSM
S LRSM(1)=$$GET1^DIQ(LRP1,LRP2,.01)
S:LRP3 LRSM(1)=$$LOW^XLFSTR(LRSM(1))
S LRSM(2)=LRP4_"-"_$$GET1^DIQ(LRP1,LRP2,".01:2")
W !?LRP5,LRSM(2)_": "_LRSM(1)
I LRP4="P" D
.S LRSM(3)=$$GET1^DIQ(LRP1,LRP2,.02,"I")
.Q:LRSM(3)=""
.W " (",$S('LRSM(3):"negative",LRSM(3)=1:"positive",1:"?"),")"
I $Y>(IOSL-5) D HDR
Q
HDR ;
I LRPG>0,IOST?1"C-".E D Q:LRQUIT
.K DIR S DIR(0)="E"
.D ^DIR W !
.S:$D(DTOUT)!(X[U) LRQUIT=1
W:LRPG>0 @IOF S LRPG=LRPG+1
W !,LRSEC,?24,"SNOMED CODE LISTING",?49,"Acc: ",LRACC
W:IOST'["BROWSE" ?71,"Pg: ",$J(LRPG,3)
W !,"Patient: ",$G(LRDEM("PNM"))
W ?49,$S(LRAU:"Resident: ",1:"Physician: ")
W $E($G(LRDEM("PRO")),1,18)
I LRAU D
.W !,"Autopsy Date: ",$G(LRDEM("AUDT")),?35,$E($G(LRDEM("AUTYP")),1,12)
.W ?49,"Date Died: ",$G(LRDEM("DTH"))
; W !,"ID: ",$G(LRDEM("SSN"))
W !,"ID: ",$$GETHRCN($G(LRDEM("SSN"))) ; IHS/MSC/MKK - LR*5.2*1031
I 'LRAU D
.W ?24,"Sex: ",$G(LRDEM("SEX")),?49,"DOB: ",$G(LRDEM("DOB"))
.W ?71,"Age:",$J($G(LRDEM("AGE")),3)
I LRAU D
.W ?24,"DOB: ",$G(LRDEM("DOB")),?49,"Age At Death: ",$G(LRDEM("AGE"))
.W ?72,"Sex: ",$G(LRDEM("SEX"))
W !,LRL
Q
END ;
W:IOST?1"P-".E @IOF
I LRDEV D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
K %,DIR,DTOUT,DUOUT,DIRUT,X,Y
Q
;
; ----- BEGIN IHS/MSC/MKK - LR*5.2*1031
GETHRCN(SOCN) ; EP - Given SSN, Return HRCN, if possible
Q:$L(SOCN) ""
;
; NEW all variables set by call to SSN^LRU
NEW DFN,LRDFN,LRDPF,HRCN,SSN,SEX,VA,VAERR
S DFN=+$O(^DPT("SSN",SOCN,0))
S LRDFN=+$G(^DPT(DFN,"LR"))
D SSN^LRU
;
Q HRCN
; ----- BEGIN IHS/MSC/MKK - LR*5.2*1031
LRAPSNMD ;VA/DALOI/WTY - Display/print SNOMED codes;08/06/01
+1 ;;5.2;LAB SERVICE;**1030,1031**;NOV 01, 1997
+2 ;
+3 ;;VA LR Patch(s): 259
+4 ;
+5 QUIT
INIT(LRDFN,LRSS,LRI,LRSF,LRAA,LRAN,LRAD,LRDEM,LRDEV) ;
+1 ; This routine displays SNOMED codes and their description for the
+2 ; given record in the LAB DATA (#63) file.
+3 ;
+4 ; LRDFN - IEN of the patient's record in the LAB DATA file (#63)
+5 ; LRSS - Anatomic Pathology section (i.e. "SP" for Surgical Pathology)
+6 ; LRI - Inverse date/time specimen taken
+7 ; LRSF - Anatomic Pathology sub-file number (i.e. 63.08 for Surg Path)
+8 ; LRAA - IEN of the accession area in the ACCESSION (#68) file
+9 ; LRAN - Accession Number
+10 ; LRAD - Accession Date
+11 ; LRDEM - Demographics Array. The following are used in the header
+12 ; code but are not required:
+13 ; LRDEM("PNM") - Patient Name
+14 ; LRDEM("PRO") - Provider
+15 ; LRDEM("AUDT") - Autopsy Date
+16 ; LRDEM("AUTYP") - Autopsy Type
+17 ; LRDEM("DTH") - Date of Death
+18 ; LRDEM("SSN") - Social Security Number
+19 ; LRDEM("SEX") - Sex
+20 ; LRDEM("AGE") - Age (or Age at Death for AU)
+21 ; LRDEM("DOB") - Date of Birth
+22 ; LRDEV - 1 indicates use device handling in this routine
+23 ; 0 indicates use device handling of calling application
+24 ;
+25 NEW LRAU,LRQUIT,LRL
+26 IF '$DATA(LRSS)!('$DATA(LRDFN))!('$DATA(LRSF))!('$DATA(LRAA))!('+$GET(LRAN))
QUIT
+27 IF '+$GET(LRAD)
QUIT
+28 SET $PIECE(LRL,"-",79)=""
+29 SET LRAU=$SELECT(LRSS'="AU":0,1:1)
+30 IF 'LRAU&('$DATA(LRI))
QUIT
MAIN ;
+1 SET LRQUIT=0
SET LRDEV=+$GET(LRDEV)
+2 IF LRDEV
DO ASKDEV
+3 IF $GET(POP)!(LRQUIT)
DO END
QUIT
+4 DO REPORT
+5 DO END
+6 QUIT
CHECK ;
+1 NEW LRSB
+2 IF LRAU
Begin DoDot:1
+3 SET LRSB=$QUERY(^LR(LRDFN,"AY",0))
+4 IF $QSUBSCRIPT(LRSB,2)'="AY"
Begin DoDot:2
+5 WRITE !!,"No SNOMED codes found."
+6 SET LRQUIT=1
End DoDot:2
End DoDot:1
QUIT
+7 SET LRSB=$QUERY(^LR(LRDFN,LRSS,LRI,2,0))
+8 IF $QSUBSCRIPT(LRSB,4)'=2
Begin DoDot:1
+9 WRITE !!,"No SNOMED codes found."
+10 SET LRQUIT=1
End DoDot:1
+11 QUIT
ASKDEV ;
+1 WRITE !
+2 SET %ZIS="Q"
DO ^%ZIS
+3 IF POP
WRITE !
SET LRQUIT=1
QUIT
+4 IF $DATA(IO("Q"))
Begin DoDot:1
+5 SET ZTDESC="LIST OF SNOMED CODES FOR AN ACCESSION"
+6 SET ZTSAVE("LR*")=""
SET ZTRTN="REPORT^LRAPSNMD"
+7 DO ^%ZTLOAD
IF $DATA(ZTSK)
WRITE !,"Request Queued, #",ZTSK
WRITE !
+8 KILL ZTSK,IO("Q")
DO HOME^%ZIS
+9 SET LRQUIT=1
End DoDot:1
+10 QUIT
REPORT ;
+1 USE IO
IF IOST["C-"
WRITE @IOF
+2 NEW LRFILE,LRFILE1,LRFILE2,LRFILE3,LRCASE,LRX
+3 NEW LRA,LRA1,LRA2,LRIENS,LRIENS1,LRIENS2,LRIENS3
+4 NEW LRP1,LRP2,LRP3,LRP4,LRP5,LRDFP,LRPRFX,LRPG,LRACC,LRSEC
+5 SET LRIENS=LRAN_","_LRAD_","_LRAA_","
+6 SET LRACC=$$GET1^DIQ(68.02,LRIENS,15,"E")
+7 SET LRSEC=$$GET1^DIQ(68,LRAA_",",.01)
+8 SET (LRQUIT,LRPG)=0
+9 DO HDR
+10 ;Print Specimens
+11 IF 'LRAU
Begin DoDot:1
+12 WRITE !,"Tissue Specimen(s): ",!
+13 SET LRX=0
+14 FOR
SET LRX=$ORDER(^LR(LRDFN,LRSS,LRI,.1,LRX))
IF LRX'>0!(LRQUIT)
QUIT
Begin DoDot:2
+15 IF $Y>(IOSL-5)
DO HDR
IF LRQUIT
QUIT
+16 WRITE ?5,$PIECE($GET(^LR(LRDFN,LRSS,LRI,.1,LRX,0)),U),!
End DoDot:2
End DoDot:1
IF LRQUIT
QUIT
+17 DO CHECK
+18 IF LRQUIT
QUIT
+19 IF LRAU
Begin DoDot:1
+20 SET LRFILE="^LR(LRDFN,""AY"","
SET LRFILE1=63.2
SET LRIENS=LRDFN_","
SET LRCASE=1
End DoDot:1
+21 IF 'LRAU
Begin DoDot:1
+22 SET LRFILE="^LR(LRDFN,LRSS,LRI,2,"
+23 SET LRFILE1=+$$GET1^DID(LRSF,10,"","SPECIFIER")
+24 SET LRIENS=LRI_","_LRDFN_","
+25 SET LRCASE=+$$GET1^DIQ(69.2,LRAA_",",.05,"I")
End DoDot:1
+26 SET LRA=0
FOR
SET LRA=$ORDER(@(LRFILE_"LRA)"))
IF LRA'>0!(LRQUIT)
QUIT
Begin DoDot:1
+27 ;Topography
+28 SET LRIENS1=LRA_","_LRIENS
+29 DO WRITE(LRFILE1,LRIENS1,LRCASE,"T",0)
+30 ;Morphology
+31 SET LRA1=0
+32 FOR
SET LRA1=$ORDER(@(LRFILE_"LRA,2,LRA1)"))
IF LRA1'>0!(LRQUIT)
QUIT
Begin DoDot:2
+33 SET LRFILE2=+$$GET1^DID(LRFILE1,4,"","SPECIFIER")
+34 SET LRIENS2=LRA1_","_LRIENS1
+35 DO WRITE(LRFILE2,LRIENS2,LRCASE,"M",5)
+36 ;Etiology
+37 SET LRA2=0
+38 FOR
SET LRA2=$ORDER(@(LRFILE_"LRA,2,LRA1,1,LRA2)"))
IF LRA2'>0!(LRQUIT)
QUIT
Begin DoDot:3
+39 SET LRFILE3=+$$GET1^DID(LRFILE2,1,"","SPECIFIER")
+40 SET LRIENS3=LRA2_","_LRIENS2
+41 DO WRITE(LRFILE3,LRIENS3,LRCASE,"E",10)
End DoDot:3
End DoDot:2
+42 ;Disease,Function,Procedure
+43 FOR LRDFP="1;3","3;1","4;1.5"
Begin DoDot:2
+44 SET LRDFP(1)=$PIECE(LRDFP,";")
SET LRDFP(2)=$PIECE(LRDFP,";",2)
SET LRA1=0
+45 FOR
SET LRA1=$ORDER(@(LRFILE_"LRA,LRDFP(1),LRA1)"))
IF LRA1'>0!(LRQUIT)
QUIT
Begin DoDot:3
+46 SET LRFILE2=+$$GET1^DID(LRFILE1,LRDFP(2),"","SPECIFIER")
+47 SET LRIENS2=LRA1_","_LRIENS1
+48 SET LRPRFX=$SELECT(LRDFP(1)=1:"D",LRDFP(1)=3:"F",1:"P")
+49 DO WRITE(LRFILE2,LRIENS2,LRCASE,LRPRFX,5)
End DoDot:3
End DoDot:2
End DoDot:1
+50 IF LRQUIT
QUIT
+51 WRITE !!,$$CJ^XLFSTR("(End of Report)",IOM)
+52 QUIT
WRITE(LRP1,LRP2,LRP3,LRP4,LRP5) ;
+1 ;LRP1=File number
+2 ;LRP2=IEN string
+3 ;LRP3=Case (Upper or Lower)
+4 ;LRP4=Prefix
+5 ;LRP5=Tab position
+6 NEW LRSM
+7 SET LRSM(1)=$$GET1^DIQ(LRP1,LRP2,.01)
+8 IF LRP3
SET LRSM(1)=$$LOW^XLFSTR(LRSM(1))
+9 SET LRSM(2)=LRP4_"-"_$$GET1^DIQ(LRP1,LRP2,".01:2")
+10 WRITE !?LRP5,LRSM(2)_": "_LRSM(1)
+11 IF LRP4="P"
Begin DoDot:1
+12 SET LRSM(3)=$$GET1^DIQ(LRP1,LRP2,.02,"I")
+13 IF LRSM(3)=""
QUIT
+14 WRITE " (",$SELECT('LRSM(3):"negative",LRSM(3)=1:"positive",1:"?"),")"
End DoDot:1
+15 IF $Y>(IOSL-5)
DO HDR
+16 QUIT
HDR ;
+1 IF LRPG>0
IF IOST?1"C-".E
Begin DoDot:1
+2 KILL DIR
SET DIR(0)="E"
+3 DO ^DIR
WRITE !
+4 IF $DATA(DTOUT)!(X[U)
SET LRQUIT=1
End DoDot:1
IF LRQUIT
QUIT
+5 IF LRPG>0
WRITE @IOF
SET LRPG=LRPG+1
+6 WRITE !,LRSEC,?24,"SNOMED CODE LISTING",?49,"Acc: ",LRACC
+7 IF IOST'["BROWSE"
WRITE ?71,"Pg: ",$JUSTIFY(LRPG,3)
+8 WRITE !,"Patient: ",$GET(LRDEM("PNM"))
+9 WRITE ?49,$SELECT(LRAU:"Resident: ",1:"Physician: ")
+10 WRITE $EXTRACT($GET(LRDEM("PRO")),1,18)
+11 IF LRAU
Begin DoDot:1
+12 WRITE !,"Autopsy Date: ",$GET(LRDEM("AUDT")),?35,$EXTRACT($GET(LRDEM("AUTYP")),1,12)
+13 WRITE ?49,"Date Died: ",$GET(LRDEM("DTH"))
End DoDot:1
+14 ; W !,"ID: ",$G(LRDEM("SSN"))
+15 ; IHS/MSC/MKK - LR*5.2*1031
WRITE !,"ID: ",$$GETHRCN($GET(LRDEM("SSN")))
+16 IF 'LRAU
Begin DoDot:1
+17 WRITE ?24,"Sex: ",$GET(LRDEM("SEX")),?49,"DOB: ",$GET(LRDEM("DOB"))
+18 WRITE ?71,"Age:",$JUSTIFY($GET(LRDEM("AGE")),3)
End DoDot:1
+19 IF LRAU
Begin DoDot:1
+20 WRITE ?24,"DOB: ",$GET(LRDEM("DOB")),?49,"Age At Death: ",$GET(LRDEM("AGE"))
+21 WRITE ?72,"Sex: ",$GET(LRDEM("SEX"))
End DoDot:1
+22 WRITE !,LRL
+23 QUIT
END ;
+1 IF IOST?1"P-".E
WRITE @IOF
+2 IF LRDEV
DO ^%ZISC
IF $DATA(ZTQUEUED)
SET ZTREQ="@"
+3 KILL %,DIR,DTOUT,DUOUT,DIRUT,X,Y
+4 QUIT
+5 ;
+6 ; ----- BEGIN IHS/MSC/MKK - LR*5.2*1031
GETHRCN(SOCN) ; EP - Given SSN, Return HRCN, if possible
+1 IF $LENGTH(SOCN)
QUIT ""
+2 ;
+3 ; NEW all variables set by call to SSN^LRU
+4 NEW DFN,LRDFN,LRDPF,HRCN,SSN,SEX,VA,VAERR
+5 SET DFN=+$ORDER(^DPT("SSN",SOCN,0))
+6 SET LRDFN=+$GET(^DPT(DFN,"LR"))
+7 DO SSN^LRU
+8 ;
+9 QUIT HRCN
+10 ; ----- BEGIN IHS/MSC/MKK - LR*5.2*1031