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

RGDRM02.m

Go to the documentation of this file.
  1. RGDRM02 ;BAY/ALS-MPI/PD AWARE DUPLICATE RECORD MERGE ;03/10/00
  1. ;;1.0;CLINICAL INFO RESOURCE NETWORK;**6,42**;30 Apr 99
  1. MRGTF(DFNFRM,DFNTO) ; Merge Treating Facility entries
  1. I '$D(DFNFRM)!'$D(DFNTO) Q
  1. Q:'$D(^DGCN(391.91,"APAT",DFNFRM))
  1. ; Add Treating Facilities in FROM record to Treating
  1. ; Facility List for TO record
  1. S INST=0
  1. F S INST=$O(^DGCN(391.91,"APAT",DFNFRM,INST)) Q:'INST D
  1. . I '$D(^DGCN(391.91,"APAT",DFNTO,INST)) DO
  1. .. ;S STANUM=0
  1. .. ;S STANUM=$P($$NS^XUAF4(INST),"^",2)
  1. .. D FILE^VAFCTFU(DFNTO,INST,1) ;**42
  1. .. I '$D(^DGCN(391.91,"APAT",DFNTO,INST)) D
  1. ... D START^RGHLLOG($G(HLMTIEN)),EXC^RGHLLOG(212,"Treating Facility Add failed for DFN: "_DFNTO_", Treating Facility: "_INST,DFNTO),STOP^RGHLLOG(0) Q
  1. . ;Delete FROM record Treating Facility data
  1. . S IEN=0
  1. . F S IEN=$O(^DGCN(391.91,"APAT",DFNFRM,INST,IEN)) Q:'IEN D
  1. .. S DA=IEN,DIK="^DGCN(391.91,"
  1. .. D ^DIK K DIK,DA
  1. K INST,STANUM,IEN
  1. Q
  1. MRGSUB(DFNFRM,DFNTO) ; Merge Subscription entries.
  1. I '$D(DFNFRM)!'$D(DFNTO) Q
  1. N SUBFRM,SUBTO
  1. S SUBFRM=$$SUBNUM^MPIFAPI(DFNFRM)
  1. Q:SUBFRM<0 ;No subscriptions in FRM record, quit
  1. S SUBTO=$$SUBNUM^MPIFAPI(DFNTO)
  1. I SUBTO<0 S SUBTO=$$GETSCN^RGJCREC(DFNTO)
  1. S ENTRYF=0,ENTRYT=0
  1. D GET^HLSUB(SUBFRM,0,"",.FROM)
  1. D GET^HLSUB(SUBTO,0,"",.TO)
  1. F S ENTRYF=$O(FROM("LINKS",ENTRYF)) Q:'ENTRYF D
  1. . S LINKF=$P(FROM("LINKS",ENTRYF),"^",2)
  1. . S MATCH=0
  1. . F S ENTRYT=$O(TO("LINKS",ENTRYT)) Q:'ENTRYT D
  1. .. S LINKT=$P(TO("LINKS",ENTRYT),"^",2)
  1. .. I LINKF=LINKT S MATCH=1 Q
  1. . I MATCH=0 D
  1. .. S TYPE=0
  1. .. D UPD^HLSUB(SUBTO,LINKF,TYPE,"","","",.ER)
  1. .. K TO
  1. .. D GET^HLSUB(SUBTO,0,"",.TO) ; get new list
  1. .. S L=0,LINK="",ADD=0
  1. .. F S L=$O(TO("LINKS",L)) Q:'L D
  1. ... S LINK=$P(TO("LINKS",L),"^",2) I LINK=LINKF S ADD=1
  1. .. I ADD=0 D
  1. ... D START^RGHLLOG($G(HLMTIEN)),EXC^RGHLLOG(224,"Subscription Add Failed for DFN: "_DFNTO_", Subscriber: "_LINKF,DFNTO),STOP^RGHLLOG(0) Q
  1. ; Delete FROM record subscription data and pointer to subscription file
  1. N RGARR,RGERR
  1. S RGARR(991.05)="@"
  1. S RGERR=$$UPDATE^MPIFAPI(DFNFRM,"RGARR")
  1. K ENTRYF,ENTRYT,LINKF,LINKT,TO,MATCH,FROM,LNAME,LIEN,TYPE,ER,ADD,L,LINK
  1. Q