source: FOIAVistA/tag/r/ZZREGIONAL-A1C-A5C-CRHD-RGED-RGUT-RGWB-RG/RGRSDYN1.m@ 1410

Last change on this file since 1410 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 3.9 KB
Line 
1RGRSDYN1 ;ALB/RJS-BUILD DYNAMIC LINK LIST FOR A TFU ;06/09/97
2 ;;1.0;CLINICAL INFO RESOURCE NETWORK;**1,3,8,23,27**;30 Apr 99
3 ;Reference to ^DGCN(391.91 supported by IA #2911
4 ;Reference to $$SEND2^VAFCUTL1 supported by IA #2779
5EN(CLIENT,CLASS) ;
6 ;CLIENT=HL7 CLIENT PROTOCOL AT TARGET SYSTEM
7 ;DATA CLASS (Opt.) = Pull from Subs. Registry ONLY
8 ;For now, anything else is both DESCRIPTIVE AND CLINICAL
9 S CLASS=$G(CLASS),CLIENT=$G(CLIENT)
10 Q:CLIENT="" ;No receiver
11 N PPF,DFN,HERE,RGRS,PPFIEN,ICN,MPI
12PARS ;Parse local outbound message
13 N RGDC
14 D INITIZE^RGRSUTIL,EN^RGRSPAR1("RGRS")
15 ;Get DFN
16 S ICN=$G(RGRS("ICN")) Q:$G(ICN)']""
17 S DFN=$$GETDFN^MPIF001(ICN) Q:+DFN'>0
18 Q:+$$SEND2^VAFCUTL1(DFN,"T") ;don't broadcast test patients
19 Q:$$IFLOCAL^MPIF001(DFN)
20 S PPF=$$GETVCCI^MPIF001(DFN)\1 Q:+PPF'>0
21 S PPFIEN=$$LKUP^XUAF4(PPF)
22 S HERE=$P($$SITE^VASITE,"^",3)\1
23NOTPPF ; if not ppf send only to ppf
24 I PPF'=HERE D Q
25 . N PPFLINK,INDEX
26 . D LINK^HLUTIL3(PPFIEN,.PPFLINK)
27 . S INDEX=$O(PPFLINK(0))
28 . I INDEX]"" S HLL("LINKS",1)=CLIENT_"^"_PPFLINK(INDEX)
29ISPPF ;
30 I PPF=HERE D Q
31 . N PARENT,INDEX,SUBCONTL,CHILDREN,INDEX1,NODE
32 . S NODE=$$MPINODE^MPIFAPI(DFN)
33 . S SUBCONTL=$P($G(NODE),"^",5)
34 . ;Get subscribers, return updated HLL array
35 . ;replaced with GET line tag: I SUBCONTL]"" D GET^HLSUB(SUBCONTL,+CLASS,CLIENT,.HLL)
36 . ;D GET(DFN,SUBCONTL,+CLASS,CLIENT,.HLL)
37 . D GETLINKS(.HLL)
38 . ;Get MPI link from SITE PARAMETER
39 . S MPI=$$MPILINK^MPIFAPI() D
40 . . I $P($G(MPI),U)'=-1 S HLL("LINKS",9999999999)=CLIENT_"^"_MPI
41 . . I $P($G(MPI),U)=-1 D
42 . . . N RGLOG,RGMTXT
43 . . . S RGMTXT=""
44 . . . D START^RGHLLOG(HLMTIEN,"","") D EXC^RGHLLOG(224,"No MPI link identified"_RGMTXT,DFN) D STOP^RGHLLOG(0)
45 ;
46 Q
47GETLINKS(HLL) ;
48 N RGTF,RGHL,X
49 S X=$$QUERYTF^VAFCTFU1($G(ICN),"RGTF")
50 ;LOOP THOUGH TF LIST AND GET LINK FOR EACH
51 N LP,CNT,STN,STNIEN,RGHL S CNT=1,LP=0 K ERROR
52 F S LP=$O(RGTF(LP)) Q:LP="" D
53 .S STN=$$STA^XUAF4($G(RGTF(LP)))
54 .S STNIEN=$$IEN^XUAF4(STN)
55 .Q:$P($$SITE^VASITE(),"^",3)=STN
56 .K RGHL D LINK^HLUTIL3(STNIEN,.RGHL)
57 .I '$O(RGHL(0)) S ERROR="-1^Unknown Logical Link for Station # "_STN_" Unable to send msg for patient "_DFN
58 .I $D(ERROR) D EXC^RGHLLOG(224,ERROR,DFN) K ERROR Q
59 .S HLL("LINKS",CNT)=CLIENT_"^"_$P(RGHL($O(RGHL(0))),"^"),CNT=CNT+1
60 Q
61GET(RGDFN,RGSCN,RGTP,RGCLP,RGLL) ;GET Subscribers
62 ;RGDFN - Patient IEN from FILE (#2)
63 ;RGSCN - Subcription Control Number
64 ;RGTP - SUBSCRIBER TYPE (0,1,2)/Null=all
65 ;RGCLP - HL7 CLIENT PROTOCOL (required)
66 ;RGLL - HLL("LINKS",x)=CLIENT PROTOCOL^LOGICAL LINK (passed by reference)
67 N RG,RGI,RGLLIEN,RGLLI,RGLLS,RGLLN,RGLLZ,RGTF,RGTFF,RGTFI,RGX,HLER
68 S U="^"
69 ;get subscribers
70 I RGSCN'="" D GET^HLSUB(RGSCN,RGTP,RGCLP,.RGLL)
71 ;check for a treating facility that is not a subscriber
72 S RGI=0 F S RGI=$O(^DGCN(391.91,"B",RGDFN,RGI)) Q:'RGI I $D(^DGCN(391.91,RGI,0)) S RGTF=$G(^DGCN(391.91,RGI,0)),RGTFI=$P(RGTF,U,2) D:RGTFI'=+$$SITE^VASITE
73 .;checking INSTITUTION of links to the TREATING FACILITY INSTITUTION
74 .;RGTFF=1 - Flag for adding Treating Facility to Subcription Control
75 .S RGTFF=1
76 .S RGX=0 F S RGX=$O(RGLL("LINKS",RGX)) Q:'RGX!(RGTFF=0) D
77 ..S RGLLIEN=$P(RGLL("LINKS",RGX),U,6)
78 ..I $G(RGLL)="" S RGLL("ERR",RGX)="No logical link defined for "_$P(RGLL("LINKS",RGX),U)_"." Q
79 ..S RGLLI=RGTFI,RGLLN=$P(RGLL("LINKS",RGX),U,2)
80 ..I '$L(RGLLI),'$D(RGLL("ERR",RGX)) S RGLL("ERR",RGX)="Link "_$P(RGLL("LINKS",RGX),U,2)_" does not contain a link to the INSTUTUTION (#4) file." Q
81 ..I $L(RGLLI) S:RGLLI'=RGTFI RGTFF=1 I RGLLI=RGTFI S RGTFF=0 Q
82 .;If TF not in Subscriber list, kill list, add to subscription control file then get new list
83 .I RGTFF=1 D LINK^HLUTIL3("`"_RGTFI,.RG,"I") S RGLLI=$O(RG(0)) D
84 ..I +$G(RGLLI)>0 S RGLLN=$P(RG(RGLLI),U),RGLLI=RGTFI
85 ..I +$G(RGLLI)>0 S:RGSCN="" RGSCN=$$GETSCN^RGJCREC(RGDFN) D UPD^HLSUB(RGSCN,RGLLN,RGTP,$$NOW^XLFDT,,,.HLER) K RGLL("LINKS") D GET^HLSUB(RGSCN,RGTP,RGCLP,.RGLL)
86 ..I +$G(RGLLI)'>0 W !,"Unable to find Logical link for "_$$GET1^DIQ(4,+RGTFI_",",.01)
87 Q
Note: See TracBrowser for help on using the repository browser.