2.2.5 • Published 1 year ago

mie-data-faker v2.2.5

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

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

  1. Patients
  2. Appointments
  3. Documents
  4. Encounters
  5. 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

config.js

.env.example

Setup Steps

NOTE: This demonstration will not write to DB, so the .env file is not needed.

  1. Create a new directory and install this package
mkdir example
cd example
npm install mie-data-faker
  1. Add config.js to your projects root directory
  1. Edit config.js

    3a. Set numberOfRecords to 10

    3b. Set table to patients

config.js

const config = {

// General Settings

    // number of records to generate
    numberOfRecords: 10,

    // which object type to generate
    table: 'patients',

    ...

}
  1. Create a file called main.js

  2. Add your imports

main.js

import { createPatients, dataInsert} from "mie-data-faker";
import fs from 'fs';
import config from './config.js';
  1. 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!');

    });
}
  1. 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": "Wyatt.Feest@yahoo.com",
        "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",
        ...
    }
}
2.2.5

1 year ago

2.2.4

1 year ago

2.2.3

1 year ago

2.2.2

1 year ago

2.2.1

1 year ago

2.2.0

1 year ago

2.1.6

1 year ago

2.1.5

1 year ago

2.1.4

1 year ago

2.1.3

1 year ago

2.1.2

1 year ago

2.1.0

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago