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

APCPAA.m

Go to the documentation of this file.
APCPAA ; IHS/TUCSON/LAB - create APC transactions AUG 14, 1992 ; [ 09/16/02 12:13 PM ]
 ;;2.0;IHS PCC DATA EXTRACTION SYSTEM;**1,6**;APR 03, 1998
 ;IHS/CMI/LAB - no longer send APC records
 ;
START ;
 D SETVARS
 D ^APCPAPRO
 I $D(APCPE("ERROR")) D COUNT^APCPDR2,EOJ Q
 D ^APCPAPOV
 I $D(APCPE("ERROR")) D COUNT^APCPDR2,EOJ Q
 D ^APCPAOTH
 I $D(APCPE("ERROR")) D COUNT^APCPDR2,EOJ Q
 D LAB
 D PROC
 I $D(APCPE("ERROR")) D COUNT^APCPDR2,EOJ Q
 D SETTX
 D EOJ
 Q
 ;
EOJ ;
 K APCPADX1,APCPADX2,I,APCPT,D
 Q
SETVARS ; set standard variables for record
 K APCPT
 S APCPT("VD")=$E(APCPV("V DATE"),4,5)_$E(APCPV("V DATE"),6,7)_$E(APCPV("V DATE"),2,3)
 S X=APCPV("V DATE") D H^%DTC S APCPT("DOW")=%Y+1 K X,%T,%Y
 S APCPT("HR")=$E($P(+$P(APCPV("V REC"),U),".",2),1,2) I APCPT("HR")="" S APCPT("HR")=12
 S APCPT("TOD")=$S(APCPT("HR")>7&(APCPT("HR")<12):1,APCPT("HR")>11&(APCPT("HR")<17):2,APCPT("HR")>16&(APCPT("HR")<22):3,1:4)
 S:APCPV("CLINIC CODE")="" APCPV("CLINIC CODE")=25
DISP ;set disposition to 2 - if admission on same day, set to 3
 NEW D,I
 S APCPT("DISP")=2,D=9999999-APCPV("V DATE"),I=$O(^AUPNVSIT("AAH",APCPV("PATIENT DFN"),D)) I I]"",(I\1)=D S APCPT("DISP")=3
 Q
LAB ;
 S APCPT("LAB")=$S($D(^AUPNVLAB("AD",APCP("V DFN"))):"        8  ",1:"0          ")
 Q
PROC ;
 S (APCPT("OP"),APCPT("SP"))=""
 I $D(^AUPNVPRC("AD",APCP("V DFN"))) S APCPT("SP")=1,APCPT("X")=$O(^AUPNVPRC("AD",APCP("V DFN"),"")),APCPT("OPP")=$P(^AUPNVPRC(APCPT("X"),0),U) D OPCODE
 Q
OPCODE ; 
 S APCPT("OP")=$P(^ICD0(APCPT("OPP"),0),U)
 I $P(^ICD0(APCPT("OPP"),0),U,9)]"" S APCPE("ERROR")="E041" Q
 I $P(^ICD0(APCPT("OPP"),0),U,10)]"",AUPNSEX'=$P(^ICD0(APCPT("OPP"),0),U,10) S APCPE("ERROR")="E043" Q
 I APCPT("OP")=.9999 S APCPE("ERROR")="E032" Q
 I $L($P(APCPT("OP"),".",2))>2 S APCPE("ERROR")="E007" Q
 S APCPT("OP")=$P(APCPT("OP"),".")_$P(APCPT("OP"),".",2),APCPT("L")=$L(APCPT("OP"))+1 F I=APCPT("L"):1:4 S APCPT("OP")=APCPT("OP")_" "
 ;
 Q
SETTX ;
 Q  ;IHS/CMI/LAB - patch 1 NO LONGER SEND APC RECORDS per hdqtrs west
 S APCP("APC")=APCP("APC")+1,APCP("COUNT")=APCP("COUNT")+1
 S APCPV("TX GENERATED")=1,^XTMP("APCP"_$S(APCPO("RUN")="NEW":"DR",APCPO("RUN")="REDO":"REDO",1:"DR"),"MAIN TX",APCP("V DFN"))=APCP("MAIN TX DATE")
 NEW Y S Y=0 F  S Y=$O(^APCPREC(1,11,"B",Y)) Q:Y'=+Y  D
 .S X=""
 .S Z=$O(^APCPREC(1,11,"B",Y,0))
 .Q:'$D(^APCPREC(1,11,Z,1))
 .X ^APCPREC(1,11,Z,1)
 .S $P(APCPV("TX"),U,Y)=X
 S ^BAPCDATA(APCP("COUNT"))="AP1"_U_APCPV("TX")
 Q