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

AMH40P4.m

Go to the documentation of this file.
AMH40P4 ; IHS/CMI/LAB - POST INIT BH 16 Apr 2009 7:37 AM 01 Aug 2009 5:37 AM ; 13 Apr 2010  3:54 PM
 ;;4.0;IHS BEHAVIORAL HEALTH;**4**;JUN 18, 2010;Build 28
 ;
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*3") D SORRY(2)
 Q
 ;
PRE ;
 S AMHPAIN=0
 S DA=0 F  S DA=$O(^AMHSORT(DA)) Q:DA'=+DA  S DIK="^AMHSORT(" D ^DIK
 S DA=0 F  S DA=$O(^AMHPCIN(DA)) Q:DA'=+DA  S DIK="^AMHPCIN(" D ^DIK
 S DA=0 F  S DA=$O(^AMHRECD(DA)) Q:DA'=+DA  S DIK="^AMHRECD(" D ^DIK
 S DA=0 F  S DA=$O(^AMHTPCAD(DA)) Q:DA'=+DA  S DIK="^AMHTPCAD(" D ^DIK
 K DA,DIK
 S DA=$O(^AMHPROBC("B",14,0))
 I DA S DIE="^AMHPROBC(",DR=".02///DEPRESSIVE DISORDERS" D ^DIE
 K DIE,DA
 I $$INSTALLD("AMH*4.0*4") S AMHPAIN=1  ;PATCH ALREADY INSTALLED ONCE
 Q
SETDSMD ;
 S AMHX=0 F  S AMHX=$O(^AMHSITE(AMHX)) Q:AMHX'=+AMHX  D
 .Q:$P($G(^AMHSITE(AMHX,18)),U,11)]""
 .S DA=AMHX,DIE="^AMHSITE(",DR="1811////3151001" D ^DIE K DIE,DA,DR
 .Q
 Q
 ;
POST ;EP
 ;STUFF DSM 5 DATE
 D SETDSMD
 S AMHX=$O(^DIC(19.1,"B","AMHZ PCC PROBLEM LIST",0))
 I AMHX D DEL^XPDKEY(AMHX)
 D DELETE^XPDMENU("AMH M PRINT TABLES","AMH P TABLES MH/SS PROBLEM DSM")
 D RENAME^XPDMENU("AMH P FREQ PROBLEMS (DSM)","AMH P FREQ PROBLEMS DX")
 D DELETE^XPDMENU("AMH M PROBLEM SPECIFIC","AMH P FREQ PROBLEMS DX")
 D ADD^XPDMENU("AMH M PROBLEM SPECIFIC","AMH P FREQ PROBLEMS DX","FDX",40)
 D ADD^XPDMENU("AMH M DATA ENTRY MENU","AMH DSM-5 COPYRIGHT","DSM",92)
 D FLAG4
 D INACTPC
 ;D FLAG5
 D FLAGOC
 D FLAGTP
 D BMXPO
 D ADDDSMV
 Q
 ;
ADDDSMV ;add all new dsm v codes
 Q:$$INSTALLD("AMH*4.0*4")
 S AMHX=0 F  S AMHX=$O(^AMHTPCAD(AMHX)) Q:AMHX'=+AMHX  D
 .I $P(^AMHTPCAD(AMHX,0),U,5)="" G DSM10
 .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")
 .;I AMHPCC S AMHPCC="`"_AMHPCC
 .S AMHICD=$P(^AMHTPCAD(AMHX,0),U,5)
 .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
 .;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^XLFST(AMHNARR)
 .;.S DA=AMHY
 .;I DA D EDIT9
 .;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_";.05///"_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
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")
 .;I AMHPCC S AMHPCC="`"_AMHPCC
 .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
 .;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^XLFST(AMHNARR)
 .;.S DA=AMHY
 .;I DA D EDIT9
 .;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
 Q
FLAGTP ;
 ;FLAG ALL TP'S with "old format", .22 field = 1
 ;FIRST CHECK TO SEE IF THIS RAN ALREADY, IF IT DID QUIT
 Q:$G(AMHPAIN)
 S AMHX=0 F  S AMHX=$O(^AMHPTXP(AMHX)) Q:AMHX'=+AMHX  D
 .S DA=AMHX,DIE="^AMHPTXP(",DR=".22///1" D ^DIE K DIE,DA,DR
 .Q
 Q
FLAGOC ;FLAG ALL OTHER CODES AS DSV IV OR PC
 ;SKIP IF ALREADY FLAGGED
 S AMHX=0 F  S AMHX=$O(^AMHPROB(AMHX)) Q:AMHX'=+AMHX  D
 .Q:$P(^AMHPROB(AMHX,0),U,10)]""
 .S C=$P(^AMHPROB(AMHX,0),U,1),S="",T=""
 .I $P(C,".")]"",$L($P(C,"."))<3 S S="P"
 .I S="" D
 ..I $T(^ICDEX)]"" S T=$P($$ICDDX^ICDEX(C),U,20) S:T=1 S=9 S:T=30 S=0 Q
 ..S S=9
 .S DA=AMHX,DIE="^AMHPROB(",DR=".1///"_S D ^DIE K DA,DIE,DR
 .W !,C,"  ",S
 Q
INACTPC ;
 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 to 4
 .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////"_DT D ^DIE K DA,DIE,DR
 ..;W AMHC,"."
 ..Q
 .Q
 Q
FLAG4 ;
 S AMHX=0 F  S AMHX=$O(^AMHPCIN(AMHX)) Q:AMHX'=+AMHX  D
 .Q:$P(^AMHPCIN(AMHX,0),U,2)'=1
 .S AMHC=$P(^AMHPCIN(AMHX,0),U,1)
 .;loop through "B" on AMHPROB and flag all that are not already flagged to 4
 .S AMHY=0 F  S AMHY=$O(^AMHPROB("B",AMHC,AMHY)) Q:AMHY'=+AMHY  D
 ..I '$D(^AMHPROB(AMHY,0)) Q
 ..Q:$P(^AMHPROB(AMHY,0),U,10)]""  ;already flagged
 ..S DA=AMHY,DIE="^AMHPROB(",DR=".1///4" D ^DIE K DA,DIE,DR
 ..;W AMHC,"."
 ..Q
 .Q
 Q
BMXPO ;-- update the RPC file
 N AMHRPC
 S AMHRPC=$O(^DIC(19,"B","AMHGRPC",0))
 Q:'AMHRPC
 D CLEAN(AMHRPC)
 D GUIEP^BMXPO(.RETVAL,AMHRPC_"|AMH")
 Q
 ;
CLEAN(APP) ;-- clean out the RPC multiple first
 S DA(1)=APP
 S DIK="^DIC(19,"_DA(1)_","_"""RPC"""_","
 N AMHDA
 S AMHDA=0 F  S AMHDA=$O(^DIC(19,APP,"RPC",AMHDA)) Q:'AMHDA  D
 . S DA=AMHDA
 . D ^DIK
 K ^DIC(19,APP,"RPC","B")
 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