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

BQIRGUTL.m

Go to the documentation of this file.
BQIRGUTL ;PRXM/HC/ALA-Register Utilities ; 26 Nov 2007  1:51 PM
 ;;2.1;ICARE MANAGEMENT SYSTEM;;Feb 07, 2011
 ;
MEAS(BQIDFN,TYPE,HDR) ;EP - Get last FEV value for this patient
 NEW IEN,QFL,VALUE,FLD
 S FLD=$S(TYPE="FEV":.05,TYPE="FEF":.06,1:.07)
 S IEN="",QFL=0,VALUE=""
 F  S IEN=$O(^AUPNVAST("C",BQIDFN,""),-1) Q:IEN=""  D  Q:QFL
 . S VALUE=$$GET1^DIQ(9000010.41,IEN_",",FLD,"E")
 . I VALUE'="" S QFL=1 Q
 I $E(HDR,1,1)="N",VALUE="" S VALUE=-1
 Q VALUE
 ;
HIV(BQIDFN,HFLD,OUT) ;EP - Get HIV register data
 NEW BQRIEN,HIVIEN,HFIL,DA,IENS
 S OUT=$G(OUT,"E")
 S BQRIEN=$$BKMIEN^BKMIXX3(BQIDFN) I BQRIEN="" Q ""
 S HIVIEN=$$HIVIEN^BKMIXX3() I HIVIEN="" Q ""
 S HFIL=90451.01
 S DA(1)=BQRIEN,DA=HIVIEN,IENS=$$IENS^DILF(.DA)
 S VAL=$$GET1^DIQ(HFIL,IENS,HFLD,OUT)
 Q VAL
 ;
HIVD(BQIDFN,HFLD) ; EP - Get HIV register dates
 NEW BQRIEN,HIVIEN,HFIL,DA,IENS
 S BQRIEN=$$BKMIEN^BKMIXX3(BQIDFN) I BQRIEN="" Q ""
 S HIVIEN=$$HIVIEN^BKMIXX3() I HIVIEN="" Q ""
 S HFIL=90451.01
 S DA(1)=BQRIEN,DA=HIVIEN,IENS=$$IENS^DILF(.DA)
 S VAL=$$GET1^DIQ(HFIL,IENS,HFLD,"I")
 S VAL=$$FMTE^BQIUL1(VAL)
 Q VAL
 ;
HIVM(BQIDFN,HFLD,HSBFLD,HSRTFLD) ; EP - Get last entry for an HIV multiple field
 NEW BQRIEN,HIVIEN,HFIL,DA,IENS,HARRAY,LIEN,BQVAL,HSBFIL,NOD,HTYPE
 NEW SARRAY,SDATA,SNOD,SORT,SPC,LSTSRT
 S BQRIEN=$$BKMIEN^BKMIXX3(BQIDFN) I BQRIEN="" Q ""
 S HIVIEN=$$HIVIEN^BKMIXX3() I HIVIEN="" Q ""
 ; Get subfile number for the multiple
 S HSRTFLD=$G(HSRTFLD)
 K HARRAY
 S HFIL=90451.01
 D FIELD^DID(HFIL,HFLD,"","SPECIFIER;GLOBAL SUBSCRIPT LOCATION","HARRAY")
 S HSBFIL=$G(HARRAY("SPECIFIER")) I HSBFIL="" Q
 S HSBFIL=$$STRIP^XLFSTR(HSBFIL,"ABCDEFGHIJKLMNOPQRSTUVWXYZ")
 S NOD=$P($G(HARRAY("GLOBAL SUBSCRIPT LOCATION")),";",1) I NOD="" Q
 S BQVAL="A"
 ;S BQVAL=""
 I HSRTFLD D
 . D FIELD^DID(HSBFIL,HSRTFLD,"","GLOBAL SUBSCRIPT LOCATION","SARRAY")
 . S SNOD=$P($G(SARRAY("GLOBAL SUBSCRIPT LOCATION")),";",1) I SNOD="" Q
 . S SPC=$P(SARRAY("GLOBAL SUBSCRIPT LOCATION"),";",2) I SPC="" Q
 . S BQVAL=0
 . F  S BQVAL=$O(^BKM(90451,BQRIEN,1,HIVIEN,NOD,BQVAL)) Q:'BQVAL  D
 .. S SORT=$P($G(^BKM(90451,BQRIEN,1,HIVIEN,NOD,BQVAL,SNOD)),U,SPC)
 .. S SDATA(" "_SORT,BQVAL)=""
 . S LIEN="",LSTSRT=$O(SDATA(""),-1) I LSTSRT'="" S LIEN=$O(SDATA(LSTSRT,""),-1)
 I 'HSRTFLD S QFL=0 D  I QFL Q ""
 . I $D(^BKM(90451,BQRIEN,1,HIVIEN,NOD,"B")) S QFL=0 D  I QFL Q
 .. S BQVAL=$O(^BKM(90451,BQRIEN,1,HIVIEN,NOD,"B",BQVAL),-1)
 .. ;S BQVAL=$O(^BKM(90451,BQRIEN,1,HIVIEN,NOD,"B",BQVAL))
 .. I BQVAL="" S QFL=1 Q
 .. S LIEN="A"
 .. S LIEN=$O(^BKM(90451,BQRIEN,1,HIVIEN,NOD,"B",BQVAL,LIEN),-1)
 .. I LIEN="" S QFL=1
 . ;
 . I '$D(^BKM(90451,BQRIEN,1,HIVIEN,NOD,"B")) D
 .. S BQVAL=$O(^BKM(90451,BQRIEN,1,HIVIEN,NOD,""),-1)
 .. S LIEN=BQVAL
 I $G(LIEN)="" Q ""
 ;
 S DA(2)=BQRIEN,DA(1)=HIVIEN,DA=LIEN,IENS=$$IENS^DILF(.DA)
 K HARRAY
 D FIELD^DID(HSBFIL,HSBFLD,"","TYPE","HARRAY")
 S HTYPE=$G(HARRAY("TYPE"))
 ;I HTYPE="POINTER"!(HTYPE="SET") S VAL=$$GET1^DIQ(HSBFIL,IENS,HSBFLD,"I")_$C(28)_$$GET1^DIQ(HSBFIL,IENS,HSBFLD,"E")
 I HTYPE'["DATE" D
 . ;I HTYPE="POINTER" S VAL=$$GET1^DIQ(HSBFIL,IENS,HSBFLD,"I")_$C(28)_$$GET1^DIQ(HSBFIL,IENS,HSBFLD,"E") Q
 . ;I HTYPE="SET" Q
 . S VAL=$$GET1^DIQ(HSBFIL,IENS,HSBFLD,"E")
 I HTYPE["DATE" S VAL=$$GET1^DIQ(HSBFIL,IENS,HSBFLD,"I"),VAL=$$FMTE^BQIUL1(VAL)
 I HTYPE="WORD-PROCESSING" D
 . K BARRAY
 . S VAL=$$GET1^DIQ(HSBFIL,IENS,HSBFLD,"Z","BARRAY")
 . S LIEN=0,VAL=""
 . F  S LIEN=$O(BARRAY(LIEN)) Q:'LIEN  D
 .. S VAL=VAL_BARRAY(LIEN,0)_$C(10)
 . S VAL=$$TKO^BQIUL1(VAL,$C(10))
 Q VAL
 ;
HIVS(STR,CSTR,SEP) ; EP - Add separator for last entry for an HIV multiple
 ; String that may need a separator
 ; String that STR will be concatenated to
 ; Separator
 ;
 I $G(SEP)="" Q STR
 I $G(CSTR)'="",$E(CSTR,$L(CSTR))'=SEP S STR=SEP_STR
 Q STR
 ;
HIVST(STR,CSTR,SEP) ; EP - Strip trailing separator
 NEW STR1,STR2
 S STR1=$$TKO^BQIUL1(CSTR_STR,SEP)
 F  S STR2=$$TKO^BQIUL1(STR1,SEP) Q:STR1=STR2!(STR2="")
 Q STR2
 ;
STRIP(STR,VAL) ;EP - Remove one or more characters in a string.
 ;
 ;Description
 ;  Removes one or more trailing characters
 ;  at the end of a string.
 ;Input
 ;  STR - String of data
 ;  VAL - Delimiter character
 ;Output
 ;  Same STR without the trailing character(s).
 ;
 I $G(STR)="" Q STR
 I $G(VAL)="" Q STR
 ;
 NEW LVAL
 S LVAL=$L(VAL)
 F  Q:$E(STR,$L(STR)-LVAL+1,$L(STR))'=VAL  S STR=$E(STR,1,($L(STR)-LVAL))
 Q STR
 ;
HIVW(BQIDFN,HFLD) ; EP - Get a word-processing field
 NEW BQRIEN,HIVIEN,HFIL,DA,IENS,HARRAY,LIEN
 S BQRIEN=$$BKMIEN^BKMIXX3(BQIDFN) I BQRIEN="" Q ""
 S HIVIEN=$$HIVIEN^BKMIXX3() I HIVIEN="" Q ""
 K HARRAY
 S HFIL=90451.01
 S DA(1)=BQRIEN,DA=HIVIEN,IENS=$$IENS^DILF(.DA)
 S VAL=$$GET1^DIQ(HFIL,IENS,HFLD,"Z","HARRAY")
 S LIEN=0,VAL=""
 F  S LIEN=$O(HARRAY(LIEN)) Q:'LIEN  D
 . S VAL=VAL_HARRAY(LIEN,0)_$C(10)
 S VAL=$$TKO^BQIUL1(VAL,$C(10))
 Q VAL
 ;
HIVTR(DATA,LOC) ; EP - BQI HMS LOCATION TRIGGER
 ;
 ; Input
 ;   LOC - Location selected (required)
 ;         If location has a facility code of 49 or larger enable Other Location
 ;         and Other Provider
 NEW UID,II,CODE,ABLE
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIQOCTR",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIRREG D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S @DATA@(II)="T00008SOURCE^T00001ABLE_FLAG"_$C(30)
 S ABLE="N"
 ; Check facility code - if >48 enable Other Location and Other Provider fields
 S CODE=$$GET1^DIQ(9999999.06,LOC,.07,"I") I CODE>48 S ABLE="Y"
 S II=II+1,@DATA@(II)="BKMOL^"_ABLE_$C(30) ; Other Location
 S II=II+1,@DATA@(II)="BKMOP^"_ABLE_$C(30) ; Other Provider
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
LST(DATA,FAKE) ;EP - BQI REGISTER TAB LIST
 NEW UID,II,CAT,CLIN,DCIEN,REGIEN,REG
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J),II=0
 S DATA=$NA(^TMP("BQIRGLST",UID))
 K @DATA
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIRGLST D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S @DATA@(II)="T00030REGISTER^I00010REG_IEN^T00030REMINDER_CATEGORY^T00030REMINDER_CLIN_GROUP"_$C(30)
 ;
 S DCIEN=0
 F  S DCIEN=$O(^BQI(90507,DCIEN)) Q:'DCIEN  D
 . S REG=$$GET1^DIQ(90507,DCIEN_",",.01,"E")
 . S REGIEN=+$$GET1^DIQ(90507,DCIEN_",",.16,"I")
 . I 'REGIEN Q
 . S CAT=$$GET1^DIQ(90507,DCIEN_",",4.01,"E")
 . S CLIN=$$GET1^DIQ(90507,DCIEN_",",4.02,"E")
 . S II=II+1,@DATA@(II)=REG_U_DCIEN_U_CAT_U_CLIN_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
HMS(BQIDFN) ;EP - Return HMS record IENS
 NEW BQRIEN,HIVIEN,IENS,DA
 S BQRIEN=$$BKMIEN^BKMIXX3(BQIDFN) I BQRIEN="" Q ""
 S HIVIEN=$$HIVIEN^BKMIXX3() I HIVIEN="" Q ""
 S DA(1)=BQRIEN,DA=HIVIEN
 Q $$IENS^DILF(.DA)