-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple_dea.js
90 lines (80 loc) · 1.88 KB
/
simple_dea.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
'use strict';
var simple_dea = (function()
{
function random(min, max)
{
return Math.floor(Math.random() * (max - min + 1)) + min;
}
var formats = {
expiration_date: function()
{
var date = new Date()
,year = date.getFullYear()
,month = random(1, 12)
,day = random(1,31)
;
return year + '-' + month + '-' + day;
}
,dea_number: function()
{
var characters = 'abcdefghijklmnopqrstuvwxyz0123456789'.split('')
,max_index = characters.length - 1
,total_output_characters = 11
,output = ''
;
while(output.length < total_output_characters)
{
output += characters[random(0,max_index)];
}
return output.toUpperCase();
}
};
jsf.format(formats);
var api = {
get_data: function(callback)
{
var schema = {
type: 'array'
,minItems: 30
,maxItems: 50
,items: {
type: 'object'
,properties: {
name: {
type: 'string'
,faker: 'name.findName'
}
,expiration_date: {
type: 'string'
,format: 'expiration_date'
}
,dea_number: {
type: 'string'
,format: 'dea_number'
}
,npi: {
type: 'integer'
,minimum: 100
,maximum: 999
}
,provider_id: {
type: 'integer'
,minimum: 100000
,maximum: 999999
}
}
,required: [
'name'
,'expiration_date'
,'dea_number'
,'npi'
,'provider_id'
]
}
};
var data = jsf(schema);
callback(data);
}
};
return api;
})();