Commit a81df474 authored by rwm's avatar rwm

gender enum constants to lowercase, allow third gender 'indeterminate'

parent 5544c7c9
......@@ -32,7 +32,9 @@
<patient id="XX12345">
<given-name>A B</given-name>
<surname>Dampf</surname>
<gender>Female</gender>
<!-- Gender allows for female, male, indeterminate -->
<!-- Gender element can also be removed or left empty -->
<gender>female</gender>
<birthdate>2001-01-01</birthdate>
<deathdate>2020</deathdate>
<source timestamp="2015-09-28T09:41:10Z"/>
......
......@@ -52,6 +52,6 @@ public interface Patient extends IdExtensionType, ExternalSourceType{
void setGivenName(String givenName);
public enum Sex{
Female, Male
female, male, indeterminate
}
}
......@@ -268,11 +268,14 @@ public class FlatObservationSupplier extends AbstractObservationParser implement
Patient.Sex sex;
switch( Character.toUpperCase(record.getValue().charAt(0)) ){
case 'F':
case 'W':
sex = Sex.Female;
sex = Sex.female;
break;
case 'M':
sex = Sex.Male;
sex = Sex.male;
break;
case 'I':
case 'X':
sex = Sex.indeterminate;
break;
default:
sex = null;
......
......@@ -137,10 +137,14 @@ class XMLObservationParser extends AbstractObservationParser{
if( visitData.containsKey("sex") ){
switch( visitData.get("sex").charAt(0) ){
case 'F':
sex = Sex.Female;
sex = Sex.female;
break;
case 'M':
sex = Sex.Male;
sex = Sex.male;
break;
case 'I':
case 'X':
sex = Sex.indeterminate;
break;
default:
// warning
......
......@@ -83,7 +83,7 @@ public class FileObservationProviderTest {
Assert.assertEquals("XX12345", p.getId());
Assert.assertEquals(DateTimeAccuracy.parsePartialIso8601("2001-01-01"), p.getBirthDate());
Assert.assertEquals(DateTimeAccuracy.parsePartialIso8601("2020"), p.getDeathDate());
Assert.assertEquals(Sex.Female, p.getSex());
Assert.assertEquals(Sex.female, p.getSex());
Assert.assertEquals("A B", p.getGivenName());
Assert.assertEquals("Dampf", p.getSurname());
// TODO: test more patient information
......
......@@ -352,10 +352,12 @@ public class PostgresPatientStore extends PostgresExtension<I2b2Patient> impleme
private static String getSexCd(Patient patient){
if( patient.getSex() == null )return null;
else switch( patient.getSex() ){
case Female:
case female:
return "F";
case Male:
case male:
return "M";
case indeterminate:
return "X";
default:
// XXX should not happen, warning
return null;
......@@ -524,11 +526,16 @@ public class PostgresPatientStore extends PostgresExtension<I2b2Patient> impleme
if( sex_cd != null ){
switch( sex_cd.charAt(0) ){
case 'F':
sex = Sex.Female;
sex = Sex.female;
break;
case 'M':
sex = Sex.Male;
sex = Sex.male;
break;
case 'X':
sex = Sex.indeterminate;
break;
default:
sex_cd = null; // unknown
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment