source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SCMSVPR1.m@ 1259

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

initial load of WorldVistAEHR

File size: 4.5 KB
Line 
1SCMSVPR1 ;ALB/ESD HL7 PR1 Segment Validation ;06/24/99
2 ;;5.3;Scheduling;**44,66,142,180**;Aug 13, 1993
3 ;06/24/99 ACS - Added CPT modifier to the validation process
4 ;
5EN(PR1ARRY,HLQ,HLFS,HLECH,VALERR,ENCDT) ;
6 ; Entry point to return the HL7 PR1 (Procedure) validation segment
7 ;
8 ; Input: PR1ARRY - Array of PR1 Segments
9 ; HLQ - HL7 null variable
10 ; HLFS - HL7 field separator
11 ; HLECH - HL7 encoding characters
12 ; VALERR - Array to put errors in
13 ; ENCDT - Date of encounter
14 ;
15 ; Output: 1 if PR1 passed validity check
16 ; Error message if PR1 failed validity check in form of:
17 ; -1^"xxx failed validity check" (xxx=element in PR1 segment)
18 ;
19 ; NOTE: This validity check will pass if at least ONE PR1 segment in
20 ; the PR1 array passes the validity checks.
21 ;
22 N I,J,MSG,OUT,PR1SEG,PR1ASEG,PRTYPE,VALID,X,CNT,SCSETID,SEG,OLD
23 S X="",(I,OUT)=0,MSG="-1^Element in PR1 segment failed validity check",(SCSETID,CNT)=1,SEG="PR1"
24 S PR1ARRY=$G(PR1ARRY)
25 S:(PR1ARRY="") PR1ARRY="^TMP(""VAFHL"",$J,""PROCEDURE"")"
26 F S I=+$O(@PR1ARRY@(I)) Q:'I D
27 . S VALID(I)=1
28 . S J="",J=$O(@PR1ARRY@(I,J)) Q:J=""
29 . ;S PR1SEG=$G(@PR1ARRY@(I,J))
30 . ;-----------------------------------------------------------
31 . ; After the merge, PR1SEG looks like this:
32 . ; PR1SEG=PR1^n^...^cpt^...
33 . ; PR1SEG(1)=|mod~desc~meth|mod~desc~meth|...
34 . ; PR1SEG(2)=|mod~desc~meth|mod~desc~meth|...
35 . ;-----------------------------------------------------------
36 . M PR1SEG=@PR1ARRY@(I,J)
37 . S OLD=CNT
38 . D VALIDATE^SCMSVUT0(SEG,PR1SEG,"0009",VALERR,.CNT)
39 . I $G(@VALERR@(SEG,OLD))="0009" Q
40 . S PR1SEG=$$CONVERT^SCMSVUT0(PR1SEG,HLFS,HLQ)
41 . ;
42 . ;- Validate procedure fields
43 . ;D PROCVAL(PR1SEG)
44 . D PROCVAL(.PR1SEG)
45 . Q
46 ;
47 I '$D(VALID) D VALIDATE^SCMSVUT0(SEG,"","0009",VALERR,.CNT)
48ENQ Q $S($D(@VALERR@(SEG)):MSG,1:1)
49 ;
50PROCVAL(PR1SEG) ; -Validate procedure fields
51 ;
52 ;N Z,DATA,CMPSEP
53 N Z,DATA,CMPSEP,REPSEP
54 S CMPSEP=$E(HLECH,1)
55 S REPSEP=$E(HLECH,2)
56 F Z="0101","0201","0401","0403" D
57 . S DATA=$P(PR1SEG,HLFS,+$E(Z,1,2))
58 . S DATA=$P(DATA,CMPSEP,+$E(Z,3,4))
59 . D VALIDATE^SCMSVUT0(SEG,DATA,$P($T(@(Z)),";",3),VALERR,.CNT)
60 ;
61 ;--------------------------------------------------------------
62 ; VALIDATE PROCEDURE MODIFIER FIELDS
63 ;
64 ; The modifier, cpt+modifier, and modifier coding method are
65 ; validated
66 ;
67 ; MODDATA = mod seq, piece 17: mod~desc~code meth|mod~desc~...
68 ; CTR = continuation segment counter
69 ; PROC = CPT procedure code
70 ;--------------------------------------------------------------
71 ;
72 ;- validate modifier components in the first PR1 array seg
73 N MODDATA,PROC
74 S PROC=$P($P(PR1SEG,HLFS,4),CMPSEP,1)
75 S MODDATA=$P(PR1SEG,HLFS,17)
76 Q:'MODDATA
77 D SETUP(MODDATA,PROC)
78 ;
79 ;- validate modifier components in the PR1 continuation segments
80 N CTR,MODDATA
81 S CTR=1,MODDATA=""
82 F S MODDATA=$E($G(PR1SEG(CTR)),2,245) Q:'MODDATA D
83 . D SETUP(MODDATA,PROC)
84 . S CTR=CTR+1
85 . Q
86 Q
87 ;
88SETUP(MODDATA,PROC) ;
89 ;
90 ;---------------------------------------------------------------
91 ; SET UP AND VALIDATE MODIFIER COMPONENTS
92 ;
93 ; INPUT: MODDATA = modifier components
94 ; format: mod~desc~meth|mod~desc~meth|...
95 ; PROC = CPT procedure
96 ;
97 ; OTHER:
98 ; REPSEP = repetition separator ("|")
99 ; SEG = PR1
100 ; CNT = 1
101 ; VALERR = error message array
102 ; MCOMPNUM = modifier component number to validate
103 ; REPCTR = modifier repetition counter
104 ; MODDATA1 = each repetition of modifier info
105 ; format: mod~desc~meth
106 ; DATA = modifier data to validate (i.e. mod or meth)
107 ;---------------------------------------------------------------
108 ;
109 N MCOMPNUM,REPCTR,MODDATA1,DATA
110 S REPCTR=1
111 ; add repetition separator to end of input data
112 S MODDATA=MODDATA_REPSEP
113 ;
114 ; validate the modifier and coding method for each repetition
115 F S MODDATA1=$P(MODDATA,REPSEP,REPCTR) Q:'MODDATA1 D
116 . F Z="1701","1703" D
117 .. S MCOMPNUM=$E(Z,3,4)
118 .. S DATA=$P(MODDATA1,"~",MCOMPNUM)
119 .. ;
120 .. ;- pass procedure AND modifier if validating modifier
121 .. S:MCOMPNUM="01" DATA=PROC_"~"_DATA
122 .. D VALIDATE^SCMSVUT0(SEG,DATA,$P($T(@(Z)),";",3),VALERR,.CNT)
123 .. Q
124 . S REPCTR=REPCTR+1
125 . Q
126 Q
127 ;
128 ;
129 ;
130 ;- PR1 data elements validated
131 ;
132 ;
1330101 ;;0035;HL7 SEGMENT NAME
1340201 ;;6250;HL7 SEQUENTIAL NUMBER (SET ID)
1350401 ;;6050;PROCEDURE CODE (CPT)
1360403 ;;6000;PROCEDURE CODING METHOD
1371701 ;;6300;PROCEDURE MODIFIER AND PROC+MOD COMBINATION
1381703 ;;6370;PROCEDURE MODIFIER CODING METHOD
Note: See TracBrowser for help on using the repository browser.