1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
27
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 }