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

BQITDVAL.m

Go to the documentation of this file.
BQITDVAL ;APTIV/HC/ALA-Dx Tag Validation Program ; 09 Apr 2008  6:58 PM
 ;;2.5;ICARE MANAGEMENT SYSTEM;**1**;May 24, 2016;Build 17
 ;
VAL(DATA,DFN,TAG,STAT) ;EP -- BQI DX TAG VALIDATION
 ; Input
 ;    DFN  - Patient internal entry number
 ;    TAG  - the diagnosis tag internal entry number for which is being updated
 ;    STAT - status of the tag management
 ;
 ; Output
 ;    RESULT  - 1 is okay to proceed, -1 cannot proceed 
 ;    HANDLER - 'W' is a warning message to be displayed, 'O' is an override
 ;    MSG     - Message to display for either a 'W' or an 'O'
 ; 
 NEW UID,II
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQITDVAL",UID))
 K @DATA
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQITDVAL D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S TAG=$G(TAG,"") I TAG="" S BMXSEC="No Diagnosis Category identified" Q
 S STAT=$G(STAT,"") I STAT="" S BMXSEC="No status identified" Q
 S DFN=$G(DFN,"") I DFN="" S BMXSEC="No patient identified" Q
 ;
 NEW THCFL,RESULT,SEX,AGE,HIEN,HORD,ACT
 S @DATA@(II)="I00010RESULT^T00001HANDLER^T01024MSG"_$C(30)
 S THCFL=+$P(^BQI(90506.2,TAG,0),U,10)
 ; If there is no hierachy, then no further checks need to be performed
 ; Status can change to any other status
 I 'THCFL S RESULT="1^^" G DONE
 ; Check status of hierarchy
 S HIEN=$O(^BQI(90506.2,TAG,4,"B",TAG,""))
 S HORD=$P(^BQI(90506.2,TAG,4,HIEN,0),U,2),ORD=HORD,ACT=0
 ; if nothing after this order, then check for higher
 I $O(^BQI(90506.2,TAG,4,"AC",ORD),-1)'="" D HG
 I ACT G DONE
 S ORD=HORD
 I $O(^BQI(90506.2,TAG,4,"AC",ORD))'="" D LW
 ;
DONE ;
 S II=II+1,@DATA@(II)=RESULT_$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
 ;
LW ; Check for an active lower hierarchy
 NEW ACT,HCIEN,HCTAG,RIEN,CSTAT ;,ORD
 S ACT=0
 F  S ORD=$O(^BQI(90506.2,TAG,4,"AC",ORD)) Q:ORD=""  D  Q:ACT
 . S HCIEN=$O(^BQI(90506.2,TAG,4,"AC",ORD,""))
 . S HCTAG=$P(^BQI(90506.2,TAG,4,HCIEN,0),U,1)
 . S RIEN=$O(^BQIREG("C",DFN,HCTAG,"")) I RIEN="" Q
 . S CSTAT=$P(^BQIREG(RIEN,0),U,3)
 . I CSTAT="A"!(CSTAT="P") S ACT=1
 I 'ACT,$P($G(RESULT),U)'<0 S RESULT="1^^"
 I ACT S RESULT="-1^O^Patient already has "_$$GET1^DIQ(90509,RIEN_",",.01,"E")_" with a status of "_$$GET1^DIQ(90509,RIEN_",",.03,"E")_"."
 Q
 ;
HG ; Check for an active higher hierarchy
 NEW ACT,HCIEN,HCTAG,RIEN,CSTAT ;,ORD
 S ACT=0
 F  S ORD=$O(^BQI(90506.2,TAG,4,"AC",ORD),-1) Q:ORD=""  D  Q:ACT
 . S HCIEN=$O(^BQI(90506.2,TAG,4,"AC",ORD,""))
 . S HCTAG=$P(^BQI(90506.2,TAG,4,HCIEN,0),U,1)
 . S RIEN=$O(^BQIREG("C",DFN,HCTAG,"")) I RIEN="" Q
 . S CSTAT=$P(^BQIREG(RIEN,0),U,3)
 . S ACT=$$ACST^BQITDUTL(CSTAT)
 I 'ACT,$P($G(RESULT),U)'<0 S RESULT="1^^"
 I ACT S RESULT="-1^W^Patient already has "_$$GET1^DIQ(90509,RIEN_",",.01,"E")_" with a status of "_$$GET1^DIQ(90509,RIEN_",",.03,"E")_".  You must first change its status to 'NOT ACCEPTED'."
 Q