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

BPXRMSNO.m

Go to the documentation of this file.
BPXRMSNO ; IHS/MSC/MGH - Use SNOMED problems in reminder resolution. ;01-Apr-2016 08:44;du
 ;;2.0;CLINICAL REMINDERS;**1002,1003,1005,1006,1007**;Feb 04, 2005;Build 12
 ;===================================================================
 ;IHS/MSC/MGH Included in patch 1005 for backards compatability
 ;
SNO(DFN,TEST,DATE,VALUE,TEXT) ;EP
 N BPXTRM,BPXPR,BPXIEN,BPXREC,BPXSTAT,X,IN,BPXSNO,FOUND,SEARCH,TODAY,Y
 ;Test will contain the name of the subset to see if this problem is in that subset
 Q:TEST=""
 S TODAY=$$DT^XLFDT()
 S SEARCH=TEST,FOUND=0
 ;First search patient's active list of problems
 S BPXPR="" F  S BPXPR=$O(^AUPNPROB("AC",DFN,BPXPR)) Q:'BPXPR!(FOUND=1)  D
 .S BPXREC=$G(^AUPNPROB(BPXPR,0))
 .Q:$P(BPXREC,U,2)'=DFN
 .S BPXIEN=$P(BPXREC,U)
 .Q:BPXIEN=""
 .;Check for which statuses to return since we only want active ones
 .S BPXSTAT=$P(BPXREC,U,12)
 .Q:BPXSTAT="D"!(BPXSTAT="I")
 .S BPXSNO=$$GET1^DIQ(9000011,BPXPR,80002)
 .Q:BPXSNO=""
 .N ARR
 .S IN=BPXSNO_U_SEARCH_U_U_1
 .S FOUND=$$VSBTRMF^BSTSAPI(IN)
 .I FOUND=1 D
 ..S IN=BPXSNO_U_U_1
 ..S Y=$$DESC^BSTSAPI(IN)
 ..S VALUE=$P(Y,U,2)
 ..S TEST=1,TEXT=VALUE,DATE=TODAY
 I FOUND=0 S TEST=0,VALUE=TEST,DATE=TODAY
 Q
POV(DFN,TEST,DATE,VALUE,TEXT) ;EP
 N BPXTRM,BPXPR,BPXIEN,BPXREC,BPXSTAT,X,IN,TODAY,BPXSNO,FOUND,SEARCH,BPXINV,Y,DONDTE,BEG,END,CODE,CODETXT
 ;Test will contain the name of the subset to see if this problem is in that subset
 Q:TEST=""
 S TODAY=$$DT^XLFDT()
 I $G(FIEVAL("EDTE"))'="" S END=9999999-FIEVAL("EDTE")
 E  S END=9999999-DT
 I $G(FIEVAL("BDTE"))'="" S BEG=9999999-FIEVAL("BDTE")
 E  S BEG=9999999-3000101
 S SEARCH=TEST,FOUND=0
 ;First search patient's pov
 S BPXINV=END F  S BPXINV=$O(^AUPNVPOV("AA",DFN,BPXINV)) Q:'BPXINV!(FOUND=1)!(BPXINV>BEG)  D
 .S BPXPR="" F  S BPXPR=$O(^AUPNVPOV("AA",DFN,BPXINV,BPXPR)) Q:'BPXPR!(FOUND=1)  D
 ..S BPXREC=$G(^AUPNVPOV(BPXPR,0))
 ..Q:$P(BPXREC,U,2)'=DFN
 ..S BPXIEN=$P(BPXREC,U)
 ..Q:BPXIEN=""
 ..S BPXSNO=$$GET1^DIQ(9000010.07,BPXPR,1102)
 ..Q:BPXSNO=""
 ..N ARR
 ..S IN=BPXSNO_U_SEARCH_U_U_1
 ..S FOUND=$$VSBTRMF^BSTSAPI(IN)
 ..I FOUND=1 D
 ...S IN=BPXSNO_U_U_1
 ...S Y=$$DESC^BSTSAPI(IN)
 ...S VALUE=$P(Y,U,2)
 ...S DONDTE=$$GET1^DIQ(9000010.07,BPXPR,1201,"I")
 ...I DONDTE="" S DONDTE=$$GET1^DIQ(9000010.07,BPXPR,.03,"I")
 ...S TEST=1,TEXT="POV code",DATE=DONDTE
 I FOUND=0 S TEST=0,VALUE=TEST,DATE=TODAY
 Q
 ;Computed finding to find an item in an IHS taxonomy
