View Javadoc
1   /*
2    * Copyright 2011 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *     
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.openehealth.ipf.commons.ihe.hl7v2ws.pcd01;
17  
18  import ca.uhn.hl7v2.HL7Exception;
19  import org.junit.Test;
20  
21  /**
22   * @author Kingsley Nwaigbo
23   * 
24   */
25  public class QA_Pcd01DataTypesTest extends AbstractPCD01ValidatorTest {
26  
27      // ################ Data types ###############################
28  
29      @Test
30      public void testCWE_AllFilled_MSH19() throws HL7Exception {
31          validate(maxMsgReplace("EN^English^ISO659",
32                                 "EN^English^ISO659^en-US^US English^ISO659^1.0^2.8^Some text"));
33      }
34  
35      @Test(expected = HL7Exception.class)
36      public void testMissingCWE2() throws HL7Exception {
37          validate(maxMsgReplace("EN^English^ISO659",
38                                 "EN^^ISO659^en-US^US English^ISO659^1.0^2.8^Some text"));
39      }
40  
41      @Test
42      public void testCX_AllFilled_PID3() throws HL7Exception {
43          validate(maxMsgReplace("111222333444^^^Imaginary Hospital&1.3.4.565&ISO^PI",
44                                 "111222333444^6430^M11^Imaginary Hospital&1.3.4.565&ISO^PI^AssigningFac&3.4.5.6&ISO^20090713^20090713^Ju01&test&test2^Ag01&test3&test4"));
45      }
46  
47      @Test(expected = HL7Exception.class)
48      public void testMissingCX1() throws HL7Exception {
49          validate(maxMsgReplace("111222333444^^^Imaginary Hospital&1.3.4.565&ISO^PI",
50                                 "^6430^M11^Imaginary Hospital&1.3.4.565&ISO^PI^AssigningFac&3.4.5.6&ISO^20090713^20090713^Ju01&test&test2^Ag01&test3&test4"));
51      }
52  
53      @Test(expected = HL7Exception.class)
54      public void testMissingCX4() throws HL7Exception {
55          validate(maxMsgReplace("111222333444^^^Imaginary Hospital&1.3.4.565&ISO^PI",
56                                 "111222333444^6430^M11^^PI^AssigningFac&3.4.5.6&ISO^20090713^20090713^Ju01&test&test2^Ag01&test3&test4"));
57      }
58  
59      @Test(expected = HL7Exception.class)
60      public void testMissingCX5() throws HL7Exception {
61          validate(maxMsgReplace("111222333444^^^Imaginary Hospital&1.3.4.565&ISO^PI",
62                                 "111222333444^6430^M11^Imaginary Hospital&1.3.4.565&ISO^^AssigningFac&3.4.5.6&ISO^20090713^20090713^Ju01&test&test2^Ag01&test3&test4"));
63      }
64  
65  
66      @Test(expected = HL7Exception.class)
67      public void testMissingEI1() throws HL7Exception {
68          validate(maxMsgReplace("IHE PCD ORU-R01 2006^HL7^1.3.6.1.4.1.19376.1.6.1.1.1^ISO",
69                                 "^HL7^2.16.840.1.113883.9.n.m^ISO"));
70      }
71  
72      @Test(expected = HL7Exception.class)
73      public void testMissingEI2_3_4() throws HL7Exception {
74          validate(maxMsgReplace("IHE PCD ORU-R01 2006^HL7^1.3.6.1.4.1.19376.1.6.1.1.1^ISO",
75                                 "IHE PCD ORU-R01 2006"));
76      }
77  
78      @Test
79      public void testMissingEI2() throws HL7Exception {
80          validate(maxMsgReplace("IHE PCD ORU-R01 2006^HL7^1.3.6.1.4.1.19376.1.6.1.1.1^ISO",
81                                 "IHE PCD ORU-R01 2006^^1.3.6.1.4.1.19376.1.6.1.1.1^ISO"));
82      }
83  
84      @Test(expected = HL7Exception.class)
85      public void testWrongISOFormatInEI3() throws HL7Exception {
86          validate(maxMsgReplace("IHE PCD ORU-R01 2006^HL7^1.3.6.1.4.1.19376.1.6.1.1.1^ISO",
87                                 "IHE PCD ORU-R01 2006^^2.16.840.1.113883.9.n.m^ISO"));
88      }
89  
90      @Test(expected = HL7Exception.class)
91      public void testWrongEUI64FormatInEI3() throws HL7Exception {
92          validate(maxMsgReplace("IHE PCD ORU-R01 2006^HL7^1.3.6.1.4.1.19376.1.6.1.1.1^ISO",
93                                 "IHE PCD ORU-R01 2006^^2.16.840.1.113883.9n-zzzz.ww.yy^EUI-64"));
94      }
95  
96      @Test
97      public void testHD_AllFilledEUI64_MSH3() throws HL7Exception {
98          validate(maxMsgReplace("AcmeInc^ACDE48234567ABCD^EUI-64",
99                                 "AcmeInc^ACDE48234567ABCD^EUI-64"));
100     }
101 
102 
103     @Test
104     public void testHD_AllFilledISO_MSH3() throws HL7Exception {
105         validate(maxMsgReplace("AcmeInc^ACDE48234567ABCD^EUI-64",
106                                "AcmeInc^1.2.3.4^ISO"));
107     }
108 
109     @Test
110     public void testXPN_AllFilled_PID5() throws HL7Exception {
111         validate(maxMsgReplace("|Doe^John^Joseph^^^^L^A|",
112                                "|Doe^John^Joseph^Snr^Dr.^^L^A^BN&Birthname^^G^20090713090030+0500^20090713090030+0500^Phd|"));
113     }
114 
115     @Test
116     public void testOnlyXPN1_7() throws HL7Exception {
117         validate(maxMsgReplace("|Doe^John^Joseph^^^^L^A|", "|Doe^^^^^^L|"));
118     }
119 
120     @Test(expected = HL7Exception.class)
121     public void testMissingXPN7() throws HL7Exception {
122         validate(maxMsgReplace("|Doe^John^Joseph^^^^L^A|", "|Doe|"));
123     }
124 
125     @Test
126     public void testXTN_AllFilledPID13_PRN() throws HL7Exception {
127         validate(maxMsgReplace("^PRN^PH^^^^123456",
128                                "^PRN^PH^wan@continua.com^001^760^123456^02^Any text^GA"));
129     }
130 
131     @Test
132     public void testXTN_AllFilledPID13_NET() throws HL7Exception {
133         validate(maxMsgReplace("^PRN^PH^^^^123456",
134                                "^NET^X.400^wan@continua.com^001^760^123456^02^Any text^GA"));
135     }
136 
137     @Test(expected = HL7Exception.class)
138     public void testMissingXTN2() throws HL7Exception {
139         validate(maxMsgReplace("^PRN^PH^^^^123456",
140                                "^^PH^wan@continua.com^001^760^123456^02^Any text^GA"));
141     }
142 
143     @Test(expected = HL7Exception.class)
144     public void testMissingXTN3() throws HL7Exception {
145         validate(maxMsgReplace("^PRN^PH^^^^123456",
146                                "^NET^^wan@continua.com^001^760^123456^02^Any text^GA"));
147     }
148 
149 }