source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SCMSVPV1.m@ 1361

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

initial load of WorldVistAEHR

File size: 2.4 KB
Line 
1SCMSVPV1 ;ALB/ESD HL7 PV1 Segment Validation ; 23 Oct 98 3:45 PM
2 ;;5.3;Scheduling;**44,55,91,66,162,387**;Aug 13, 1993
3 ;
4 ;
5EN(PV1SEG,HLQ,HLFS,VALERR,NODE,EVNTHL7,ENCNDT) ;
6 ; Entry point to return the HL7 PV1 (Patient Visit) validation segment
7 ;
8 ; Input: PV1SEG - PV1 Segment
9 ; HLQ - HL7 null variable
10 ; HLFS - HL7 field separator
11 ; VALERR - The array to put errors in
12 ; EVNTHL7 - Event type ("A08" for add/edit, "A23" for delete)
13 ; ENCNDT - Encounter date
14 ;
15 ; Output: 1 if PV1 passed validity check
16 ; Error message if PV1 failed validity check in form of:
17 ; -1^"xxx failed validity check" (xxx=element in PV1 segment)
18 ;
19 ;NOTE:
20 ;this routine uses the variable NODE which would contain the zero node
21 ;of the encounter. It is looking for the division in the 11th piece.
22 ;this is for the check on the facility.
23 ;
24 N I,MSG,X,CNT,DATA,SEG,SD,XMTFLG
25 ;
26 ;-Create array of elements to validate
27 F I=1,3,5,510,15,40,401,45,51 S SD(I)="" ;Elements for 'add' or 'edit' transactions
28 I $G(EVNTHL7)="A23" K SD F I=40,45,51 S SD(I)="" ;Elements for 'delete' transactions
29 ;
30 S MSG="-1^Element in PV1 segment failed validity check",CNT=1
31 S PV1SEG=$G(PV1SEG),SEG="PV1"
32 D VALIDATE^SCMSVUT0(SEG,PV1SEG,"0008",VALERR,.CNT)
33 I $D(@VALERR@(SEG)) G ENQ
34 ;
35 ;- Convert HLQ to null
36 S PV1SEG=$$CONVERT^SCMSVUT0(PV1SEG,HLFS,HLQ)
37 ;
38 ;- Validate data elements
39 F I=1,3,5,510,15,40,401,45,51 D
40 . S DATA=$S(I=45:$$FMDATE^HLFNC($P(PV1SEG,HLFS,+I)),I=510:$P(PV1SEG,HLFS,+$E(I,1,1)),I=401:$P(PV1SEG,HLFS,+$E(I,1,2)),1:$P(PV1SEG,HLFS,+I))
41 . I I=40!(I=401) N DIV S DIV=$S($D(NODE):$P(NODE,U,11),1:"")
42 . I I=45 S XMTFLG=$S($P(PV1SEG,HLFS,3)="I":1,1:0)
43 . D:$D(SD(I)) VALIDATE^SCMSVUT0(SEG,DATA,$P($T(@(I)),";",3),VALERR,.CNT)
44 . Q
45 ;if inpatient perform validation for NPCD closeout on encounter date
46 I $P(PV1SEG,HLFS,3)="I" D
47 .S XMTFLG=0
48 .D VALIDATE^SCMSVUT0(SEG,ENCNDT,"4200",VALERR,.CNT)
49 ;
50ENQ Q $S($D(@VALERR@(SEG)):MSG,1:1)
51 ;
52 ;
53 ;
54ERR ;;Invalid or missing patient visit data for encounter (HL7 PV1 segment)
55 ;
56 ;
57 ;- PV1 data elements validated
58 ;
591 ;;0035;HL7 SEGMENT NAME
603 ;;4000;PATIENT CLASS
615 ;;4050;PURPOSE OF VISIT/APPT TYPE
62510 ;;Z000;Invalid Appointment Type (Computer Generated)
6315 ;;4070;LOCATION OF VISIT
6440 ;;4150;FACILITY NUMBER/SUFFIX
65401 ;;4160;INACTIVE FACILITY
6645 ;;4200;VISIT (ENCOUNTER) DATE/TIME
6751 ;;4100;UNIQUE IDENTIFIER (PCE)
Note: See TracBrowser for help on using the repository browser.