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

BQIDCAH6.m

Go to the documentation of this file.
BQIDCAH6 ;GDIT/HS/ALA-Ad Hoc Logic ; 26 Apr 2013  11:00 AM
 ;;2.6;ICARE MANAGEMENT SYSTEM;;Jul 07, 2017;Build 72
 ;
ALGY(FGLOB,TGLOB,BEN,MPARMS) ;EP - Allergy search
 NEW ALGPT,AIEN,ACT,AL,CT,LIEN
 I $G(TGLOB)="" Q
 I $G(ALNAS)'="" D ANAS Q
 I $G(ALNKN)'="" D NKNN Q
 I $G(ALLERGY)]"" D ALGY1
 I $D(MPARMS("ALLERGY")) D
 . I ALLOP="!" D  Q
 .. S ALLERGY="" F  S ALLERGY=$O(MPARMS("ALLERGY",ALLERGY)) Q:ALLERGY=""  D ALGY1
 . I ALLOP="&" D
 .. S ALLERGY="",CT=0
 .. F  S ALLERGY=$O(MPARMS("ALLERGY",ALLERGY)) Q:ALLERGY=""  S CT=CT+1
 .. F  S ALLERGY=$O(MPARMS("ALLERGY",ALLERGY)) Q:ALLERGY=""  D ALGY1
 .. I ALLOP="&" D
 ... S IEN=""
 ... F  S IEN=$O(ALGPT(IEN)) Q:IEN=""  D
 .... S ACT=0,AL=""
 .... F  S AL=$O(ALGPT(IEN,AL)) Q:AL=""  S ACT=ACT+1
 .... I ACT'=CT K @CRIT@("ALGY",IEN) Q
 .... S AL="" F  S AL=$O(ALGPT(IEN,AL)) Q:AL=""  S @TGLOB@(IEN)="",LIEN=ALGPT(IEN,AL),@CRIT@("ALGY",IEN,LIEN)=""
 K ALGPT
 Q
 ;
