View Javadoc
1   /*
2    * Copyright 2009 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.transform.hl7.pid;
17  
18  import static org.junit.Assert.*;
19  
20  import org.junit.Test;
21  import org.openehealth.ipf.commons.ihe.xds.core.metadata.PatientInfo;
22  
23  import java.util.ListIterator;
24  
25  /**
26   * Tests for administrative gender code transformation in SourcePatientInfo.
27   * @author Jens Riemschneider
28   */
29  public class GenderPIDTransformerTest {
30  
31      @Test
32      public void testToHL7() {
33          PatientInfo patientInfo = new PatientInfo();        
34          patientInfo.setGender("M");
35          ListIterator<String> iterator = patientInfo.getHl7FieldIterator("PID-8");
36          assertEquals("M", iterator.next());
37          assertFalse(iterator.hasNext());
38      }
39      
40      @Test
41      public void testToHL7Null() {
42          PatientInfo patientInfo = new PatientInfo();
43          ListIterator<String> iterator = patientInfo.getHl7FieldIterator("PID-8");
44          assertFalse(iterator.hasNext());
45          assertNull(patientInfo.getGender());
46      }
47      
48      
49      @Test
50      public void testFromHL7() {
51          PatientInfo patientInfo = new PatientInfo();
52          patientInfo.getHl7FieldIterator("PID-8").add("F");
53          assertEquals("F", patientInfo.getGender());
54      }
55      
56      @Test
57      public void testFromHL7Null() {
58          PatientInfo patientInfo = new PatientInfo();
59          patientInfo.getHl7FieldIterator("PID-8").add(null);
60          assertNull(patientInfo.getGender());
61      }
62      
63      @Test
64      public void testFromHL7Empty() {
65          PatientInfo patientInfo = new PatientInfo();
66          patientInfo.getHl7FieldIterator("PID-8").add("");
67          assertNull(patientInfo.getGender());
68      }    
69  }