MHV7RU ;WAS/GPM - HL7 RECEIVER UTILITIES ; [12/13/07 10:26pm]
;;1.0;My HealtheVet;**2**;Aug 23, 2005;Build 22
;;Per VHA Directive 2004-038, this routine should not be modified.
;
Q
;
VALIDDT(DT) ; Validate and convert date
;
; Integration Agreements:
; 10103 : HL7TFM^XLFDT
;
I DT="" Q 1
I DT'?8.16N Q 0
S DT=$$HL7TFM^XLFDT(DT)\1
I DT'?7N Q 0
Q 1
;
VALRTYPE(TYPE,REQ,ERR) ; Validate request type
;
; Input:
; TYPE - Request type string
;
; Output:
; REQ - Request parameter array
; REQ("TYPE")
; REQ("REQNAME")
; REQ("BLOCKED")
; REQ("REALTIME")
; REQ("EXECUTE")
; REQ("BUILDER")
;
; ERR - Caret delimited error string
; segment^sequence^field^code^ACK type^error text
;
N REQTIEN,REQT0
S REQTIEN=$O(^MHV(2275.3,"D",TYPE,0))
I 'REQTIEN S ERR="103^AE^Request Type Not Found" Q 0
S REQT0=$G(^MHV(2275.3,REQTIEN,0))
;
S REQ("REQNAME")=$P(REQT0,"^",1)
S REQ("TYPE")=$P(REQT0,"^",2)
S REQ("BLOCKED")=$P(REQT0,"^",3)
S REQ("REALTIME")=$P(REQT0,"^",4)
S REQ("EXECUTE")=$TR($P(REQT0,"^",5),"~","^")
S REQ("BUILDER")=$TR($P(REQT0,"^",6),"~","^")
Q 1
;
VALIDID(ICN,DFN,SSN,ERR) ;Validate patient identifiers
; Will accept ICN, SSN, or DFN, but must have at least one.
; Validate one, in order of preference: ICN, SSN, DFN.
; If more than once sent, all must resolve to the same patient.
; Those not sent will be resolved and returned.
;
; Integration Agreements:
; 2701 : GETDFN^MPIF001, GETICN^MPIF001
; 10035 : Direct reference of ^DPT(DFN,0);9
; and reference of ^DPT("SSN") x-ref
;
; Input:
; ICN, DFN, SSN - Identifiers
;
; Output: Function value True if IDs are valid, False otherwise
; ICN, DFN, SSN - Identifiers
; ERR - Caret delimited error string
; segment^sequence^field^code^ACK type^error text
;
N XSSN,XDFN
S ERR=""
I ICN="",SSN="",DFN="" S ERR="101^AE^Missing Patient ID" Q 0
;
I ICN'="" D Q:ERR'="" 0 Q 1
. D LOG^MHVUL2("VALIDID","ICN="_ICN,"S","DEBUG")
. I ICN'?9.10N1"V"6N S ERR="102^AE^Invalid ICN" Q
. S XDFN=$$GETDFN^MPIF001(+ICN)
. I XDFN<1 S ERR="204^AR^Patient Not Found" Q
. I '$D(^DPT(XDFN,0)) S ERR="204^AR^Patient Not Found" Q
. S XSSN=$P($G(^DPT(XDFN,0)),"^",9)
. I SSN'="" D Q:ERR'=""
.. I SSN'?9N S ERR="102^AE^Invalid SSN" Q
.. I SSN'=XSSN S ERR="204^AE^Patient SSN Mismatch" Q
.. Q
. I DFN'="" D Q:ERR'=""
.. I DFN'?1N.N S ERR="102^AE^Invalid DFN" Q
.. I DFN<1 S ERR="102^AE^Invalid DFN" Q
.. I DFN'=XDFN S ERR="204^AE^Patient DFN Mismatch" Q
.. Q
. S DFN=XDFN,SSN=XSSN
. D LOG^MHVUL2("VALIDID","SSN="_SSN,"S","DEBUG")
. D LOG^MHVUL2("VALIDID","DFN="_DFN,"S","DEBUG")
. Q
;
I SSN'="" D Q:ERR'="" 0 Q 1
. D LOG^MHVUL2("VALIDID","SSN="_SSN,"S","DEBUG")
. I SSN'?9N S ERR="102^AE^Invalid SSN" Q
. S XDFN=$O(^DPT("SSN",SSN,""))
. I XDFN<1 S ERR="204^AR^Patient Not Found" Q
. I '$D(^DPT(XDFN,0)) S ERR="204^AR^Patient Not Found" Q
. S ICN=$$GETICN^MPIF001(XDFN)
. I ICN<1 S ICN=""
. I DFN'="" D Q:ERR'=""
.. I DFN'?1N.N S ERR="102^AE^Invalid DFN" Q
.. I DFN<1 S ERR="102^AE^Invalid DFN" Q
.. I DFN'=XDFN S ERR="204^AE^Patient DFN Mismatch" Q
.. Q
. S DFN=XDFN
. D LOG^MHVUL2("VALIDID","ICN="_ICN,"S","DEBUG")
. D LOG^MHVUL2("VALIDID","DFN="_DFN,"S","DEBUG")
. Q
;
I DFN'="" D Q:ERR'="" 0 Q 1
. D LOG^MHVUL2("VALIDID","DFN="_DFN,"S","DEBUG")
. I DFN'?1N.N S ERR="102^AE^Invalid DFN" Q
. I DFN<1 S ERR="102^AE^Invalid DFN" Q
. I '$D(^DPT(DFN,0)) S ERR="204^AR^Patient Not Found" Q
. S ICN=$$GETICN^MPIF001(DFN)
. I ICN<1 S ICN=""
. S SSN=$P($G(^DPT(DFN,0)),"^",9)
. D LOG^MHVUL2("VALIDID","ICN="_ICN,"S","DEBUG")
. D LOG^MHVUL2("VALIDID","SSN="_SSN,"S","DEBUG")
. Q
;
S ERR="101^AE^Missing Patient ID"
Q 0
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMHV7RU 3910 printed Dec 13, 2024@02:15:59 Page 2
MHV7RU ;WAS/GPM - HL7 RECEIVER UTILITIES ; [12/13/07 10:26pm]
+1 ;;1.0;My HealtheVet;**2**;Aug 23, 2005;Build 22
+2 ;;Per VHA Directive 2004-038, this routine should not be modified.
+3 ;
+4 QUIT
+5 ;
VALIDDT(DT) ; Validate and convert date
+1 ;
+2 ; Integration Agreements:
+3 ; 10103 : HL7TFM^XLFDT
+4 ;
+5 IF DT=""
QUIT 1
+6 IF DT'?8.16N
QUIT 0
+7 SET DT=$$HL7TFM^XLFDT(DT)\1
+8 IF DT'?7N
QUIT 0
+9 QUIT 1
+10 ;
VALRTYPE(TYPE,REQ,ERR) ; Validate request type
+1 ;
+2 ; Input:
+3 ; TYPE - Request type string
+4 ;
+5 ; Output:
+6 ; REQ - Request parameter array
+7 ; REQ("TYPE")
+8 ; REQ("REQNAME")
+9 ; REQ("BLOCKED")
+10 ; REQ("REALTIME")
+11 ; REQ("EXECUTE")
+12 ; REQ("BUILDER")
+13 ;
+14 ; ERR - Caret delimited error string
+15 ; segment^sequence^field^code^ACK type^error text
+16 ;
+17 NEW REQTIEN,REQT0
+18 SET REQTIEN=$ORDER(^MHV(2275.3,"D",TYPE,0))
+19 IF 'REQTIEN
SET ERR="103^AE^Request Type Not Found"
QUIT 0
+20 SET REQT0=$GET(^MHV(2275.3,REQTIEN,0))
+21 ;
+22 SET REQ("REQNAME")=$PIECE(REQT0,"^",1)
+23 SET REQ("TYPE")=$PIECE(REQT0,"^",2)
+24 SET REQ("BLOCKED")=$PIECE(REQT0,"^",3)
+25 SET REQ("REALTIME")=$PIECE(REQT0,"^",4)
+26 SET REQ("EXECUTE")=$TRANSLATE($PIECE(REQT0,"^",5),"~","^")
+27 SET REQ("BUILDER")=$TRANSLATE($PIECE(REQT0,"^",6),"~","^")
+28 QUIT 1
+29 ;
VALIDID(ICN,DFN,SSN,ERR) ;Validate patient identifiers
+1 ; Will accept ICN, SSN, or DFN, but must have at least one.
+2 ; Validate one, in order of preference: ICN, SSN, DFN.
+3 ; If more than once sent, all must resolve to the same patient.
+4 ; Those not sent will be resolved and returned.
+5 ;
+6 ; Integration Agreements:
+7 ; 2701 : GETDFN^MPIF001, GETICN^MPIF001
+8 ; 10035 : Direct reference of ^DPT(DFN,0);9
+9 ; and reference of ^DPT("SSN") x-ref
+10 ;
+11 ; Input:
+12 ; ICN, DFN, SSN - Identifiers
+13 ;
+14 ; Output: Function value True if IDs are valid, False otherwise
+15 ; ICN, DFN, SSN - Identifiers
+16 ; ERR - Caret delimited error string
+17 ; segment^sequence^field^code^ACK type^error text
+18 ;
+19 NEW XSSN,XDFN
+20 SET ERR=""
+21 IF ICN=""
IF SSN=""
IF DFN=""
SET ERR="101^AE^Missing Patient ID"
QUIT 0
+22 ;
+23 IF ICN'=""
Begin DoDot:1
+24 DO LOG^MHVUL2("VALIDID","ICN="_ICN,"S","DEBUG")
+25 IF ICN'?9.10N1"V"6N
SET ERR="102^AE^Invalid ICN"
QUIT
+26 SET XDFN=$$GETDFN^MPIF001(+ICN)
+27 IF XDFN<1
SET ERR="204^AR^Patient Not Found"
QUIT
+28 IF '$DATA(^DPT(XDFN,0))
SET ERR="204^AR^Patient Not Found"
QUIT
+29 SET XSSN=$PIECE($GET(^DPT(XDFN,0)),"^",9)
+30 IF SSN'=""
Begin DoDot:2
+31 IF SSN'?9N
SET ERR="102^AE^Invalid SSN"
QUIT
+32 IF SSN'=XSSN
SET ERR="204^AE^Patient SSN Mismatch"
QUIT
+33 QUIT
End DoDot:2
if ERR'=""
QUIT
+34 IF DFN'=""
Begin DoDot:2
+35 IF DFN'?1N.N
SET ERR="102^AE^Invalid DFN"
QUIT
+36 IF DFN<1
SET ERR="102^AE^Invalid DFN"
QUIT
+37 IF DFN'=XDFN
SET ERR="204^AE^Patient DFN Mismatch"
QUIT
+38 QUIT
End DoDot:2
if ERR'=""
QUIT
+39 SET DFN=XDFN
SET SSN=XSSN
+40 DO LOG^MHVUL2("VALIDID","SSN="_SSN,"S","DEBUG")
+41 DO LOG^MHVUL2("VALIDID","DFN="_DFN,"S","DEBUG")
+42 QUIT
End DoDot:1
if ERR'=""
QUIT 0
QUIT 1
+43 ;
+44 IF SSN'=""
Begin DoDot:1
+45 DO LOG^MHVUL2("VALIDID","SSN="_SSN,"S","DEBUG")
+46 IF SSN'?9N
SET ERR="102^AE^Invalid SSN"
QUIT
+47 SET XDFN=$ORDER(^DPT("SSN",SSN,""))
+48 IF XDFN<1
SET ERR="204^AR^Patient Not Found"
QUIT
+49 IF '$DATA(^DPT(XDFN,0))
SET ERR="204^AR^Patient Not Found"
QUIT
+50 SET ICN=$$GETICN^MPIF001(XDFN)
+51 IF ICN<1
SET ICN=""
+52 IF DFN'=""
Begin DoDot:2
+53 IF DFN'?1N.N
SET ERR="102^AE^Invalid DFN"
QUIT
+54 IF DFN<1
SET ERR="102^AE^Invalid DFN"
QUIT
+55 IF DFN'=XDFN
SET ERR="204^AE^Patient DFN Mismatch"
QUIT
+56 QUIT
End DoDot:2
if ERR'=""
QUIT
+57 SET DFN=XDFN
+58 DO LOG^MHVUL2("VALIDID","ICN="_ICN,"S","DEBUG")
+59 DO LOG^MHVUL2("VALIDID","DFN="_DFN,"S","DEBUG")
+60 QUIT
End DoDot:1
if ERR'=""
QUIT 0
QUIT 1
+61 ;
+62 IF DFN'=""
Begin DoDot:1
+63 DO LOG^MHVUL2("VALIDID","DFN="_DFN,"S","DEBUG")
+64 IF DFN'?1N.N
SET ERR="102^AE^Invalid DFN"
QUIT
+65 IF DFN<1
SET ERR="102^AE^Invalid DFN"
QUIT
+66 IF '$DATA(^DPT(DFN,0))
SET ERR="204^AR^Patient Not Found"
QUIT
+67 SET ICN=$$GETICN^MPIF001(DFN)
+68 IF ICN<1
SET ICN=""
+69 SET SSN=$PIECE($GET(^DPT(DFN,0)),"^",9)
+70 DO LOG^MHVUL2("VALIDID","ICN="_ICN,"S","DEBUG")
+71 DO LOG^MHVUL2("VALIDID","SSN="_SSN,"S","DEBUG")
+72 QUIT
End DoDot:1
if ERR'=""
QUIT 0
QUIT 1
+73 ;
+74 SET ERR="101^AE^Missing Patient ID"
+75 QUIT 0
+76 ;