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

BQIRMDR1.m

Go to the documentation of this file.
BQIRMDR1 ;VNGT/HS/ALA-Reminders continued ; 06 Nov 2008  3:53 PM
 ;;2.5;ICARE MANAGEMENT SYSTEM;;May 24, 2016;Build 27
 ;
REA ;EP - Reactivate record
 NEW DIE,DR,DA,CODE
 S DA=RIEN
 S BQIUPD(90506.1,DA_",",.1)="@"
 S BQIUPD(90506.1,DA_",",.11)="@"
 S BQIUPD(90506.1,DA_",",.03)=TEXT
 S BQIUPD(90506.1,DA_",",.08)=HDR
 S BQIUPD(90506.1,DA_",",.09)=$S($G(DEF)=1:"D",1:"O")
 S CODE=$P(^BQI(90506.1,DA,0),U,1)
 I CODE["AUTTIMM" D
 . I 'IMOK S BQIUPD(90506.1,DA_",",3.07)=1 Q
 . I IMOK S BQIUPD(90506.1,DA_",",3.07)="@"
 D FILE^DIE("","BQIUPD","ERROR")
 ;
 S BQIUPD(90506.1,DA_",",3.01)=SOURCE
 S BQIUPD(90506.1,DA_",",3.02)=RCLIN
 S BQIUPD(90506.1,DA_",",3.03)=RCAT
 S BQIUPD(90506.1,DA_",",3.04)=$S($G(DEF)=1:"Default",1:"Optional")
 D FILE^DIE("E","BQIUPD","ERROR")
 ;
 ; Make sure that the new style cross-references are set
 ;NEW DIK
 ;S DIK="^BQI(90506.1,",DIK(1)="3.01"
 ;D ENALL^DIK
 ;
 Q
 ;
EHR ;
 NEW EHIEN,ETLP,FN,IMM,PXN,FT,AST,UTEXT
 S SOURCE="Reminders",DEF=0,RCLIN=""
 S EHIEN=0
 F  S EHIEN=$O(^PXD(811.9,EHIEN)) Q:'EHIEN  D
 . I $G(^PXD(811.9,EHIEN,0))="" Q
 . ; If it is inactive, ignore
 . I $P(^PXD(811.9,EHIEN,0),U,6)=1 Q
 . S TEXT=$P(^PXD(811.9,EHIEN,0),U,3) I TEXT="" Q
 . S UTEXT=$$UP^XLFSTR(TEXT)
 . S FN=0,IMM=0,AST=0
 . ;I UTEXT="Immunization Forecast" S IMM=1
 . I UTEXT["IMMUNIZATION" S IMM=1
 . I $P(^PXD(811.9,EHIEN,0),U,1)[" IMMUN" S IMM=1
 . F  S FN=$O(^PXD(811.9,EHIEN,20,FN)) Q:'FN  D
 .. NEW DA,IENS
 .. S DA(1)=EHIEN,DA=FN,IENS=$$IENS^DILF(.DA)
 .. I $$GET1^DIQ(811.902,IENS,.01,"E")["IMMUNIZATION" S IMM=1 Q
 .. I $$GET1^DIQ(811.902,IENS,.01,"E")["ASTHMA" S AST=1 Q
 .. ;
 .. I $$GET1^DIQ(811.902,IENS,.01,"I")["PXRMD(811.5" D
 ... S PXN=$P($$GET1^DIQ(811.902,IENS,.01,"I"),";",1)
 ... S FT=0
 ... F  S FT=$O(^PXRMD(811.5,PXN,20,FT)) Q:'FT  D
 .... NEW DA,IENS
 .... S DA(1)=PXN,DA=FT,IENS=$$IENS^DILF(.DA)
 .... I $$GET1^DIQ(811.52,IENS,.01,"I")["AUTTIMM" S IMM=1
 . ;If the finding contains IMMUNIZATIONS and it is not turned on, quit
 . ;I IMM,+$P(^BQI(90508,1,0),U,16)=0 Q
 . I IMM Q
 . ;If the finding contains ASTHMA and it is not turned on, quit
 . I AST,+$P(^BQI(90508,1,0),U,17)=0 Q
 . S RCLIN=$$GET1^DIQ(811.9,EHIEN_",",100,"E")
 . S RCLIN=$$LOWER^VALM1(RCLIN)
 . S RCAT="EHR Clinical Reminders"
 . S CODE="EHR_"_EHIEN
 . S HDR="T00050"_CODE
 . S RIEN=$O(^BQI(90506.1,"B",CODE,""))
 . I RIEN="" D FILE^BQIRMDR Q
 . S ETLP=0 K ^BQI(90506.1,RIEN,4)
 . I $G(^BQI(90506.1,RIEN,4,0))="" S ^BQI(90506.1,RIEN,4,0)="^^"
 . F  S ETLP=$O(^PXD(811.9,EHIEN,1,ETLP)) Q:'ETLP  S ^BQI(90506.1,RIEN,4,ETLP,0)=^PXD(811.9,EHIEN,1,ETLP,0)
 . D REA
 Q
 ;
EMR(APCHSPAT,CODE) ;EP
 NEW EHIEN,RNAME
 S EHIEN=$P(CODE,"_",2)
 I $G(ERRCNT)="" S ERRCNT=0
 ;
 S (REMDUE,REMLAST,REMNEXT,RDATA)=""
 S DFN=APCHSPAT
 D MAIN^PXRM(DFN,EHIEN,1,1)
 I $G(%ZTERZE)'="" S ERRCNT=ERRCNT+1 K %ZTERZE Q
 S RNAME=$O(^TMP("PXRHM",$J,EHIEN,""))
 I RNAME'="" D
 . S RDATA=$G(^TMP("PXRHM",$J,EHIEN,RNAME))
 S REMDUE=$P(RDATA,U,2),REMLAST=$P(RDATA,U,3),REMNEXT=$P(RDATA,U,1)
 ;
 D FIL^BQIRMDR
 Q
 ;
VAR ;EP - Set variables
 S APCHSPAT=DFN
 S APCHSDOB=$P($G(^DPT(APCHSPAT,0)),U,3) I APCHSDOB="" Q
 S APCHSAGE=$$AGE^BQIAGE(APCHSPAT)
 S APCHSEX=$P(^DPT(APCHSPAT,0),U,2)
 S APCHSCVD="S:Y]"""" Y=+Y,Y=$E(Y,4,5)_""/""_$S($E(Y,6,7):$E(Y,6,7)_""/"",1:"""")_$E(Y,2,3)"
 S (APCHSANY,APCHSITM)=0,APCHNON=1,APCHSURX=""
 S APCHSCKP="S APCHSQIT=1 Q"
 S APCHSBRK="Q"
 S APCHSNPG=0
 K APCHSTEX
 Q
 ;
REG(APCHSPAT,CODE) ;EP
 NEW REG,HIEN,EXEC,RIEN,TAG,CMN,DEN,VAL
 S REG=$P(CODE,"_",2)
 S HIEN=$P(CODE,"_",3)
 ;
 ; Check if tag is associated with register
 S TAG=$O(^BQI(90506.2,"AD",REG,""))
 I TAG="" Q
 S CMN=$O(^BQI(90506.5,"D",REG,""))
 I CMN="" Q
 S DEN=$G(^BQI(90506.5,CMN,1))
 I DEN'="" X DEN I VAL'="Y" Q
 ;S RIEN=$O(^BQIREG("C",APCHSPAT,TAG,""))
 ;I RIEN="" Q
 ; Check if person has an active tag
 ;S CSTAT=$P(^BQIREG(RIEN,0),U,3)
 ;I '$$ACST^BQITDUTL(CSTAT) Q
 ;I CSTAT'="P"&(CSTAT'="A") Q
 ;I CSTAT'="P"&(CSTAT'="A") S RQFL=0 D  Q:RQFL
 ;. I '$$ORG^BQITDUTL(APCHSPAT,REG) S RQFL=1
 ;
 S EXEC="D "_$P(^BQI(90507,REG,15,HIEN,0),U,2)
 S EXEC=$TR(EXEC,";","^")
 S (REMDUE,REMLAST,REMNEXT)=""
 S DFN=APCHSPAT
 X EXEC
 ;
 D FIL^BQIRMDR
 Q
 ;
CMET ;
 NEW CIEN
 S SOURCE="Reminders",DEF=0,RCLIN=""
 S CIEN=0
 F  S CIEN=$O(^BTPW(90621,CIEN)) Q:'CIEN  D
 . ; If it is inactive, ignore
 . I $P(^BTPW(90621,CIEN,0),U,3)'="" Q
 . S TEXT=$P(^BTPW(90621,CIEN,0),U,1) I TEXT="N/A" Q
 . S RCLIN=$$GET1^DIQ(90621,CIEN_",",.1,"E")
 . S RCLIN=$$LOWER^VALM1(RCLIN)
 . S RCAT="CMET"
 . S CODE="CMET_"_CIEN
 . S HDR="T00050"_CODE
 . S RIEN=$O(^BQI(90506.1,"B",CODE,""))
 . I RIEN="" D FILE^BQIRMDR Q
 . D REA
 Q
 ;
CMT(APCHSPAT,CODE) ;EP
 NEW CRIEN
 S CRIEN=$P(CODE,"_",2)
 ;
 S (REMDUE,REMLAST,REMNEXT,RDATA)=""
 S DFN=APCHSPAT
 S RDATA=$$EVT^BTPWRMDR(APCHSPAT,CRIEN)
 I RDATA="" Q
 S REMDUE=$P(RDATA,U,7),REMLAST=$P(RDATA,U,5),VISIT=$P(RDATA,U,9)
 D FIL^BQIRMDR
 Q
 ;
VAL(CODE) ;EP - Get the name of a reminder given the CODE
 NEW RN,NAME
 S RN=$O(^BQI(90506.1,"B",CODE,"")) I RN="" Q ""
 S NAME=$P(^BQI(90506.1,RN,0),"^",3)
 I $P(CODE,"_",1)="AUTTIMM" Q ""
 I $P(CODE,"_",1)'="EHR",$P(CODE,"_",1)'="REG",$P(CODE,"_",1)'="CMET" S NAME=NAME_" (HS)"
 I $P(CODE,"_",1)="EHR" S NAME=NAME_" (EHR)"
 I $P(CODE,"_",1)="REG" S NAME=NAME_" (HMS)"
 I $P(CODE,"_",1)="CMET" S NAME=NAME_" (CMET)"
 I $P(CODE,"_",1)="IZ" S NAME=NAME_" (Forecaster)"
 Q NAME