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

ACHSC6C.m

Go to the documentation of this file.
ACHSC6C ; IHS/ITSC/PMF - CALCULATE EXPENDITURE REPORT BY PATIENT/COMMUNITY ;   [ 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))
 G ^ACHSC6P:ACHSTRDT<1!(ACHSTRDT>ACHSEDT),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))
 S 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 (ACHSTAO,ACHSP3B)=0
 I $G(^ACHSF(DUZ(2),"D",DOC,"PA"))>0 D
 .S ACHSTAO=+^ACHSF(DUZ(2),"D",DOC,"PA") S 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 ACHSTAO<1 S ACHSTAO=$P(X,U,9) G Z2:+ACHSTAO=0
 S ACHSTOS=$S(ACHSTY=1:43,ACHSTY=2:57,ACHSTY=3:64,1:"")
 S:ACHSTOS=64 ACHST64=ACHST64+ACHSTAO
 S:ACHSTOS=43 ACHST43=ACHST43+ACHSTAO
 S:ACHSTOS=57 ACHST57=ACHST57+ACHSTAO
 S ACHSESDA=$S($D(^ACHSF(DUZ(2),"D",DOC,1)):+$G(^ACHSF(DUZ(2),"D",DOC,1)),1:0),ACHSNAME=$P($G(^DPT(DFN,0)),U)
COMM ; Community Of Residence.
 F ACHSCOMM=0:0 Q:'$O(^AUPNPAT(DFN,51,ACHSCOMM))  S ACHSCOMM=$O(^AUPNPAT(DFN,51,ACHSCOMM))
 S ACHSCOMM=$S(ACHSCOMM:$P($G(^AUPNPAT(DFN,51,ACHSCOMM,0)),U,3),1:"")
 S ACHSCOMN=""
 I ACHSCOMM,($D(^AUTTCOM(ACHSCOMM,0))#2) S ACHSCOMN=$P($G(^AUTTCOM(ACHSCOMM,0)),U)
 I ACHSCOMN="",($D(^AUPNPAT(DFN,11))#2) S ACHSCOMN=$P($G(^AUPNPAT(DFN,11)),U,18)
 S:ACHSCOMN="" ACHSCOMN="UNKNOWN"
 I ACHSRPT=2 S ACHSNAME=ACHSCOMN
 I ACHSRPT=5 S ACHSNAME=$P($G(^AUPNPAT(DFN,11)),U,8),ACHSNAME=$S(ACHSNAME:$P($G(^AUTTTRI(ACHSNAME,0)),U),1:"UNKNOWN")
SET ; Set Work File.
 I '$D(^TMP("ACHSC6",$J,"P",ACHSNAME,ACHSTOS)) S ^TMP("ACHSC6",$J,"P",ACHSNAME,ACHSTOS)=DFN_U_ACHSCOMN_U_1_U_ACHSESDA_U_ACHSTAO_U_ACHSP3B G Z2
 S A=$P($G(^TMP("ACHSC6",$J,"P",ACHSNAME,ACHSTOS)),U,3)+1
 S B=$P($G(^TMP("ACHSC6",$J,"P",ACHSNAME,ACHSTOS)),U,4)+ACHSESDA
 S C=$P($G(^TMP("ACHSC6",$J,"P",ACHSNAME,ACHSTOS)),U,5)+ACHSTAO
 S D=$P($G(^TMP("ACHSC6",$J,"P",ACHSNAME,ACHSTOS)),U,6)+$S(ACHSTOS=57:ACHSTAO,1:0)
 S ^TMP("ACHSC6",$J,"P",ACHSNAME,ACHSTOS)=DFN_U_ACHSCOMN_U_A_U_B_U_C_U_D
 ;
 G Z2
 ;