[613] | 1 | PXRM ; SLC/PKR - Clinical Reminders entry points. ; 06/09/2006
|
---|
| 2 | ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
|
---|
| 3 | ;Entry points in this routine are listed in DBIA #2182.
|
---|
| 4 | ;==========================================================
|
---|
| 5 | MAIN(DFN,PXRMITEM,OUTTYPE,DISC) ;Main driver for clinical reminders.
|
---|
| 6 | ;INPUT DFN - Pointer to Patient File (#2)
|
---|
| 7 | ; PXRMITEM - IEN of reminder to evaluate.
|
---|
| 8 | ; OUTTYPE - Flag to indicate type of output information.
|
---|
| 9 | ; 0 - Reminders DUE NOW only (CLINICAL REMINDERS DUE
|
---|
| 10 | ; HS component)
|
---|
| 11 | ; 1 - All Reminders with Next and Last Information
|
---|
| 12 | ; (CLINICAL REMINDERS SUMMARY HS component)
|
---|
| 13 | ; 5 - Health Maintenance (CLINICAL REMINDERS MAINTENANCE
|
---|
| 14 | ; HS component)
|
---|
| 15 | ; 10 - MyHealtheVet summary
|
---|
| 16 | ; 11 - MyHealtheVet detailed
|
---|
| 17 | ; 12 - MyHealtheVet combined
|
---|
| 18 | ; DISC - (optional) if this is true then the disclaimer will
|
---|
| 19 | ; be loaded in ^TMP("PXRM",$J,"DISC").
|
---|
| 20 | ;
|
---|
| 21 | ;OUTPUT ^TMP("PXRHM",$J,PXRMITEM,PXRMRNAM)=
|
---|
| 22 | ; STATUS_U_DUE DATE_U_LAST DONE
|
---|
| 23 | ; where PXRMRNAM is the PRINT NAME or if it is undefined then
|
---|
| 24 | ; it is the NAME (.01).
|
---|
| 25 | ; For the Clinical Maintenance component, OUTTYPE=5, there is
|
---|
| 26 | ; subsequent output of the form
|
---|
| 27 | ; ^TMP("PXRHM",$J,PXRMITEM,PXRMRNAM,"TXT",N)=TEXT
|
---|
| 28 | ; where N is a number and TEXT is a text string.
|
---|
| 29 | ;
|
---|
| 30 | ; If DISC is true then the disclaimer will be loaded into
|
---|
| 31 | ; ^TMP("PXRM",$J,"DISC"). The calling application should
|
---|
| 32 | ; delete this when it is done.
|
---|
| 33 | ;
|
---|
| 34 | ; The calling application can display the contents of these
|
---|
| 35 | ; two ^TMP arrays as it chooses. The caller should also make
|
---|
| 36 | ; sure the ^TMP globals are killed before it exits.
|
---|
| 37 | ;
|
---|
| 38 | N DEFARR,FIEVAL
|
---|
| 39 | ;Load the definition into DEFARR.
|
---|
| 40 | D DEF^PXRMLDR(PXRMITEM,.DEFARR)
|
---|
| 41 | ;
|
---|
| 42 | I $G(NODISC)="" S NODISC=1
|
---|
| 43 | I $D(GMFLAG) S NODISC=0
|
---|
| 44 | D EVAL(DFN,.DEFARR,OUTTYPE,NODISC,.FIEVAL)
|
---|
| 45 | Q
|
---|
| 46 | ;
|
---|
| 47 | ;==========================================================
|
---|
| 48 | EVAL(DFN,DEFARR,OUTTYPE,NODISC,FIEVAL,DATE) ;Reminder evaluation entry
|
---|
| 49 | ;point. This entry point uses the local array DEFARR for the reminder
|
---|
| 50 | ;definition and returns the Finding Evaluation Array, FIEVAL.
|
---|
| 51 | ;PXRM namespaced variables are the reminder evaluation "global"
|
---|
| 52 | ;variables. If date is specified then the reminder will be evaluated
|
---|
| 53 | ;as if the current date is DATE.
|
---|
| 54 | N PXRMAGE,PXRMDATE,PXRMDOB,PXRMDOD,PXRMLAD,PXRMPDEM,PXRMPID,PXRMITEM
|
---|
| 55 | N PXRMRM,PXRMRNAM,PXRMSEX,PXRMXTLK
|
---|
| 56 | ;Make sure the reminder exists.
|
---|
| 57 | I $D(DEFARR("DNE")) D NODEF^PXRMERRH(DEFARR("IEN")) Q
|
---|
| 58 | ;PXRMRM is the right margin for output.
|
---|
| 59 | S PXRMRM=70
|
---|
| 60 | S PXRMDATE=$G(DATE)
|
---|
| 61 | S PXRMITEM=DEFARR("IEN")
|
---|
| 62 | S PXRMPID="PXRM"_PXRMITEM_$H
|
---|
| 63 | N D00
|
---|
| 64 | S D00=DEFARR(0)
|
---|
| 65 | S PXRMRNAM=$P(D00,U,3)
|
---|
| 66 | ;If the print name is null use the .01.
|
---|
| 67 | I PXRMRNAM="" S PXRMRNAM=$P(D00,U,1)
|
---|
| 68 | ;
|
---|
| 69 | ;Set the error handler to the PXRMERRH routine. Use the new style of
|
---|
| 70 | ;error trapping.
|
---|
| 71 | N $ES,$ET
|
---|
| 72 | S $ET="D ERRHDLR^PXRMERRH"
|
---|
| 73 | ;
|
---|
| 74 | ;Initialize the working array.
|
---|
| 75 | K ^TMP(PXRMPID,$J)
|
---|
| 76 | ;
|
---|
| 77 | N DUE,DUEDATE,FREQ,PCLOGIC,RESDATE,RESLOGIC
|
---|
| 78 | ;Make sure the reminder is active.
|
---|
| 79 | I $P(D00,U,6) D G OUTPUT
|
---|
| 80 | . S ^TMP(PXRMPID,$J,PXRMITEM,"N/A","INACTIVE")="The reminder "_PXRMRNAM_" was inactivated "_$$FMTE^XLFDT($P(D00,U,7),"5Z")
|
---|
| 81 | . S PXRMPDEM("DFN")=DFN,PCLOGIC=0,RESLOGIC="",DUE="",DUEDATE=0
|
---|
| 82 | . S RESDATE="",FREQ="0Y"
|
---|
| 83 | ;
|
---|
| 84 | ;Make sure the "E" node exists
|
---|
| 85 | I $D(DEFARR(20))&'$D(DEFARR("E")) D G EXIT
|
---|
| 86 | . W !,"Reminder definition is corrupted, ENODE is missing cannot continue!"
|
---|
| 87 | . S ^TMP("PXRHM",$J,PXRMITEM,PXRMRNAM)="ERROR"_U_"E NODE MISSING"
|
---|
| 88 | . S ^TMP(PXRMPID,$J,PXRMITEM,"FERROR","NO ENODE")=""
|
---|
| 89 | ;
|
---|
| 90 | ;Establish the main findings evaluation variables.
|
---|
| 91 | S (DUE,DUEDATE,FREQ,RESDATE)=0
|
---|
| 92 | S (PCLOGIC,RESLOGIC)=""
|
---|
| 93 | ;
|
---|
| 94 | ;Establish the patient demographic information.
|
---|
| 95 | N TODAY
|
---|
| 96 | S TODAY=$G(DATE,DT)
|
---|
| 97 | D DEM^PXRMPINF(DFN,TODAY,.PXRMPDEM)
|
---|
| 98 | I PXRMPDEM("PATIENT")="" D G EXIT
|
---|
| 99 | . S ^TMP(PXRMPID,$J,PXRMITEM,"FERROR","PATIENT","NO PAT")="DFN "_DFN_" IS NOT A VALID PATIENT"
|
---|
| 100 | . S PCLOGIC=0
|
---|
| 101 | ;
|
---|
| 102 | ;Load the local demographic variables for use in condition.
|
---|
| 103 | S PXRMAGE=PXRMPDEM("AGE"),PXRMDOB=PXRMPDEM("DOB"),PXRMDOD=PXRMPDEM("DOD")
|
---|
| 104 | S PXRMLAD=PXRMPDEM("LAD"),PXRMSEX=PXRMPDEM("SEX")
|
---|
| 105 | ;
|
---|
| 106 | ;Check for a date of death.
|
---|
| 107 | I PXRMPDEM("DOD")'="" D
|
---|
| 108 | . S ^TMP(PXRMPID,$J,PXRMITEM,"N/A","DEAD")=""
|
---|
| 109 | . S ^TMP(PXRMPID,$J,PXRMITEM,"DEAD")="Patient is deceased."
|
---|
| 110 | ;
|
---|
| 111 | ;If the component is CR and the patient is deceased we are done.
|
---|
| 112 | I OUTTYPE=0,PXRMPDEM("DOD")'="",'$G(PXRMIDOD) G OUTPUT
|
---|
| 113 | ;
|
---|
| 114 | ;Check for a sex specific reminder.
|
---|
| 115 | N SEXOK
|
---|
| 116 | S SEXOK=$$SEX^PXRMLOG(.DEFARR,PXRMPDEM("SEX"))
|
---|
| 117 | S FIEVAL("SEX")=SEXOK
|
---|
| 118 | ;If the patient is the wrong sex then don't do anything else.
|
---|
| 119 | I 'SEXOK D G OUTPUT
|
---|
| 120 | . S PCLOGIC=0
|
---|
| 121 | . S ^TMP(PXRMPID,$J,PXRMITEM,"N/A","SEX")=""
|
---|
| 122 | . S ^TMP(PXRMPID,$J,PXRMITEM,"INFO","SEX")="Patient is the wrong sex!"
|
---|
| 123 | ;
|
---|
| 124 | ;Evaluate the findings.
|
---|
| 125 | S PXRMXTLK=""
|
---|
| 126 | D EVAL^PXRMEVFI(DFN,.DEFARR,.FIEVAL)
|
---|
| 127 | I +PXRMXTLK>0 D G OUTPUT
|
---|
| 128 | . S ^TMP(PXRMPID,$J,PXRMITEM,"FERROR","EXPANDED TAXONOMY","NO LOCK")="NO LOCK for ien "_+PXRMXTLK
|
---|
| 129 | . S PCLOGIC=0
|
---|
| 130 | ;
|
---|
| 131 | ;Check for missing index.
|
---|
| 132 | I $D(^TMP(PXRMPID,$J,PXRMITEM,"WARNING","MISSING INDEX")) D G OUTPUT
|
---|
| 133 | . S (DUE,DUEDATE)="CNBD",PCLOGIC=1
|
---|
| 134 | ;
|
---|
| 135 | ;Evaluate the Patient Cohort Logic.
|
---|
| 136 | D EVALPCL^PXRMLOG(.DEFARR,.PXRMPDEM,.FREQ,.PCLOGIC,.FIEVAL)
|
---|
| 137 | ;
|
---|
| 138 | ;Evaluate the resolution logic and get the last resolution date.
|
---|
| 139 | D EVALRESL^PXRMLOG(.DEFARR,.RESDATE,.RESLOGIC,.FIEVAL)
|
---|
| 140 | ;
|
---|
| 141 | ;If the reminder is applicable calculate the due date.
|
---|
| 142 | I PCLOGIC D DUE^PXRMDATE(.DEFARR,RESDATE,FREQ,.DUE,.DUEDATE,.FIEVAL)
|
---|
| 143 | ;
|
---|
| 144 | OUTPUT ;Prepare the final output.
|
---|
| 145 | D OUTPUT^PXRMOUTD(OUTTYPE,.DEFARR,.PXRMPDEM,PCLOGIC,RESLOGIC,DUE,DUEDATE,RESDATE,FREQ,.FIEVAL)
|
---|
| 146 | ;
|
---|
| 147 | EXIT ;Kill the working arrays unless this was a test run.
|
---|
| 148 | I $G(PXRMDEBG) D
|
---|
| 149 | . S PXRMID=PXRMPID
|
---|
| 150 | . S FIEVAL("PATIENT AGE")=$G(PXRMPDEM("AGE"))
|
---|
| 151 | . S FIEVAL("DFN")=DFN
|
---|
| 152 | . S FIEVAL("EVAL DATE/TIME")=$$NOW^PXRMDATE
|
---|
| 153 | . S ^TMP(PXRMPID,$J,PXRMITEM,"REMINDER NAME")=$G(PXRMRNAM)
|
---|
| 154 | E K ^TMP(PXRMPID,$J)
|
---|
| 155 | ;
|
---|
| 156 | ;I DISC is true load the disclaimer.
|
---|
| 157 | I $G(DISC) D LOAD^PXRMDISC
|
---|
| 158 | Q
|
---|
| 159 | ;
|
---|
| 160 | ;==========================================================
|
---|
| 161 | FIDATA(DFN,PXRMITEM,FINDINGS) ;Return the finding evaluation array to the
|
---|
| 162 | ;caller in the array FINDINGS. The caller should use the form
|
---|
| 163 | ;D FIDATA^PXRM(DFN,PXRMITEM,.FINDINGS)
|
---|
| 164 | ;The elements of the FINDINGS array will correspond to the
|
---|
| 165 | ;findings in the reminder definition. For finding N FINDINGS(N)
|
---|
| 166 | ;will be 0 if the finding is false and 1 if it is true. For
|
---|
| 167 | ;true findings there will be additional elements. The exact set
|
---|
| 168 | ;of additional elements will depend of the type of finding.
|
---|
| 169 | ;Some typical examples are:
|
---|
| 170 | ;FINDINGS(N)=1
|
---|
| 171 | ;FINDINGS(N,"DATE")=FileMan date
|
---|
| 172 | ;FINDINGS(N,"FINDING")=variable pointer to the finding
|
---|
| 173 | ;FINDINGS(N,"FILE NUMBER")=file number of data source
|
---|
| 174 | ;FINDINGS(N,"VALUE")=value of the finding, for example the
|
---|
| 175 | ; value of a lab test
|
---|
| 176 | ;
|
---|
| 177 | N DEFARR,FI,FIEVAL
|
---|
| 178 | ;Load the definition into DEFARR.
|
---|
| 179 | D DEF^PXRMLDR(PXRMITEM,.DEFARR)
|
---|
| 180 | D EVAL(DFN,.DEFARR,0,1,.FIEVAL)
|
---|
| 181 | K ^TMP("PXRM",$J),^TMP("PXRHM",$J)
|
---|
| 182 | ;Load the FINDINGS array.
|
---|
| 183 | S FI=0
|
---|
| 184 | F S FI=+$O(FIEVAL(FI)) Q:FI=0 D
|
---|
| 185 | . S FINDINGS(FI)=FIEVAL(FI)
|
---|
| 186 | . I 'FIEVAL(FI) Q
|
---|
| 187 | . S FINDINGS(FI,"DATE")=FIEVAL(FI,"DATE")
|
---|
| 188 | . I FIEVAL(FI,"FINDING")["PSDRUG" S FINDINGS(FI,"DRUG")=1
|
---|
| 189 | . S FINDINGS(FI,"FILE NUMBER")=FIEVAL(FI,"FILE NUMBER")
|
---|
| 190 | . S FINDINGS(FI,"FINDING")=FIEVAL(FI,"FINDING")
|
---|
| 191 | . I $D(FIEVAL(FI,"TERM")) S FINDINGS(FI,"TERM")=FIEVAL(FI,"TERM")
|
---|
| 192 | . I $D(FIEVAL(FI,"VALUE")) S (FINDINGS(FI,"RESULT"),FINDINGS(FI,"VALUE"))=FIEVAL(FI,"VALUE")
|
---|
| 193 | . I $D(FIEVAL(FI,"VISIT")) S FINDINGS(FI,"VIEN")=FIEVAL(FI,"VISIT")
|
---|
| 194 | Q
|
---|
| 195 | ;
|
---|
| 196 | ;==========================================================
|
---|
| 197 | INACTIVE(PXRMITEM) ;Return the INACTIVE FLAG, which has a value of 1
|
---|
| 198 | ;if the reminder is inactive.
|
---|
| 199 | I '$D(^PXD(811.9,PXRMITEM)) Q 1
|
---|
| 200 | Q $P(^PXD(811.9,PXRMITEM,0),U,6)
|
---|
| 201 | ;
|
---|