mie-data-faker
v2.2.5
Published
A package for generating fake table data for the MIE database.
Downloads
24
Readme
Table of Contents
About
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.
Tables Currently Supported
- Patients
- Appointments
- Documents
- Encounters
- Translate
Getting Started
Install the npm
package
npm install mie-data-faker
Add configuration and environment files
Option 1: Download the raw files manually from this repository
Option 2: Copy them from node_modules
The npm package has config templates in node_modules/mie-data-faker/config-templates
Example - Creating Fake Patients
Setup Steps
NOTE: This demonstration will not write to DB, so the .env
file is not needed.
- Create a new directory and install this package
mkdir example
cd example
npm install mie-data-faker
- Add config.js to your projects root directory
Edit
config.js
3a. Set
numberOfRecords
to10
3b. Set
table
topatients
config.js
const config = {
// General Settings
// number of records to generate
numberOfRecords: 10,
// which object type to generate
table: 'patients',
...
}
- Create a file called
main.js
- Add your imports
main.js
import { createPatients, dataInsert} from "mie-data-faker";
import fs from 'fs';
import config from './config.js';
- Generate some patients
main.js
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!');
});
}
- View your results JSON
patients-results.json
{
"patients": [{
"first_name": "Raymond",
"last_name": "King",
"middle_name": "Shaun",
"title": "",
"suffix": "PhD",
"address1": "296 Ankunding Center",
"county": "Bedfordshire",
"city": "Claircester",
"state": "HI",
"zip_code": "00366",
"home_phone": "298-579-9040 x559",
"work_phone": "1-896-456-6938 x20650",
"cell_phone": "1-875-711-4110",
"fax_number": "349-209-1644 x80718",
"alternate_phone": "441-240-4577",
"email": "[email protected]",
"sex": "M",
"ssn": 852839207,
"marital_status": "D",
"spouse_name": "",
"spouse_birthdate": "0000-00-00 00:00:00",
"emergency_contact": "",
"emergency_phone": "(366) 659-0520 x453",
"employment_status": "E",
"employer_name": "Hermiston, McKenzie and King",
"employer_addr1": "3292 Rogahn Forges",
"employer_county": "Cambridgeshire",
"employer_city": "North Yesenia",
"employer_state": "MD",
"employer_zipcode": "91315",
"employer_country": "US",
"interface": "MIE DataFaker",
"birth_date": "1960-08-20 11:52",
"death_indicator": 1,
"death_date": "1978-06-12 13:42",
"active": 0,
"is_patient": 1,
"create_date": "2023-03-17 12:45"
}, {
"first_name": "Ginger",
"last_name": "Torphy",
"middle_name": "Jessica",
...
}
}