| 
      
      
      From: Russell B. <ru...@wi...> - 2023-06-13 20:44:22
      
     | 
| In the code below, I have an incoming Patient which has all the fields 
that interest me filled in (see debugger image, but if it doesn't come 
through, it shows that patient is filled out for name, gender, birthdate 
and address).
However, when I attempt to inspect *gender* and *birthdate*, these are 
*null* despite the API telling me they exist (which, of course, they 
do--see attached image). Note that I create a new Patient, named worthy, 
and experimentation demonstrates that my code below copies the name and 
the address successfully to worthy. It's just trying to copy gender and 
birthdate that result in null. If I stop at the lines with *******, 
patient.getGender() and patient.getBirthDate() return null.
There must be some very fundamental bit of understanding of which I'm 
completely ignorant.
   {
     worthy = new Patient();
     // name
     if( !patient.hasName() )
       patientTooThin( "name" );
     HumanName          humanName = patient.getNameFirstRep();
     List< StringType > givens    = humanName.getGiven();
     String             family    = humanName.getFamily();
     String             first = null, middle = null;
     for( StringType given : givens )
     {
       if( isNull( first ) )
         first = given.toString();
       else if( isNull( middle ) )
         middle = given.toString();
       else
         break;
     }
     if( isNull( family ) || isNull( first ) )
       patientTooThin( "first or last name" );
     worthy.setName( Collections.singletonList( humanName ) );
     // gender  *************
     if( !patient.hasGender() )
       patientTooThin( "gender" );
     worthy.setGender( patient.getGender() );   // ***************
     // birthDate
     if( !patient.hasBirthDate() )
       patientTooThin( "birth date" );
     worthy.setBirthDate( patient.getBirthDate() );  // ***************
     // address
     if( !patient.hasAddress() )
       patientTooThin( "address" );
     worthy.setAddress( Collections.singletonList( 
patient.getAddressFirstRep() ) );
   }
 |