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

PXRMVSC.m

Go to the documentation of this file.
PXRMVSC ; SLC/PKR - Code to handle V Standard Codes data. ;02/03/2022
 ;;2.0;CLINICAL REMINDERS;**42,65**;Feb 04, 2005;Build 438
 ;
 ;===============================================
FPDAT(DFN,TAXARR,NGET,SDIR,BDT,EDT,FLIST) ;Find data for a patient.
 N CODESYS,CSYST,DATE,DS,EDTT,IND,NFOUND,NNODES,TLIST
 S NNODES=TAXARR("APDS",9000010.71,"NNODES")
 I NNODES=0 Q
 I $G(^PXRMINDX(9000010.71,"DATE BUILT"))="" D  Q
 . D NOINDEX^PXRMERRH("TX",TAXARR("IEN"),9000010.71)
 I '$D(^PXRMINDX(9000010.71,"PI",DFN)) Q
 S EDTT=$S(EDT[".":EDT+.0000001,1:EDT+.240001)
 S DS=$S(SDIR=+1:BDT-.000001,1:EDTT)
 S CODESYS="",NFOUND=0
 F  S CODESYS=$O(^PXRMINDX(9000010.71,"PI",DFN,CODESYS)) Q:CODESYS=""  D
 . D FPDCSYS(DFN,CODESYS,.TAXARR,NGET,.NFOUND,BDT,EDTT,DS,SDIR,.TLIST)
 ;Return up to NGET of the most recent entries.
 S DATE="",NFOUND=0
 F  S DATE=$O(TLIST(DATE),SDIR) Q:(DATE="")!(NFOUND=NGET)  D
 . S IND=0
 . F  S IND=$O(TLIST(DATE,IND)) Q:(IND="")!(NFOUND=NGET)  D
 .. S NFOUND=NFOUND+1
 .. S FLIST(DATE,NFOUND,9000010.71)=TLIST(DATE,IND)
 Q
 ;
 ;===============================================
FPDCSYS(DFN,CODESYS,TAXARR,NGET,NFOUND,BDT,EDTT,DS,SDIR,TLIST) ;Find data for
 ;a patient in V Standard Codes.
 N CODE,DAS,DATE,NODE,TDATE,TIND
 S CODE=""
 F  S CODE=$O(TAXARR("AE",CODESYS,CODE)) Q:CODE=""  D
 . I '$D(^PXRMINDX(9000010.71,"PI",DFN,CODESYS,CODE)) Q
 . S DATE=DS
 . F  S DATE=+$O(^PXRMINDX(9000010.71,"PI",DFN,CODESYS,CODE,DATE),SDIR) Q:$S(DATE=0:1,DATE<BDT:1,DATE>EDTT:1,1:0)  D
 .. S DAS=$O(^PXRMINDX(9000010.71,"PI",DFN,CODESYS,CODE,DATE,""))
 .. S NFOUND=NFOUND+1
 .. S TLIST(DATE,NFOUND)=DAS_U_DATE_U_CODESYS_U_CODE
 .. I NFOUND>NGET D
 ... S TDATE=$O(TLIST(""),-SDIR),TIND=$O(TLIST(TDATE,""))
 ... K TLIST(TDATE,TIND)
 Q
 ;
 ;===============================================
GETDATA(DAS,FIEVT) ;Return data for a specified V Standard Codes entry.
 ;DBIA #4250.
 D VSCDATA^PXPXRM(DAS,.FIEVT)
 Q
 ;
 ;===============================================
GPLIST(TAXARR,NOCC,BDT,EDT,PLIST) ;Build patient list for V CPT entries.
 N CODE,CODEP,CODESYS,DAS,DATE,DFN,DS,NFOUND,TEMP,TLIST
 S NNODES=TAXARR("APDS",9000010.71,"NNODES")
 I NNODES=0 Q
 I $G(^PXRMINDX(9000010.71,"DATE BUILT"))="" D  Q
 . D NOINDEX^PXRMERRH("TX",TAXARR("IEN"),9000010.71)
 S TLIST="GPLIST_PXRMVSC"
 K ^TMP($J,TLIST)
 S DS=$S(EDT[".":EDT+.0000001,1:EDT+.240001)
 S CODESYS=""
 F  S CODESYS=$O(TAXARR("AE",CODESYS)) Q:CODESYS=""  D
 . S CODE=""
 . F  S CODE=$O(TAXARR("AE",CODESYS,CODE)) Q:(CODE="")  D
 .. D GPLCSYS(CODESYS,CODE,.TAXARR,BDT,DS,TLIST)
 ;Return up to NOCC of the most recent entries for each patient.
 S DFN=0
 F  S DFN=$O(^TMP($J,TLIST,DFN)) Q:DFN=""  D
 . S DATE="",NFOUND=0
 . F  S DATE=$O(^TMP($J,TLIST,DFN,DATE),-1) Q:(DATE="")!(NFOUND=NOCC)  D
 .. S DAS=""
 .. F  S DAS=$O(^TMP($J,TLIST,DFN,DATE,DAS)) Q:DAS=""  D
 ... S NFOUND=NFOUND+1
 ... S TEMP=^TMP($J,TLIST,DFN,DATE,DAS)
 ... S ^TMP($J,PLIST,1,DFN,NFOUND,9000010.71)=DAS_U_DATE_U_TEMP
 K ^TMP($J,TLIST)
 Q
 ;
 ;===============================================
GPLCSYS(CODESYS,CODE,TAXARR,BDT,DS,TLIST) ;Build patient list for V
 ;Standard Codes.
 I '$D(^PXRMINDX(9000010.71,"IP",CODESYS,CODE)) Q
 N DAS,DATE,DFN
 S DFN=0
 F  S DFN=$O(^PXRMINDX(9000010.71,"IP",CODESYS,CODE,DFN)) Q:DFN=""  D
 . S DATE=DS
 . F  S DATE=+$O(^PXRMINDX(9000010.71,"IP",CODESYS,CODE,DFN,DATE),-1) Q:(DATE=0)!(DATE<BDT)  D
 .. S DAS=$O(^PXRMINDX(9000010.71,"IP",CODESYS,CODE,DFN,DATE,""))
 .. S ^TMP($J,TLIST,DFN,DATE,DAS)=CODESYS_U_CODE
 Q
 ;
 ;===============================================
MHVOUT(INDENT,OCCLIST,IFIEVAL,NLINES,TEXT) ;Produce the MHV output.
 N CDATA,CODE,CODESYS,IND,JND,NAME,NIN,NOUT
 N PN,PP,RESULT,TEMP,TEXTOUT,VDATE
 S NAME="Encounter - Additional Terminologies = "
 S IND=0
 F  S IND=$O(OCCLIST(IND)) Q:IND=""  D
 . S VDATE=IFIEVAL(IND,"DATE")
 . S CODE=IFIEVAL(IND,"CODE")
 . S CODESYS=IFIEVAL(IND,"CODESYS")
 . K CDATA
 .;DBIA #5679
 . S RESULT=$$CSDATA^LEXU(CODE,CODESYS,VDATE,.CDATA)
 . S TEMP=NAME_$P(CDATA("LEX",1),U,2)_" ("_$$EDATE^PXRMDATE(VDATE)_")"
 . D FORMATS^PXRMTEXT(INDENT+2,PXRMRM,TEMP,.NOUT,.TEXTOUT)
 . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
 . I IFIEVAL(IND,"MEASUREMENT")'="" D
 .. N MAGNITUDE,UCUMIEN
 .. S MAGNITUDE=$P(IFIEVAL(IND,"MEASUREMENT"),U,1)
 .. I MAGNITUDE="" Q
 .. S NLINES=NLINES+1
 .. S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT+1," ")_"Measurement: "_MAGNITUDE
 .. S UCUMIEN=$P(IFIEVAL(IND,"MEASUREMENT"),U,2)
 .. I UCUMIEN'="" S TEXT(NLINES)=TEXT(NLINES)_" "_$$UCUMFIELDS^PXRMUCUM(UCUMIEN,"DESCRIPTION")
 S NLINES=NLINES+1,TEXT(NLINES)=""
 Q
 ;
 ;===============================================
OUTPUT(INDENT,OCCLIST,IFIEVAL,NLINES,TEXT) ;Produce the clinical
 ;maintenance output.
 N CDATA,CODE,CODESYS,CODESYSN,D0,HIER,IND,JND,NIN,NOUT
 N RESULT,TEXTIN,TEXTOUT,VDATE
 S NLINES=NLINES+1
 S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"Encounter - Additional Terminologies:"
 ;DBIA #5679
 S IND=0
 F  S IND=$O(OCCLIST(IND)) Q:IND=""  D
 . S VDATE=IFIEVAL(IND,"DATE")
 . S CODE=IFIEVAL(IND,"CODE")
 . S CODESYS=IFIEVAL(IND,"CODESYS")
 . S CODESYSN=$P($$CSYS^LEXU(CODESYS),U,4)
 . K CDATA
 .;DBIA #5679
 . S RESULT=$$CSDATA^LEXU(CODE,CODESYS,VDATE,.CDATA)
 . S D0=$G(^AUPNVSC(IFIEVAL(IND,"DAS"),0))
 . S TEXTIN(1)=$$EDATE^PXRMDATE(VDATE)_"  "_CODE_" - "_CODESYSN
 . I CODESYS="SCT" D
 .. S HIER=$$SCTHIER^PXRMTXIN(CODE,VDATE)
 .. S TEXTIN(1)=TEXTIN(1)_" "_HIER
 . S TEXTIN(2)=$P(CDATA("LEX",1),U,2)_"\\"
 . D FORMAT^PXRMTEXT(INDENT+2,PXRMRM,2,.TEXTIN,.NOUT,.TEXTOUT)
 . F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
 . I IFIEVAL(IND,"MEASUREMENT")'="" D
 .. N MAGNITUDE,UCUMIEN
 .. S MAGNITUDE=$P(IFIEVAL(IND,"MEASUREMENT"),U,1)
 .. I MAGNITUDE="" Q
 .. S NLINES=NLINES+1
 .. S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT+1," ")_"Measurement: "_MAGNITUDE
 .. S UCUMIEN=$P(IFIEVAL(IND,"MEASUREMENT"),U,2)
 .. I UCUMIEN'="" S TEXT(NLINES)=TEXT(NLINES)_" "_$$UCUMFIELDS^PXRMUCUM(UCUMIEN,"DESCRIPTION")
 . I IFIEVAL(IND,"COMMENTS")'="" D
 .. S TEMP="Comments: "_IFIEVAL(IND,"COMMENTS")
 .. D FORMATS^PXRMTEXT(INDENT+3,PXRMRM,TEMP,.NOUT,.TEXTOUT)
 .. F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
 S NLINES=NLINES+1,TEXT(NLINES)=""
 Q
 ;