1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.commons.ihe.hl7v2ws.pcd01;
17
18 import ca.uhn.hl7v2.HL7Exception;
19 import ca.uhn.hl7v2.model.v26.message.ORU_R01;
20 import org.junit.Ignore;
21 import org.junit.Test;
22
23 import static org.junit.Assert.assertEquals;
24
25
26
27
28
29 @Ignore
30 public class QA_Pcd01OBXValidatorTest extends AbstractPCD01ValidatorTest {
31
32 @Test
33 public void testSyntheticMessageTrimmed() throws HL7Exception{
34 ORU_R01 adapter = (ORU_R01)getParser().parse(maximumMessage.toString().trim());
35 validate(adapter);
36 assertObservationCount(5, adapter);
37 }
38
39
40
41 @Test(expected = HL7Exception.class)
42 public void testMissingOBX1() throws HL7Exception {
43 validate(maxMsgReplace("OBX|1|NM|528391", "OBX||NM|528391"));
44 }
45
46 @Test(expected = HL7Exception.class)
47 public void testWrongSetIDForOBX1() throws HL7Exception {
48 validate(maxMsgReplace("OBX|2||150020", "OBX|1||150020"));
49 }
50
51 @Test(expected = HL7Exception.class)
52 public void testMissingOBX2_filledOBX5() throws HL7Exception {
53 validate(maxMsgReplace("OBX|1|NM|528391", "OBX|1||528391"));
54 }
55
56 @Test
57 public void testOBX2_SN() throws HL7Exception {
58 validate(maxMsgReplace("OBX|1|NM|528391^MDC_DEV_SPEC_PROFILE_BP^MDC|1|80|", "OBX|1|SN|528391^MDC_DEV_SPEC_PROFILE_BP^MDC|1|>80|"));
59 }
60
61
62 @Ignore
63 @Test(expected = HL7Exception.class)
64 public void testMissingOBX2_filledOBX11() throws HL7Exception {
65
66
67 validate(maxMsgReplace("OBX|1|NM|528391^MDC_DEV_SPEC_PROFILE_BP^MDC|1|80|", "OBX|1||528391^MDC_DEV_SPEC_PROFILE_BP^MDC|1||"));
68 }
69
70 @Test(expected = HL7Exception.class)
71 public void testMissingOBX3() throws HL7Exception {
72 validate(maxMsgReplace("OBX|1|NM|528391^MDC_DEV_SPEC_PROFILE_BP^MDC|1|80|", "OBX|1|NM||1||"));
73 }
74
75 @Test(expected = HL7Exception.class)
76 public void testSpaceAsOBX3() throws HL7Exception {
77 validate(maxMsgReplace("OBX|1|NM|528391^MDC_DEV_SPEC_PROFILE_BP^MDC|1|80|", "OBX|1|NM| |1||"));
78 }
79
80
81 @Test(expected = HL7Exception.class)
82 public void testMissingOBX3_2() throws HL7Exception {
83 validate(maxMsgReplace("OBX|1|NM|528391^MDC_DEV_SPEC_PROFILE_BP^MDC|1|", "OBX|1|NM|528391^^MDC|1|"));
84 }
85
86 @Test(expected = HL7Exception.class)
87 public void testSpaceAsOBX3_2() throws HL7Exception {
88 validate(maxMsgReplace("OBX|1|NM|528391^MDC_DEV_SPEC_PROFILE_BP^MDC|1|", "OBX|1|NM|528391^ ^MDC|1|"));
89 }
90
91 @Test(expected = HL7Exception.class)
92 public void testMissingOBX4() throws HL7Exception {
93 validate(maxMsgReplace("OBX|1|NM|528391^MDC_DEV_SPEC_PROFILE_BP^MDC|1|80|", "OBX|1|NM|528391^MDC_DEV_SPEC_PROFILE_BP^MDC|||"));
94 }
95
96 @Test(expected = HL7Exception.class)
97 public void testSpaceAsOBX4() throws HL7Exception {
98 validate(maxMsgReplace("OBX|1|NM|528391^MDC_DEV_SPEC_PROFILE_BP^MDC|1|80|", "OBX|1|NM|528391^MDC_DEV_SPEC_PROFILE_BP^MDC| ||"));
99 }
100
101 @Test(expected = HL7Exception.class)
102 @Ignore
103 public void testSameValueIn2OBX3AndOBX4Fields() throws HL7Exception {
104
105 validate(maxMsgReplace("OBX|4|NM|1500212^MDC_PRESS_BLD_NONINV_SYS^MDC|1.0.1.2|", "OBX|4|NM|1500212^MDC_PRESS_BLD_NONINV_SYS^MDC|1.0.1.1|"));
106 }
107
108 @Test
109 public void testMissingOBX5() throws HL7Exception {
110 validate(maxMsgReplace("|80|mmHg|", "||mmHg|"));
111 }
112
113 @Test
114 public void testMissingOBX5_OBX6() throws HL7Exception {
115 validate(maxMsgReplace("|80|mmHg|", "|||"));
116 }
117
118 @Test
119 public void testMissingOBX7() throws HL7Exception {
120 validate(maxMsgReplace("|75 - 90|TEST|||R|", "||TEST|||R|"));
121 }
122
123 @Test
124 public void testMissingOBX8() throws HL7Exception {
125 validate(maxMsgReplace("|75 - 90|TEST|||R|", "|75 - 90||||R|"));
126 }
127
128 @Test(expected = HL7Exception.class)
129 @Ignore
130 public void testMissingOBX6_filledOBX5() throws HL7Exception {
131
132
133 validate( maxMsgReplace("|80|mmHg|", "|80||"));
134 }
135
136 @Test(expected = HL7Exception.class)
137 public void testMissingOBX11() throws HL7Exception {
138 validate(maxMsgReplace("|75 - 90|TEST|||R|||", "|75 - 90|TEST||||||"));
139 }
140
141 @Ignore
142 @Test(expected = HL7Exception.class)
143 public void testMissingOBR7_OBR8_OBX14() throws HL7Exception {
144 ORU_R01 msg = (ORU_R01)getParser().parse(maximumMessage.toString().replace("|20090813095715+0500|20090813105715+0500", "||"));
145 msg = (ORU_R01)getParser().parse(msg.toString().replace("|R|||20090813095725+0500|", "|R||||"));
146 validate(msg);
147 }
148
149 @Test(expected = HL7Exception.class)
150 @Ignore
151 public void testEquivalenceOfOBX14AndOBX19() throws HL7Exception {
152
153 validate(maxMsgReplace("|0123456789ABCDEF^EUI-64|20090813095725+0500||", "|0123456789ABCDEF^EUI-64|20100813095725+0500||"));
154 }
155
156
157
158 private void assertObservationCount(int expected, ORU_R01 msg){
159 int observationsInMsg = msg.getPATIENT_RESULT().getORDER_OBSERVATION().getOBSERVATIONReps();
160 assertEquals(expected, observationsInMsg);
161 }
162
163 }