ALGY1 ;EP
 NEW IEN,ALGTX,AN,DFN,TALLG
 I $G(FGLOB)'="" D  Q
 . S IEN=""
 . F  S IEN=$O(@FGLOB@(IEN)) Q:'IEN  D
 .. S AN=""
 .. F  S AN=$O(^GMR(120.8,"B",IEN,AN)) Q:AN=""  D
 ... ; If ENTERED IN ERROR, ignore
 ... I $$GET1^DIQ(120.8,AN_",",22,"I")=1 Q
 ... S ALGTX=$$GET1^DIQ(120.8,AN_",",.02,"E")
 ... I $E(ALGTX,$L(ALGTX),$L(ALGTX))=" " S ALGTX=$$STRIP^BQIUL1(ALGTX," ")
 ... I ALGTX=ALLERGY D
 .... I ALLOP="!" S @TGLOB@(IEN)="",@CRIT@("ALGY",IEN,AN)=AN Q
 .... S ALGPT(IEN,AN)=AN
 ;
 I $L(ALLERGY)'>30 D
 . NEW ALGTX,TXT
 . S IEN=""
 . F  S IEN=$O(^GMR(120.8,"C",ALLERGY,IEN)) Q:IEN=""  D ALCK
 . S ALGTX=$O(^GMR(120.8,"C",ALLERGY)),TXT=ALLERGY_" "
 . I ALGTX=TXT D
 .. F  S IEN=$O(^GMR(120.8,"C",ALGTX,IEN)) Q:IEN=""  D ALCK
 ;
 I $L(ALLERGY)>30 D
 . S TALLG=ALLERGY
 . F  S TALLG=$O(^GMR(120.8,"C",TALLG)) Q:TALLG=""!($E(ALLERGY,1,30)'=$E(TALLG,1,30))  D
 .. S IEN=""
 .. F  S IEN=$O(^GMR(120.8,"C",TALLG,IEN)) Q:IEN=""  D ALCK
 Q
 ;
ALCK ;EP
 I $$GET1^DIQ(120.8,IEN_",",22,"I")=1 Q
 S DFN=$$GET1^DIQ(120.8,IEN_",",.01,"I")
 I ALLOP="!" S @TGLOB@(DFN)="",@CRIT@("ALGY",DFN,IEN)=IEN Q
 S ALGPT(DFN,IEN)=IEN
 Q
 ;
ANAS ;EP - No allergy assessment
 NEW ADATA,IEN
 I $G(FGLOB)'="" D  Q
 . S IEN=""
 . F  S IEN=$O(@FGLOB@(IEN)) Q:'IEN  D
 .. D DETAIL^BEHOCACV(.ADATA,IEN)
 .. I $G(@ADATA@(1))="No allergy assessment." S @TGLOB@(IEN)=""
 I $G(FGLOB)="" D  Q
 . S IEN=0
 . F  S IEN=$O(^AUPNPAT(IEN)) Q:'IEN  D
 .. I $D(^AUPNPAT(IEN,-9)) Q
 .. D DETAIL^BEHOCACV(.ADATA,IEN)
 .. I $G(@ADATA@(1))="No allergy assessment." S @TGLOB@(IEN)=""
 Q
 ;
NKNN ;EP - No known allergy
 NEW ADATA,IEN
 I $G(FGLOB)'="" D  Q
 . S IEN=""
 . F  S IEN=$O(@FGLOB@(IEN)) Q:'IEN  D
 .. D DETAIL^BEHOCACV(.ADATA,IEN)
 .. I $G(@ADATA@(1))="No known allergies." S @TGLOB@(IEN)=""
 I $G(FGLOB)="" D  Q
 . S IEN=0
 . F  S IEN=$O(^AUPNPAT(IEN)) Q:'IEN  D
 .. I $D(^AUPNPAT(IEN,-9)) Q
 .. D DETAIL^BEHOCACV(.ADATA,IEN)
 .. I $G(@ADATA@(1))="No known allergies." S @TGLOB@(IEN)=""
 Q
 ;
REM(FGLOB,TGLOB,REMCODE,RMFROM,RMTHRU,OVD,FUT,MPARMS) ;EP
 I $G(TGLOB)="" Q
 I $G(REMCODE)'="" D RMD
 I $D(MPARMS("REMCODE")) D
 . S REMCODE=""
 . F  S REMCODE=$O(MPARMS("REMCODE",REMCODE)) Q:REMCODE=""  D RMD
 Q
 ;
RMD ;EP
 NEW IEN
 I $G(FGLOB)'="" D  Q
 . S IEN=""
 . F  S IEN=$O(@FGLOB@(IEN)) Q:'IEN  D RMF(IEN)
 ;
 I $G(FGLOB)="" D
 . S IEN=0
 . F  S IEN=$O(^BQIPAT(IEN)) Q:'IEN  D RMF(IEN)
 Q
 ;
RMF(DFN) ;EP - Find reminder
 NEW RIEN,RDATA
 S RIEN=$O(^BQIPAT(DFN,40,"B",REMCODE,""))
 I RIEN="" Q
 S RDATA=$G(^BQIPAT(DFN,40,RIEN,0)) I RDATA="" Q
 I $P(RDATA,U,3)=""!($P(RDATA,U,3)="N/A")&($P(RDATA,U,4)="") Q
 ;
 I FUT'=0 D  Q
 . I $P(RDATA,U,3)="DUE NOW" Q
 . I $P(RDATA,U,3)="RESOLVED" Q
 . I $P(RDATA,U,3)="DONE" Q
 . I $P(RDATA,U,4)'="" D
 .. I $G(RMFROM)'="" D
 ... I $P(RDATA,U,4)<RMFROM!($P(RDATA,U,4)>RMTHRU) Q
 ... S @TGLOB@(DFN)="",@CRIT@("REM",DFN,REMCODE)=""
 .. I $G(RMFROM)="",$P(RDATA,U,4)>DT S @TGLOB@(DFN)="",@CRIT@("REM",DFN,REMCODE)="" Q
 ;
 I OVD'=0 D  Q
 . I $P(RDATA,U,3)="RESOLVED" Q
 . I $P(RDATA,U,3)="DONE" Q
 . I $P(RDATA,U,4)>DT Q
 . S @TGLOB@(DFN)="",@CRIT@("REM",DFN,REMCODE)=""
 Q
 ;
POVS(FGLOB,TGLOB,POVS,POVSB,FDT,TDT,CNOT,MPARMS) ;EP - POV SNOMED search
 NEW PVPT,PSUB,TREF,NGLOB,LCT,CT,IEN,PVS
 S NGLOB=$NA(^TMP("BQIDCPOVS",$J)) K @NGLOB
 I $G(TGLOB)="" Q
 I $G(POVS)'="" D PVS
 I $G(POVSB)'="" D
 . S TREF=$NA(^TMP("BQISNLST",$J))
 . K @TREF
 . S OK=$$SUBLST^BSTSAPI(TREF,POVSB_"^36^1")
 . S PVS="" F  S PVS=$O(@TREF@(PVS)) Q:PVS=""  S POVS=$P(@TREF@(PVS),"^",1),MPARMS("POVS",POVS)=""
 I PVOP="!" D
 . I $D(MPARMS("POVS")) S POVS="" F  S POVS=$O(MPARMS("POVS",POVS)) Q:POVS=""  D PVS
 I PVOP="&" D
 . K PVPT
 . S POVS="",CT=0 F  S POVS=$O(MPARMS("POVS",POVS)) Q:POVS=""  D PVS S CT=CT+1
 . S IEN=""
 . F  S IEN=$O(PVPT(IEN)) Q:IEN=""  D
 .. S LCT=0,LB=""
 .. F  S LB=$O(PVPT(IEN,LB)) Q:LB=""  S LCT=LCT+1
 .. I LCT'=CT K PVPT(IEN),@CRIT@("POV",IEN) Q
 .. I LCT=CT,'CNOT S @TGLOB@(IEN)="" Q
 .. I LCT=CT,CNOT S @NGLOB@(IEN)="" K @CRIT@("POV",IEN)
 ;
 I CNOT,$G(FGLOB)'="" D
 . S IEN="" F  S IEN=$O(@FGLOB@(IEN)) Q:IEN=""  D
 .. I '$D(@NGLOB@(IEN)) S @TGLOB@(IEN)=""
 I CNOT,$G(FGLOB)="" D
 . S IEN=0 F  S IEN=$O(^AUPNPAT(IEN)) Q:'IEN  I '$D(@NGLOB@(IEN)) S @TGLOB@(IEN)=""
 K @NGLOB
 Q
 ;
PVS ;
 NEW DFN,IEN
 S TDT=$S(TDT'="":TDT,1:DT)
 I $G(FGLOB)'="" D  Q
 . NEW IEN
 . S IEN=""
 . F  S IEN=$O(@FGLOB@(IEN)) Q:'IEN  D
 .. I FDT="" D
 ... S BDT=""
 ... F  S BDT=$O(^AUPNVPOV("ASNC",IEN,POVS,BDT)) Q:BDT=""  D PVSDT
 .. I FDT'="" D
 ... S BGT=9999999-FDT,ENT=9999999-TDT,BDT=ENT-1
 ... F  S BDT=$O(^AUPNVPOV("ASNC",IEN,POVS,BDT)) Q:BDT=""!(BDT>BGT)  D PVSDT
 ;
 S IEN=""
 F  S IEN=$O(^AUPNVPOV("ASCI",POVS,IEN)) Q:IEN=""  D
 . I $G(^AUPNVPOV(IEN,0))="" Q
 . S DFN=$P($G(^AUPNVPOV(IEN,0)),U,2),VIS=$P(^AUPNVPOV(IEN,0),U,3) I VIS="" Q
 . I $G(^AUPNVSIT(VIS,0))="" Q
 . Q:"DXCT"[$P(^AUPNVSIT(VIS,0),U,7)
 . S VSDTM=$P(^AUPNVSIT(VIS,0),U,1)\1
 . I FDT'="",VSDTM<FDT!(VSDTM>TDT) Q
 . I DFN'="",PVOP="!",'CNOT S @TGLOB@(DFN)="",@CRIT@("POV",DFN,IEN)="" Q
 . I DFN'="",PVOP="!",CNOT S @NGLOB@(DFN)="" Q
 . I DFN'="",PVOP="&" S PVPT(DFN,POV)=IEN,@CRIT@("POV",DFN,IEN)=""
 ;
 Q
 ;
PVSDT ; EP
 S LIEN=""
 F  S LIEN=$O(^AUPNVPOV("ASNC",IEN,POVS,BDT,LIEN)) Q:LIEN=""  D
 . I $P($G(^AUPNVPOV(LIEN,11)),U,1)'=POVS Q
 . S VIS=$P($G(^AUPNVPOV(LIEN,0)),U,3) I VIS="" Q
 . I $G(^AUPNVSIT(VIS,0))="" Q
 . Q:"DXCT"[$P(^AUPNVSIT(VIS,0),U,7)
 . I PVOP="!",'CNOT S @TGLOB@(IEN)=LIEN,@CRIT@("POV",IEN,LIEN)="" Q
 . I PVOP="!",CNOT S @NGLOB@(IEN)="" Q
 . I PVOP="&" S PVPT(IEN,POV)=LIEN,@CRIT@("POV",DFN,IEN)=""
 Q
 ;
POV(FGLOB,TGLOB,POV,POVTX,FDT,TDT,CNOT,MPARMS) ;EP - POV search
 NEW PVPT,PTAX,TREF,NGLOB,LCT,CT,IEN
 S NGLOB=$NA(^TMP("BQIDCPOV",$J)) K @NGLOB
 I $G(TGLOB)="" Q
 I $G(POV)'="" D PV
 I $G(POVTX)'="" D
 . S TREF=$NA(MPARMS("POV"))
 . K @TREF
 . S PTAX=$P(@("^"_$P(POVTX,";",2)_$P(POVTX,";",1)_",0)"),"^",1)
 . D BLD^BQITUTL(PTAX,TREF)
 I PVOP="!" D
 . I $D(MPARMS("POV")) S POV="" F  S POV=$O(MPARMS("POV",POV)) Q:POV=""  D PV
 I PVOP="&" D
 . K PVPT
 . S POV="",CT=0 F  S POV=$O(MPARMS("POV",POV)) Q:POV=""  D PV S CT=CT+1
 . S IEN=""
 . F  S IEN=$O(PVPT(IEN)) Q:IEN=""  D
 .. S LCT=0,LB=""
 .. F  S LB=$O(PVPT(IEN,LB)) Q:LB=""  S LCT=LCT+1
 .. I LCT'=CT K PVPT(IEN),@CRIT@("POV",IEN) Q
 .. I LCT=CT,'CNOT S @TGLOB@(IEN)="" Q
 .. I LCT=CT,CNOT S @NGLOB@(IEN)="" K @CRIT@("POV",IEN)
 ;
 I CNOT,$G(FGLOB)'="" D
 . S IEN="" F  S IEN=$O(@FGLOB@(IEN)) Q:IEN=""  D
 .. I '$D(@NGLOB@(IEN)) S @TGLOB@(IEN)=""
 I CNOT,$G(FGLOB)="" D
 . S IEN=0 F  S IEN=$O(^AUPNPAT(IEN)) Q:'IEN  I '$D(@NGLOB@(IEN)) S @TGLOB@(IEN)=""
 K @NGLOB
 Q
 ;
PV ;EP
 NEW DFN,IEN
 S TDT=$S(TDT'="":TDT,1:DT)
 I $G(FGLOB)'="" D  Q
 . NEW IEN
 . S IEN=""
 . F  S IEN=$O(@FGLOB@(IEN)) Q:'IEN  D
 .. I FDT="" D
 ... S BDT=""
 ... F  S BDT=$O(^AUPNVPOV("AA",IEN,BDT)) Q:BDT=""  D PVDT
 .. I FDT'="" D
 ... S BGT=9999999-FDT,ENT=9999999-TDT,BDT=ENT-1
 ... F  S BDT=$O(^AUPNVPOV("AA",IEN,BDT)) Q:BDT=""!(BDT>BGT)  D PVDT
 ;
 S IEN=""
 F  S IEN=$O(^AUPNVPOV("B",POV,IEN)) Q:IEN=""  D
 . I $G(^AUPNVPOV(IEN,0))="" Q
 . S DFN=$P($G(^AUPNVPOV(IEN,0)),U,2),VIS=$P(^AUPNVPOV(IEN,0),U,3) I VIS="" Q
 . I $G(^AUPNVSIT(VIS,0))="" Q
 . Q:"DXCT"[$P(^AUPNVSIT(VIS,0),U,7)
 . S VSDTM=$P(^AUPNVSIT(VIS,0),U,1)\1
 . I FDT'="",VSDTM<FDT!(VSDTM>TDT) Q
 . I DFN'="",PVOP="!",'CNOT S @TGLOB@(DFN)="",@CRIT@("POV",DFN,IEN)="" Q
 . I DFN'="",PVOP="!",CNOT S @NGLOB@(DFN)="" Q
 . I DFN'="",PVOP="&" S PVPT(DFN,POV)=IEN,@CRIT@("POV",DFN,IEN)=""
 ;
 Q
 ;
PVDT ;EP
 S LIEN=""
 F  S LIEN=$O(^AUPNVPOV("AA",IEN,BDT,LIEN)) Q:LIEN=""  D
 . I $P($G(^AUPNVPOV(LIEN,0)),U,1)'=POV Q
 . S VIS=$P($G(^AUPNVPOV(LIEN,0)),U,3) I VIS="" Q
 . I $G(^AUPNVSIT(VIS,0))="" Q
 . Q:"DXCT"[$P(^AUPNVSIT(VIS,0),U,7)
 . I PVOP="!",'CNOT S @TGLOB@(IEN)=LIEN,@CRIT@("POV",IEN,LIEN)="" Q
 . I PVOP="!",CNOT S @NGLOB@(IEN)="" Q
 . I PVOP="&" S PVPT(IEN,POV)=LIEN,@CRIT@("POV",DFN,IEN)=""
 Q