Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: PXRMRCPT

PXRMRCPT.m

Go to the documentation of this file.
PXRMRCPT ; SLC/PKR - Code to handle radiology CPT data. ;12/19/2012
 ;;2.0;CLINICAL REMINDERS;**4,12,26**;Feb 04, 2005;Build 404
 ;
 ;==============================================
FPDAT(DFN,TAXARR,NOCC,BDT,EDT,STATUSA,FLIST) ;Find radiology procedures for a
 ;patient from the linkage of a radiology procedure to a CPT4 code.
 N CPT4P,CODE,DATE,FIEVT,IND,NOCCABS,NFOUND,PFINDPA
 N RADIEN,SDIR,TE,TDATE,TIND,TF,TLIST
 I TAXARR("APDS",71,"NNODES")=0 Q
 I $G(^PXRMINDX(70,"DATE BUILT"))="" D  Q
 . D NOINDEX^PXRMERRH("TX",TAXARR("IEN"),70)
 I '$D(^PXRMINDX(70,"PI",DFN)) Q
 S $P(PFINDPA(0),U,8)=BDT
 S $P(PFINDPA(0),U,11)=EDT
 S $P(PFINDPA(0),U,14)=NOCC
 S SDIR=$S(NOCC<0:+1,1:-1)
 F IND=1:1:STATUSA(0) S PFINDPA(5,IND)=STATUSA(IND)
 S NFOUND=0,CPT4P=""
 F  S CPT4P=$O(TAXARR("AE","CPT",CPT4P)) Q:CPT4P=""  D
 . S RADIEN=""
 .;DBIA #586
 . F  S RADIEN=$O(^RAMIS(71,"D",CPT4P,RADIEN)) Q:RADIEN=""  D
 .. I '$D(^PXRMINDX(70,"PI",DFN,RADIEN)) Q
 .. K FIEVT
 .. D FIEVAL^PXRMINDX(70,"PI",DFN,RADIEN,.PFINDPA,.FIEVT)
 .. I FIEVT D
 ...;DBIA #1995
 ... S CODE=$P($$CPT^ICPTCOD(CPT4P),U,2)
 ... S IND=0
 ... F  S IND=+$O(FIEVT(IND)) Q:IND=0  D
 .... S NFOUND=NFOUND+1
 .... S TLIST(FIEVT(IND,"DATE"),NFOUND)=FIEVT(IND,"DAS")_U_FIEVT(IND,"DATE")_U_"CPT4"_U_CODE_U_U_RADIEN
 .... I NFOUND>NGET D
 ..... S TDATE=$O(TLIST(""),-SDIR),TIND=$O(TLIST(TDATE,""))
 ..... K TLIST(TDATE,TIND)
 ;Return up to NOCC of the most recent entries.
 S NOCCABS=$S(NOCC<0:-NOCC,1:NOCC)
 S NFOUND=0
 S DATE=""
 F  S DATE=$O(TLIST(DATE),SDIR) Q:(DATE="")!(NFOUND=NOCCABS)  D
 . S IND=0
 . F  S IND=$O(TLIST(DATE,IND)) Q:(IND="")!(NFOUND=NOCCABS)  D
 .. S NFOUND=NFOUND+1
 .. S FLIST(DATE,NFOUND,70)=TLIST(DATE,IND)
 Q
 ;
 ;==============================================
GPLIST(TAXARR,PFINDPA,PLIST) ;Build a patient list for radiology procedures
 ;based on the linkage to CPT4 codes.
 N CPT4P,DAS,DATE,DFN,NFOUND
 N RADIEN,TEMP,TF,TLIST,VALUE
 I TAXARR("APDS",71,"NNODES")=0 Q
 I $G(^PXRMINDX(70,"DATE BUILT"))="" D  Q
 . D NOINDEX^PXRMERRH("TX",TAXARR("IEN"),70)
 S TLIST="GPLIST_PXRMRCPT"
 S CPT4P=""
 F  S CPT4P=$O(TAXARR("AE","CPT",CPT4P)) Q:CPT4P=""  D
 . S RADIEN=""
 .;DBIA #586
 . F  S RADIEN=$O(^RAMIS(71,"D",CPT4P,RADIEN)) Q:RADIEN=""  D
 .. I '$D(^PXRMINDX(70,"IP",RADIEN)) Q
 .. S CPT4P=TAXARR("AE","RADPROC",RADIEN)
 .. K ^TMP($J,TLIST)
 .. D GPLIST^PXRMINDL(70,"IP",RADIEN,.PFINDPA,TLIST)
 .. F TF=0,1 D
 ... S DFN=0
 ... F  S DFN=$O(^TMP($J,TLIST,TF,DFN)) Q:DFN=""  D
 .... S NFOUND=0
 .... F  S NFOUND=$O(^TMP($J,TLIST,TF,DFN,RADIEN,NFOUND)) Q:NFOUND=""  D
 ..... S TEMP=^TMP($J,TLIST,TF,DFN,RADIEN,NFOUND,70)
 ..... S DAS=$P(TEMP,U,1)
 ..... S DATE=$P(TEMP,U,2)
 ..... S VALUE=$P(TEMP,U,4)
 ..... S ^TMP($J,PLIST,TF,DFN,DATE,70)=DAS_U_DATE_U_CPT4P_U_"CPT"_U_VALUE
 K ^TMP($J,TLIST)
 Q
 ;
 ;==============================================
