Skip to content

Instantly share code, notes, and snippets.

@AGhost-7
Last active March 28, 2016 21:46
Show Gist options
  • Select an option

  • Save AGhost-7/3b06d3e59b472fc8857b to your computer and use it in GitHub Desktop.

Select an option

Save AGhost-7/3b06d3e59b472fc8857b to your computer and use it in GitHub Desktop.
Create Micro-Dsl
var vm = require('vm');
var fs = require('fs');
var _ = require('lodash');
var path = require('path');
// Define a few globals to reuse...
var predef = {
string: {
type: 'string',
index: 'not_analyzed',
fields: {
_search: {
type: 'string',
analyzer: 'case_insensitive_keyword'
}
}
},
picklist: {
type: 'string',
index: 'not_analyzed',
fields: {
_search: {
type: 'string',
analyzer: 'case_insensitive_keyword'
}
}
},
bool: {
type: 'boolean'
},
date: true,
number: true
};
var results = fs
.readdirSync(__dirname)
.map(function(file) {
var exports = {};
var ctx = _.assign({
module: {
exports: exports
},
exports: exports,
}, _.cloneDeep(predef));
if(file !== 'index.js') {
var code = fs.readFileSync(path.join(__dirname, file)).toString();
vm.runInNewContext(code, ctx);
return ctx.module.exports;
}
})
.reduce(function (accu, mod) {
if(mod === undefined) return accu;
return accu.concat(mod);
}, []);
console.log(JSON.stringify(results, null, 2));
module.exports = {
name: 'case',
base: 'sys',
indexedAttributes: {
areaOfResponsibility: picklist,
caseCategory: picklist,
caseSubCategory: picklist,
patientLastName: string,
patientFirstName: string,
bookingOrCaseNumber: string,
nysid: string,
dateOfBirth: date,
assignedFacility: picklist,
assignedFacilityOther: string,
assignedHousingArea: picklist,
facilityOfClaim: picklist,
facilityOfClaimOther: string,
dateOfRequest: date,
meansOfNotice: picklist,
sourceComplaintChs: picklist,
sourceComplaintOther: string,
sourceLastName: string,
sourceFirstName: string,
addressOfSource: string,
releaseSigned: bool,
sourceOfRequest: picklist,
sourceOfRequestOther: string,
userId: picklist,
recipientNameOther: string,
incidentInitiallyReportedBy: picklist,
incidentInitiallyReportedByOther: string,
dateOfIncident: date,
timeOfIncident: true,
tourOfIncident: picklist,
dateReportedOperations: string,
timeReportedOperations: true,
locationOfIncident: picklist,
locationIncidentOther: string,
facilityOfIncident: picklist,
locationIncidentFacility: string,
hospitalOfIncident: picklist,
courtPenIncident: picklist,
useForce: string,
withTouching: string,
incidentOccurredCustody: bool,
writtenConsent: string,
patientUnder18: bool,
nysHotline: bool,
localSocialServiceNotified: bool,
localSocialServiceSubmitted: bool,
tourCommanderName: string,
tourCommanderShield: string,
dateTourCommander: date,
timeTourCommander: true,
listPartiesNotifiedReport: picklist,
patientDescriptionIncident: string,
patientSeenMedical: bool,
urgentCareNotified: bool,
patientSeenUrgentCare: bool,
medicalForensicExamination: string,
patientReferredHospital: string,
sexualAdvocateInformationGivenPatient: bool,
initiallyReportedBy: string
}
};
[
{
"name": "case",
"base": "sys",
"indexedAttributes": {
"areaOfResponsibility": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"caseCategory": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"caseSubCategory": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"patientLastName": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"patientFirstName": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"bookingOrCaseNumber": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"nysid": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"dateOfBirth": true,
"assignedFacility": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"assignedFacilityOther": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"assignedHousingArea": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"facilityOfClaim": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"facilityOfClaimOther": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"dateOfRequest": true,
"meansOfNotice": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"sourceComplaintChs": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"sourceComplaintOther": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"sourceLastName": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"sourceFirstName": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"addressOfSource": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"releaseSigned": {
"type": "boolean"
},
"sourceOfRequest": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"sourceOfRequestOther": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"userId": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"recipientNameOther": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"incidentInitiallyReportedBy": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"incidentInitiallyReportedByOther": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"dateOfIncident": true,
"timeOfIncident": true,
"tourOfIncident": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"dateReportedOperations": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"timeReportedOperations": true,
"locationOfIncident": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"locationIncidentOther": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"facilityOfIncident": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"locationIncidentFacility": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"hospitalOfIncident": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"courtPenIncident": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"useForce": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"withTouching": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"incidentOccurredCustody": {
"type": "boolean"
},
"writtenConsent": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"patientUnder18": {
"type": "boolean"
},
"nysHotline": {
"type": "boolean"
},
"localSocialServiceNotified": {
"type": "boolean"
},
"localSocialServiceSubmitted": {
"type": "boolean"
},
"tourCommanderName": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"tourCommanderShield": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"dateTourCommander": true,
"timeTourCommander": true,
"listPartiesNotifiedReport": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"patientDescriptionIncident": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"patientSeenMedical": {
"type": "boolean"
},
"urgentCareNotified": {
"type": "boolean"
},
"patientSeenUrgentCare": {
"type": "boolean"
},
"medicalForensicExamination": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"patientReferredHospital": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
},
"sexualAdvocateInformationGivenPatient": {
"type": "boolean"
},
"initiallyReportedBy": {
"type": "string",
"index": "not_analyzed",
"fields": {
"_search": {
"type": "string",
"analyzer": "case_insensitive_keyword"
}
}
}
}
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment