Skip to content

Commit

Permalink
insurances added
Browse files Browse the repository at this point in the history
  • Loading branch information
byshiny committed Jun 27, 2014
1 parent 7d4d42a commit 9886cc1
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 37 deletions.
3 changes: 2 additions & 1 deletion lib/parser/cms/cmsObjConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ var bbDocumentModel = {
"immunizations": [],
"socialHistory": [],
"problems": [],
"procedures": []
"procedures": [],
"insurance": []
},
"meta": {
"type" : "cms",
Expand Down
74 changes: 43 additions & 31 deletions lib/parser/cms/sections/commonFunctions.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,55 @@
//these are common models that must be hardcoded...
//might want to modify later so that HERE it also takes in custom default values.


var sections = {
'cda_name': cda_name,
'cda_concept': cda_concept,
'cda_id': cda_id,
'cda_coded_entry': cda_coded_entry
};
var special = {
var functions = {
'cda_name': cda_name,
'cda_concept': cda_concept,
'cda_id': cda_id,
'cda_date': cda_date,
'cda_coded_entry': cda_coded_entry,
'cda_phone': cda_phone,
'cda_email': cda_email
'cda_email': cda_email,
'cda_line_address': cda_line_address,
};





//later on, this functions might become MUCH more complicated, because
//cities are not necessarily one word entries
function cda_line_address(addressString) {
var addressObj = {
"use": "primary",
"streetLines": [],
"city": "",
"state": "",
"zip": "",
"country": "United States"};
var addressArray = addressString.trim().split(',');
if(addressArray.length == 2){
var streetAndCity = addressArray[0].trim();
var stateAndZip = addressArray[1].trim();

var street = streetAndCity.substring(0, streetAndCity.lastIndexOf(' '));
var city = streetAndCity.substring(streetAndCity.lastIndexOf(' ')+1, streetAndCity.length);

stateAndZip = stateAndZip.split(' ');
var state = stateAndZip[0];
var zip = stateAndZip[1];
addressObj.streetLines.push(street);
addressObj.city = city;
addressObj.state = state;
addressObj.zip = zip;
return addressObj;
}
return null;


}



function cda_phone(numberString, type) {
var phoneObj = {};
phoneObj.number = numberString;
Expand Down Expand Up @@ -166,34 +197,15 @@ function writeValue(value, obj, key){
obj[key] = value;
}



//gets a common model function if it's defined in the section
var getCommonModelFunction = function(commonModelName, type) {

//sectionName = keyMap[sectionName];
if (commonModelName in sections && arguments[1] === undefined) {
if (sections[commonModelName] !== null) {
return sections[commonModelName];
}
} else if (type == 'special') {
return special[commonModelName];
} else {
return null;
}
};

var getFunction = function(commonModelName) {
if (commonModelName in special) {
if (special[commonModelName] !== null) {
return special[commonModelName];
if (commonModelName in functions) {
if (functions[commonModelName] !== null) {
return functions[commonModelName];
}
}
return null;
};

module.exports.getCommonModelFunction = getCommonModelFunction;
module.exports.sections = sections;
module.exports.writeValue = writeValue;
module.exports.getFunction = getFunction;
module.exports.getValueType = getValueType;
14 changes: 9 additions & 5 deletions lib/parser/cms/sections/insurance.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ var commonFunctions = require('./commonFunctions');
function parseInsurance(intObj, sectionType) {
var result = [];
var resultChild;
console.log('section type ' + sectionType);
for(var x in intObj){
var child = intObj[x];
console.log(child);
Expand Down Expand Up @@ -107,7 +106,6 @@ function processEmployerChild(childObj){
returnChildObj.name = value;
}
else if(key.indexOf('date') >= 0){
//console.log(key);
var processDate = commonFunctions.getFunction('cda_date');
var dateObj = processDate(value);
dateArray.push(dateObj);
Expand Down Expand Up @@ -135,9 +133,10 @@ function processInsuranceChild(childObj){
var emailArray = [];
var phoneArray = [];
var typeArray = [];
var addressArray = [];
for(var key in childObj){
var key = key.toLowerCase();
var value = childObj[key].toLowerCase();
var value = childObj[key];
if(key.indexOf('msp type') >= 0 && value.length > 0){
returnChildObj.type = 'medicare msp:' + value;
}
Expand All @@ -150,10 +149,12 @@ function processInsuranceChild(childObj){
else if(key.indexOf('insurer name') >= 0){
returnChildObj.payer_name = value;
}
else if(key.indexOf('insurer address') >= 9){
else if(key.indexOf('insurer address') >= 0){
//needs to be updated to an address object
//try to split by state name first.
returnChildObj.address = value;
var processLineAddr = commonFunctions.getFunction('cda_line_address');
var addressObj = processLineAddr(value);
addressArray.push(addressObj);
}
else if(key.indexOf('date') >= 0){
var processDate = commonFunctions.getFunction('cda_date');
Expand All @@ -175,6 +176,9 @@ function processInsuranceChild(childObj){
if(dateArray.length > 0){
returnChildObj.date = dateArray;
}
if(addressArray.length > 0){
returnChildObj.addresses = addressArray;
}
return returnChildObj;
}

Expand Down
117 changes: 117 additions & 0 deletions test/fixtures/cms/bbModel.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,123 @@
}
]
}
],
"insurance": [
{
"plan_id": "H9999/9999",
"name": "HealthCare Payer",
"type": [
"medicare",
"A Medicare Plan Plus (HMO)",
"3 - Coordinated Care Plan (HMO, PPO, PSO, SNP)"
]
},
{
"plan_id": "S9999/000",
"name": "Another HealthCare Payer",
"type": [
"medicare",
"A Medicare Rx Plan (PDP)",
"11 - Medicare Prescription Drug Plan"
]
},
{
"name": "STATE HEALTH BENEFITS PROGRAM",
"type": [
"employer subsidy"
],
"date": [
{
"date": "2011-01-01T00:00:00.000Z",
"precision": "day"
},
{
"date": "2011-12-31T00:00:00.000Z",
"precision": "day"
}
]
},
{
"type": "medicare msp:End stage Renal Disease (ESRD)",
"policy_number": "1234567890",
"payer_name": "Insurer1",
"date": [
{
"date": "2011-01-01T00:00:00.000Z",
"precision": "day"
},
{
"date": "2011-09-30T00:00:00.000Z",
"precision": "day"
}
],
"addresses": [
{
"use": "primary",
"streetLines": [
"PO BOX 0000"
],
"city": "Anytown",
"state": "CO",
"zip": "00002-0000",
"country": "United States"
}
]
},
{
"type": "medicare msp:End stage Renal Disease (ESRD)",
"policy_number": "12345678901",
"payer_name": "Insurer2",
"date": [
{
"date": "2010-01-01T00:00:00.000Z",
"precision": "day"
},
{
"date": "2010-12-31T00:00:00.000Z",
"precision": "day"
}
],
"addresses": [
{
"use": "primary",
"streetLines": [
"0000 Any ROAD"
],
"city": "ANYWHERE",
"state": "VA",
"zip": "00000-0000",
"country": "United States"
}
]
},
{
"type": "medicare msp",
"policy_number": "00001",
"payer_name": "Insurer",
"date": [
{
"date": "1984-10-01T00:00:00.000Z",
"precision": "day"
},
{
"date": "2008-11-30T00:00:00.000Z",
"precision": "day"
}
],
"addresses": [
{
"use": "primary",
"streetLines": [
"00 Address STREET"
],
"city": "ANYWHERE",
"state": "PA",
"zip": "00000",
"country": "United States"
}
]
}
]
},
"meta": {
Expand Down
1 change: 1 addition & 0 deletions test/test-cms-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ describe.only('Test file parsing beginning to end', function () {
var outputFilename = __dirname+ '/fixtures/cms/bbModel.json';
var intObj = txtToIntObj.getIntObj(this.txtdata);
var bbModel = objConverter.convertToBBModel(intObj);
console.log(bbModel);

fs.writeFile(outputFilename, JSON.stringify(bbModel, null, 4), function(err) {
if(err) {
Expand Down

0 comments on commit 9886cc1

Please sign in to comment.