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

BQIPTALG.m

Go to the documentation of this file.
BQIPTALG ;PRXM/HC/ALA-Patient Allergies ; 25 Apr 2007  4:52 PM
 ;;2.3;ICARE MANAGEMENT SYSTEM;;Apr 18, 2012;Build 59
 ;
 Q
 ;
EN(DATA,DFN) ;EP -- BQI PATIENT ALLERGIES
 ;Input
 ;  DFN - Patient internal entry number
 ;
 NEW UID,II,HDR,IEN,AGENT,RN,REAC,REC,H,LEN,LENGTH,DLEN,BQID,BI
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIPTALG",UID))
 K @DATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIPTALG D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 NEW ONSET,OBHIS,AGLIST,ALENGTH,ALEN
 S HDR="I00010ALLERGY_IEN^T00064AGENT^T"
 S IEN="",AGLIST=""
 F  S IEN=$O(^GMR(120.8,"B",DFN,IEN)) Q:IEN=""  D
 . I $$GET1^DIQ(120.8,IEN_",",22,"I")=1 Q
 . ;S AGENT=$$GET1^DIQ(120.8,IEN_",",1,"E")
 . S AGENT=$$GET1^DIQ(120.8,IEN_",",.02,"E")
 . S AGLIST=AGLIST_AGENT_";"
 . S ONSET=$$GET1^DIQ(120.8,IEN_",",4,"I")
 . I ONSET S ONSET=$$FMTE^BQIUL1($P(ONSET,"."))
 . S OBHIS=$$GET1^DIQ(120.8,IEN_",",6,"E")
 . ;S RN=0,REAC=$$GET1^DIQ(120.8,IEN_",",.02,"E")
 . ;S REAC=$S(REAC=AGENT:"",1:REAC_";")
 . S RN=0,REAC=""
 . F  S RN=$O(^GMR(120.8,IEN,10,RN)) Q:'RN  D
 .. NEW DA,IENS
 .. S DA(1)=IEN,DA=RN,IENS=$$IENS^DILF(.DA)
 .. S REC=$$GET1^DIQ(120.81,IENS,.01,"E")
 .. I REC="OTHER REACTION" S REC=$$GET1^DIQ(120.81,IENS,1,"E")
 .. S REAC=REAC_REC_";"
 . S REAC=$$TKO^BQIUL1(REAC,";"),LEN=$L(REAC),H(LEN)=IEN
 . S BQID(IEN)=AGENT_U_REAC_U_ONSET_U_OBHIS
 ;
 S AGLIST=$$TKO^BQIUL1(AGLIST,";"),ALENGTH=$L(AGLIST)
 S LENGTH=$O(H(""),-1)
 I +LENGTH=0 S LENGTH=1
 I +ALENGTH=0 S ALENGTH=1
 S DLEN=$E("00000",$L(LENGTH)+1,5)_LENGTH
 S ALEN=$E("00000",$L(ALENGTH)+1,5)_ALENGTH
 S HDR=HDR_DLEN_"REACTION"_U_"D00020DATE_OF_ONSET^T00020OBSERVED/HISTORICAL^T00025ASSESSMENT"
 S @DATA@(II)=HDR_$C(30)
 I '$D(BQID) S II=II+1,$P(@DATA@(II),U,6)=$$ASE(DFN)_$C(30)
 S BI=""
 F  S BI=$O(BQID(BI)) Q:BI=""  S II=II+1,@DATA@(II)=BI_U_BQID(BI)_U_$C(30)
 ;
 S II=II+1,@DATA@(II)=$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(II),$D(DATA) S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
ALG(DFN) ;EP
 NEW IEN,AGLIST,AGENT
 ; Call EHR API to find out no allergy assessment or no known allergies
 D DETAIL^BEHOCACV(.ADATA,DFN)
 I $O(@ADATA@(1))'="" D
 . S IEN="",AGLIST=""
 . F  S IEN=$O(^GMR(120.8,"B",DFN,IEN)) Q:IEN=""  D
 .. I $$GET1^DIQ(120.8,IEN_",",22,"I")=1 Q
 .. S AGENT=$$GET1^DIQ(120.8,IEN_",",.02,"E")
 .. S AGLIST=AGLIST_AGENT_"; "_$C(13)_$C(10)
 ;
 I $O(@ADATA@(1))="" D
 . S AGLIST=$G(@ADATA@(1))
 . S AGLIST=$$LOWER^VALM1(AGLIST)
 . S AGLIST=$TR(AGLIST,".","")
 ;
 Q $$TKO^BQIUL1(AGLIST,"; "_$C(13)_$C(10))
 ;
ASE(DFN) ;EP - Assess allergies
 NEW ADATA,AGLIST
 S AGLIST=""
 ; Call EHR API to find out no allergy assessment or no known allergies
 D DETAIL^BEHOCACV(.ADATA,DFN)
 I $O(@ADATA@(1))="" D
 . S AGLIST=$G(@ADATA@(1))
 . S AGLIST=$$LOWER^VALM1(AGLIST)
 . S AGLIST=$TR(AGLIST,".","")
 Q AGLIST