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

BDW1VBL2.m

Go to the documentation of this file.
BDW1VBL2 ;IHS/CMI/LAB - DW process visit during backload;
 ;;1.0;IHS DATA WAREHOUSE;;JAN 23, 2006
 ;
 ;
 K BDWE
 D VISIT
 I $D(BDWE) D ^BDW1VBLE Q
 D PROCTX
 K BDWE,BDWT,BDWH
 Q
 ;
VISIT ;EP
 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  ;cmi/anch/maw 7/26/2004 changed due to location at Crow being 0
 I '+$G(BDWV("LOC DFN")) S BDWE("ERROR")="111",BDW("NO LOC")=BDW("NO LOC")+1 Q  ;cmi/anch/maw 7/26/2004 modified
 I '$D(^AUTTLOC(BDWV("LOC DFN"),0)) S BDWE("ERROR")="111",BDW("NO LOC")=BDW("NO LOC")+1 Q  ;cmi/anch/maw 7/26/2004 modified
 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"),0)) 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 statistical record
 S BDW("VISITS")=$G(BDW("VISITS"))+1
 S BDWVMSG=$$DW1A08^BHLEVENT(BDW("V DFN"))
 S ^BDWTMP(BDWIEDST,BDWVMSG)=""
 ;I BDWVA D VA
 D VA
 D RESET^BDW1VBL
 Q
VREC(BDWVIEN,BDWRTYP,DFN,BDWVFIEN) ;EP
 S BDWRIEN=$O(^BDWVARD("B",BDWRTYP,0))
 I 'BDWRIEN Q ""
 NEW BDWY,BDWT S BDWY=0,BDWT="" F  S BDWY=$O(^BDWVARD(BDWRIEN,11,"B",BDWY)) Q:BDWY'=+BDWY  D
 .S X=""
 .S BDWZ=$O(^BDWVARD(BDWRIEN,11,"B",BDWY,0))
 .Q:'$D(^BDWVARD(BDWRIEN,11,BDWZ,1))
 .X ^BDWVARD(BDWRIEN,11,BDWZ,1)
 .S $P(BDWT,U,BDWY)=X
 Q BDWT
VA ;EP
 S BDWVIEN=BDW("V DFN")
 S BDWPDFN=$P($G(^AUPNVSIT(BDWVIEN,0)),U,5)
 I BDWPDFN="" Q ""
 S BDWUVID=$$UIDV^BDWAID(BDWVIEN)
 S BDWVAX=$$VREC(BDWVIEN,"V000",BDWPDFN,0)
 D SET
 K BDWVAY D PROV^BDWUTIL1(.BDWVAY,BDWVIEN)
 I $G(BDWVAY(1))="" D
 . S BDWVAX="V010"_U_BDWUVID_U_"1^^^" D SET
 S BDWVAY=0 F  S BDWVAY=$O(BDWVAY(BDWVAY)) Q:BDWVAY'=+BDWVAY  D
 .S BDWVAX="V010"_U_BDWUVID_U_BDWVAY_U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