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

IBDFUTL3.m

Go to the documentation of this file.
IBDFUTL3 ;ALB/MAF - MAINTENANCE UTILITY CONT. ;4/24/95
 ;;3.0;AUTOMATED INFO COLLECTION SYS;**63,70**;APR 24, 1997;Build 46
 ;
 ;
 ;
REPLACE ;  -- Replace invalid code with another valid code... it will be in
 ;     the same place as the old invalid code.
 N IBDFVALM,VALMY,IBBLK,IBDFSLC,IBDFSLC1,IBDFSLC2,IBFORM,IBGRP,IBLIST,DA,IBSEL,ORDER,IEN,IBDN,IBDX,IBD9,IBD10,IBDQUIT,IBDREP
 N IBDN,IBDX,IBD9,IBD10,IBDINV,IBDSV
 S IBDQUIT=0
 S VALMBCK=""
 D EN^VALM2($G(XQORNOD(0)),"S") G REP:'$O(VALMY(0)) S IBDFVALM=0
 D FULL^VALM1 S VALMBCK="R"
 F IBDFVALM=0:0 S IBDFVALM=$O(VALMY(IBDFVALM)) Q:IBDFVALM']""  D  Q:$G(IBDINV)=1
 .I $G(^XTMP("CPTIDX",IBDFVALM))="*Replaced*"!($G(^XTMP("CPTIDX",IBDFVALM))="*Deleted*") S IBDINV=1 W !,"Not a valid selection; selection has already been replaced or deleted." H 3 Q
 .S (IBDFSEL,DA)=$P($G(^XTMP("CPTIDX",IBDFVALM)),"^",4) I DA]"" S IBDFSLC=$G(^IBE(357.3,DA,0)),IBDFSLC1=$G(^IBE(357.3,DA,1,1,0)),IBDFSLC2=$G(^IBE(357.3,DA,1,2,0)) D
 ..I $G(^XTMP("CPTIDX",IBDFVALM))="*Replaced*"!($G(^XTMP("CPTIDX",IBDFVALM))="*Deleted*") S IBDINV=1 W !,"Not a valid selection; selection has already been replaced or deleted." H 3 Q
 ..S IBFORM=$P($G(^XTMP("CPTIDX",IBDFVALM)),"^",5)
 ..S IBGRP=$P(IBDFSLC,"^",4)
 ..S IBLIST=$P(IBDFSLC,"^",3)
 ..S ORDER=$P(IBDFSLC,"^",5)
 ..S IBBLK=$P($G(^XTMP("CPTIDX",IBDFVALM)),"^",6)
 ..S IBDREP=$P($G(^XTMP("CPTIDX",IBDFVALM)),"^")
 ..S IBDSV(IBDREP)=IBDFVALM
 Q:$G(IBDINV)=1
 D REPLC(IBLIST,IBGRP,ORDER,.IBSEL,IBBLK,IBFORM,.IBDQUIT)
 Q:IBDQUIT
 I ^XTMP("IBDCPT",IBDREP,0)'["*******Replaced*******",^XTMP("IBDCPT",IBDREP,0)'="   " S ^XTMP("IBDCPT",IBDREP,0)=$P(^XTMP("IBDCPT",IBDREP,0),")")_")        *******Replaced*******" D
 .S ^XTMP("CPTIDX",IBDSV(IBDREP))="*Replaced*"
 S IBDN="",(IBD9,IBD10)=0 F  S IBDN=$O(^IBE(357.2,"C",IBBLK,IBDN)) Q:IBDN=""  S IBDX=$P($G(^IBE(357.2,IBDN,0)),U,11) I IBDX?1.N S IBDX=$E($P($G(^IBE(357.6,IBDX,0)),U,1),1,30) D
 .I IBDX="DG SELECT ICD-9 DIAGNOSIS CODE" S IBD9=1
 .I IBDX="DG SELECT ICD-10 DIAGNOSIS COD" S IBD10=1
 ;Now update history if ICD-9 or ICD-10 was present before or after the change
 N IBDX
 I IBD9 S IBDX=$$CSUPD357^IBDUTICD(IBFORM,1,"",$$NOW^XLFDT(),DUZ)
 I IBD10 S IBDX=$$CSUPD357^IBDUTICD(IBFORM,30,"",$$NOW^XLFDT(),DUZ)
 K IBDF,^TMP("UTIL",$J) D INIT^IBDFUTL S VALMBCK="R" Q
 ;
 ;
