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

APCDVM2.m

Go to the documentation of this file.
APCDVM2 ; IHS/CMI/LAB - VISIT MERGE ;
 ;;2.0;IHS PCC SUITE;**8**;MAY 14, 2009;Build 2
 ;
 ; Given the 'from' visit DFN in APCDVMF and the 'to' visit DFN in
 ; APCDVMT merge two visits.  Variables passed are left alone.  If
 ; an error is encountered APCDVMQF will exist upon exit.  VISITs must
 ; be for the same patient.
 ;
 K APCDVMQF
 S U="^"
 I '$D(APCDVMF)!('$D(APCDVMT)) S APCDVMQF=21 Q
 I 'APCDVMF!('APCDVMT)!(APCDVMF=APCDVMT) S APCDVMQF=22 Q
 I '$D(^AUPNVSIT(APCDVMF,0)) S APCDVMQF=23 Q
 I '$D(^AUPNVSIT(APCDVMT,0)) S APCDVMQF=24 Q
 I $P(^AUPNVSIT(APCDVMF,0),U,5)'=$P(^AUPNVSIT(APCDVMT,0),U,5) S APCDVMQF=25 Q
 S APCDVMUX=1  ;for trigger cross references
 S APCDVMFL=9000010 F APCDVML=0:0 S APCDVMFL=$O(^DIC(APCDVMFL)) Q:APCDVMFL>9000010.99!(APCDVMFL'=+APCDVMFL)  D PROCESS
 S AUPNVSIT=APCDVMT D MOD^AUPNVSIT
 I $T(A42^BTSEVENT)]"" S APCDHLER=$$A42^BTSEVENT(APCDVMF,APCDVMT) K APCDHLER  ;IHS/Daou/CJS - for HL7
 K APCDVMFL,APCDVMG,APCDVML,APCDVMN,APCDVMX,APCDVMUX
 Q
 ;
PROCESS ; PROCESS ONE V FILE
 S APCDVMG=^DIC(APCDVMFL,0,"GL")
 Q:'$D(@(APCDVMG_"""AD"","_APCDVMF_")"))
 W:'$D(ZTQUEUED) !,APCDVMFL
 S APCDVMN="" F APCDVML=0:0 S APCDVMN=$O(@(APCDVMG_"""AD"","_APCDVMF_",APCDVMN)")) Q:APCDVMN=""  D PROCESS2
 Q
PROCESS2 ; PROCESS ONE V FILE ENTRY
 W:'$D(ZTQUEUED) "."
 S DIK=APCDVMG,DA=APCDVMN,X=2 D DD^DIK,1^DIK1 K DIK,DA
 S $P(@(APCDVMG_APCDVMN_",0)"),U,3)=APCDVMT
 S DIK=APCDVMG,DA=APCDVMN,X=1 D DD^DIK,1^DIK1 K DIK,DA
 ;S APCDVMX=0 F APCDVML=0:0 S APCDVMX=$O(^DD(APCDVMFL,.03,1,APCDVMX)) Q:APCDVMX'=+APCDVMX  S DA=APCDVMN,X=APCDVMF X ^DD(APCDVMFL,.03,1,APCDVMX,2)
 ;S $P(@(APCDVMG_APCDVMN_",0)"),U,3)=APCDVMT
 ;S APCDVMX=0 F APCDVML=0:0 S APCDVMX=$O(^DD(APCDVMFL,.03,1,APCDVMX)) Q:APCDVMX'=+APCDVMX  S DA=APCDVMN,X=APCDVMT X ^DD(APCDVMFL,.03,1,APCDVMX,1)
 Q