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

AMH40P8.m

Go to the documentation of this file.
AMH40P8 ; IHS/CMI/LAB - POST INIT BH 4.0 P8
 ;;4.0;IHS BEHAVIORAL HEALTH;**8**;JUN 02, 2010;Build 7
 ;
ENV ;EP 
 F X="XPO1","XPZ1","XPZ2","XPI1" S XPDDIQ(X)=0
 I +$$VERSION^XPDUTL("XU")<8 D MES^XPDUTL($$CJ^XLFSTR("Version 8.0 of KERNEL is required.  Not installed",80)) D SORRY(2) I 1
 E  D MES^XPDUTL($$CJ^XLFSTR("Requires Kernel Version 8.0....Present.",80))
 I +$$VERSION^XPDUTL("DI")<22 D MES^XPDUTL($$CJ^XLFSTR("Version 22.0 of FILEMAN is required.  Not installed.",80)) D SORRY(2) I 1
 E  D MES^XPDUTL($$CJ^XLFSTR("Requires Fileman v22....Present.",80))
 I $E($$VERSION^XPDUTL("AMH"),1,3)'="4.0" D MES^XPDUTL($$CJ^XLFSTR("Version 4.0 of AMH is required.  Not installed.",80)) D SORRY(2) I 1
 E  D MES^XPDUTL($$CJ^XLFSTR("Requires AMH v4.0....Present.",80))
 I '$$INSTALLD("AMH*4.0*7") D SORRY(2)
 ;I +$$VERSION^XPDUTL("AUM")<17 D MES^XPDUTL($$CJ^XLFSTR("Version 17.0 of AUM (ICD UPDATE) is required.  Not installed",80)) D SORRY(2) I 1
 ;E  D MES^XPDUTL($$CJ^XLFSTR("Requires AUM Version 17.0....Present.",80))
 Q
 ;
PRE ;
 NEW AMHX,DIK,DA
 S AMHX=0 F  S AMHX=$O(^AMHSORT(AMHX)) Q:AMHX'=+AMHX  S DA=AMHX,DIK="^AMHSORT(" D ^DIK K DIK,DA
 S AMHX=0 F  S AMHX=$O(^AMHTPCAD(AMHX)) Q:AMHX'=+AMHX  S DA=AMHX,DIK="^AMHTPCAD(" D ^DIK K DIK,DA
 Q
FIXF1420 ;
 S AMHX=0 F  S AMHX=$O(^AMHTPCAD("B","F14.20",AMHX)) Q:AMHX'=+AMHX  D
 .S AMHT=$P(^AMHTPCAD(AMHX,0),U,2)
 .S AMHIEN=0 F  S AMHIEN=$O(^AMHPROB("C",AMHT,AMHIEN)) Q:AMHIEN'=+AMHIEN  D
 ..Q:'$D(^AMHPROB(AMHIEN,0))
 ..Q:$P(^AMHPROB(AMHIEN,0),U,1)'="F14.10"
 ..S DA=AMHIEN,DIE="^AMHPROB(",DR=".01///F14.20" D ^DIE K DA,DIE,DR
 ..Q
 .Q
 Q
 ;
POST ;EP
 D ADDZ86
 D FIXF1420
 D ADDDSMV
 S X=$$ADD^XPDMENU("AMH MENU SCREENING REPORTS","AMH M SUICIDE RISK REPORTS","SRA",35)
 I 'X W !,"Attempt to add SUICIDE SCREENING REPORTS option failed.." H 3
 S X=$$ADD^XPDMENU("AMH MENU SCREENING REPORTS","AMH GAD ONE PATIENT","GAD",50)
 I 'X W !,"Attempt to add AMH GAD ONE PATIENT option failed.." H 3
 S X=$$ADD^XPDMENU("AMH DE MENU MORE","AMH GAD ONE PATIENT","GAD",68)
 I 'X W !,"Attempt to add AMH GAD ONE PATIENT option failed.." H 3
 S X=$$ADD^XPDMENU("AMH MENU SCREENING REPORTS","AMH GAD MULTIPLE PTS","GADS",52)
 I 'X W !,"Attempt to add AMH GAD MULTIPLE PATIENTS option failed.." H 3
 S X=$$ADD^XPDMENU("AMH DE MENU MORE","AMH GAD MULTIPLE PTS","GADS",69)
 I 'X W !,"Attempt to add AMH GAD MULTIPLE PATIENTS option failed.." H 3
 S X=$$ADD^XPDMENU("AMH M PATIENT LISTINGS","AMHR SBIRT","SB")
 I 'X W !,"Attempt to add SBIRT REPORT option failed.." H 3
 Q
 ;
ADDDSMV ;add all new dsm v codes
 D MES^XPDUTL($$CJ^XLFSTR("Adding codes.",IOM))
 S AMHX=0 F  S AMHX=$O(^AMHTPCAD(AMHX)) Q:AMHX'=+AMHX  D
DSM10 .;ADD DSM5 ICD10 CODES
 .S AMHCODE=$P(^AMHTPCAD(AMHX,0),U,1)
 .Q:AMHCODE=""
 .S AMHNARR=$P(^AMHTPCAD(AMHX,0),U,2)
 .S AMHPC=$P(^AMHTPCAD(AMHX,0),U,3)
 .S AMHPCC=$O(^AMHPROBC("B",AMHPC,0))
 .I 'AMHPCC D MES^XPDUTL("PROBLEM CODE MISSING: "_AMHPC_" CODE "_AMHCODE_" NOT UPLOADED") Q
 .S AMHICD=$P(^AMHTPCAD(AMHX,0),U,17)
 .S AMHEHR=$P(^AMHTPCAD(AMHX,0),U,15)
 .S AMHNOBH=$P(^AMHTPCAD(AMHX,0),U,18)
 .S AMHCS=$P(^AMHTPCAD(AMHX,0),U,10)
 .;FIND EXISTING AND OVERLAY
 .K DIE,DA,DR
 .S DA=""
 .S AMHY=0 F  S AMHY=$O(^AMHPROB("B",AMHCODE,AMHY)) Q:AMHY'=+AMHY!(DA)  D
 ..Q:$P(^AMHPROB(AMHY,0),U,10)'=5  ;ONLY DSMV
 ..Q:$$UP^XLFSTR($P(^AMHPROB(AMHY,0),U,2))'=$$UP^XLFSTR(AMHNARR)
 ..S DA=AMHY
 .I DA D EDITC Q
 .;ADD THEN EDIT
 .K DIC,DLAYGO,DIADD,DD,D0
 .S DITC=1
 .S X=AMHCODE,DIC="^AMHPROB(",DLAYGO=9002012.2,DIADD=1,DIC(0)="EMQ"
 .S DIC("DR")=".02///"_AMHNARR_";.03////"_AMHPCC_";.17///"_AMHICD_";.1///"_AMHCS_";.15///"_AMHEHR_";.18///"_AMHNOBH
 .D FILE^DICN
 .I Y=-1 W !,"ERROR ON ",AMHX," ",AMHCODE," ",DIC("DR") K DA,DIC,DIADD,DLAYGO,DR,DD,D0,DO,DITC Q
 .K DA,DIC,DIADD,DLAYGO,DR,DD,D0,DO,DITC
 .D MES^XPDUTL("."_$P(^AMHPROB(+Y,0),U,1))
 .Q
 Q
EDITC ;
 S DIE="^AMHPROB(",DR=".02///"_AMHNARR_";.03////"_AMHPCC_";.17///"_AMHICD_";.1///"_AMHCS_";.15///"_AMHEHR_";.18///"_AMHNOBH
 D ^DIE
 I $D(Y) D MES^XPDUTL("DSM CODE FAILED UPDATING: "_AMHCODE) K DIE,DA,DR Q
 D MES^XPDUTL("."_$P(^AMHPROB(DA,0),U,1))
 K DIE,DA,DR
 Q
