def _create_pid_segment(fhir_resource: dict) -> Segment: pid = Segment("PID") pid.PID_1 = str(1) for id_ in fhir_resource.get("identifier"): id_value = id_.get("value", "") id_type = id_.get("type", {}) if any([id_value, id_type]): pid_3 = pid.add_field("PID_3") pid_3.PID_3_1 = id_value pid_3.PID_3_4 = id_.get("system", "") if id_type_coding := id_type.get("coding"): pid_3.PID_3_5 = id_type_coding[0].get("code", "") if assigner := id_.get("assigner"): pid_3.PID_3_9 = assigner.get("display", "")