View Javadoc
1   /*
2    * Copyright 2013 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.xds.core.validate;
17  
18  import ca.uhn.hl7v2.model.v25.datatype.CWE;
19  import ca.uhn.hl7v2.model.v25.datatype.HD;
20  
21  import static org.apache.commons.lang3.StringUtils.isEmpty;
22  
23  /**
24   * @author Dmytro Rud
25   */
26  public class HL7ValidationUtils {
27  
28      public static boolean isEmptyField(HD hd) {
29          return isEmpty(hd.getHd1_NamespaceID().getValue()) &&
30                 isEmpty(hd.getHd2_UniversalID().getValue()) &&
31                 isEmpty(hd.getHd3_UniversalIDType().getValue());
32      }
33  
34      public static boolean isNotEmptyField(HD hd) {
35          return !isEmptyField(hd);
36      }
37  
38      public static boolean isEmptyField(CWE cwe) {
39          return isEmpty(cwe.getCwe1_Identifier().getValue()) &&
40                 isEmpty(cwe.getCwe2_Text().getValue()) &&
41                 isEmpty(cwe.getCwe3_NameOfCodingSystem().getValue()) &&
42                 isEmpty(cwe.getCwe4_AlternateIdentifier().getValue()) &&
43                 isEmpty(cwe.getCwe5_AlternateText().getValue()) &&
44                 isEmpty(cwe.getCwe6_NameOfAlternateCodingSystem().getValue()) &&
45                 isEmpty(cwe.getCwe7_CodingSystemVersionID().getValue()) &&
46                 isEmpty(cwe.getCwe8_AlternateCodingSystemVersionID().getValue()) &&
47                 isEmpty(cwe.getCwe9_OriginalText().getValue());
48      }
49  
50  }