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

BPXRMAS1.m

Go to the documentation of this file.
BPXRMAS1 ; IHS/MSC/MGH - Handle Asthma findings. ;24-May-2013 15:04;DU
 ;;2.0;CLINICAL REMINDERS;**1001**;Feb 04 2005;Build 21
 ;
 ;Entries in the PCC asthma types can be used in findings for the EHR reminder terms
 ;=======================================================================
EVALFI(DFN,DEFARR,ENODE,FIEVAL) ;Evaluate refusal findings.
 N ITEM,INVDATE,REFTYP,FINDING,FIEVT
 S ITEM=""
 F  S ITEM=$O(DEFARR("E",ENODE,ITEM)) Q:ITEM=""  D
 . S FINDING=""
 . F  S FINDING=$O(DEFARR("E",ENODE,ITEM,FINDING)) Q:+FINDING=0  D
 ..M FINDPA=DEFARR(20,FINDING)
 ..K FIEVT
 ..D FIEVAL(DFN,ITEM,FINDING,.FINDPA,.FIEVT)
 ..M FIEVAL(FINDING)=FIEVT
 ..S FIEVAL(FINDING,"FINDING")=$P(FINDPA(0),U,1)
 Q
 ;
 ;=======================================================================
EVALTERM(DFN,FINDING,TERMIEN,TFIEVAL) ;Evaluate refusal terms.
 N REFIEN,FIND0,FIND3,INVDATE,LFIEVAL,TFIND0,TFIND3,TFINDING
 F  S ITEM=$O(TERMARR("E",ENODE,ITEM)) Q:+ITEM=0  D
 . S TFINDING=""
 . F  S TFINDING=$O(TERMARR("E",ENODE,ITEM,TFINDING)) Q:+TFINDING=0  D
 .. K FIEVT,PFINDPA,TFINDPA
 .. M TFINDPA=TERMARR(20,TFINDING)
 ..;Set the finding parameters.
 .. D SPFINDPA^PXRMTERM(.FINDPA,.TFINDPA,.PFINDPA)
 .. D FIEVAL(DFN,ITEM,.PFINDPA,.FIEVT)
 .. M TFIEVAL(TFINDING)=FIEVT
 .. S TFIEVAL(TFINDING,"FINDING")=$P(TFINDPA(0),U,1)
 Q
 ;
 ;=======================================================================
FIEVAL(DFN,ITEM,FINDING,PFINDPA,FIEVAL) ;
 N DATE,IEN,IND,USESTRT,RSLT,TEMP,VALID,VIEN,FIEN,FINISHED,ASTYPE
 ;Set finding to zero to start
 ;Set the finding search parameters.
 N NFOUND,NGET,NOCC,NP,SDIR,SAVE,SSFIND,CASESEN,UCIFS,VSLIST
 N NP,DAS,IND
 D SSPAR^PXRMUTIL(PFINDPA(0),.NOCC,.BDT,.EDT)
 S SDIR=$S(NOCC<0:+1,1:-1)
 S NOCC=$S(NOCC<0:-NOCC,1:NOCC)
 S NGET=NOCC
 S SSFIND=0,USESTRT=0
 S ASTYP=$P($G(DEFARR(20,FINDING,0)),";",1)
 D FPDAT(DFN,ASTYP,NGET,SDIR,BDT,EDT,.NFOUND,.FLIST)
 I NFOUND=0 S FIEVAL=0 Q
 S NP=0
 S SAVE=0
 F IND=1:1:NFOUND Q:NP=NOCC  D
 . S DAS=$P(FLIST(IND),U,1)
 . ;get the data on the findings
 . D GETDATA(DAS,.FIEVD)
 . S NP=NP+1
 . S FIEVAL(NP)=1
 . S FIEVAL(NP,"DAS")=$P(FLIST(IND),U,1)
 . S FIEVAL(NP,"DATE")=$P(FLIST(IND),U,2)
 . M FIEVAL(NP)=FIEVD
 . I $G(PXRMDEBG) M FIEVAL(NP,"CSUB")=FIEVD
 ;Save the finding result.
 D SFRES^PXRMUTIL(SDIR,NP,.FIEVAL)
 S FIEVAL("FILE NUMBER")=9000010.41
 Q
 ;=======================================================================