INACTPC ;
 D MES^XPDUTL($$CJ^XLFSTR("Inactivating codes.",IOM))
 S AMHX=0 F  S AMHX=$O(^AMHPCIN(AMHX)) Q:AMHX'=+AMHX  D
 .Q:$P(^AMHPCIN(AMHX,0),U,3)'=1
 .S AMHC=$P(^AMHPCIN(AMHX,0),U,1)
 .;loop through "B" on AMHPROB and flag all that are not already flagged
 .S AMHY=0 F  S AMHY=$O(^AMHPROB("B",AMHC,AMHY)) Q:AMHY'=+AMHY  D
 ..I '$D(^AMHPROB(AMHY,0)) Q
 ..;I $P(^AMHPROB(AMHY,0),U,13),$P(^AMHPROB(AMHY,0),U,14)]"" Q  ;already flagged
 ..S DA=AMHY,DIE="^AMHPROB(",DR=".13///1;.14////"_$P(^AMHPCIN(AMHX,0),U,5) D ^DIE K DA,DIE,DR
 ..D MES^XPDUTL("."_$P(^AMHPROB(AMHY,0),U,1))
 ..Q
 .Q
 Q
ADDZ86 ;
 I $O(^AMHPROB("B","Z86.59",0)) G ADDZ86E
 ;ADD THEN EDIT
 K DIC,DLAYGO,DIADD,DD,D0
 S DITC=1
 S X="Z86.59",DIC="^AMHPROB(",DLAYGO=9002012.2,DIADD=1,DIC(0)="EMQ"
 S DIC("DR")=".02///PERSONAL HISTORY OF OTHER MENTAL AND BEHAVIORAL DISORDERS;.03///99.9;.1///0;.17///Z86.59"
 D FILE^DICN
 I Y=-1 W !,"ERROR ON ",AMHX," ",AMHCODE," ",DIC("DR") K DA,DIC,DIADD,DLAYGO,DR,DD,D0,DO,DITC Q
 K DA,DIC,DIADD,DLAYGO,DR,DD,D0,DO,DITC
 D MES^XPDUTL("ADDED "_$P(^AMHPROB(+Y,0),U,1))
 Q
ADDZ86E ;
 S DA=$O(^AMHPROB("B","Z86.59",0))
 S DIE="^AMHPROB(",DR=".02///PERSONAL HISTORY OF OTHER MENTAL AND BEHAVIORAL DISORDERS;.03///99.9;.1///0;.17///Z86.59" D ^DIE K DIE,DA,DR
 Q
 ;
INSTALLD(AMHSTAL) ;EP - Determine if patch AMHSTAL was installed, where
 ; APCLSTAL is the name of the INSTALL.  E.g "AG*6.0*11".
 ;
 NEW AMHY,DIC,X,Y
 S X=$P(AMHSTAL,"*",1)
 S DIC="^DIC(9.4,",DIC(0)="FM",D="C"
 D IX^DIC
 I Y<1 D IMES Q 0
 S DIC=DIC_+Y_",22,",X=$P(AMHSTAL,"*",2)
 D ^DIC
 I Y<1 D IMES Q 0
 S DIC=DIC_+Y_",""PAH"",",X=$P(AMHSTAL,"*",3)
 D ^DIC
 S AMHY=Y
 D IMES
 Q $S(AMHY<1:0,1:1)
IMES ;
 D MES^XPDUTL($$CJ^XLFSTR("Patch """_AMHSTAL_""" is"_$S(Y<1:" *NOT*",1:"")_" Present.",IOM))
 Q
SORRY(X) ;
 KILL DIFQ
 I X=3 S XPDQUIT=2 Q
 S XPDQUIT=X
 W *7,!,$$CJ^XLFSTR("Sorry....FIX IT!",IOM)
 Q