diff --git a/src/main/java/org/immregistries/iis/kernal/model/PatientMaster.java b/src/main/java/org/immregistries/iis/kernal/model/PatientMaster.java index 04b65d3a..8d785aa7 100644 --- a/src/main/java/org/immregistries/iis/kernal/model/PatientMaster.java +++ b/src/main/java/org/immregistries/iis/kernal/model/PatientMaster.java @@ -417,17 +417,21 @@ public PatientName getLegalName() { return patientNames.stream().filter(patientName -> "L".equals(patientName.getNameType())).findFirst().orElse(null); } + public PatientName getLegalNameOrFirst() { + return patientNames.stream().filter(patientName -> "L".equals(patientName.getNameType())).findFirst().orElse(this.getPatientNameFirst()); + } + public String getNameLast() { - return this.getPatientNameFirst().getNameLast(); + return this.getLegalNameOrFirst().getNameLast(); } public String getNameFirst() { - return this.getPatientNameFirst().getNameFirst(); + return this.getLegalNameOrFirst().getNameFirst(); } public String getNameMiddle() { - return this.getPatientNameFirst().getNameMiddle(); + return this.getLegalNameOrFirst().getNameMiddle(); } }