A package for generating fake table data for the MIE database.
npm install mie-data-faker
This repository is dedicated to distribution and maintenance of the mie-data-faker npm package
MIE-DataFaker is a program designed to generate fake table data. For example, it can genereate a fake appointment and insert it into the appointments table as well as inserting the related fields into the multi_resources_apt table.
The backbone of this project is the npm package @faker-js/faker.
1. Patients
2. Appointments
3. Documents
4. Encounters
5. Translate
``sh`
npm install mie-data-faker
#### Option 1: Download the raw files manually from this repository
config.js
.env.example
#### Option 2: Copy them from node_modulesnode_modules/mie-data-faker/config-templates
The npm package has config templates in
Example - Creating Fake Patients
file is not needed.
1. Create a new directory and install this package
`sh
mkdir example
cd example
npm install mie-data-faker
`
2. Add config.js to your projects root directory
3. Edit
config.js 3a. Set
numberOfRecords to 10 3b. Set
table to patients
config.js
`javascript
const config = {// General Settings
// number of records to generate
numberOfRecords: 10,
// which object type to generate
table: 'patients',
...
}
`
4. Create a file called
main.js
5. Add your imports
main.js
`javascript
import { createPatients, dataInsert} from "mie-data-faker";
import fs from 'fs';
import config from './config.js';
`
6. Generate some patients
main.js
`javascript
const table = config.table;
const rowsToInsert = config.numberOfRecords;const obj = {patients: []};
// Wrap loop and logic in async function to ensure all patients are built prior to writing to JSON
(async () => {
for (let i = 0; i < rowsToInsert; i++) {
const patient = JSON.stringify(createPatients());
obj.patients.push(JSON.parse(patient));
};
})().then(() => {
console.log('Done');
writeToJSON(table, JSON.stringify(obj));
}).catch((err) => {
console.error(err);
});
function writeToJSON(table, obj) {
const filePath =
${table}-results.json; fs.writeFile(filePath, obj, function (err) {
if (err) throw err;
console.log('Saved!');
});
}
`
7. View your results JSON
patients-results.json
``javascript