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

BQIPTREG.m

Go to the documentation of this file.
BQIPTREG ;PRXM/HC/ALA-RPMS Registers a Patient is on ; 07 Nov 2005  1:59 PM
 ;;2.1;ICARE MANAGEMENT SYSTEM;;Feb 07, 2011
 ;
 Q
 ;
REG(DATA,DFN) ; EP -- BQI PATIENT RPMS REGISTERS
 ;
 ;Find all the registers a patient is on
 ;
 ;Description
 ;  For all the active designated registers, see if a patient is on it
 ;Input
 ;  DFN - Patient internal entry number
 ;
 NEW REGIEN,RDATA,FILE,FIELD,XREF,GLREF,REGISTER,BQI,UID,TITLE,STAT
 NEW GLBREF,RIEN,BQIREG,DX,RGCAT,RGDUZ,STATDT,KEY,RACC,NMSP,X,IEN
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIPTREG",UID))
 K @DATA
 ;
 S BQI=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIPTREG D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S @DATA@(BQI)="T00040COMBINED^T00004ANAMESPACE^T00030REG_TITLE^T00015REG_STAT^D00030REG_STATDT^T00030REG_CAT^T00035REG_CREATOR^T00003REG_ACCESS"_$C(30)
 ;
 ;  for each defined registry index definition, determine if this patient is in
 ;  that registry
 S REGIEN=0
 F  S REGIEN=$O(^BQI(90507,REGIEN)) Q:'REGIEN  D
 . Q:$$GET1^DIQ(90507,REGIEN_",",.08,"I")=1
 . S RDATA=^BQI(90507,REGIEN,0)
 . S FILE=$P(RDATA,"^",7),FIELD=$P(RDATA,"^",5),XREF=$P(RDATA,"^",6)
 . S TITLE=$P(RDATA,"^",1),KEY=$P(RDATA,"^",10),NMSP=$P(RDATA,"^",13)
 . I '$$VFILE^DILFD(FILE) Q
 . S GLBREF=$$ROOT^DILFD(FILE,"")_XREF_")"
 . Q:'$D(@GLBREF@(DFN))
 . ; HMS Registry
 . I FILE=90451 D
 .. S REGISTER=$$HIVIEN^BKMIXX3()
 .. S IEN=$O(@GLBREF@(DFN,""))
 .. NEW DA,IENS
 .. S DA(1)=IEN,DA=REGISTER,IENS=$$IENS^DILF(.DA)
 .. S STAT=$$GET1^DIQ(90451.01,IENS,.5,"E")
 .. S STATDT=$$GET1^DIQ(90451.01,IENS,.75,"I")
 .. S RGCAT=$$GET1^DIQ(90451.01,IENS,2.3,"E")
 .. S RGDUZ=$$GET1^DIQ(90451.01,IENS,.025,"E")
 .. S RACC=$$KEYCHK^BQIULSC(KEY,DUZ)
 .. D STOR
 . ; CMS Registry
 . I FILE=9002241 D
 .. S TITLE=$$GET1^DIQ(90507,REGIEN_",",.01,"E")
 .. S REGISTER=$$GET1^DIQ(90507,REGIEN_",",.09,"E")
 .. I REGISTER="" D ACM Q
 .. D CMSI^BQIUL1(REGISTER) S BQIREG=+Y K X,Y
 .. I BQIREG<1 Q
 .. S DX=$O(^ACM(44,"AC",BQIREG,DFN,"")) Q:DX=""
 .. S IEN=^ACM(44,"AC",BQIREG,DFN,DX)
 .. S RIEN=$$GET1^DIQ(9002244,IEN_",",.03,"I")
 .. S STAT=$$GET1^DIQ(9002241,RIEN_",",1,"E")
 .. S STATDT=$$GET1^DIQ(9002241,RIEN_",",11,"I")
 .. S RGCAT=$$GET1^DIQ(9002244,IEN_",",.01,"E")
 .. S RGDUZ=$$GET1^DIQ(9002241.1,BQIREG_",",3.5,"E")
 .. S RACC=$$KEYCHK^BQIULSC(KEY,DUZ)
 .. D STOR
 . ;
 . I FILE=90181.01 D
 .. S TITLE=$$GET1^DIQ(90507,REGIEN_",",.01,"E")
 .. S IEN=DFN
 .. S STAT=$$GET1^DIQ(FILE,IEN_",",.02,"E"),STATDT="",RGCAT=""
 .. S RGDUZ=$$GET1^DIQ(FILE,IEN_",",.11,"E")
 .. S RACC=$$KEYCHK^BQIULSC(KEY,DUZ)
 .. D STOR
 ;
 S BQI=BQI+1,@DATA@(BQI)=$C(31)
 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(BQI),$D(DATA) S BQI=BQI+1,@DATA@(BQI)=$C(31)
 Q
 ;
STOR ;  Store value
 S BQI=BQI+1
 S @DATA@(BQI)=NMSP_": "_TITLE_"^"_NMSP_"^"_TITLE_"^"_STAT_"^"_$$FMTE^BQIUL1(STATDT)_"^"_RGCAT_"^"_RGDUZ_"^"_$S(RACC=-1:"N/A",RACC=1:"Y",1:"N")_$C(30)
 Q
 ;
ACM ;  Get all sub-registers a patient is on
 S RACC=$$KEYCHK^BQIULSC(KEY,DUZ)
 S RIEN=""
 F  S RIEN=$O(^ACM(41,"C",DFN,RIEN)) Q:RIEN=""  D
 . S STAT=$$GET1^DIQ(9002241,RIEN_",",1,"E")
 . S STATDT=$$GET1^DIQ(9002241,RIEN_",",11,"I")
 . S IEN=$O(^ACM(44,"D",RIEN,"")),RGCAT=""
 . I IEN'="" S RGCAT=$$GET1^DIQ(9002244,IEN_",",.01,"E")
 . S BQIREG=$$GET1^DIQ(9002241,RIEN_",",.01,"I") I BQIREG="" Q
 . S RGDUZ=$$GET1^DIQ(9002241.1,BQIREG_",",3.5,"E")
 . S TITLE=$$GET1^DIQ(9002241,RIEN_",",.01,"E")
 . D STOR
 Q