LA7UTL03 ;HOIFO/BH - Surgical Pathology Query Utility ; 3/11/03 10:45am
;;5.2;AUTOMATED LAB INSTRUMENTS;**69**;Sep 27, 1994
;
;
SPATH(LRDFN,IEN,RET,ERR) ; Returns data for a given SP Encounter
;
; Input:
;
; LRDFN - Patient Lab DFN (Required)
; IEN - IEN of SP entry (Required)
; RET - Array reference for passing back data (Required)
; ERR - Error array to pass back (Not required)
;
; Output:
;
; '0' - If the API encountered an Error along with @ERR array
;
; '1' - if the API ran successfully and the following data if it exists
;
; Specimen field .01 of file 63.812.
; @RET("SPEC",ien of Specimen entry)=Specimen Data
;
; Clinical History field .01 of sub file 63.813.
; @RET("CHIS",ien of the Clinical History entry)=Clinical His.
;
; Pre Operative Diagnosis field .01 of sub file 63.814.
; @RET@("PREDX",ien of the Pre. Op. Diagnosis entry)=Pre Op Diag.
;
; Operative Diagnosis field .01 of sub file 63.815.
; @RET@("OPERDX",ien of the Op. Diagnosis entry)=Op Diag.
;
; Post Operative Diagnosis field .01 of sub file 63.816.
; @RET@("POSTDX,ien of the Post. Op Diagnosis entry)=Pst. Op Diag.
;
; Gross Description field .01 of sub file 63.81.
; @RET@("GROSSD",ien of the Gross Description entry)=Gross Desc.
;
; Microscopic Description field .01 of sub file 63.811.
; @RET@("MICROD",ien of the Microspc. Description entry)=Micro Desc.
;
; Surgical Pathology field .01 of sub file 63.802.
; @RET@("SURGP",ien of the Surgical Path. entry)=Surgical Path.
;
; ICD field .01 of sub file 63.88.
; @RET@("ICD9",ien of the ICD9 entry)=ICD9
;
K @RET
K @ERR
I $G(LRDFN)="" D Q 0
. I $G(ERR)'="" S @ERR@("-1")="No Lab DFN." Q
;
I $G(IEN)="" D Q 0
. I $G(ERR)'="" S @ERR@("-1")="No Surgical Pathology record IEN." Q
;
I $G(RET)="" D Q 0
. I $G(ERR)'="" S @ERR@("-1")="No results array reference passed." Q
;
;
N QUIT
D SPECIMEN
I 'QUIT D HISTORY
I 'QUIT D PDIAG
I 'QUIT D OPDIAG
I 'QUIT D POSTDIAG
I 'QUIT D GROSSD
I 'QUIT D MICROD
I 'QUIT D SURGPATH
I 'QUIT D ICD
I QUIT Q 0
Q 1
;
;
SPECIMEN ;
N SPIENS,SPIEN,SPECIMEN S SPIEN="0",QUIT=0
F S SPIEN=$O(^LR(LRDFN,"SP",IEN,.1,SPIEN)) Q:'SPIEN!(QUIT) D
. Q:QUIT
. S SPIENS=SPIEN_","_IEN_","_LRDFN_","
. S SPECIMEN=$$GET1^DIQ(63.812,SPIENS,.01,"I")
. I $G(DIERR) D Q
. . K @RET
. . I $G(ERR)'="" S @ERR@("-1")="Fileman Error within GET1 call (Specimen data)."
. . S QUIT=1
. I SPECIMEN="" Q
. S @RET@("SPEC",SPIEN)=SPECIMEN
Q
;
;
HISTORY N CHIENS,CHIEN,HISTORY S CHIEN="0"
F S CHIEN=$O(^LR(LRDFN,"SP",IEN,.2,CHIEN)) Q:'CHIEN!(QUIT) D
. Q:QUIT
. S CHIENS=CHIEN_","_IEN_","_LRDFN_","
. S HISTORY=$$GET1^DIQ(63.813,CHIENS,.01,"I")
. I $G(DIERR) D Q
. . K @RET
. . I $G(ERR)'="" S @ERR@("-1")="Fileman Error within GET1 call (Clinical History data)."
. . S QUIT=1
. I HISTORY="" Q
. S @RET@("CHIS",CHIEN)=HISTORY
Q
;
PDIAG N PDIENS,PDIEN,PREOPDX S PDIEN="0"
F S PDIEN=$O(^LR(LRDFN,"SP",IEN,.3,PDIEN)) Q:'PDIEN!(QUIT) D
. Q:QUIT
. S PDIENS=PDIEN_","_IEN_","_LRDFN_","
. S PREOPDX=$$GET1^DIQ(63.814,PDIENS,.01,"I")
. I $G(DIERR) D Q
. . K @RET
. . I $G(ERR)'="" S @ERR@("-1")="Fileman Error within GET1 call (Pre Operative Diagnosis data)."
. . S QUIT=1
. I PREOPDX="" Q
. S @RET@("PREDX",PDIEN)=PREOPDX
Q
;
;
OPDIAG N ODIENS,ODIEN,OPERDX S ODIEN="0"
F S ODIEN=$O(^LR(LRDFN,"SP",IEN,.4,ODIEN)) Q:'ODIEN!(QUIT) D
. Q:QUIT
. S ODIENS=ODIEN_","_IEN_","_LRDFN_","
. S OPERDX=$$GET1^DIQ(63.815,ODIENS,.01,"I")
. I $G(DIERR) D Q
. . K @RET
. . I $G(ERR)'="" S @ERR@("-1")="Fileman Error within GET1 call (Operative Diagnosis data)."
. . S QUIT=1
. I OPERDX="" Q
. S @RET@("OPERDX",ODIEN)=OPERDX
Q
;
;
POSTDIAG ;
N PSDIENS,PSDIEN,POSTDX S PSDIEN="0"
F S PSDIEN=$O(^LR(LRDFN,"SP",IEN,.5,PSDIEN)) Q:'PSDIEN!(QUIT) D
. Q:QUIT
. S PSDIENS=PSDIEN_","_IEN_","_LRDFN_","
. S POSTDX=$$GET1^DIQ(63.816,PSDIENS,.01,"I")
. I $G(DIERR) D Q
. . K @RET
. . I $G(ERR)'="" S @ERR@("-1")="Fileman Error within GET1 call (Post Operative Diagnosis data)."
. . S QUIT=1
. I POSTDX="" Q
. S @RET@("POSTDX",PSDIEN)=POSTDX
Q
;
;- Gross Description Data
GROSSD N GDIENS,GDIEN,GROSSD S GDIEN="0"
F S GDIEN=$O(^LR(LRDFN,"SP",IEN,1,GDIEN)) Q:'GDIEN!(QUIT) D
. Q:QUIT
. S GDIENS=GDIEN_","_IEN_","_LRDFN_","
. S GROSSD=$$GET1^DIQ(63.81,GDIENS,.01,"I")
. I $G(DIERR) D Q
. . K @RET
. . I $G(ERR)'="" S @ERR@("-1")="Fileman Error within GET1 call (Gross Description data)."
. . S QUIT=1
. I GROSSD="" Q
. S @RET@("GROSSD",GDIEN)=GROSSD
Q
;
MICROD ; Microscopic Description
N MDIENS,MDIEN,MICROD S MDIEN="0"
F S MDIEN=$O(^LR(LRDFN,"SP",IEN,1.1,MDIEN)) Q:'MDIEN!(QUIT) D
. Q:QUIT
. S MDIENS=MDIEN_","_IEN_","_LRDFN_","
. S MICROD=$$GET1^DIQ(63.811,MDIENS,.01,"I")
. I $G(DIERR) D Q
. . K @RET
. . I $G(ERR)'="" S @ERR@("-1")="Fileman Error within GET1 call (Microscopic Description data)."
. . S QUIT=1
. I MICROD="" Q
. S @RET@("MICROD",MDIEN)=MICROD
Q
;
SURGPATH ; - Surgical Pathology
N SGIENS,SGIEN,SURGP S SGIEN="0"
F S SGIEN=$O(^LR(LRDFN,"SP",IEN,1.4,SGIEN)) Q:'SGIEN!(QUIT) D
. Q:QUIT
. S SGIENS=SGIEN_","_IEN_","_LRDFN_","
. S SURGP=$$GET1^DIQ(63.802,SGIENS,.01,"I")
. I $G(DIERR) D Q
. . K @RET
. . I $G(ERR)'="" S @ERR@("-1")="Fileman Error within GET1 call (Surgical Pathology data)."
. . S QUIT=1
. I SURGP="" Q
. S @RET@("SURGP",SGIEN)=SURGP
Q
;
ICD ; - Get ICD Data
N ICDIENS,ICDIEN,ICD9 S ICDIEN="0"
F S ICDIEN=$O(^LR(LRDFN,"SP",IEN,3,ICDIEN)) Q:'ICDIEN!(QUIT) D
. Q:QUIT
. S ICDIENS=ICDIEN_","_IEN_","_LRDFN_","
. S ICD9=$$GET1^DIQ(63.88,ICDIENS,.01,"E")
. I $G(DIERR) D Q
. . K @RET
. . I $G(ERR)'="" S @ERR@("-1")="Fileman Error within GET1 call (ICD9 data)."
. . S QUIT=1
. I ICD9="" Q
. S @RET@("ICD9",ICDIEN)=ICD9
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HLA7UTL03 6078 printed Nov 22, 2024@16:50:13 Page 2
LA7UTL03 ;HOIFO/BH - Surgical Pathology Query Utility ; 3/11/03 10:45am
+1 ;;5.2;AUTOMATED LAB INSTRUMENTS;**69**;Sep 27, 1994
+2 ;
+3 ;
SPATH(LRDFN,IEN,RET,ERR) ; Returns data for a given SP Encounter
+1 ;
+2 ; Input:
+3 ;
+4 ; LRDFN - Patient Lab DFN (Required)
+5 ; IEN - IEN of SP entry (Required)
+6 ; RET - Array reference for passing back data (Required)
+7 ; ERR - Error array to pass back (Not required)
+8 ;
+9 ; Output:
+10 ;
+11 ; '0' - If the API encountered an Error along with @ERR array
+12 ;
+13 ; '1' - if the API ran successfully and the following data if it exists
+14 ;
+15 ; Specimen field .01 of file 63.812.
+16 ; @RET("SPEC",ien of Specimen entry)=Specimen Data
+17 ;
+18 ; Clinical History field .01 of sub file 63.813.
+19 ; @RET("CHIS",ien of the Clinical History entry)=Clinical His.
+20 ;
+21 ; Pre Operative Diagnosis field .01 of sub file 63.814.
+22 ; @RET@("PREDX",ien of the Pre. Op. Diagnosis entry)=Pre Op Diag.
+23 ;
+24 ; Operative Diagnosis field .01 of sub file 63.815.
+25 ; @RET@("OPERDX",ien of the Op. Diagnosis entry)=Op Diag.
+26 ;
+27 ; Post Operative Diagnosis field .01 of sub file 63.816.
+28 ; @RET@("POSTDX,ien of the Post. Op Diagnosis entry)=Pst. Op Diag.
+29 ;
+30 ; Gross Description field .01 of sub file 63.81.
+31 ; @RET@("GROSSD",ien of the Gross Description entry)=Gross Desc.
+32 ;
+33 ; Microscopic Description field .01 of sub file 63.811.
+34 ; @RET@("MICROD",ien of the Microspc. Description entry)=Micro Desc.
+35 ;
+36 ; Surgical Pathology field .01 of sub file 63.802.
+37 ; @RET@("SURGP",ien of the Surgical Path. entry)=Surgical Path.
+38 ;
+39 ; ICD field .01 of sub file 63.88.
+40 ; @RET@("ICD9",ien of the ICD9 entry)=ICD9
+41 ;
+42 KILL @RET
+43 KILL @ERR
+44 IF $GET(LRDFN)=""
Begin DoDot:1
+45 IF $GET(ERR)'=""
SET @ERR@("-1")="No Lab DFN."
QUIT
End DoDot:1
QUIT 0
+46 ;
+47 IF $GET(IEN)=""
Begin DoDot:1
+48 IF $GET(ERR)'=""
SET @ERR@("-1")="No Surgical Pathology record IEN."
QUIT
End DoDot:1
QUIT 0
+49 ;
+50 IF $GET(RET)=""
Begin DoDot:1
+51 IF $GET(ERR)'=""
SET @ERR@("-1")="No results array reference passed."
QUIT
End DoDot:1
QUIT 0
+52 ;
+53 ;
+54 NEW QUIT
+55 DO SPECIMEN
+56 IF 'QUIT
DO HISTORY
+57 IF 'QUIT
DO PDIAG
+58 IF 'QUIT
DO OPDIAG
+59 IF 'QUIT
DO POSTDIAG
+60 IF 'QUIT
DO GROSSD
+61 IF 'QUIT
DO MICROD
+62 IF 'QUIT
DO SURGPATH
+63 IF 'QUIT
DO ICD
+64 IF QUIT
QUIT 0
+65 QUIT 1
+66 ;
+67 ;
SPECIMEN ;
+1 NEW SPIENS,SPIEN,SPECIMEN
SET SPIEN="0"
SET QUIT=0
+2 FOR
SET SPIEN=$ORDER(^LR(LRDFN,"SP",IEN,.1,SPIEN))
if 'SPIEN!(QUIT)
QUIT
Begin DoDot:1
+3 if QUIT
QUIT
+4 SET SPIENS=SPIEN_","_IEN_","_LRDFN_","
+5 SET SPECIMEN=$$GET1^DIQ(63.812,SPIENS,.01,"I")
+6 IF $GET(DIERR)
Begin DoDot:2
+7 KILL @RET
+8 IF $GET(ERR)'=""
SET @ERR@("-1")="Fileman Error within GET1 call (Specimen data)."
+9 SET QUIT=1
End DoDot:2
QUIT
+10 IF SPECIMEN=""
QUIT
+11 SET @RET@("SPEC",SPIEN)=SPECIMEN
End DoDot:1
+12 QUIT
+13 ;
+14 ;
HISTORY NEW CHIENS,CHIEN,HISTORY
SET CHIEN="0"
+1 FOR
SET CHIEN=$ORDER(^LR(LRDFN,"SP",IEN,.2,CHIEN))
if 'CHIEN!(QUIT)
QUIT
Begin DoDot:1
+2 if QUIT
QUIT
+3 SET CHIENS=CHIEN_","_IEN_","_LRDFN_","
+4 SET HISTORY=$$GET1^DIQ(63.813,CHIENS,.01,"I")
+5 IF $GET(DIERR)
Begin DoDot:2
+6 KILL @RET
+7 IF $GET(ERR)'=""
SET @ERR@("-1")="Fileman Error within GET1 call (Clinical History data)."
+8 SET QUIT=1
End DoDot:2
QUIT
+9 IF HISTORY=""
QUIT
+10 SET @RET@("CHIS",CHIEN)=HISTORY
End DoDot:1
+11 QUIT
+12 ;
PDIAG NEW PDIENS,PDIEN,PREOPDX
SET PDIEN="0"
+1 FOR
SET PDIEN=$ORDER(^LR(LRDFN,"SP",IEN,.3,PDIEN))
if 'PDIEN!(QUIT)
QUIT
Begin DoDot:1
+2 if QUIT
QUIT
+3 SET PDIENS=PDIEN_","_IEN_","_LRDFN_","
+4 SET PREOPDX=$$GET1^DIQ(63.814,PDIENS,.01,"I")
+5 IF $GET(DIERR)
Begin DoDot:2
+6 KILL @RET
+7 IF $GET(ERR)'=""
SET @ERR@("-1")="Fileman Error within GET1 call (Pre Operative Diagnosis data)."
+8 SET QUIT=1
End DoDot:2
QUIT
+9 IF PREOPDX=""
QUIT
+10 SET @RET@("PREDX",PDIEN)=PREOPDX
End DoDot:1
+11 QUIT
+12 ;
+13 ;
OPDIAG NEW ODIENS,ODIEN,OPERDX
SET ODIEN="0"
+1 FOR
SET ODIEN=$ORDER(^LR(LRDFN,"SP",IEN,.4,ODIEN))
if 'ODIEN!(QUIT)
QUIT
Begin DoDot:1
+2 if QUIT
QUIT
+3 SET ODIENS=ODIEN_","_IEN_","_LRDFN_","
+4 SET OPERDX=$$GET1^DIQ(63.815,ODIENS,.01,"I")
+5 IF $GET(DIERR)
Begin DoDot:2
+6 KILL @RET
+7 IF $GET(ERR)'=""
SET @ERR@("-1")="Fileman Error within GET1 call (Operative Diagnosis data)."
+8 SET QUIT=1
End DoDot:2
QUIT
+9 IF OPERDX=""
QUIT
+10 SET @RET@("OPERDX",ODIEN)=OPERDX
End DoDot:1
+11 QUIT
+12 ;
+13 ;
POSTDIAG ;
+1 NEW PSDIENS,PSDIEN,POSTDX
SET PSDIEN="0"
+2 FOR
SET PSDIEN=$ORDER(^LR(LRDFN,"SP",IEN,.5,PSDIEN))
if 'PSDIEN!(QUIT)
QUIT
Begin DoDot:1
+3 if QUIT
QUIT
+4 SET PSDIENS=PSDIEN_","_IEN_","_LRDFN_","
+5 SET POSTDX=$$GET1^DIQ(63.816,PSDIENS,.01,"I")
+6 IF $GET(DIERR)
Begin DoDot:2
+7 KILL @RET
+8 IF $GET(ERR)'=""
SET @ERR@("-1")="Fileman Error within GET1 call (Post Operative Diagnosis data)."
+9 SET QUIT=1
End DoDot:2
QUIT
+10 IF POSTDX=""
QUIT
+11 SET @RET@("POSTDX",PSDIEN)=POSTDX
End DoDot:1
+12 QUIT
+13 ;
+14 ;- Gross Description Data
GROSSD NEW GDIENS,GDIEN,GROSSD
SET GDIEN="0"
+1 FOR
SET GDIEN=$ORDER(^LR(LRDFN,"SP",IEN,1,GDIEN))
if 'GDIEN!(QUIT)
QUIT
Begin DoDot:1
+2 if QUIT
QUIT
+3 SET GDIENS=GDIEN_","_IEN_","_LRDFN_","
+4 SET GROSSD=$$GET1^DIQ(63.81,GDIENS,.01,"I")
+5 IF $GET(DIERR)
Begin DoDot:2
+6 KILL @RET
+7 IF $GET(ERR)'=""
SET @ERR@("-1")="Fileman Error within GET1 call (Gross Description data)."
+8 SET QUIT=1
End DoDot:2
QUIT
+9 IF GROSSD=""
QUIT
+10 SET @RET@("GROSSD",GDIEN)=GROSSD
End DoDot:1
+11 QUIT
+12 ;
MICROD ; Microscopic Description
+1 NEW MDIENS,MDIEN,MICROD
SET MDIEN="0"
+2 FOR
SET MDIEN=$ORDER(^LR(LRDFN,"SP",IEN,1.1,MDIEN))
if 'MDIEN!(QUIT)
QUIT
Begin DoDot:1
+3 if QUIT
QUIT
+4 SET MDIENS=MDIEN_","_IEN_","_LRDFN_","
+5 SET MICROD=$$GET1^DIQ(63.811,MDIENS,.01,"I")
+6 IF $GET(DIERR)
Begin DoDot:2
+7 KILL @RET
+8 IF $GET(ERR)'=""
SET @ERR@("-1")="Fileman Error within GET1 call (Microscopic Description data)."
+9 SET QUIT=1
End DoDot:2
QUIT
+10 IF MICROD=""
QUIT
+11 SET @RET@("MICROD",MDIEN)=MICROD
End DoDot:1
+12 QUIT
+13 ;
SURGPATH ; - Surgical Pathology
+1 NEW SGIENS,SGIEN,SURGP
SET SGIEN="0"
+2 FOR
SET SGIEN=$ORDER(^LR(LRDFN,"SP",IEN,1.4,SGIEN))
if 'SGIEN!(QUIT)
QUIT
Begin DoDot:1
+3 if QUIT
QUIT
+4 SET SGIENS=SGIEN_","_IEN_","_LRDFN_","
+5 SET SURGP=$$GET1^DIQ(63.802,SGIENS,.01,"I")
+6 IF $GET(DIERR)
Begin DoDot:2
+7 KILL @RET
+8 IF $GET(ERR)'=""
SET @ERR@("-1")="Fileman Error within GET1 call (Surgical Pathology data)."
+9 SET QUIT=1
End DoDot:2
QUIT
+10 IF SURGP=""
QUIT
+11 SET @RET@("SURGP",SGIEN)=SURGP
End DoDot:1
+12 QUIT
+13 ;
ICD ; - Get ICD Data
+1 NEW ICDIENS,ICDIEN,ICD9
SET ICDIEN="0"
+2 FOR
SET ICDIEN=$ORDER(^LR(LRDFN,"SP",IEN,3,ICDIEN))
if 'ICDIEN!(QUIT)
QUIT
Begin DoDot:1
+3 if QUIT
QUIT
+4 SET ICDIENS=ICDIEN_","_IEN_","_LRDFN_","
+5 SET ICD9=$$GET1^DIQ(63.88,ICDIENS,.01,"E")
+6 IF $GET(DIERR)
Begin DoDot:2
+7 KILL @RET
+8 IF $GET(ERR)'=""
SET @ERR@("-1")="Fileman Error within GET1 call (ICD9 data)."
+9 SET QUIT=1
End DoDot:2
QUIT
+10 IF ICD9=""
QUIT
+11 SET @RET@("ICD9",ICDIEN)=ICD9
End DoDot:1
+12 QUIT
+13 ;