MHVOUT(INDENT,OCCLIST,IFIEVAL,NLINES,TEXT) ;Produce the MHV output.
 N CODE,CDATA,DATE,ICPTP,IND,JND,NAME,NOUT,RESULT,TEXTIN,TEXTOUT
 S NAME="Radiology Procedure = "
 S IND=0
 F  S IND=$O(OCCLIST(IND)) Q:IND=""  D
 . S CODE=IFIEVAL(IND,"CODE")
 . S CODESYS=IFIEVAL(IND,"CODESYS")
 .;DBIA #5679
 . I '$D(CODESYSN(CODESYS)) S CODESYSN(CODESYS)=$P($$CSYS^LEXU(CODESYS),U,4)
 . S DATE=IFIEVAL(IND,"DATE")
 . K CDATA
 .;DBIA #5679
 . S RESULT=$$CSDATA^LEXU(CODE,CODESYS,DATE,.CDATA)
 . S DATE=IFIEVAL(IND,"DATE")
 . S TEXTIN(1)=NAME_" "_IFIEVAL(IND,"PROCEDURE")_"\\"
 . S TEXTIN(2)=$P(CDATA("LEX",1),U,2)_" ("_$$EDATE^PXRMDATE(DATE)_")"
 . D FORMAT^PXRMTEXT(INDENT+2,PXRMRM,2,.TEXTIN,.NOUT,.TEXTOUT)
 . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
 S NLINES=NLINES+1,TEXT(NLINES)=""
 Q
 ;
 ;==============================================
OUTPUT(INDENT,OCCLIST,IFIEVAL,NLINES,TEXT) ;Produce the clinical
 ;maintenance output.
 N CDATA,CODE,CODESYS,CODESYSN,DATE,IND,JND,NOUT,RESULT
 N TAXIEN,TEMP,TEXTIN,TEXTOUT
 S TEMP=IFIEVAL("FINDING")
 S TAXIEN=$P(TEMP,";",1)
 S TEMP="Radiology Procedure(s) from taxonomy "_$P(^PXD(811.2,TAXIEN,0),U,1)
 S NLINES=NLINES+1
 S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_TEMP
 S IND=0
 F  S IND=$O(OCCLIST(IND)) Q:IND=""  D
 . S CODE=IFIEVAL(IND,"CODE")
 . S CODESYS=IFIEVAL(IND,"CODESYS")
 .;DBIA #5679
 . I '$D(CODESYSN(CODESYS)) S CODESYSN(CODESYS)=$P($$CSYS^LEXU(CODESYS),U,4)
 . S DATE=IFIEVAL(IND,"DATE")
 . K CDATA
 .;DBIA #5679
 . S RESULT=$$CSDATA^LEXU(CODE,CODESYS,DATE,.CDATA)
 . S TEXTIN(1)=$$EDATE^PXRMDATE(DATE)_" "_IFIEVAL(IND,"PROCEDURE")_"\\"
 . S TEXTIN(2)=CODESYSN(CODESYS)_": "_CODE_" - "_$P(CDATA("LEX",1),U,2)_"\\"
 . S TEXTIN(3)="Status: "_IFIEVAL(IND,"STATUS")
 . S TEXTIN(4)="; Report Status: "_IFIEVAL(IND,"RPT STATUS")
 . D FORMAT^PXRMTEXT(INDENT+2,PXRMRM,4,.TEXTIN,.NOUT,.TEXTOUT)
 . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
 S NLINES=NLINES+1,TEXT(NLINES)=""
 Q
 ;