Since I don’t know the exact data type of your stored data, I can’t provide a precise solution. However, there is an open-source tool that can read various data formats and transform FHIR resources into different flat structures (such as CSV, relational database tables, or JSON arrays). It allows you to define mappings and work with different file types effortlessly. I believe this tool can be highly beneficial in transforming your data into FHIR-compliant data.
Disclaimer: I am the lead developer of this tool.