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

ACHSC6D.m

Go to the documentation of this file.
ACHSC6D ; IHS/ITSC/PMF - CALCULATE EXPENDITURE REPORT BY AGE GROUP ;   [ 10/16/2001   8:16 AM ]
 ;;3.1;CONTRACT HEALTH MGMT SYSTEM;;JUN 11, 2001
 ;
ST ;
 D NOW^ACHS
 K ^TMP("ACHSC6",$J)
Z ;
 S ACHSTRDT=ACHSBDT-1,(ACHST64,ACHST43,ACHST57)=0
Z1 ;
 S ACHSTRDT=$O(^ACHSF(DUZ(2),"TB",ACHSTRDT))
 I ACHSTRDT<1!(ACHSTRDT>ACHSEDT) G ^ACHSC6P:ACHSRPT<3,^ACHSC6P1
 G Z1:'$D(^ACHSF(DUZ(2),"TB",ACHSTRDT,"I"))
 S DOC=0
Z2 ;
 S DOC=$O(^ACHSF(DUZ(2),"TB",ACHSTRDT,"I",DOC))
 G Z1:DOC<1,Z2:'$D(^ACHSF(DUZ(2),"D",DOC,0)) S X=$G(^ACHSF(DUZ(2),"D",DOC,0)),ACHSTY=$P(X,U,4)
 I ACHSRPT1<4,ACHSTY'=ACHSRPT1 G Z2
 S DFN=$P(X,U,22)
 G Z2:DFN<1,Z2:'$D(^DPT(DFN,0))
 S (ACHSTOT,ACHSTOA,ACHSP3B,ACHSESDA,ACHST43,ACHSWKL,ACHST64,ACHST57)=0
 I $G(^ACHSF(DUZ(2),"D",DOC,"PA"))>0 S ACHSTOA=+$G(^ACHSF(DUZ(2),"D",DOC,"PA")),ACHS=0 F  S ACHS=$O(^ACHSF(DUZ(2),"D",DOC,"T",ACHS)) Q:+ACHS=0  S ACHSP3B=ACHSP3B+$P($G(^ACHSF(DUZ(2),"D",DOC,"T",ACHS,0)),U,8)
 I ACHSTOA<1 S ACHSTOA=$P(X,U,9) G Z2:+ACHSTOA=0
 S ACHSTOS=$S(ACHSTY=1:43,ACHSTY=2:57,ACHSTY=3:64,1:"")
 S:ACHSTOS=64 ACHST64=ACHST64+ACHSTOA
 S:ACHSTOS=43 ACHST43=ACHST43+ACHSTOA
 S:ACHSTOS=57 ACHST57=ACHST57+ACHSTOA
 S ACHSESDA=$S($D(^ACHSF(DUZ(2),"D",DOC,1)):+$G(^ACHSF(DUZ(2),"D",DOC,1)),1:0)
 S ACHSNAME=$P($G(^DPT(DFN,0)),U)
 S ACHSSEX=$P($G(^DPT(DFN,0)),U,2)
 S X2=$P($G(^DPT(DFN,0)),U,3),X1=DT,X=""
 D ^%DTC
 S X=X\365.25
 S ACHSGRP=$S(+X<1:"A",+X>0&(+X<5):"B",+X>4&(+X<10):"C",+X>9&(+X<15):"D",+X>14&(+X<20):"E",+X>19&(+X<25):"F",+X>24&(+X<30):"G",+X>29&(+X<40):"H",+X>39&(+X<55):"I",+X>54&(+X<65):"J",1:"K")
SET ; Set Work Global.
 S (B,E,H)=0,ACHSTOT=ACHSP3B+ACHSTOA
 S:ACHSTOS=43 B=1
 S:ACHSTOS=64 E=1
 S:ACHSTOS=57 H=1
 I '$D(^TMP("ACHSC6",$J,"P",ACHSGRP,ACHSSEX)) S ^(ACHSSEX)=1_U_B_U_ACHSESDA_U_ACHST43_U_E_U_ACHSWKL_U_ACHST64_U_H_U_ACHST57_U_ACHSTOA_U_ACHSP3B_U_ACHSTOT G Z2
 S X=$G(^TMP("ACHSC6",$J,"P",ACHSGRP,ACHSSEX)),B=$P(X,U,2),E=$P(X,U,5),H=$P(X,U,8)
 S A=$P(X,U)+1
 S:ACHSTOS=43 B=$P(X,U,2)+1
 S C=$P(X,U,3)+ACHSESDA,D=$P(X,U,4)+ACHST43
 S:ACHSTOS=64 E=$P(X,U,5)+1
 S F=$P(X,U,6)+ACHSWKL,G=$P(X,U,7)+ACHST64
 S:ACHSTOS=57 H=$P(X,U,8)+1
 S I=$P(X,U,9)+ACHST57,ACHSTOAA=$P(X,U,10)+ACHST43+ACHST64+ACHST57
 S ACHST3P=$P(X,U,11)+ACHSP3B S ACHSTOTT=$P(X,U,12)+ACHSTOT
 S ^TMP("ACHSC6",$J,"P",ACHSGRP,ACHSSEX)=A_U_B_U_C_U_D_U_E_U_F_U_G_U_H_U_I_U_ACHSTOAA_U_ACHST3P_U_ACHSTOTT
 G Z2
 ;