POVTAX(DFN,TEST,DATE,VALUE,TEXT) ;EP
 N BPXTRM,BPXPR,BPXIEN,BPXREC,BPXSTAT,TAX,TODAY,Y,DONDTE,BEG,END
 ;Test will contain the name of the taxonomy to see if this POV is in that taxonomy
 Q:TEST=""
 S TODAY=$$DT^XLFDT()
 S TAX=TEST,FOUND=0
 I $G(FIEVAL("EDTE"))'="" S END=9999999-FIEVAL("EDTE")
 E  S END=9999999-DT
 I $G(FIEVAL("BDTE"))'="" S BEG=9999999-FIEVAL("BDTE")
 E  S BEG=9999999-3000101
 ;First search patient's pov
 S BPXINV=END F  S BPXINV=$O(^AUPNVPOV("AA",DFN,BPXINV)) Q:'BPXINV!(FOUND=1)!(BPXINV>BEG)  D
 .S BPXPR="" F  S BPXPR=$O(^AUPNVPOV("AA",DFN,BPXINV,BPXPR)) Q:'BPXPR!(FOUND=1)  D
 ..S BPXREC=$G(^AUPNVPOV(BPXPR,0))
 ..Q:$P(BPXREC,U,2)'=DFN
 ..S BPXIEN=$P(BPXREC,U)
 ..Q:BPXIEN=""
 ..S CODE=$$GET1^DIQ(9000010.07,BPXPR,.01,"I")
 ..I $$ICD^ATXAPI(CODE,$O(^ATXAX("B",TAX,0)),9) D
 ...S FOUND=1
 ...S CODETXT=$$GET1^DIQ(9000010.07,BPXPR,.01)
 ...S DONDTE=$$GET1^DIQ(9000010.07,BPXPR,1201,"I")
 ...I DONDTE="" S DONDTE=$$GET1^DIQ(9000010.07,BPXPR,.03,"I")
 ...S TEST=1,TEXT="Diagnosis Code",DATE=DONDTE,VALUE=CODETXT
 I FOUND=0 S TEST=0,DATE=TODAY
 Q
 ;Computed finding to find a CPT item in an IHS taxonomy
CPTTAX(DFN,TEST,DATE,VALUE,TEXT) ;EP
 N BPXTRM,BPXPR,BPXIEN,BPXCODE,BPXREC,BPXSTAT,TAX,TODAY,Y,DONDTE,BEG,END
 ;Test will contain the name of the taxonomy to see if this CPT is in that taxonomy
 Q:TEST=""
 S TODAY=$$DT^XLFDT()
 S TAX=TEST,FOUND=0
 I $G(FIEVAL("EDTE"))'="" S END=9999999-FIEVAL("EDTE")
 E  S END=9999999-DT
 I $G(FIEVAL("BDTE"))'="" S BEG=9999999-FIEVAL("BDTE")
 E  S BEG=9999999-2400101
 ;First search patient's CPT file
 S BPXCODE="" F  S BPXCODE=$O(^AUPNVCPT("AA",DFN,BPXCODE)) Q:'BPXCODE!(FOUND=1)  D
 .S BPXINV=END F  S BPXINV=$O(^AUPNVCPT("AA",DFN,BPXCODE,BPXINV)) Q:'BPXINV!(FOUND=1)!(BPXINV>BEG)  D
 ..S BPXPR="" F  S BPXPR=$O(^AUPNVCPT("AA",DFN,BPXCODE,BPXINV,BPXPR)) Q:'BPXPR!(FOUND=1)  D
 ...S BPXREC=$G(^AUPNVCPT(BPXPR,0))
 ...Q:$P(BPXREC,U,2)'=DFN
 ...S BPXIEN=$P(BPXREC,U)
 ...Q:BPXIEN=""
 ...S CODE=$$GET1^DIQ(9000010.18,BPXPR,.01,"I")
 ...I $$ICD^ATXAPI(CODE,$O(^ATXAX("B",TAX,0)),1) D
 ....S FOUND=1
 ....S CODETXT=$P($G(^ICPT(CODE,0)),U,2)
 ....S DONDTE=$$GET1^DIQ(9000010.18,BPXPR,1201)
 ....I DONDTE="" S DONDTE=$$GET1^DIQ(9000010.18,BPXPR,.03)
 ....S TEST=1,TEXT="CPT Code",DATE=DONDTE,VALUE=CODETXT
 I FOUND=0 S TEST=0,DATE=TODAY
 Q