REPLC(IBLIST,IBGRP,ORDER,IBSEL,IBBLK,IBFORM,IBDQUIT) ;allows the user to add a selection to the selection group for replacement - returns 0 if it was done, 1 otherwise
 N SUB,IBRTN,IBDSERCH
 ;
 Q:'$$FORMDSCR^IBDFU1C(.IBFORM)
 Q:$$BLKDESCR^IBDFU1B(.IBBLK) 1
 Q:$$LSTDESCR^IBDFU1(.IBLIST) 1
 S IBRTN=IBLIST("RTN")
 D RTNDSCR^IBDFU1B(.IBRTN)
 ;N QUIT S QUIT=0
 I IBRTN("ACTION")'=3 D NOGOOD^IBDF4 Q 1
 S IBDSERCH=2  ;Lexicon search.
 K @IBRTN("DATA_LOCATION")
 I '$$DORTN^IBDFU1B(.IBRTN,IBDSERCH) D NOGOOD^IBDF4 Q 1
 I $D(DUOUT)!($D(DTOUT))!('$D(@IBRTN("DATA_LOCATION"))) D:$D(IBSEL) KILL3573(IBSEL) S IBDQUIT=1 Q
 D ADDREC^IBDF4(.IBDQUIT,ORDER,.IBSEL,$P($G(@IBRTN("DATA_LOCATION")),U)) ;edits and adds the selection
 I IBDQUIT=1 D KILL3573(IBSEL)
 K @IBRTN("DATA_LOCATION")
 ;  -- If a selection has been chosen,  the old node is killed off and
 ;     the block/selection list is updated.
 I IBDQUIT Q
 S DA=IBDFSEL,DIK="^IBE(357.3," D ^DIK K DIK D BLKCHNG^IBDF19(IBFORM,IBBLK)
 Q
 ;To kill incomplete entries in ^IBE(357.3
KILL3573(IBDSEL) ;
 N DA,DIK
 S DA=IBDSEL,DIK="^IBE(357.3," D ^DIK K DIK ;D BLKCHNG^IBDF19(IBFORM,IBBLK)
 Q
REP K IBDF D INIT^IBDFUTL S VALMBG=1,VALMBCK="R"
 Q
REPLALL ;Replace all invalid code with another valid code, in same spot
 ;     the same place as the old invalid code.
 N IBDFVALM,VALMY,IBBLK,IBDFSLC,IBDFSLC1,IBDFSLC2,IBFORM,IBGRP,IBLIST,DA,IBSEL,ORDER,IEN,IBDN,IBDX,IBD9,IBD10,IBDQUIT
 N IBDN,IBDX,IBD9,IBD10,IBDRPCAL,IBDFSEL,IBDSEL1,IBDTMP,IBDINV,Y
 S IBDQUIT=0,IBDRPCAL=1
 S VALMBCK=""
 D EN^VALM2($G(XQORNOD(0)),"S") G REP:'$O(VALMY(0)) S IBDFVALM=0
 Q:$G(IBDINV)
 D FULL^VALM1 S VALMBCK="R"
 F IBDFVALM=0:0 S IBDFVALM=$O(VALMY(IBDFVALM)) Q:IBDFVALM']""  D  Q:$G(IBDINV)=1
 .I $G(^XTMP("CPTIDX",IBDFVALM))="*Replaced*"!($G(^XTMP("CPTIDX",IBDFVALM))="*Deleted*") S IBDINV=1 W !,"Not a valid selection; selection has already been replaced or deleted." H 3 Q
 .S (IBDFSEL,DA)=$P($G(^XTMP("CPTIDX",IBDFVALM)),"^",4) I DA]"" S IBDFSLC=$G(^IBE(357.3,DA,0)),IBDFSLC1=$G(^IBE(357.3,DA,1,1,0)),IBDFSLC2=$G(^IBE(357.3,DA,1,2,0)) D
 ..S IBFORM=$P($G(^XTMP("CPTIDX",IBDFVALM)),"^",5)
 ..S IBGRP=$P(IBDFSLC,"^",4)
 ..S IBLIST=$P(IBDFSLC,"^",3)
 ..S ORDER=$P(IBDFSLC,"^",5)
 ..S IBBLK=$P($G(^XTMP("CPTIDX",IBDFVALM)),"^",6)
 ..S IBDTMP=$P($G(^XTMP("CPTIDX",IBDFVALM)),"^")
 ..S IBDSEL1(IBDFVALM)=""
 Q:$G(IBDINV)=1
 D REPLC(IBLIST,IBGRP,ORDER,.IBSEL,IBBLK,IBFORM,.IBDQUIT)
 Q:IBDQUIT
 I ^XTMP("IBDCPT",IBDTMP,0)'["*******Replaced*******",^XTMP("IBDCPT",IBDTMP,0)'="   " S ^XTMP("IBDCPT",IBDTMP,0)=$P(^XTMP("IBDCPT",IBDTMP,0),")")_")        *******Replaced*******"
 S IBDN="",(IBD9,IBD10)=0 F  S IBDN=$O(^IBE(357.2,"C",IBBLK,IBDN)) Q:IBDN=""  S IBDX=$P($G(^IBE(357.2,IBDN,0)),U,11) I IBDX?1.N S IBDX=$E($P($G(^IBE(357.6,IBDX,0)),U,1),1,30) D
 .I IBDX="DG SELECT ICD-9 DIAGNOSIS CODE" S IBD9=1
 .I IBDX="DG SELECT ICD-10 DIAGNOSIS COD" S IBD10=1
 ;Now update history if ICD-9 or ICD-10 was present before or after the change
 ;I IBD10 S IBDX=$$CSUPD357^IBDUTICD(IBFORM,30,"",$$NOW^XLFDT(),DUZ)
 F  S DIR(0)="Y",DIR("A")="Would you like to add another replacement code to the original",Y="" D ^DIR Q:'Y  D REPMULT
 K IBDF,^TMP("UTIL",$J),^TMP("IBDANT",$J) D INIT^IBDFUTL S VALMBCK="R" Q
 ;
REPMULT ;Replace Mutilple codes for a  single
 N IBDX,IBDRPCAL,IBLIST,IBDORDER,IBDQT,SLCTN,IBFORM,IBDSERCH,IBDGRP,IBDYS,IBDOLD,IBDERR,IBDX1,IBDGRP1,IBDSUB,IBDSUB1,IBDSNEW,IBDSELN,IBDSBI,IBDNEW,IBDN1,IBDCODE,IBDATA,IBDATA1,X,IBDSLLT
 S IBDQT=0
 S IBDX=0 S IBDX=$O(^TMP("IBDANT",$J,IBDX)) Q:'IBDX!(IBDQT=1)  S IBLIST=$P(^TMP("IBDANT",$J,IBDX),U,3),IBFORM=$P(^TMP("IBDANT",$J,IBDX),U),IBDGRP=$P(^TMP("IBDANT",$J,IBDX),U,4)
 D LSTDESCR^IBDFU1(.IBLIST)
 S IBRTN=IBLIST("RTN")
 D RTNDSCR^IBDFU1B(.IBRTN)
 S IBDSERCH=2  ;Lexicon search.
 K @IBRTN("DATA_LOCATION")
 I '$$DORTN^IBDFU1B(.IBRTN,IBDSERCH) D NOGOOD^IBDF4 Q
 I $D(DUOUT)!($D(DTOUT))!('$D(@IBRTN("DATA_LOCATION"))) D:$D(IBSEL) KILL3573(IBSEL) S IBDQT=1 Q
 S IBDORDER=$P(^TMP("IBDANT",$J,IBDX),U,5) F  S IBDORDER=IBDORDER+.1 Q:'$D(^IBE(357.3,"APO",IBLIST,IBDGRP,IBDORDER))
 D ADDREC^IBDF4(.IBDQUIT,IBDORDER,.IBSEL,$P($G(@IBRTN("DATA_LOCATION")),U)) ;edits and adds the selection
 F  S IBDX=$O(^TMP("IBDANT",$J,IBDX)) Q:'IBDX  D
 .S IBDGRP=$P(^TMP("IBDANT",$J,IBDX),U,4)
 .S IBDSLLT=$P(^TMP("IBDANT",$J,IBDX),U,3)
 .S IBDORDER=$P(^TMP("IBDANT",$J,IBDX),U,5) F  S IBDORDER=IBDORDER+.1 Q:'$D(^IBE(357.3,"APO",IBDSLLT,IBDGRP,IBDORDER))
 .S IBDYS=IBSEL_"," D GETS^DIQ(357.3,IBDYS,"**","NI","IBDOLD","IBDERR")
 .K DIC,DD,DO,DINUM S DIC="^IBE(357.3,",X=$P(^IBE(357.3,IBSEL,0),"^",1),DIC(0)="FL",DLAYGO=357.3 D FILE^DICN S IBDNEW=+Y K DIC,DIE,DA
 .S DIE="^IBE(357.3,",DA=IBDNEW S IBDATA=$G(IBDOLD(357.3,IBDYS,.02,"I")) I IBDATA'="" S DR=".02///"_IBDATA D ^DIE
 .S DR=".03////"_IBDSLLT D ^DIE
 .S DR=".04////"_IBDGRP D ^DIE
 .S DR=".05///"_IBDORDER D ^DIE
 .S IBDN=.05 F  S IBDN=$O(IBDOLD(357.3,IBDYS,IBDN)) Q:'IBDN  S IBDATA=IBDOLD(357.3,IBDYS,IBDN,"I") I IBDATA'="" I IBDN'=2.02 I IBDN'=4.02 S DR=IBDN_"///"_IBDATA D ^DIE
 .S IBDATA=$G(IBDOLD(357.3,IBDYS,2.02,"I")) I IBDATA'="" S DR=2.02_"////"_IBDATA D ^DIE
 .S IBDATA=$G(IBDOLD(357.3,IBDYS,4.02,"I")) I IBDATA'="" S DR=4.02_"////"_IBDATA D ^DIE
 .S IBDSELN=IBSEL_"," D GETS^DIQ(357.3,IBDSELN,"**","N","IBDCODE","IBDERR")
 .I $D(IBDCODE(357.31)) S IBDSUB="" F  S IBDSUB=$O(IBDCODE(357.31,IBDSUB)) Q:IBDSUB=""  S IBDSBI=IBDCODE(357.31,IBDSUB,.01) S DIC="^IBE(357.3,"_IBDNEW_",1,",X=IBDSBI,DA(1)=IBDNEW,DA=X,DIC(0)="FL",DLAYGO=357.31 D FILE^DICN S IBDSNEW=+Y D
 ..S IBDN1=.01,DIE="^IBE(357.3,"_DA(1)_",1,",DA(1)=IBDNEW,DA=IBDSNEW,IBDSUB1=.01 F  S IBDSUB1=$O(IBDCODE(357.31,IBDSUB,IBDSUB1)) Q:IBDSUB1=""  S IBDATA1=IBDCODE(357.31,IBDSUB,IBDSUB1) I IBDATA1'="" S DR=IBDSUB1_"///^S X=IBDATA1" D ^DIE
 .I $D(IBDCODE(357.33)) S IBDSUB="" F  S IBDSUB=$O(IBDCODE(357.33,IBDSUB)) Q:IBDSUB=""  S IBDSBI=IBDCODE(357.33,IBDSUB,.01) S DIC="^IBE(357.3,"_IBDNEW_",3,",X=IBDSBI,DA(1)=IBDNEW,DA=X,DIC(0)="FL",DLAYGO=357.33 D FILE^DICN S IBDSNEW=+Y D
 ..S IBDN1=.01,DIE="^IBE(357.3,"_DA(1)_",3,",DA(1)=IBDNEW,DA=IBDSNEW,IBDSUB1=.01 F  S IBDSUB1=$O(IBDCODE(357.33,IBDSUB,IBDSUB1)) Q:IBDSUB1=""  S IBDATA1=IBDCODE(357.31,IBDSUB,IBDSUB1) I IBDATA1'="" S DR=IBDSUB1_"///^S X=IBDATA1" D ^DIE
 Q