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

BPXRMREF.m

Go to the documentation of this file.
BPXRMREF ; IHS/MSC/MGH - Handle Refusal findings. ;16-Aug-2013 12:38;DU
 ;;2.0;CLINICAL REMINDERS;**1001**;Feb 04 2005;Build 21
 ;
 ;Entries in the refuals file 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 CONVAL,DATE,IEN,IND,USESTRT,RSLT,TEMP,VALID,VIEN,FIEN,FINISHED,INVDATE
 ;Set finding to zero to start
 ;Set the finding search parameters.
 N NFOUND,NGET,NOCC,NP,SDIR,SAVE,SSFIND,COND,CASESEN,UCIFS,ICOND,VSLIST
 N NP,DAS,IND
 D SSPAR^PXRMUTIL(PFINDPA(0),.NOCC,.BDT,.EDT)
 D SCPAR^PXRMCOND(.PFINDPA,.CASESEN,.COND,.UCIFS,.ICOND,.VSLIST)
 S SDIR=$S(NOCC<0:+1,1:-1)
 S NOCC=$S(NOCC<0:-NOCC,1:NOCC)
 S NGET=$S(UCIFS:50,1:NOCC)
 S SSFIND=0,USESTRT=0
 S REFTYP=$P($G(DEFARR(20,FINDING,0)),";",1)
 D FPDAT(DFN,REFTYP,NGET,SDIR,BDT,EDT,.NFOUND,.FLIST)
 ;If there is a type of refusal to be examined (and there should be),evaluate it
 ;If there is no condition, then the first finging of this type is sufficient
 ;If there is a condition for this finding evaluate it.
 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)
 . D GETDATA(DAS,.FIEVD)
 . S COND=$G(FIEVD("RESULT"))
 . I COND="" S SAVE=1
 . E  S CONVAL=$$COND(CASESEN,ICOND,.FIEVD)
 . I +CONVAL S SAVE=1
 . I SAVE D
 .. S NP=NP+1
 .. S FIEVAL(NP)=CONVAL
 .. I COND'="" S FIEVAL(NP,"CONDITION")=CONVAL
 .. 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")=9000022
 Q
 ;=======================================================================
FPDAT(DFN,REFTYP,NGET,SDIR,BDT,EDT,NFOUND,FLIST) ;Find pt data
 N DAS,DATE,DONE,EDTT,FIEN
 S EDTT=$S(EDT[".":EDT+.0000001,1:EDT+.240001)
 S (FINISHED,NFOUND)=0
 S DATE=$S(SDIR=+1:BDT-.000001,1:EDTT)
 S FIEN="" F  S FIEN=$O(^AUPNPREF("AC",DFN,FIEN)) Q:FIEN=""  D
 .S TEMP=$G(^AUPNPREF(FIEN,0))
 .Q:REFTYP'=$P(TEMP,U,1)
 .Q:$P(TEMP,U,3)<BDT
 .Q:$P(TEMP,U,3)>EDTT
 .S NFOUND=NFOUND+1
 .S FLIST(NFOUND)=FIEN_U_DATE
 Q
 ;===========================================================
GETDATA(DAS,FIEVD) ;Get refusal data
 N TEMP
 S TEMP=^AUPNPREF(DAS,0)
 S FIEVD("TYPE")=$P(TEMP,U,1)
 S FIEVD("DATE")=$P(TEMP,U,3)
 S FIEVD("RESULT")=$P(TEMP,U,4)
 S FIEVD("POINTER")=$P(TEMP,U,6)
 Q
 ;============================================================
COND(CASESEN,ICOND,FIEVD) ;Check condition for refusal name
 N V,CONVAL,BPXFIND,BPXTYPE,BPXTEST,BPXFILE,TERM
 S V=FIEVD("RESULT")
 S V=$TR(V," ","~")
 I 'CASESEN D
 .S ICOND=$$UP^XLFSTR(ICOND)
 .S V=$$UP^XLFSTR(V)
 X ICOND
 S CONVAL=$T
 I CONVAL=0 D
 .;CHECK FOR A REMINDER TERM
 .S ICOND=$P(ICOND,"=",2)
 .Q:ICOND=""
 .S ICOND=$TR(ICOND,"""","")
 .S TERM="" S TERM=$O(^PXRMD(811.5,"B",ICOND,TERM))
 .Q:TERM=""
 .S BPXFIND=0 F  S BPXFIND=$O(^PXRMD(811.5,TERM,20,BPXFIND)) Q:BPXFIND=""  D
 ..S BPXTYPE=$P($G(^PXRMD(811.5,TERM,20,BPXFIND,0)),U,1)
 ..S BPXTEST=$P(BPXTYPE,";",1),BPXFILE=$P(BPXTYPE,";",2)
 ..I $G(FIEVD("POINTER"))=BPXTEST S CONVAL=1
 Q CONVAL
 ;============================================================
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=^AUPNPREF(FIEN,0)
 S PNAME=$P(TEMP,U,1)
 S PNAME=$P(^AUTTREFT(PNAME,0),U,1)
 S NAME=$$INSCHR^PXRMEXLC(INDENT," ")_"Refusal Type: "_PNAME_" = "
 S IND=0
 F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
 . S RESULT=$G(IFIEVAL(IND,"RESULT"))
 . I RESULT'="" S RESULT=$$EXTERNAL^DILFD(9000022,.04,"",RESULT,.EM)
 . S VDATE=IFIEVAL(IND,"DATE")
 . S TEMP=NAME_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 PNAME=$P(^AUTTREFT(FIEN,0),U,1)
 S NLINES=NLINES+1
 S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"Refusal Type: "_PNAME
 S IND=0
 F  S IND=+$O(IFIEVAL(IND)) Q:IND=0  D
 . S VDATE=IFIEVAL(IND,"DATE")
 . S TEMP=$$EDATE^PXRMDATE(VDATE)
 . S RESULT=$G(IFIEVAL(IND,"RESULT"))
 . I RESULT'="" D
 .. S TEMP=TEMP_" Service not done - "
 .. S TEMP=TEMP_$$EXTERNAL^DILFD(9000022,.04,"",RESULT,.EM)
 . 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
 ;=======================================================================