updateHumanNamePrefix method

Practitioner updateHumanNamePrefix(
  1. List<String> prefix, [
  2. int index = 0
])

Implementation

Practitioner updateHumanNamePrefix(List<String> prefix, [int index = 0]) {
  if (name == null || name!.isEmpty) {
    return copyWith(name: <HumanName>[HumanName(prefix: prefix)]);
  } else if (index >= name!.length) {
    return copyWith(name: <HumanName>[...name!, HumanName(prefix: prefix)]);
  } else {
    return copyWith(name: <HumanName>[
      ...name!.sublist(0, index),
      name![index].copyWith(prefix: prefix),
      ...name!.sublist(index + 1)
    ]);
  }
}