source: WorldVistAEHR/trunk/r/VISTA_OFFICE_EHR-VEPE/VEPER7EX.m@ 1742

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

initial load of WorldVistAEHR

File size: 5.6 KB
Line 
1VEPER7EX ;RSL/DAOU; HL7 EXTRACT FROM FILE; 05/20/2005 10:24 ; 8/23/05 11:29am
2 ;;1.0;VISTA EHR DOQ IT HL7 extraction using Clinical Reminders; 05/20/05 ;;Build 1
3 ;This is the beginning of the extraction from the extract file
4 ;
5 ;VARIABLE LIST
6 Q
7EXTRACT(VBDT,VEDT,PXRMLIST) ;
8 N FHSC,BHSC,MSHC,RXAC,HL7DIR,HL7FN,DFN,NPID,PCID,PROD,SF,VID,BDT,EDT
9 N CONFIG,HL7DIR,HL7FN,TOPTYP,TOPIND,INST,FNMID,TTIEN,TODAY,DFNSQ
10 S (FHSC,BHSC,MSHC,RXAC,ORCC)=0 ;Initialize counts
11 ;
12 ;**** Switch from Test to Production ****
13 S PROD=0
14 ;******************************************
15 ;
16 S CFGIEN="1,"
17 K CONFIG D GETS^DIQ(19904.5,CFGIEN,"**","","CONFIG")
18 S INSTIEN=DUZ(2)_","
19 K INST D GETS^DIQ(4,INSTIEN,"**","","INST")
20 ; ---- ** Need to build and fetch area for Client Start date and end date
21 S CLSTDT=""
22 S CLENDDT=""
23 S %DT="T",X="N" D ^%DT S TODAY=$P(Y,".")
24 S BDT=$S(VBDT:VBDT,1:0),EDT=$S(VEDT:VEDT,1:TODAY)
25 S HL7DIR=CONFIG(19904.5,CFGIEN,1) ;Directory from Configuration where to place the HL7 files
26 S SF=INST(4,INSTIEN,.01) ;Sending Facility Name
27 S FNMID=INST(4,INSTIEN,52)
28 I HL7DIR="" D Q
29 . W "HL7 directory is not defined. Quiting.",!!
30 . W "Please enter HL7 send directory into configuration."
31 S %DT="T",X="N" D ^%DT
32 N DTZ S DTZ=$$FMTHL7^XLFDT(Y),DTZ=$P(DTZ,"-")
33 S HL7FN="DOQITHL7_"_DTZ_".DAT"
34 W !!,"HL7 DOQ IT file name for transmission will be:",!
35 W HL7DIR_HL7FN,!!
36 W "Status messages will be sent to Mail Group: ",CONFIG(19904.5,"1,",2),!!
37 S ZTER="OPENERR",POP=0
38 D OPEN^%ZISH("",HL7DIR,HL7FN,"W") Q:POP
39 U IO
40 ;-Verify Values
41 S TOPTYP=$S(ID[" CAD ":"CAD",ID[" HTN ":"HTN",ID[" DM ":"DM",ID[" HF ":"HF",1:"PC"),TTIEN=$O(^DOQIT(19904.6,"B",TOPTYP,""))_","
42 K TDATA D GETS^DIQ(19904.6,TTIEN,"**","","TDATA")
43 S DFNSQ=0 F S DFNSQ=$O(^PXRMXP(810.5,PXRMLIST,30,DFNSQ)) Q:DFNSQ=""!(DFNSQ'?.N) S DFN=$P(^(DFNSQ,0),"^"),X=$$PTPROCES(DFN) I X D
44 . I X=1 W !,"ERROR: Patient DFN # is not in file #2 for IEN #",IEN,"." Q
45 ;
46 I BHSC D BTS^VEPER7SG(MSHC)
47 I FHSC D FTS^VEPER7SG(BHSC)
48 ;End of EXTRACT *********
49 D CLOSE^%ZISH("")
50 K ^TMP("VEPER7EX",$J)
51 Q
52 ;
53PTPROCES(DFN) ;Process Patient information out to DOQ IT HL7 file.
54 ;
55 ; DFN - Patient Identification Number for link to DPT file #2.
56 ;
57 N IDXSQ,VEPER7PT,TOPIND,TTP,ALERGY,ORC,ENEFFDT,ENCLSDT,DTTM
58 I '$D(^DPT(DFN)) Q 1 ;DFN is not on file in #2.
59 ;
60 ;
61 K VEPER7PT S DFN=DFN_"," D GETS^DIQ(2,DFN,"**","","VEPER7PT")
62 D GETS^DIQ(2,DFN,.03,"I","VEPER7PT")
63 K DOQREG D GETS^DIQ(19904.4,DFN,"**","","DOQREG")
64 S ALERGY=0
65 S ENEFFDT=$$DTCALC^VEPER7SG("","")
66 S ENCLSDT=""
67 ;
68 ;----- Follow links to fetch Institution Name & Info
69 ;
70 ;K MCDIVA,INSTLNK,INST
71 ;S X=$O(VEPER7PT(2.101,"")),X=X_","
72 ;K MCDIVA D GETS^DIQ(2.101,X,"3","I","MCDIVA")
73 ;S MCDIV=MCDIVA(2.101,X,3,"I")_","
74 ;K INSTLNK D GETS^DIQ(40.8,MCDIV,".07","I","INSTLNK")
75 ;S INSTNO=INSTLNK(40.8,MCDIV,.07,"I")
76 ;K INST D GETS^DIQ(4,INSTNO,"**","","INST")
77 ;
78 ;------ End of Institution links for data -------
79 ;
80 ;-------- Follow links for Primary Physician Info --------
81 ;
82 S X=$O(VEPER7EX(2.312,""))
83 K PPIEN I X'="" D
84 . D GETS^DIQ(2.312,X,"4.01","I","PPIEN")
85 . S PPIEN=$G(PPIEN(2.312,X,4.01,"I"))_","
86 . K PRIPHN D GETS^DIQ(200,PPIEN,53.2,"","PRIPHN")
87 I X="" S PPIEN=","
88 K PRIPHN S PRIPHN(200,PPIEN,53.2)="" I PPIEN'="," D GETS^DIQ(200,PPIEN,"**","","PRIPHN")
89 ;
90 ;--------- End of Primary Physician Info Link -------
91 ;
92 ;S TOPI=TTIEN F S TOPI=$O(TDATA(19904.62,TOPI)) Q:TOPI="" S TOPIND=$P(TOPI,",") D
93 S TOPI=1 F S TOPI=$O(TDATA(19904.62,TOPI)) Q:TOPI="" I $P(TOPI,",",2)=$P(TTIEN,",") D
94 .S TOPIND=$P(TOPI,",")
95 .S TTP=TOPIND-2*2+1
96 .I TTP>0 S FLD=$S(TOPTYP="CAD":.2,TOPTYP="DM":.3,TOPTYP="HTN":.4,TOPTYP="HF":.5,1:.6)_(TOPIND-1)
97 .I TTP<0 S FLD=$S(TOPTYP="CAD":.02,TOPTYP="DM":.03,TOPTYP="HTN":.04,TOPTYP="HF":.05,1:.06)
98 .I DOQREG(19904.4,DFN,FLD)?1"C".E,DOQREG(19904.4,DFN,FLD_1)="" D Q
99 ..D CANCEL^VEPER7SB
100 ..N UPDTREG,ERR
101 ..K UPDTREG S UPDTREG(19904.4,DFN,FLD_1)=TODAY
102 ..D FILE^DIE("","UPDTREG","ERR")
103 ..K UPDTREG,ERR
104 .I DOQREG(19904.4,DFN,FLD)'?1"R".E Q ;If patient not registered then stop processing
105 .I DOQREG(19904.4,DFN,FLD_1)="" D
106 ..D REGISTER^VEPER7SB
107 ..N UPDTREG,ERR
108 ..K UPDTREG S UPDTREG(19904.4,DFN,FLD_1)=TODAY
109 ..D FILE^DIE("","UPDTREG","ERR")
110 ..K UPDTREG,ERR
111 .;
112 .;--- Fetch visit records for patient to process ---
113 .;
114 .D VISIT^VEPEREX($E(DFN,1,$L(DFN)-1),20,BDT,EDT,.NFOUND,.TEST,.DATE,.DATA,.TEXT)
115 .S VSTNO="" F S VSTNO=$O(DATA(VSTNO)) Q:VSTNO="" S VSTIEN=DATA(VSTNO)_"," D
116 ..I $D(^TMP("VEPER7EX",$J,"V",DFN,VSTNO)) Q ;Don't process 2ce
117 ..K VISIT D GETS^DIQ(9000010,VSTIEN,.01,"I","VISIT")
118 ..D PTVISIT^VEPER7SB
119 ..S ^TMP("VEPER7EX",$J,"V",DFN,VSTNO)=""
120 .S BVDATE=9999998-EDT,EVDATE=9999999-BDT
121 .S VAX="" F S VAX=$O(^AUPNVIMM("AA",DFN,VAX)) Q:VAX="" D
122 ..S BVDATE=$O(^AUPNVIMM("AA",DFN,VAX,BVDATE)) Q:BVDATE=""!(BVDATE>EVDATE) D
123 ...S VIMMIEN="" F S VIMMEIN=$O(^AUPNVIMM("AA",DFN,VAX,BVDATE,VIMMIEN)) Q:VIMMEIN="" D
124 ....I $D(^TMP("VEPER7EX",$J,DFN,VAX,BVDATE,VIMMIEN)) Q ;Don't process a 2nd time
125 ....K VIMM D GETS^DIQ(9000010.11,VIMMIEN_",","**","","VIMM")
126 ....D GETS^DIQ(9000010.11,VIMMIEN_",",1201,"I","VIMM")
127 ....D VAXMSG^VEPER7SB
128 ....S ^TMP("VEPER7EX",$J,DFN,VAX,BVDATE,VIMMIEN)=""
129 ....K VIMM
130 .S BVDATE=9999998-EDT
131 .S MED="" F S MED=$O(^AUPNVMED("AA",DFN,MED)) Q:MED="" D
132 ..S BVDATE=$O(^AUPNVMED("AA",DFN,MED,BVDATE)) Q:BVDATE=""!(BVDATE>EVDATE) D
133 ...S VMEDIEN="" F S VMEDIEN=$O(^AUPNVMED("AA",DFN,MED,BVDATE,VMEDIEN)) Q:VMEDIEN="" D
134 ....I $D(^TMP("VEPER7EX",$J,DFN,MED,BVDATE,VMEDIEN)) Q ;Don't process a 2nd time
135 ....K VMED D GETS^DIQ(9000010.14,VMEDIEN_",","**","","VMED")
136 ....D PXTRTOM^VEPER7SB
137 ....S ^TMP("VEPER7EX",$J,DFN,MED,BVDATE,VMEDIEN)=""
138 ....K VMED
139 Q 0
140 ;
141 ;
Note: See TracBrowser for help on using the repository browser.