source: FOIAVistA/trunk/r/E_CLAIMS_MGMT_ENGINE-BPS/BPSJPREG.m@ 1553

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

initial load of FOIAVistA 6/30/08 version

File size: 3.9 KB
Line 
1BPSJPREG ;BHAM ISC/LJF - HL7 Registration MFN Message ;21-NOV-2003
2 ;;1.0;E CLAIMS MGMT ENGINE;**1,3,2,5**;JUN 2004;Build 45
3 ;;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5 ;**Program Description**
6 ; This program will process the outgoing registration MFN message
7 ;
8 ; Variable
9 ; HL = HL7 parameters
10 ; HL7DTG = Date time in HL7 format
11 ; HLECH = HL7 Encoding Characters
12 ; HLEID = HL7 Link id
13 ; HLFS = HL7 Field separator
14 ; HLLNK = HL7 E-Pharm Link
15 ; HLRESET = HL7 generate results
16 ; IPP = IP Port
17 ; IPA = IP Address
18 ; MCT = Message Count
19 ; MGRP = E-Mail message group
20 ; MSG = Message
21 ;
22 ; Don't allow direct execution
23 ;
24 W !!!,"DIRECT ENTRY NOT ALLOWED",!!!
25 Q
26 ;
27REG(PHARMIX,BPSJVAL) ; Registration message for when a site installs
28 ;
29 N HL,HL7DTG,HLECH,HLEID,HLFS,HLLNK,HLPRO,BPSHLRS,IPA,IPP,NPKEY,NCPDP
30 N MGRP,MCT,MSG,TAXID,ZRPSEG,BPSJVAL2,BPSJPRES
31 ;
32 S (MCT,TAXID)=0,BPSJVAL=$G(BPSJVAL)
33 ;
34 I '$G(PHARMIX) Q
35 K ^TMP("HLS",$J)
36 ;
37 ; NPI Processing
38 ; Get DropDeadDate and Date/Time Last Change
39 N BPSJAPI,BPSJNPI,BPSJNDT,BPSJOP,BPSJOPS,BPSJDDD,NPKEY
40 S BPSJDDD=$$NPIREQ^BPSNPI(DT)
41 N NOW,%,%H,%I,X D NOW^%DTC S BPSJNDT=%
42 ; Get OP site for pharmacy and NPIAPI
43 S BPSJOP=0,BPSJAPI=""
44 F S BPSJOP=$O(^BPS(9002313.56,PHARMIX,"OPSITE",BPSJOP)) Q:'BPSJOP D I BPSJAPI'="" Q
45 . S BPSJOPS=$G(^BPS(9002313.56,PHARMIX,"OPSITE",BPSJOP,0))
46 . S BPSJAPI=$$NPI^BPSNPI("Pharmacy_ID",BPSJOPS)
47 . I $P(BPSJAPI,U,1)=-1 S BPSJAPI="" Q
48 . I $P(BPSJAPI,U)>0 S BPSJAPI=$P(BPSJAPI,U)
49 ; Check for existing NPI
50 S BPSJNPI=$P($G(^BPS(9002313.56,PHARMIX,"NPI")),U)
51 I 'BPSJAPI,BPSJNPI,BPSJVAL<2 D
52 . N DA,DIC,DIE,DINUM,DIR,DIRUT,DIROUT,DLAYGO,DR,DTOUT,DUOUT,X,Y
53 . S DA=PHARMIX,DIE=$$ROOT^DILFD(9002313.56)
54 . S DR="41.01///@;41.02///@" D ^DIE
55 I BPSJAPI,BPSJVAL<2 D
56 . S ^XTMP("BPSJ",0)=(BPSJNDT+7)_U_BPSJNDT_U_"BPS NPI HL7 DATA"
57 . S ^XTMP("BPSJ","NPI",BPSJAPI)=PHARMIX_U_BPSJNDT
58 ;
59 ; Get Link data from HL7 table
60 S HLPRO="BPSJ REGISTER",(IPA,IPP)=""
61 S HLLNK=$$FIND1^DIC(870,"",,"EPHARM OUT","B")
62 I HLLNK S IPA=$$GET1^DIQ(870,HLLNK_",",400.01),IPP=$$GET1^DIQ(870,HLLNK_",",400.02)
63 ;
64 ; Error if any missing data
65 I IPA=""!(IPP="") S MCT=MCT+1,MSG(MCT)="IP Address or Port is not defined. "
66 ;
67 ; Initialize the HL7
68 D INIT^HLFNC2(HLPRO,.HL)
69 S HLFS=$G(HL("FS")) I HLFS="" S HLFS="|"
70 S HLECH=$E($G(HL("ECH"),1)) I HLECH="" S HLECH="^"
71 S HL("SITE")=$$SITE^VASITE,HL("SAF")=$P(HL("SITE"),U,2,3)
72 S HL("EPPORT")=IPP,HLEID=$$HLP^BPSJUTL(HLPRO)
73 ;
74 ;Get fileman date/time, ensuring seconds are included: 3031029.135636
75 S HL7DTG=$E($$HTFM^XLFDT($H)_"000000",1,14)
76 ;Set HL7 Date/Time format: 20031029135636-0400
77 S HL7DTG=$$FMTHL7^XLFDT(HL7DTG)
78 ;
79 ; Set the ZRP Segment
80 D EN^BPSJZRP(.HL,PHARMIX,.ZRPSEG,BPSJAPI,.NCPDP)
81 M ^TMP("HLS",$J,3)=ZRPSEG K ZRPSEG
82 ;
83 ; Set the MFE segment
84 N BPSMFE S BPSMFE="MUP"
85 S NPKEY=$$NPKEY^BPSNPI(NCPDP,BPSJNPI,BPSJAPI)
86 I NPKEY D
87 . I '$$BPSACTV^BPSUTIL(PHARMIX) S BPSMFE="MDC"
88 . S ^TMP("HLS",$J,2)="MFE"_HLFS_BPSMFE_HLFS_HLFS_HL7DTG
89 . S ^TMP("HLS",$J,2)=^TMP("HLS",$J,2)_HLFS_NPKEY_HLFS_"ST"
90 ;
91 ; Set the MFI segment
92 S ^TMP("HLS",$J,1)="MFI"_HLFS_"Pharmacy Table"_HLFS_HLFS_"UPD"_HLFS
93 S ^TMP("HLS",$J,1)=^TMP("HLS",$J,1)_HL7DTG_HLFS_HL7DTG_HLFS_"NE"
94 ;
95 S BPSJPRES=$$VAL2^BPSJVAL(BPSJVAL,BPSJDDD) ; 0 = ok
96 I BPSJVAL=3 G FINI ; Just checking to see if data valid.
97 ;
98 ;-Check if msg valid.
99 I 'BPSJPRES D G FINI
100 . N BPSHLRS
101 . D GENERATE^HLMA(HLEID,"GM",1,.BPSHLRS,"")
102 . I $P($G(BPSHLRS),U,2)]"" D Q
103 .. I BPSJVAL D Q ; Interactive: show no success
104 ... W !!,"ECME Pharmacy Registration HL7 Message not created: "_BPSHLRS
105 ... W !," PHARMIX: "_PHARMIX_""
106 .. S MCT=MCT+1,MSG(MCT)="ECME Pharmacy Registration HL7 Message not created. (PHARMIX: "_PHARMIX_")"
107 .. S MCT=MCT+1,MSG(MCT)=BPSHLRS
108 .. D MSG^BPSJUTL(.MSG,"ECME Pharmacy Registration")
109 . I BPSJVAL D ;Interactive: show success
110 .. W !!,"ECME Pharmacy Registration HL7 Message was created successfully."
111 ;
112 ;
113FINI ; Clean up
114 K ^TMP("HLS",$J)
115 Q
Note: See TracBrowser for help on using the repository browser.