Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Validate Patient Data Entries
00:00
5 left

Validate Patient Data Entries

MediumPython

Problem

Can you write a function to validate patient data entries and handle invalid inputs? The function receives a list containing patient dictionaries or invalid values. A valid patient has a non-empty string patient_id, a non-empty string name, and an integer age from 0 through 120. Return a dictionary containing the valid entries and indexed validation errors for invalid entries.

Constraints

  • entries is a list with 0 to 10^4 elements.
  • Each element is either a dictionary or an arbitrary invalid value.
  • Valid dictionaries require patient_id, name, and age.
  • patient_id and name must be non-empty strings after trimming whitespace.
  • age must be an integer from 0 through 120, inclusive.
  • Additional dictionary fields do not affect validity.

Function Signature

def validate_patient_entries(entries):
Interviewer

Your question is Validate Patient Data Entries. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.