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

BDWRDR2.m

Go to the documentation of this file.
BDWRDR2 ; IHS/CMI/LAB - DW PROCESS VISIT ;
 ;;1.0;IHS DATA WAREHOUSE;**2,4**;JAN 23, 2006;Build 24
 ;
 K BDWE
 D VISIT
 I $D(BDWE) D ^BDWRERR Q
 D PROCTX
 K BDWE,BDWT,BDWH
 Q
 ;
VISIT ;EP
 I $P(BDWV("V REC"),U,23)=.5 S BDW("MFI")=BDW("MFI")+1,BDWE("ERROR")=120 Q
 I '$P(BDWV("V REC"),U,9),'$P(BDWV("V REC"),U,11) S BDW("ZERO")=BDW("ZERO")+1,BDWE("ERROR")=102 Q
 S BDWV("TYPE")=$P(BDWV("V REC"),U,3)
 I BDWV("TYPE")="" S BDWE("ERROR")="130",BDW("NO TYPE")=BDW("NO TYPE")+1 Q
 S BDWV("SRV CAT")=$P(BDWV("V REC"),U,7)
 I BDWV("SRV CAT")="" S BDWE("ERROR")="132",BDW("NO CAT")=BDW("NO CAT")+1 Q
 S BDWV("LOC DFN")=$P(BDWV("V REC"),U,6)
 I BDWV("LOC DFN")="" S BDWE("ERROR")="111",BDW("NO LOC")=BDW("NO LOC")+1 Q
 I '$D(^AUTTLOC(BDWV("LOC DFN"),0)) S BDWE("ERROR")="111",BDW("NO LOC")=BDW("NO LOC")+1 Q
 S BDWV("IHS LOCATION CODE")=$P(^AUTTLOC(BDWV("LOC DFN"),0),U,10) I BDWV("IHS LOCATION CODE")="" S BDWE("ERROR")="113",BDW("NO LOC")=BDW("NO LOC")+1 Q
 S BDWV("PATIENT DFN")=$P(BDWV("V REC"),U,5) I BDWV("PATIENT DFN")="" S BDWE("ERROR")="104",BDW("NO PAT")=BDW("NO PAT")+1 Q
 I '$D(^DPT(BDWV("PATIENT DFN"))) S BDWE("ERROR")="104",BDW("NO PAT")=BDW("NO PAT")+1 Q
 I '$D(^AUPNPAT(BDWV("PATIENT DFN"))) S BDWE("ERROR")="104",BDW("NO PAT")=BDW("NO PAT")+1 Q
 S Y=BDWV("PATIENT DFN") D ^AUPNPAT
 S BDWV("PATIENT NAME")=$P(^DPT(BDWV("PATIENT DFN"),0),U)
 I BDWV("PATIENT NAME")["DEMO,PATIENT" S BDW("DEMO")=BDW("DEMO")+1,BDWE("ERROR")=101 Q
 Q
 ;
PROCTX ; process and generate appropriate hl7 message
 S BDW("VISITS")=$G(BDW("VISITS"))+1
 I '$G(BDWDDR) S BDWV("TX GENERATED")=1,^XTMP("BDW"_$S(BDWO("RUN")="NEW":"DR",BDWO("RUN")="REDO":"REDO",1:"DR"),"MAIN TX",BDW("V DFN"))=BDW("MAIN TX DATE")
 I $G(BDWDDR) S BDWV("TX GENERATED")=1,^TMP($J,"BDW",BDW("V DFN"))=BDW("MAIN TX DATE")
 S ^XTMP("BDWALPMR",$J,BDWV("PATIENT DFN"))=""  ;p5 add set so patient centric messages can run later
 S BDWVMSG=$$DW1A08^BHLEVENT(BDW("V DFN"))
 S ^BDWTMP(BDWIEDST,BDWVMSG)=""
 S X=$P(^AUPNVSIT(BDW("V DFN"),0),U,3)_"-"_$E($$EXTSET^XBFUNC(9000010,.03,$P(^AUPNVSIT(BDW("V DFN"),0),U,3)),1,9)_"/"_$P(^AUPNVSIT(BDW("V DFN"),0),U,7)_"-"_$E($$EXTSET^XBFUNC(9000010,.07,$P(^AUPNVSIT(BDW("V DFN"),0),U,7)),1,17)
 S Y=$S($P(^AUPNVSIT(BDW("V DFN"),0),U,11):"D",$P(^AUPNVSIT(BDW("V DFN"),11),U,6)]"":"M",1:"A")
 S ^TMP($J,"BDWTRAILER",$P(^AUPNVSIT(BDW("V DFN"),0),U,6),"TYPE",X,Y)=$G(^TMP($J,"BDWTRAILER",$P(^AUPNVSIT(BDW("V DFN"),0),U,6),"TYPE",X,Y))+1
 S ^TMP($J,"BDWTRAILER",$P(^AUPNVSIT(BDW("V DFN"),0),U,6),"TYPE",X,"TOT")=$G(^TMP($J,"BDWTRAILER",$P(^AUPNVSIT(BDW("V DFN"),0),U,6),"TYPE",X,"TOT"))+1
 S ^TMP($J,"BDWTRAILER",$P(^AUPNVSIT(BDW("V DFN"),0),U,6),"DATE",X,$E($P(^AUPNVSIT(BDW("V DFN"),0),U),1,5)_"00")=$G(^TMP($J,"BDWTRAILER",$P(^AUPNVSIT(BDW("V DFN"),0),U,6),"DATE",X,$E($P(^AUPNVSIT(BDW("V DFN"),0),U),1,5)_"00"))+1
 ;call audit
 I $P(^AUPNVSIT(BDW("V DFN"),0),U,11) S BDW("DELS")=BDW("DELS")+1 Q
 I $P(^AUPNVSIT(BDW("V DFN"),11),U,6)]"" S BDW("MODS")=BDW("MODS")+1 Q
 S BDW("ADDS")=BDW("ADDS")+1
 Q
 ;
ALPMR ;-- process ALPMR patient centric messages
 ;the following is for testing all patients
 ;N BDA
 ;S BDA=0 F  S BDA=$O(^DPT(BDA)) Q:'BDA  D
 ;. S ^XTMP("BDWALPMR",$J,BDA)=""
 N BDWADA,BDWAMSG
 S BDW("ALPMR")=0,BDWCNTR=0
 W:'$D(ZTQUEUED) !,"Generating transactions.  Counting patient centric records.  (0)"
 S BDWADA=0 F  S BDWADA=$O(^XTMP("BDWALPMR",$J,BDWADA)) Q:'BDWADA  D
 . I '$$CHKALPMR(BDWADA) K ^XTMP("BDWALPMR",$J,BDWADA) Q
 . S BDW("ALPMR")=BDW("ALPMR")+1
 . S BDWAMSG=$$DW1ALPMR^BDWBHL1(BDWADA)
 . S ^BDWTMP(BDWIEDST,BDWAMSG)=""
 . D SET61(BDW("RUN LOG"),BDWADA,BDWAMSG)
 . X BDWCNT
 K ^XTMP("BDWALPMR",$J)
 Q
 ;
SET61(RL,ADA,AMSG)  ;--lets set the log here
 S:'$D(^BDWXLOG(RL,61,0)) ^BDWXLOG(RL,61,0)="^90213.06101PA^^"
 S ^BDWXLOG(RL,61,ADA,0)=ADA_U_$G(AMSG)
 S $P(^BDWXLOG(RL,61,0),U,3)="",$P(^(0),U,4)=$P(^(0),U,4)+1
 Q
 ;
CHKALPMR(ADA) ;-- check to see if the patient has any data for ALPMR
 I $D(^AUPNPROB("AC",ADA)) Q 1
 I $D(^AUPNPREF("AC",ADA)) Q 1
 I $D(^BIPC("B",ADA)) Q 1
 I $D(^BWPCD("C",ADA)) Q 1
 Q 0
 ;