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

BQIREM.m

Go to the documentation of this file.
BQIREM ;PRXM/HC/DLS - BQI PATIENT NATIONAL REMINDERS ; 20 Dec 2005  3:52 PM
 ;;2.5;ICARE MANAGEMENT SYSTEM;**2**;May 24, 2016;Build 14
 ;
 Q
 ;
EN(DATA,DFN) ; EP -- BQI PATIENT NATIONAL REMINDERS
 ;Description
 ;  Gets a list of precalculated reminders for a patient
 ;
 ;Input
 ;  DFN   - Patient IEN
 ;
 ;Output
 ;  DATA - Name of global in which data is stored(^TMP("BQIREM"))
 ;
 NEW UID,X,BQII,RDATA,IEN,REMCODE,REMNEXT,REMDUE,REMLAST,UPDT,VISIT
 NEW REMDATE,RCAT,RCLIN,ORD,PRI,REMDESC,NPRI,LPRI,REG,RGIEN,RIEN,RLIST
 NEW QFL,PREV,PRDT
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIREM",UID))
 K @DATA
 ;
 S RLIST=$G(RLIST,"")
 S BQII=0
 ;
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIREM D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 D HDR
 S IEN=0
 F  S IEN=$O(^BQIPAT(DFN,40,IEN)) Q:'IEN  D
 . S RDATA=^BQIPAT(DFN,40,IEN,0)
 . S REMCODE=$P(RDATA,U,1)
 . S RIEN=$O(^BQI(90506.1,"B",REMCODE,""))
 . I RIEN="" Q
 . I $P(^BQI(90506.1,RIEN,0),U,10)=1 Q
 . S REMDESC=$P(^BQI(90506.1,RIEN,0),U,3)
 . I REMDESC'?.U S REMDESC=REMDESC
 . I REMDESC?.UP S REMDESC=$$LOWER^VALM1(REMDESC)
 . I REMDESC="Breast Mri" S REMDESC="Breast MRI"
 . S REMLAST=$P(RDATA,U,2)
 . S REMNEXT=$P(RDATA,U,3)
 . I $P(REMCODE,"_",1)="EHR",REMNEXT="N/A" Q
 . S REMDUE=$P(RDATA,U,4)
 . S UPDT=$P(RDATA,U,5)
 . S VISIT=$P(RDATA,U,6)
 . I REMNEXT="",REMDUE="" Q
 . S PREV="N/A",PRDT=""
 . S:REMDUE="" REMDUE=DT
 . I $P(REMCODE,"_",1)="EHR" D
 .. I REMNEXT="DONE" S REMDUE=""
 .. I REMNEXT="RESOLVED" S REMDUE=""
 . ;S RCAT=$$GET1^DIQ(90506.1,RIEN_",",2.03,"E")
 . S RCAT=$$GET1^DIQ(90506.1,RIEN_",",3.03,"E")
 . ;S RCLIN=$$GET1^DIQ(90506.1,RIEN_",",2.05,"E")
 . S RCLIN=$$GET1^DIQ(90506.1,RIEN_",",3.02,"E")
 . S PRI="~",QFL=0
 . I $P(REMCODE,"_",1)="REG" D  Q:QFL
 .. S REG=$P(REMCODE,"_",2),RGIEN=$P(REMCODE,"_",3)
 .. NEW SRC
 .. S SRC=$O(^BQI(90506.5,"D",REG,""))
 .. I SRC'="",'$$NRPC^BQICMDNM(DFN,SRC) S QFL=1 Q
 .. S PRI=$P(^BQI(90507,REG,15,RGIEN,0),U,9)
 . I $P(REMCODE,"_",1)="CMET" D
 .. NEW PRVN,RMIEN
 .. S RMIEN=""
 .. F  S RMIEN=$O(^BTPWP("AE",DFN,"F",RMIEN)) Q:RMIEN=""  D
 ... I $P(^BTPWP(RMIEN,0),U,1)'=$P(REMCODE,"_",2) Q
 ... S PRVN=$P(^BTPWP(RMIEN,0),U,11)
 ... S PREV=$$GET1^DIQ(90620,PRVN_",",.01,"E")
 ... S PRDT=$$FMTE^BQIUL1($$GET1^DIQ(90620,PRVN_",",.03,"I"))
 . ;
 . S ORD(PRI,RIEN)=RCAT_U_RCLIN_U_REMCODE_U_REMDESC_U_$$FMTE^BQIUL1(REMLAST)_U_REMNEXT_U_$$FMTE^BQIUL1(REMDUE)_U_$$FMTE^BQIUL1(UPDT)_U_VISIT_U_PREV_U_PRDT
 ;
 S PRI=""
 F  S PRI=$O(ORD(PRI)) Q:PRI=""  D  S:PRI'="~" NPRI=PRI
 . S RIEN=""
 . F  S RIEN=$O(ORD(PRI,RIEN)) Q:RIEN=""  D
 .. I PRI'="~" S LPRI=PRI
 .. I PRI="~" S NPRI=$G(NPRI)+1,LPRI=NPRI
 .. S BQII=BQII+1,@DATA@(BQII)=ORD(PRI,RIEN)_U_LPRI_$C(30)
 ;
