Given a messy, nested JSON file of patient demographics, write a Python script to flatten the data and remove duplicates.