source: FOIAVistA/tag/r/SCHEDULING-SD-SC/SCMSVPID.m@ 1071

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

initial load of FOIAVistA 6/30/08 version

File size: 4.3 KB
Line 
1SCMSVPID ;ALB/ESD HL7 PID Segment Validation ; 23 Oct 98 3:36 PM
2 ;;5.3;Scheduling;**44,66,162,254,293**;Aug 13, 1993
3 ;
4 ;
5EN(PIDSEG,HLQ,HLFS,HLECH,VALERR,ENCDT,EVNTHL7) ;
6 ; Entry point to return the HL7 PID (Patient ID) validation segment
7 ;
8 ; Input: PIDSEG - Array containing PID segment (pass by ref)
9 ; PIDSEG = First 245 characters
10 ; PIDSEG(1..n) = Continuation nodes
11 ; HLQ - HL7 null variable
12 ; HLFS - HL7 field separator
13 ; HLECH - HL7 encoding characters
14 ; VALERR - The array name to put the errors in
15 ; ENCDT - The date/time of the encounter.
16 ; EVNTHL7 - Event type ("A08" for add/edit, "A23" for delete)
17 ;
18 ; Output: 1 if PID passed validity check
19 ; Error message if PID failed validity check in form of:
20 ; -1^"xxx failed validity check" (xxx=element in PID segment)
21 ;
22 ;Declare variables
23 N MSG,SEQ,SD,PARSEG,SEG
24 S PARSEG=$NA(^TMP("SCMSVPID",$J,"PARSEG"))
25 K @PARSEG
26 S MSG="-1^Element in PID segment failed validity check"
27 ;-Set encoding chars to standard HL7 encoding chars if not passed in
28 I '$D(HLQ) S HLQ=$C(34,34)
29 S HLECH=$G(HLECH)
30 S:HLECH="" HLECH="~|\&"
31 ;-Create array of elements to validate
32 F SEQ=3,5,7,8,10,11,16,17,19,22 S SD(SEQ)="" ;Elements for 'add' or 'edit' transactions
33 I $G(EVNTHL7)="A23" K SD F I=3,19 S SD(SEQ)="" ;Elements for 'delete' transactions
34 ;
35 S SEG="PID"
36 D VALIDATE^SCMSVUT0(SEG,$G(PIDSEG),"0006",VALERR,.CNT)
37 I $D(@VALERR@(SEG)) G ENQ
38 ;-Parse out fields
39 D SEGPRSE^SCMSVUT5("PIDSEG",PARSEG,HLFS)
40 ;-Remember DFN
41 ;S DFN=$$CONVERT^SCMSVUT0($G(@PARSEG@(3)),$E(HLECH,1),HLQ)
42 ;S DFN=+$P(DFN,$E(HLECH,1),1)
43 ;-Validate segment name
44 S CNT=1
45 D VALIDATE^SCMSVUT0(SEG,$G(@PARSEG@(0)),$P($T(0),";",3),VALERR,.CNT)
46 ;-Validate fields
47 S SEQ=0
48 F S SEQ=+$O(SD(SEQ)) Q:'SEQ D
49 .I SEQ=11 D ADDRCHK(SEG,VALERR,.CNT) Q
50 .I (SEQ=10)!(SEQ=22) D Q
51 ..N PARSEQ,REP,COMP
52 ..S PARSEQ=$NA(^TMP("SCMSVPID",$J,"PARSEQ"))
53 ..K @PARSEQ
54 ..D SEQPRSE^SCMSVUT5($NA(@PARSEG@(SEQ)),PARSEQ,HLECH)
55 ..S REP=0
56 ..F S REP=+$O(@PARSEQ@(REP)) Q:'REP D
57 ...S DATA=$$CONVERT^SCMSVUT0($G(@PARSEQ@(REP,1)),$E(HLECH,4),HLQ)
58 ...D VALIDATE^SCMSVUT0(SEG,$P(DATA,$E(HLECH,1),1),$P($T(@(SEQ)),";",3),VALERR,.CNT)
59 ..K @PARSEQ
60 .S DATA=$G(@PARSEG@(SEQ))
61 .S DATA=$$CONVERT^SCMSVUT0(DATA,$E(HLECH,1),HLQ)
62 .S:SEQ=3 DATA=$P(DATA,$E(HLECH,1),1)
63 .S:SEQ=5 DATA=$$FMNAME^HLFNC(DATA)
64 .S:SEQ=7 DATA=$$FMDATE^HLFNC(DATA)
65 .D VALIDATE^SCMSVUT0(SEG,DATA,$P($T(@(SEQ)),";",3),VALERR,.CNT)
66 ;
67ENQ K @PARSEG
68 Q $S($D(@VALERR@(SEG,1)):MSG,1:1)
69 ;
70 ;
71ADDRCHK(SEG,VALERR,CNT) ;- Validity check for address (seq 11)
72 ;
73 ;Declare variables
74 N PARSEQ,REP,COMP,DATA,TYPE,OFFSET,CODE,STATE,SKIP
75 ;Parse sequence into repeated components
76 S PARSEQ=$NA(^TMP("SCMSVPID",$J,"PARSEQ"))
77 K @PARSEQ
78 D SEQPRSE^SCMSVUT5($NA(@PARSEG@(11)),PARSEQ,HLECH)
79 ;Validate
80 S REP=0
81 F S REP=+$O(@PARSEQ@(REP)) Q:'REP D
82 .;Get address type
83 .S TYPE=$$CONVERT^SCMSVUT0($G(@PARSEQ@(REP,7)),$E(HLECH,4),HLQ)
84 .S:TYPE="" TYPE="P" S:TYPE'="P" TYPE="VACA"
85 .;Calculate error code offset
86 .S OFFSET=$S($E(TYPE,1,4)="VACA":200,TYPE="P":0,1:0)
87 .;If it's a confidential address, everything is allowed to be empty
88 .I $E(TYPE,1,4)="VACA" S SKIP=1 D Q:SKIP
89 ..F SEQ=1,2,3,4,5,8,9,12 D Q:'SKIP
90 ...S DATA=$$CONVERT^SCMSVUT0($G(@PARSEQ@(REP,SEQ)),$E(HLECH,4),HLQ)
91 ...I SEQ=12 Q:DATA=$E(HLECH,4) S SKIP=0 Q
92 ...I DATA'="" S SKIP=0
93 .;Validate components
94 .S STATE=0
95 .F SEQ=1,2,3,4,5,7,9,12 D
96 ..I TYPE="P" Q:((SEQ=7)!(SEQ=12))
97 ..S DATA=$$CONVERT^SCMSVUT0($G(@PARSEQ@(REP,SEQ)),$E(HLECH,4),HLQ)
98 ..I SEQ=9 S STATE=$G(@PARSEQ@(REP,4)) I STATE'="" S STATE=+$O(^DIC(5,"C",STATE,""))
99 ..S CODE=$S(SEQ<10:"110",1:"11")_SEQ
100 ..S CODE=OFFSET+$P($T(@(CODE)),";",3)
101 ..D VALIDATE^SCMSVUT0(SEG,DATA,CODE,VALERR,.CNT)
102 K @PARSEQ
103 Q
104 ;
105ERR ;;Invalid or missing patient ID data for encounter (HL7 PID data segment)
106 ;
107 ;
108 ;- PID data elements validated
109 ;
1100 ;;0035;HL7 SEGMENT NAME
1113 ;;2030;PATIENT ID (INTERNAL)
1125 ;;2000;NAME
1137 ;;2050;DATE OF BIRTH
1148 ;;2100;SEX
11510 ;;2150;RACE
1161101 ;;2200;STREET ADDRESS 1
1171102 ;;2210;STREET ADDRESS 2
1181103 ;;2220;CITY
1191104 ;;2230;STATE
1201105 ;;2240;ZIP CODE
1211107 ;;2270;ADDRESS TYPE
1221109 ;;2250;COUNTY CODE
1231112 ;;2280;ADDRESS START/STOP DATE
12416 ;;2300;MARITAL STATUS
12517 ;;2330;RELIGION
12619 ;;2360;SSN
12722 ;;2380;ETHNICITY
Note: See TracBrowser for help on using the repository browser.