source: WorldVistAEHR/trunk/r/MY_HEALTHEVET-MHV/MHV7RU.m@ 975

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

initial load of WorldVistAEHR

File size: 3.7 KB
Line 
1MHV7RU ;WAS/GPM - HL7 RECEIVER UTILITIES ; [12/13/07 10:26pm]
2 ;;1.0;My HealtheVet;**2**;Aug 23, 2005;Build 22
3 ;;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5 Q
6 ;
7VALIDDT(DT) ; Validate and convert date
8 ;
9 ; Integration Agreements:
10 ; 10103 : HL7TFM^XLFDT
11 ;
12 I DT="" Q 1
13 I DT'?8.16N Q 0
14 S DT=$$HL7TFM^XLFDT(DT)\1
15 I DT'?7N Q 0
16 Q 1
17 ;
18VALRTYPE(TYPE,REQ,ERR) ; Validate request type
19 ;
20 ; Input:
21 ; TYPE - Request type string
22 ;
23 ; Output:
24 ; REQ - Request parameter array
25 ; REQ("TYPE")
26 ; REQ("REQNAME")
27 ; REQ("BLOCKED")
28 ; REQ("REALTIME")
29 ; REQ("EXECUTE")
30 ; REQ("BUILDER")
31 ;
32 ; ERR - Caret delimited error string
33 ; segment^sequence^field^code^ACK type^error text
34 ;
35 N REQTIEN,REQT0
36 S REQTIEN=$O(^MHV(2275.3,"D",TYPE,0))
37 I 'REQTIEN S ERR="103^AE^Request Type Not Found" Q 0
38 S REQT0=$G(^MHV(2275.3,REQTIEN,0))
39 ;
40 S REQ("REQNAME")=$P(REQT0,"^",1)
41 S REQ("TYPE")=$P(REQT0,"^",2)
42 S REQ("BLOCKED")=$P(REQT0,"^",3)
43 S REQ("REALTIME")=$P(REQT0,"^",4)
44 S REQ("EXECUTE")=$TR($P(REQT0,"^",5),"~","^")
45 S REQ("BUILDER")=$TR($P(REQT0,"^",6),"~","^")
46 Q 1
47 ;
48VALIDID(ICN,DFN,SSN,ERR) ;Validate patient identifiers
49 ; Will accept ICN, SSN, or DFN, but must have at least one.
50 ; Validate one, in order of preference: ICN, SSN, DFN.
51 ; If more than once sent, all must resolve to the same patient.
52 ; Those not sent will be resolved and returned.
53 ;
54 ; Integration Agreements:
55 ; 2701 : GETDFN^MPIF001, GETICN^MPIF001
56 ; 10035 : Direct reference of ^DPT(DFN,0);9
57 ; and reference of ^DPT("SSN") x-ref
58 ;
59 ; Input:
60 ; ICN, DFN, SSN - Identifiers
61 ;
62 ; Output: Function value True if IDs are valid, False otherwise
63 ; ICN, DFN, SSN - Identifiers
64 ; ERR - Caret delimited error string
65 ; segment^sequence^field^code^ACK type^error text
66 ;
67 N XSSN,XDFN
68 S ERR=""
69 I ICN="",SSN="",DFN="" S ERR="101^AE^Missing Patient ID" Q 0
70 ;
71 I ICN'="" D Q:ERR'="" 0 Q 1
72 . D LOG^MHVUL2("VALIDID","ICN="_ICN,"S","DEBUG")
73 . I ICN'?9.10N1"V"6N S ERR="102^AE^Invalid ICN" Q
74 . S XDFN=$$GETDFN^MPIF001(+ICN)
75 . I XDFN<1 S ERR="204^AR^Patient Not Found" Q
76 . I '$D(^DPT(XDFN,0)) S ERR="204^AR^Patient Not Found" Q
77 . S XSSN=$P($G(^DPT(XDFN,0)),"^",9)
78 . I SSN'="" D Q:ERR'=""
79 .. I SSN'?9N S ERR="102^AE^Invalid SSN" Q
80 .. I SSN'=XSSN S ERR="204^AE^Patient SSN Mismatch" Q
81 .. Q
82 . I DFN'="" D Q:ERR'=""
83 .. I DFN'?1N.N S ERR="102^AE^Invalid DFN" Q
84 .. I DFN<1 S ERR="102^AE^Invalid DFN" Q
85 .. I DFN'=XDFN S ERR="204^AE^Patient DFN Mismatch" Q
86 .. Q
87 . S DFN=XDFN,SSN=XSSN
88 . D LOG^MHVUL2("VALIDID","SSN="_SSN,"S","DEBUG")
89 . D LOG^MHVUL2("VALIDID","DFN="_DFN,"S","DEBUG")
90 . Q
91 ;
92 I SSN'="" D Q:ERR'="" 0 Q 1
93 . D LOG^MHVUL2("VALIDID","SSN="_SSN,"S","DEBUG")
94 . I SSN'?9N S ERR="102^AE^Invalid SSN" Q
95 . S XDFN=$O(^DPT("SSN",SSN,""))
96 . I XDFN<1 S ERR="204^AR^Patient Not Found" Q
97 . I '$D(^DPT(XDFN,0)) S ERR="204^AR^Patient Not Found" Q
98 . S ICN=$$GETICN^MPIF001(XDFN)
99 . I ICN<1 S ICN=""
100 . I DFN'="" D Q:ERR'=""
101 .. I DFN'?1N.N S ERR="102^AE^Invalid DFN" Q
102 .. I DFN<1 S ERR="102^AE^Invalid DFN" Q
103 .. I DFN'=XDFN S ERR="204^AE^Patient DFN Mismatch" Q
104 .. Q
105 . S DFN=XDFN
106 . D LOG^MHVUL2("VALIDID","ICN="_ICN,"S","DEBUG")
107 . D LOG^MHVUL2("VALIDID","DFN="_DFN,"S","DEBUG")
108 . Q
109 ;
110 I DFN'="" D Q:ERR'="" 0 Q 1
111 . D LOG^MHVUL2("VALIDID","DFN="_DFN,"S","DEBUG")
112 . I DFN'?1N.N S ERR="102^AE^Invalid DFN" Q
113 . I DFN<1 S ERR="102^AE^Invalid DFN" Q
114 . I '$D(^DPT(DFN,0)) S ERR="204^AR^Patient Not Found" Q
115 . S ICN=$$GETICN^MPIF001(DFN)
116 . I ICN<1 S ICN=""
117 . S SSN=$P($G(^DPT(DFN,0)),"^",9)
118 . D LOG^MHVUL2("VALIDID","ICN="_ICN,"S","DEBUG")
119 . D LOG^MHVUL2("VALIDID","SSN="_SSN,"S","DEBUG")
120 . Q
121 ;
122 S ERR="101^AE^Missing Patient ID"
123 Q 0
124 ;
Note: See TracBrowser for help on using the repository browser.