FPDAT(DFN,ASTYP,NGET,SDIR,BDT,EDT,NFOUND,FLIST) ;Find pt data
 N DAS,DATE,DONE,EDTT,FIEN,INVDATE,FOUND,IEN,VIEN,DATE,RSLT,TEMP,CONTROL,INV
 S EDTT=$S(EDT[".":EDT+.0000001,1:EDT+.240001)
 S (FINISHED,NFOUND)=0
 ;S DATE=$S(SDIR=+1:BDT-.000001,1:EDTT)
 S FOUND=0
 S INV=999999-BDT
 S CONTROL=$P($G(^APCDACV(ASTYP,0)),U,2)
 S INVDATE="" F  S INVDATE=$O(^AUPNVAST("AA",DFN,INVDATE)) Q:'+INVDATE!(FOUND=1)  D
 .S FIEN="" F  S FIEN=$O(^AUPNVAST("AA",DFN,INVDATE,FIEN)) Q:'+FIEN!(FOUND=1)  D
 ..S TEMP=$G(^AUPNVAST(FIEN,0))
 ..S RSLT=$P(TEMP,U,14)
 ..S VIEN=$P(TEMP,U,3)
 ..Q:RSLT=""
 ..Q:RSLT'=CONTROL
 ..S DATE=$P($G(^AUPNVAST(FIEN,12)),U,1)    ;Get date entered
 ..I DATE="" S DATE=$$VDATE^PXRMDATE(VIEN) ;else get visit date
 ..Q:DATE<BDT
 ..Q:DATE>EDTT
 ..S NFOUND=NFOUND+1
 ..S FOUND=1
 ..S FLIST(NFOUND)=FIEN_U_DATE
 Q
 ;===========================================================
GETDATA(DAS,FIEVD) ;Get the asthma data
 N TEMP,VIEN,DATE,RES1,RES2
 S TEMP=$G(^AUPNVAST(DAS,0))
 S VIEN=$P(TEMP,U,3)
 S DATE=$P($G(^AUPNVAST(DAS,12)),U,1)    ;Get date entered
 I DATE="" S DATE=$$VDATE^PXRMDATE(VIEN)
 S RES1=$P(TEMP,U,14)
 S RES2=$S(RES1="W":"WELL CONTROLLED",RES1="N":"NOT WELL CONTROLLED",RES1="V":"VERY POORLY CONTROLLED",1:"")
 S FIEVD("RESULT")=RES2
 S FIEVD("DATE")=DATE
 S FIEVD("VISIT")=$P(TEMP,U,3)
 Q
 ;============================================================
MHVOUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the MHV output
 N EM,FIEN,IND,JND,NAME,NOUT,PNAME,RESULT,TEMP,TEXTOUT,VDATE
 S FIEN=$P(IFIEVAL("FINDING"),";",1)
 S TEMP=$G(^AUPNVAST(FIEN,0))
 S PNAME=$P(TEMP,U,1)
 S PNAME=$P(^APCDACV(PNAME,0),U,1)
 S NAME=$$INSCHR^PXRMEXLC(INDENT," ")_"Asthma Control: "_PNAME_" = "
 S IND=0
 F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
 . S VDATE=IFIEVAL(IND,"DATE")
 . S RESULT=$G(IFIEVAL(IND,"RESULT"))
 . S TEMP=RESULT_"("_$$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)
 S NLINES=NLINES+1,TEXT(NLINES)=""
 Q
 ;============================================================
OUTPUT(INDENT,IFIEVAL,NLINES,TEXT) ;Produce the clinical
 ;maintenance output.
 N REFIEN,EM,FIEN,IND,PNAME,RSLT,TEMP,VDATE
 S FIEN=$P(IFIEVAL("FINDING"),";",1)
 S NLINES=NLINES+1
 S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"Asthma Control: "
 S IND=0
 F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
 . S VDATE=IFIEVAL(IND,"DATE")
 . S RESULT=$G(IFIEVAL(IND,"RESULT"))
 . S TEMP=RESULT_" "_$$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)
 S NLINES=NLINES+1,TEXT(NLINES)=""
 Q
 ;=======================================================================