Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: SCMSVPV1

SCMSVPV1.m

Go to the documentation of this file.
  1. SCMSVPV1 ;ALB/ESD HL7 PV1 Segment Validation ; 23 Oct 98 3:45 PM
  1. ;;5.3;Scheduling;**44,55,91,66,162,387**;Aug 13, 1993
  1. ;
  1. ;
  1. EN(PV1SEG,HLQ,HLFS,VALERR,NODE,EVNTHL7,ENCNDT) ;
  1. ; Entry point to return the HL7 PV1 (Patient Visit) validation segment
  1. ;
  1. ; Input: PV1SEG - PV1 Segment
  1. ; HLQ - HL7 null variable
  1. ; HLFS - HL7 field separator
  1. ; VALERR - The array to put errors in
  1. ; EVNTHL7 - Event type ("A08" for add/edit, "A23" for delete)
  1. ; ENCNDT - Encounter date
  1. ;
  1. ; Output: 1 if PV1 passed validity check
  1. ; Error message if PV1 failed validity check in form of:
  1. ; -1^"xxx failed validity check" (xxx=element in PV1 segment)
  1. ;
  1. ;NOTE:
  1. ;this routine uses the variable NODE which would contain the zero node
  1. ;of the encounter. It is looking for the division in the 11th piece.
  1. ;this is for the check on the facility.
  1. ;
  1. N I,MSG,X,CNT,DATA,SEG,SD,XMTFLG
  1. ;
  1. ;-Create array of elements to validate
  1. F I=1,3,5,510,15,40,401,45,51 S SD(I)="" ;Elements for 'add' or 'edit' transactions
  1. I $G(EVNTHL7)="A23" K SD F I=40,45,51 S SD(I)="" ;Elements for 'delete' transactions
  1. ;
  1. S MSG="-1^Element in PV1 segment failed validity check",CNT=1
  1. S PV1SEG=$G(PV1SEG),SEG="PV1"
  1. D VALIDATE^SCMSVUT0(SEG,PV1SEG,"0008",VALERR,.CNT)
  1. I $D(@VALERR@(SEG)) G ENQ
  1. ;
  1. ;- Convert HLQ to null
  1. S PV1SEG=$$CONVERT^SCMSVUT0(PV1SEG,HLFS,HLQ)
  1. ;
  1. ;- Validate data elements
  1. F I=1,3,5,510,15,40,401,45,51 D
  1. . 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))
  1. . I I=40!(I=401) N DIV S DIV=$S($D(NODE):$P(NODE,U,11),1:"")
  1. . I I=45 S XMTFLG=$S($P(PV1SEG,HLFS,3)="I":1,1:0)
  1. . D:$D(SD(I)) VALIDATE^SCMSVUT0(SEG,DATA,$P($T(@(I)),";",3),VALERR,.CNT)
  1. . Q
  1. ;if inpatient perform validation for NPCD closeout on encounter date
  1. I $P(PV1SEG,HLFS,3)="I" D
  1. .S XMTFLG=0
  1. .D VALIDATE^SCMSVUT0(SEG,ENCNDT,"4200",VALERR,.CNT)
  1. ;
  1. ENQ Q $S($D(@VALERR@(SEG)):MSG,1:1)
  1. ;
  1. ;
  1. ;
  1. ERR ;;Invalid or missing patient visit data for encounter (HL7 PV1 segment)
  1. ;
  1. ;
  1. ;- PV1 data elements validated
  1. ;
  1. 1 ;;0035;HL7 SEGMENT NAME
  1. 3 ;;4000;PATIENT CLASS
  1. 5 ;;4050;PURPOSE OF VISIT/APPT TYPE
  1. 510 ;;Z000;Invalid Appointment Type (Computer Generated)
  1. 15 ;;4070;LOCATION OF VISIT
  1. 40 ;;4150;FACILITY NUMBER/SUFFIX
  1. 401 ;;4160;INACTIVE FACILITY
  1. 45 ;;4200;VISIT (ENCOUNTER) DATE/TIME
  1. 51 ;;4100;UNIQUE IDENTIFIER (PCE)