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

APCPACHA.m

Go to the documentation of this file.
APCPACHA ; IHS/TUCSON/LAB - create CHA activity reporting system record AUGUST 14, 1992 ; [ 09/16/02 12:15 PM ]
 ;;2.0;IHS PCC DATA EXTRACTION SYSTEM;**6**;APR 03, 1998
 ;
 D ACTCODE
 S (APCPCHD1,APCPCHD2)="   "
 D POV
 G:$D(APCPE) EOJ
 D TIME
 G:$D(APCPE) EOJ
 D CHART
 D SETTX
EOJ ;
 K APCPT,APCPCHD1,APCPCHD2
 Q
ACTCODE ;
 I APCPV("SRV CAT")="N" S APCPT("ACTC")="03" Q
 S APCPT("ACTC")=$S(APCPV("CLINIC CODE")=11:"01",1:"02")
 Q
POV ;get POV information
 S (APCPT(1),APCPT(2))=0 F  S APCPT(2)=$O(^AUPNVPOV("AD",APCP("V DFN"),APCPT(2))) Q:APCPT(1)>1!(APCPT(2)'=+APCPT(2))!($D(APCPE("ERROR")))  S APCPT(1)=APCPT(1)+1 D GETPOV
 Q
GETPOV ;
 S APCPT("ICD PTR")=$P(^AUPNVPOV(APCPT(2),0),U),(APCPT("X"),APCPT("ICD"))=$P(^ICD9(APCPT("ICD PTR"),0),U) D ^APCPCICD
 Q:$D(APCPE("ERROR"))
GETCODE ;
 S APCPT("ICD")=$P(APCPT("ICD"),".")_$P(APCPT("ICD"),".",2)_" "
 I $E(APCPT("X"))="V" S APCPT("X")=(9_$E(APCPT("X"),2,9999)-.000001),APCPT("X")="V"_$E(APCPT("X"),2,9999),APCPT("X")=$P(APCPT("X"),".")_$P(APCPT("X"),".",2)_" " G HIGH
 I $E(APCPT("X"))="0" S APCPT("X")=(9_$E(APCPT("X"),2,9999)-.000001),APCPT("X")="0"_$E(APCPT("X"),2,9999),APCPT("X")=$P(APCPT("X"),".")_$P(APCPT("X"),".",2)_" " G HIGH
 I $E(APCPT("X"))="." S APCPT("X")=(9_$E(APCPT("X"),2,9999)-.000001),APCPT("X")="."_$E(APCPT("X"),2,9999),APCPT("X")=$P(APCPT("X"),".")_$P(APCPT("X"),".",2)_" " G HIGH
 S APCPT("X")=APCPT("X")-.000001
 S APCPT("AC")="",APCPT("X")=($P(APCPT("X"),".")_$P(APCPT("X"),".",2))_" "
HIGH S APCPT("HIGH")=$O(^AUTTCHA("AH",APCPT("X"))) I APCPT("HIGH")="" S APCPE("ERROR")="E064",APCPE("EDFN")=APCPT(2),APCPE("FILE")=9000010.07 Q
 S APCPT("DA1")=$O(^AUTTCHA("AH",APCPT("HIGH"),"")) I APCPT("DA1")="" S APCPE("ERROR")="E064",APCPE("EDFN")=APCPT(2),APCPE("FILE")=9000010.07 Q
 S APCPT("DA2")=$O(^AUTTCHA("AH",APCPT("HIGH"),APCPT("DA1"),""))
 S APCPT("LOW")=$P(^AUTTCHA(APCPT("DA1"),11,APCPT("DA2"),0),U)_" "
 I APCPT("LOW")]APCPT("ICD") S APCPE("ERROR")="E064",APCPE("FILE")=9000010.07,APCPE("EDFN")=APCPT(2) Q
 S APCPT("AC")=$P(^AUTTCHA(APCPT("DA1"),0),U)
SETPOV S APCPT("VAR")="APCPCHD"_APCPT(1),@APCPT("VAR")=APCPT("AC")
 Q
 ;
TIME ;
 S APCPT("AT REC")=$O(^AUPNVTM("AD",APCP("V DFN"),""))
 I APCPT("AT REC")="" S APCPE("ERROR")="E054" Q
 S APCPT("ACT TIME MIN")=$P(^AUPNVTM(APCPT("AT REC"),0),U),APCPT("TRAVEL TIME MIN")=$P(^AUPNVTM(APCPT("AT REC"),0),U,4)
 I 'APCPT("ACT TIME MIN") S APCPE("ERROR")="E052" Q
 S APCPT("ACT TIME MIN")=APCPT("ACT TIME MIN")*APCPT("CHA")
 S X=APCPT("ACT TIME MIN") D CONVERT S:H>9 H=9
 S APCPT("ACT TIME")=H_M
 I 'APCPT("TRAVEL TIME MIN") S APCPT("TRAVEL TIME MIN")=0 S APCPT("TRAVEL TIME")="000" Q
 S X=APCPT("TRAVEL TIME MIN") D CONVERT I H>9 S APCPE("ERROR")="E053" Q
 S APCPT("TRAVEL TIME")=H_M
 K X,Y,M,H
 Q
CHART ;CHANGE CHART TO DUZ(2) IF EQUAL 999999
 S APCPT("CHA CHART")=""
 I $D(^AUPNPAT(APCPV("PATIENT DFN"),41,DUZ(2),0))#2 S APCPT("CHA CHART")=$P(^AUPNPAT(APCPV("PATIENT DFN"),41,DUZ(2),0),U,2)
 I APCPT("CHA CHART")="",$D(^AUPNPAT(APCPV("PATIENT DFN"),41,APCPV("LOC DFN"),0))#2 S APCPT("CHA CHART")=$P(^(0),U,2)
 I APCPT("CHA CHART")="" S APCPT("CHA CHART")=999999
 Q
SETTX ;
 S APCPT("VD")=$E(APCPV("V DATE"),4,5)_$E(APCPV("V DATE"),6,7)_$E(APCPV("V DATE"),2,3)
 S APCP("CHA")=APCP("CHA")+1,APCP("COUNT")=APCP("COUNT")+1
 S APCPV("CHA TX GENERATED")=1,APCPV("TX GENERATED")=1
 S APCPV("TX")="CHN"_U_14_U_$E(APCP("RUN LOCATION"),1,2)_U_$E(APCP("RUN LOCATION"),3,4)_U_$E(APCP("RUN LOCATION"),5,6)_U_"00"_U_APCPT("VD")_U_$E(APCPV("COMM CODE"),5,7)_U_APCPT("ACTC")_U_APCPCHD1_U_U_U_APCPCHD2_U_U_U
 S APCPV("TX")=APCPV("TX")_APCPT("ACT TIME")_U_U_APCPT("CHA CHART")_U_$E(AUPNDOB,4,5)_$E(AUPNDOB,6,7)_$E(AUPNDOB,2,3)_U_AUPNSEX_U_U_APCPT("TRAVEL TIME")
 S ^BAPCDATA(APCP("COUNT"))=APCPV("TX")
 Q
 ;
CONVERT ;convert minutes to hours
 S H=$P((X/60),"."),M=X-(H*60)
 I $L(M)=1 S M=0_M
 S:'H H=0
 Q
 ;left zero fill minutes
 ;if hours >9 error