DONE ; Finished
 S BQII=BQII+1
 S @DATA@(BQII)=$C(31)
 Q
 ;
HDR ; Header
 S @DATA@(BQII)="T00030CATEGORY^T00030CLIN_GROUP^T00015REM_CODE^T00050REM_DESC^D00010REM_LAST^"
 S @DATA@(BQII)=@DATA@(BQII)_"T00040REM_NEXT^D00010REM_DUE^D00030LAST_UPDATED^I00010VISIT_IEN^"
 S @DATA@(BQII)=@DATA@(BQII)_"T00050PREV_EVENT^D00015PREV_DATE^I00003DISPLAY_ORDER"_$C(30)
 Q
 ;
ERR ;
 D ^%ZTER
 NEW Y,ERRDTM
 S Y=$$NOW^XLFDT() X ^DD("DD") S ERRDTM=Y
 S BMXSEC="Recording that an error occurred at "_ERRDTM
 I $D(BQII),$D(DATA) S BQII=BQII+1,@DATA@(BQII)=$C(31)
 I $$TMPFL^BQIUL1("C")
 Q
 ;
IMM(IDFN,IMIEN) ;EP - Get immunization due/last information
 ; Input
 ;  IDFN  - Patient internal entry number
 ;  IMIEN - Immunization internal entry number
 ;
 NEW BIIEN,BIDATA,BILAST
 S BIIEN="",BIDATA=""
 F  S BIIEN=$O(^BIPDUE("B",IDFN,BIIEN)) Q:BIIEN=""  D
 . I $G(^BIPDUE(BIIEN,0))="" Q
 . I $P(^BIPDUE(BIIEN,0),U,2)'=IMIEN Q
 . S BIDATA=$P(^BIPDUE(BIIEN,0),U,4)_U_$$FMTE^XLFDT($P(^BIPDUE(BIIEN,0),U,5),"2Z")
 . I $$PATCH^XPDUTL("BI*8.3*1") S BIDATA=BIDATA_U_$$LIMM(IDFN,IMIEN)
 Q BIDATA
 ;
LIMM(IDFN,IMIEN) ; EP - Get Last Immunization
 ; Input
 ;  IDFN  - Patient internal entry number
 ;  IMIEN - Immunization internal entry number
 NEW IRVDT,IRIEN,RVIS,RVALUE,FOK
 S RVALUE="",FOK=0,IRVDT=""
 F  S IRVDT=$O(^AUPNVIMM("AA",IDFN,IMIEN,IRVDT)) Q:IRVDT=""  D  Q:FOK
 . S IRIEN=""
 . F  S IRIEN=$O(^AUPNVIMM("AA",IDFN,IMIEN,IRVDT,IRIEN)) Q:IRIEN=""  D  Q:FOK
 .. S RVIS=$P($G(^AUPNVIMM(IRIEN,0)),U,3) I RVIS="" Q
 .. I $$GET1^DIQ(9000010,RVIS_",",.11,"I")=1 Q
 .. S RVALUE=$$GET1^DIQ(9000010,RVIS_",",.01,"I")\1_U_RVIS_U_IRIEN,FOK=1
 Q RVALUE