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

AMHCDBL2.m

Go to the documentation of this file.
  1. AMHCDBL2 ; IHS/CMI/LAB - backload pcc visits ;
  1. ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
  1. ;
  1. ;backfill BH with CDMIS Data
  1. CS ;EP
  1. ;create MHSS record first
  1. S AMHCDST=0 F S AMHCDST=$O(^ACDCS("C",AMHIEN,AMHCDST)) Q:AMHCDST'=+AMHCDST D CS1
  1. Q
  1. CS1 ;
  1. ;get activity code from acdcs
  1. S A=$P(^ACDCS(AMHCDST,0),U,2) I A="" W !,"Client service, no activity code. ",AMHIEN," ",$P(^ACDCS(AMHCDST,0),U,2)," is ien of activity" Q
  1. S A=$P($G(^ACDSERV(A,0)),U,2) I A="" W !,"Client service, no activity code to map. ",AMHIEN," ",$P(^ACDCS(AMHCDST,0),U,2)," is ien of activity" Q
  1. S AMHACT=$$ACONV(A)
  1. I AMHACT="" W !,"No conversion of activity code on client service. ",AMHIEN," code is ",A Q
  1. S AMHDAY=$P(^ACDCS(AMHCDST,0),U) I $L(AMHDAY)=1 S AMHDAY="0"_AMHDAY
  1. S AMHDATE=$E(AMHDATE,1,5)_AMHDAY
  1. K DIC S DIC(0)="EL",DIC="^AMHREC(",DLAYGO=9002011,DIADD=1,X=AMHDATE,DIC("DR")=".02///C;.03///^S X=DT;.19////"_DUZ_";.33////R;.28////"_DUZ_";.22///A;.21///^S X=DT"
  1. K DD,DO,D0 D FILE^DICN K DIC,DR,DIE,DIADD,DLAYGO,X,D0
  1. I Y=-1 W !!,$C(7),$C(7),"Error creating Behavioral Health Record!! Deleting Record.",! Q
  1. S AMHR=+Y,DIE="^AMHREC(",DA=AMHR,DR="5100///NOW",DR(2,9002011.5101)=".02////^S X=DUZ" D ^DIE K DIE,DA,DR
  1. S AMHTIME=$P($G(^ACDCS(AMHCDST,0)),U,4) S AMHTIME=AMHTIME*60 I 'AMHTIME S AMHTIME=1
  1. S DIE="^AMHREC(",DA=AMHR,DR=".04////"_AMHLOC_";.05////"_AMHDCOM_";.06///"_AMHACT_";.07///2;.08////"_AMHPAT_";.09///1;1101///"_AMHCOMP_";.12///"_AMHTIME_";.25///43;.32///"_AMHTC_";1105///"_AMHCOMT,DIE="^AMHREC(" D ^DIE
  1. I $D(Y) W !!,"error editing MHSS Record entry ",AMHIEN," ",AMHMIEN
  1. ;get initial entry and file activity time and mhss staging tool entry, get problem for later use
  1. S AMHSTR0=^ACDCS(AMHCDST,0)
  1. K AMHPROB
  1. ;S X=$O(^TMP($J,"ACDCONV",AMHPAT,0)) Q:X="" S AMHPROB(1)=^TMP($J,"ACDCONV",AMHPAT,X)
  1. ;I X="" W !,"could not find problem code for this client service...SKIPPING ",AMHCDST,! Q
  1. D GETVSITS,CHKFIN
  1. I 'AMHY W !!,AMHIEN," ",AMHCDST," no initial to get problems." Q
  1. S AMHINI=$O(^ACDIIF("C",AMHY,0))
  1. S AMHSTR0=^ACDIIF(AMHINI,0)
  1. S AMHPROB(1)=$P(AMHSTR0,U)_U_$P(^ACDPROB($P(AMHSTR0,U),0),U)_U_$P(^ACDPROB($P(AMHSTR0,U),0),U,2)
  1. D PROBCONV
  1. D ^XBFMK
  1. ;now create pov/provider
  1. S X=AMHPROV,DIC("DR")=".02////"_AMHPAT_";.03////"_AMHR_";.04///P",DIC="^AMHRPROV(",DIC(0)="MLQ",DIADD=1,DLAYGO=9002011.02
  1. K DD,DO D FILE^DICN K DIC,DA,DO,DD,D0,DG,DH,DI,DIW,DIU,DIADD,DIE,DQ,DLAYGO
  1. I Y=-1 W !!,"Creating Primary Provider entry failed!!!",$C(7),$C(7) H 2
  1. D ^XBFMK
  1. S AMHX=0 F S AMHX=$O(^ACDCS(AMHCDST,1,AMHX)) Q:AMHX'=+AMHX D
  1. .S AMHPRV1=$P($G(^ACDCS(AMHCDST,1,AMHX,0)),U)
  1. .Q:AMHPRV1=""
  1. .S X=AMHPRV1,DIC("DR")=".02////"_AMHPAT_";.03////"_AMHR_";.04///P",DIC="^AMHRPROV(",DIC(0)="MLQ",DIADD=1,DLAYGO=9002011.02
  1. .K DD,DO D FILE^DICN K DIC,DA,DO,DD,D0,DG,DH,DI,DIW,DIU,DIADD,DIE,DQ,DLAYGO
  1. .I Y=-1 W !!,"Creating Secondary Prov entry for Client Service entry failed!!!"," ",$P(^VA(200,AMHPRV1,0),U)," ",AMHCDST H 2
  1. S AMHX=0 F S AMHX=$O(AMHPROB(AMHX)) Q:AMHX'=+AMHX D
  1. .S X=$P(AMHPROB(AMHX),U,5),DIC("DR")=".02////"_AMHPAT_";.03////"_AMHR_";.04///"_$P(AMHPROB(AMHX),U,2),DIC="^AMHRPRO(",DIC(0)="MLQ",DIADD=1,DLAYGO=9002011.01 K DD,DO D FILE^DICN K DIC,DA,DO,DD,D0,DG,DH,DI,DIW,DIU,DIADD,DIE,DQ,DLAYGO
  1. .I Y=-1 W !!,"Creating POV entry failed!!!",$C(7),$C(7) H 2
  1. .D ^XBFMK
  1. ;S AMHACTN=1
  1. ;D PCCLINK^AMHCDBL
  1. Q
  1. PROBCONV ;
  1. S X=0 F S X=$O(AMHPROB(X)) Q:X'=+X S %=$$PCONV($P(AMHPROB(X),U,3)),$P(AMHPROB(X),U,4)=%,$P(AMHPROB(X),U,5)=$O(^AMHPROB("B",%,0))
  1. Q
  1. GETVSITS ; EP - GET CDMIS VISITS FOR THIS CLIENT
  1. K ^TMP("AMHCONV",$J,"VISITS")
  1. S AMHVCNT=0,Y=0
  1. F S Y=$O(^ACDVIS("D",AMHPAT,Y)) Q:'Y S X=^ACDVIS(Y,0) I $P($G(^("BWP")),U)=AMHLOC D
  1. . S ^TMP("AMHCONV",$J,"VISITS",$P(X,U),Y)=X,AMHVCNT=AMHVCNT+1
  1. . Q
  1. Q
  1. CHKFIN ; EP - CHECK FOR INITIAL CONTACT TYPE
  1. S AMHX="",(AMHY,Y)=0
  1. F S AMHX=$O(^TMP("AMHCONV",$J,"VISITS",AMHX)) Q:AMHX="" S Y=0 F S Y=$O(^TMP("AMHCONV",$J,"VISITS",AMHX,Y)) Q:'Y S X=^(Y) I $P(X,U,2)=AMHCOMPI,$P(X,U,7)=AMHCOMTI,$P(X,U,4)="IN" S AMHY=Y Q
  1. Q
  1. ACONV(P) ;
  1. I P=7 Q 41
  1. I P="ACU" Q 23
  1. I P=19 Q 23
  1. I P=6 Q 23
  1. I P=11 Q 23
  1. I P=23 Q 23
  1. I P="ACO" Q 12
  1. I P="DUI" Q 12
  1. I P="AOT" Q 12
  1. I P=14 Q 34
  1. I P=16 Q 31
  1. I P=15 Q 61
  1. I P=13 Q 14
  1. I P=3 Q 14
  1. I P=4 Q 14
  1. I P=2 Q 13
  1. I P=1 Q 12
  1. I P="MAS" Q 23
  1. I P=20 Q 23
  1. I P="MMO" Q 23
  1. I P=10 Q 34
  1. I P=12 Q 34
  1. I P="PH" Q 26
  1. I P=10 Q 23
  1. I P=22 Q 23
  1. I P=17 Q 25
  1. I P=21 Q 23
  1. I P=9 Q 14
  1. I P=8 Q 14
  1. I P=5 Q 82
  1. I P=18 Q 38
  1. I P="URS" Q 23
  1. I P="CNOS1" Q 12
  1. I P="CNOS2" Q 12
  1. I P="CNOS3" Q 12
  1. I P="MIA" Q 23
  1. I P="OTH" Q 23
  1. Q 23
  1. PCONV(P) ;
  1. I P=17 Q 89
  1. I P=1 Q 29
  1. I P=18 Q 94
  1. I P=30 Q 43
  1. I P=2 Q 30
  1. I P=42 Q 23
  1. I P=16 Q 3
  1. I P=36 Q 42.2
  1. I P=40 Q 44.2
  1. I P=32 Q 43.2
  1. I P=12 Q 59
  1. I P=14 Q 79
  1. I P=60 Q 312.31
  1. I P=61 Q 26
  1. I P=44 Q 302.6
  1. I P=53 Q 80
  1. I P=3 Q "305.90"
  1. I P=13 Q 88
  1. I P=11 Q 56
  1. I P=15 Q 5
  1. I P=55 Q 3
  1. I P="MIA" Q 8
  1. I P=37 Q 47
  1. I P=41 Q 48
  1. I P=33 Q 49
  1. I P=19 Q 82
  1. I P=20 Q 26
  1. I P=34 Q 42.1
  1. I P=38 Q 44.1
  1. I P=49 Q 66
  1. I P=35 Q 42.3
  1. I P=39 Q 44.3
  1. I P=31 Q 43.3
  1. I P=43 Q 302.9
  1. I P=50 Q 62
  1. I P=10 Q 304.83
  1. I P=9 Q 62
  1. I P=47 Q 40
  1. I P=48 Q 41
  1. I P=46 Q 41
  1. I P=45 Q 39
  1. I P=29 Q "305.10"
  1. Q 4