Created
August 11, 2025 22:12
-
-
Save ppazos/64d4fffac81726f32885ca37a43762ba to your computer and use it in GitHub Desktop.
Read all the names and extensions from given and family names from a patient resource instance in HAPI FHIR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Patient fhirPatient = ... | |
for (HumanName name : fhirPatient.getName()) | |
{ | |
// family names with extensions | |
StringType familyElement = name.getFamilyElement(); | |
if (familyElement != null) { | |
System.out.println("Family: " + familyElement.getValue()); | |
for (Extension ext : familyElement.getExtension()) { | |
System.out.println(" Family Extension: " + ext.getUrl() + " = " + ext.getValue()); | |
} | |
} | |
// Given names with extensions | |
for (StringType givenElement : name.getGiven()) { | |
System.out.println("Given: " + givenElement.getValue()); | |
for (Extension ext : givenElement.getExtension()) { | |
System.out.println(" Given Extension: " + ext.getUrl() + " = " + ext.getValue()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment