source: WorldVistAEHR/trunk/r/ZZREGIONAL-A1C-A5C-CRHD-RGED-RGUT-RGWB-RG/RGMTHL2.m@ 1578

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

initial load of WorldVistAEHR

File size: 6.8 KB
Line 
1RGMTHL2 ;BIR/CML-COMPILE MPI/PD HL7 DATA FOR BI-DIRECTIONAL TCP ;11/15/01
2 ;;1.0;CLINICAL INFO RESOURCE NETWORK;**21,23,28,20**;30 Apr 99
3 ;
4 ;Reference to ^ORD(101 supported by IA #2596
5 ;Reference to ^HL(772 supported by IA #3464
6 ;Reference to ^HL(771.6 supported by IA #2507
7 ;Reference to ^HLMA( supported by IA #3273
8 ;Reference to ^DPT("AICN" supported by IA #2070
9 ;
10 ;Check to see if the ^XTMP global is present and/or complete
11 W @IOF
12 W !,"This utility searches the HL7 MESSAGE TEXT (#772) file for a selected"
13 W !,"date range. Each HL7 message in the date range is examined. If the"
14 W !,"RELATED EVENT PROTOCOL field contains the MPI/PD protocols (e.g., ""VAF"","
15 W !,"""RG"", or ""MPI"") data is compiled into the ^XTMP(""RGMT"",""HL"" array."
16 W !!,"A cross-reference is built on patient ICN and DFN for faster data retrieval"
17 W !,"for the associated reports."
18 ;
19 G:'$D(^XTMP("RGMT","HL")) BEGIN
20 I '$D(^XTMP("RGMT","HL","@@@@","STOPPED")) D
21 .W !!,$C(7),"The Compile MPI/PD HL7 Data compilation is already running!" G QUIT
22 S CDT=$$FMTE^XLFDT($E(+^XTMP("RGMT","HL","@@@@","STOPPED"),1,12))
23 W !!,"=> ""Compile MPI/PD HL7 Data"" last ran to completion on "_CDT_".",!
24 I $D(^XTMP("RGMT","HL","@@@@","RANGE")) D
25 .W !,"=> Data has been compiled for ",^XTMP("RGMT","HL","@@@@","RANGE"),"."
26 W ! K DIR S DIR(0)="SMB^D:DELETE;A:APPEND"
27 S DIR("A",1)="Do you want to:"
28 S DIR("A",2)="(D)elete existing data and recompile."
29 S DIR("A")="(A)ppend new data after last date of existing data"
30 S DIR("B")="A"
31 S DIR("?",1)="Enter:",DIR("?",2)="D if you want to delete exiting data and recompile."
32 S DIR("?",3)="A or <RET> to append new data after last date of existing data."
33 S DIR("?")="""^"" to HALT."
34 D ^DIR K DIR G:$D(DIRUT) QUIT S ACT=Y
35 ;
36BEGIN ;
37 S RGNOW=$$NOW^XLFDT()
38 S:'$D(ACT) ACT="D"
39 W !!,"Enter date range for data to be compiled."
40 I ACT="A" D
41 .S X1=^XTMP("RGMT","HL","@@@@","COMPENDDATE"),X2=1 D C^%DTC
42 .S RGBDT=X W !,"Beginning Date for Report: ",$$FMTE^XLFDT(X)
43 I ACT="D" D G:$D(DIRUT) QUIT
44 .K DIR,DIRUT,DTOUT,DUOUT
45 .S DIR(0)="DAO^:"_$$NOW^XLFDT()_":EPXT",DIR("A")="Beginning Date for Report: "
46 .D ^DIR K DIR Q:$D(DIRUT) S RGBDT=Y
47 K DIR,DIRUT,DTOUT,DUOUT
48 S DIR(0)="DAO^"_RGBDT_":"_$$NOW^XLFDT()_":EPXT",DIR("A")="Ending Date for Report: "
49 D ^DIR K DIR G:$D(DIRUT) QUIT S RGEDT=Y
50 ;
51QUE ;Queue the task.
52 S ZTSAVE("RGBDT")="",ZTSAVE("RGEDT")="",ZTSAVE("ACT")=""
53 S ZTIO="",ZTRTN="START^RGMTHL2",ZTDESC="Compile MPI/PD HL7 Data (bi-directional)" D ^%ZTLOAD
54 G QUIT
55 ;
56START ;
57 S QFLG=0
58 K ^XTMP("RGMT","HL","@@@@","STOPPED")
59 I ACT="D" K ^XTMP("RGMT","HL"),^XTMP("RGMT","HLICN"),^XTMP("RGMT","HLDFN")
60 S U="^" D NOW^%DTC
61 S ^XTMP("RGMT","HL","@@@@","STARTED")=%
62 S ^XTMP("RGMT",0)=$$FMADD^XLFDT(DT,30)_"^"_%_"^MPI/PD Maintenance Data"
63 S STOPDT=$S($L(RGEDT)=7:RGEDT_.24,1:RGEDT)
64 S RGDT=$S($L(RGBDT)=7:$$FMADD^XLFDT(RGBDT,-1)_.24,1:RGBDT-.0001)
65 I ACT="D" S ^XTMP("RGMT","HL","@@@@","COMPBEGINDATE")=RGDT
66 S ^XTMP("RGMT","HL","@@@@","COMPENDDATE")=STOPDT
67 S PRGBDT=$$FMTE^XLFDT(RGDT)
68 S PRGEDT=$$FMTE^XLFDT(STOPDT)
69 S ^XTMP("RGMT","HL","@@@@","RANGE")=PRGBDT_" to "_PRGEDT
70 ;
71LOOP ;Loop on ^HL(772 date xref
72 F S RGDT=$O(^HL(772,"B",RGDT)) Q:'RGDT Q:RGDT>STOPDT Q:QFLG D
73 .I $D(^XTMP("RGMT","HL","@@@@","FORCE STOP")) S QFLG=1 Q
74 .S ^XTMP("RGMT","HL","@@@@","NOW PROCESSING DATE")=RGDT
75 .S IEN=0
76 .F S IEN=$O(^HL(772,"B",RGDT,IEN)) Q:'IEN S IEN0=$G(^HL(772,IEN,0)) Q:'IEN0 D
77 ..S REP=$P(IEN0,U,10)
78 ..I REP D
79 ...I '$D(^ORD(101,REP,0)) Q
80 ...S REPNM=$P(^ORD(101,REP,0),U),RPNM=$E(REPNM,1,4)
81 ...I RPNM["VAF"!(RPNM["RG")!(RPNM["MPI") D
82 ....S TYPE=$P(IEN0,U,4),STAT=$P($G(^HL(772,IEN,"P")),U)
83 ....I STAT="" D
84 .....S HL773=$O(^HLMA("B",IEN,0))
85 .....S STAT=$P($G(^HLMA(HL773,"P")),"^")
86 ....I STAT S STATNM=$P(^HL(771.6,STAT,0),U)
87 ....I STAT="" S STATNM="NO STATUS"
88 ....S ^XTMP("RGMT","HL",REPNM,$P(RGDT,"."),TYPE,STATNM,IEN)=""
89PAT ....S TXT=0 F S TXT=$O(^HL(772,IEN,"IN",TXT)) Q:'TXT D
90 .....I $P(^HL(772,IEN,"IN",TXT,0),U)="PID" S GOT=0 D Q:GOT
91 ......I $P(^HL(772,IEN,"IN",TXT,0),"^",4)["V" S ICN=+$P(^(0),"^",4) D SET
92 ......I $P(^HL(772,IEN,"IN",TXT,0),"^",3)["V" S ICN=+$P(^(0),"^",3) D SET
93 .....I $P(^HL(772,IEN,"IN",TXT,0),U)="QAK" S GOT=0 D Q:GOT
94 ......I +$P(^(0),U,2) S DFN=+$P(^(0),U,2) S ^XTMP("RGMT","HLDFN",DFN,RGDT,REPNM,TYPE,STATNM,IEN)="",GOT=1
95 .....I $P(^HL(772,IEN,"IN",TXT,0),U)="RDT" S ICN=+$P($P(^(0),U,6),"V") I ICN D Q
96 ......S ^XTMP("RGMT","HLICN",ICN,RGDT,REPNM,TYPE,STATNM,IEN)="(Look at ^HL(772,"_IEN_",""IN"","_TXT_",0)",GOT=1
97 .....I $P(^HL(772,IEN,"IN",TXT,0),U)="VTQ" S GOT=0 D Q:GOT
98 ......S SSN=$P($P(^HL(772,IEN,"IN",TXT,0),"@00122",2),"~",3) I SSN D
99 .......S DFN=$O(^DPT("SSN",SSN,0)) I DFN D
100 ........S ^XTMP("RGMT","HLDFN",DFN,RGDT,REPNM,TYPE,STATNM,IEN)="(Look at ^HL(772,"_IEN_",""IN"","_TXT_",0)",GOT=1
101 .....I $P(^HL(772,IEN,"IN",TXT,0),U)="MFE",$P(^(0),U,2)="MAD" S ICN=+$P($P(^(0),U,5),"~",4) D SET Q
102 .....I $P(^HL(772,IEN,"IN",TXT,0),U)="MFE",$P(^(0),U,2)="MUP" D Q
103 ......S ICN=+$P(^HL(772,IEN,"IN",TXT,0),U,5) I $L(ICN)=3 S ICN=+$P($P(^HL(772,IEN,"IN",TXT,0),U,5),"~",4)
104 ......D SET
105 ;
106 D NOW^%DTC S ^XTMP("RGMT","HL","@@@@","STOPPED")=%
107 K ^XTMP("RGMT","HL","@@@@","NOW PROCESSING DATE"),^XTMP("RGMT","HL","@@@@","FORCE STOP")
108 ;
109QUIT ;
110 K %,ACT,CDT,DFN,GOT,HL773,ICN,IEN,IEN0,PRGBDT,PRGEDT,REP,REPNM,RGBDT,RGDT
111 K RGEDT,RGNOW,RPNM,SSN,STAT,STATNM,STOPDT,TYPE,TXT,X,X1,X2,Y,ZTSK,STOP,FROM,QFLG,RANGE
112 S:$D(ZTQUEUED) ZTREQ="@"
113 Q
114 ;
115SET ;
116 S GOT=1
117 S ^XTMP("RGMT","HLICN",ICN,RGDT,REPNM,TYPE,STATNM,IEN)=""
118 S DFN=$O(^DPT("AICN",ICN,0)) I +DFN S ^XTMP("RGMT","HLDFN",DFN,RGDT,REPNM,TYPE,STATNM,IEN)=""
119 Q
120 ;
121STOP ;stop the compile
122 W !!,"Stop HL7 Message Compile."
123 I '$D(^XTMP("RGMT","HL","@@@@","STARTED")) W !?3,"<< No compile is currently running >>" G QUIT
124 I $D(^XTMP("RGMT","HL","@@@@","STARTED"))&($D(^XTMP("RGMT","HL","@@@@","STOPPED"))) W !?3,"<< No compile is currently running >>" G QUIT
125 ;
126 W !!,"A compile is currently running for ",?35,": ",^XTMP("RGMT","HL","@@@@","RANGE"),"."
127 W ! S DIR(0)="Y",DIR("B")="Yes",DIR("A")="Do you want to stop this compile" D ^DIR K DIR
128 I +Y D
129 .S ^XTMP("RGMT","HL","@@@@","FORCE STOP")=""
130 .S STOP=$$NOW^XLFDT
131 .S RANGE=^XTMP("RGMT","HL","@@@@","RANGE"),FROM=$P(RANGE," to ",1)
132 .S ^XTMP("RGMT","HL","@@@@","RANGE")=FROM_" to "_$$FMTE^XLFDT(STOP)
133 G QUIT
134 ;
135SHOW ;show status of compile
136 W !!,"Show status of HL7 Message Compile."
137 I '$D(^XTMP("RGMT","HL","@@@@","STARTED")) W !?3,"<< No compile is currently running >>" G QUIT
138 W !!,"Compile range ",?31,": ",^XTMP("RGMT","HL","@@@@","RANGE")
139 W !,"The compile was started ",?31,": ",$$FMTE^XLFDT(^XTMP("RGMT","HL","@@@@","STARTED"))
140 I $D(^XTMP("RGMT","HL","@@@@","NOW PROCESSING DATE")) D
141 .W !,"The compile is now processing ",?31,": ",$$FMTE^XLFDT(^XTMP("RGMT","HL","@@@@","NOW PROCESSING DATE"))
142 I $D(^XTMP("RGMT","HL","@@@@","STOPPED")) D
143 .W !,"The compile was stopped ",?31,": ",$$FMTE^XLFDT(^XTMP("RGMT","HL","@@@@","STOPPED"))
144 G QUIT
Note: See TracBrowser for help on using the repository browser.