source: FOIAVistA/trunk/r/SCHEDULING-SD-SC/SCMSVROL.m@ 1712

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

initial load of FOIAVistA 6/30/08 version

File size: 3.6 KB
Line 
1SCMSVROL ;BP/JRP - HL7 ROL Segment Validation;6-MAR-1998
2 ;;5.3;Scheduling;**142,245**;Aug 13, 1993
3 ;
4 ;
5EN(ROLARRY,HLQ,HLFS,HLECH,VALERR) ;Entry point to validate all HL7 ROL
6 ; (Role) segments built for message
7 ;
8 ;Input : ROLARRY - Array of ROL Segments
9 ; HLQ - HL7 null designation
10 ; HLFS - HL7 field separator
11 ; HLECH - HL7 encouding characters
12 ; VALERR - Array to return error list in (full global reference)
13 ;
14 ;Output: 1 - All ROL segments passed validity checks
15 ; -1^Text - One/many/all ROL segments failed validity checks
16 ; List of errors returned as follows:
17 ; VALERR("ROL",x) = Error Code
18 ;Notes : Initialization of VALERR() is the reponsibility of the
19 ; calling program
20 ; : Existance/validity of input is assumed
21 ;
22 ;Declare variables
23 N LOOP1,CNT,MSG,PRIMECNT,TMP,SCMSVROL,PRIME
24 S MSG="-1^Element in ROL segment failed validity check"
25 S PRIMECNT=0
26 ;Loop through array of ROL segments
27 S LOOP1=0
28 F S LOOP1=+$O(@ROLARRY@(LOOP1)) Q:('LOOP1) D
29 .;Validate individual segment
30 .S TMP=$$EN1($NA(@ROLARRY@(LOOP1)),HLQ,HLFS,HLECH,VALERR,.PRIME)
31 .;Track total number of primary providers designated
32 .I PRIME S PRIMECNT=PRIMECNT+1
33 ;Make logic in D050 only allow the number 1
34 S SCMSVROL=1
35 ;Validate number of primary providers designated (must be 1)
36 S CNT=1+$O(@VALERR@("ROL",""),-1)
37 D VALIDATE^SCMSVUT0("ROL",PRIMECNT,"D050",VALERR,.CNT)
38ENQ Q $S($D(@VALERR@("ROL")):MSG,1:1)
39 ;
40EN1(ROLSEG,HLQ,HLFS,HLECH,VALERR,PRIME) ;Entry point to validate the HL7 ROL
41 ; (Role) segment
42 ;
43 ;Input : ROLSEG - Array containing ROL Segment (full global reference)
44 ; ROLSEG = First 245 characters
45 ; ROLSEG(x) = Continuation nodes
46 ; HLQ - HL7 null designation
47 ; HLFS - HL7 field separator
48 ; HLECH - HL7 encoding characters
49 ; VALERR - Array to return error list in (full global reference)
50 ; PRIME - Output variable (pass by reference)
51 ;
52 ;Output: 1 - ROL segment passed validity checks
53 ; -1^Text - ROL segment failed validity checks
54 ; List of errors returned as follows:
55 ; VALERR("ROL",x) = Error Code
56 ; PRIME = 1 if primary encounter provider
57 ; PRIME = 0 if not primary encounter provider
58 ;Notes : Initialization of VALERR() is the reponsibility of the
59 ; calling program
60 ; : Existance/validity of input is assumed
61 ;
62 ;Declare variables
63 N SEG,MSG,CNT,TMP,PARSEG,OLDCNT,CMPSEP,SCMSVROL,LOOP,CODE,CHECK
64 S MSG="-1^Element in ROL segment failed validity check"
65 S (OLDCNT,CNT)=1+$O(@VALERR@("ROL",""),-1)
66 S PRIME=0
67 ;Parse out fields
68 S TMP("FS")=HLFS,TMP("ECH")=HLECH,TMP("Q")=HLQ
69 D PARSEG^SCMSVUT4(ROLSEG,"PARSEG",.TMP,0,1)
70 I PARSEG(0)'="ROL" D VALIDATE^SCMSVUT0("ROL","","0370",VALERR,.CNT) G EN1Q
71 ;Remember component separator
72 S CMPSEP=$E(HLECH,1)
73 ;Primary care provider ?
74 S DATA=$G(PARSEG(3,1))
75 S:($P(DATA,CMPSEP,4)=1) PRIME=1
76 ;Make logic in D050 allow numbers 0 and 1
77 S SCMSVROL=0
78 ;Validate
79 S CODE=""
80 F LOOP=1:1 D Q:CODE=""
81 .S DATA=$T(ERRORS+LOOP)
82 .S CODE=$P(DATA,";",3)
83 .Q:(CODE="")
84 .S CHECK=$P(DATA,";",1)
85 .S DATA=$G(PARSEG(+$E(CHECK,1,2),+$E(CHECK,3,4)))
86 .S DATA=$P(DATA,CMPSEP,+$E(CHECK,5,6),+$E(CHECK,7,8))
87 .D VALIDATE^SCMSVUT0("ROL",DATA,CODE,VALERR,.CNT)
88EN1Q Q $S(CNT'=OLDCNT:MSG,1:1)
89 ;
90 ;Line tag format is SSRRBCEC
91 ; SS=sequence, RR=repetition
92 ; BC=begining component, EC=ending component
93ERRORS ;Data elements validated
9401010101 ;;D150;ROLE INSTANCE ID
9503010101 ;;D000;PROVIDER TYPE CODE
9603010404 ;;D050;PRIMARY ENCOUNTER PROVIDER DESIGNATION
9704010101 ;;D070;INVALID PROVIDER ID
9804010207 ;;D130;PROVIDER NAME
9904020101 ;;D140;PROVIDER SSN
100 ;;
101 ;;
Note: See TracBrowser for help on using the repository browser.