Skip to content

Commit

Permalink
snake case for street_lines fixes #76 #110
Browse files Browse the repository at this point in the history
  • Loading branch information
kachok committed Aug 12, 2014
1 parent 279f3ec commit 3938ed0
Show file tree
Hide file tree
Showing 24 changed files with 182 additions and 182 deletions.
6 changes: 3 additions & 3 deletions lib/generator/ccda/lib/templating_functions.js
Expand Up @@ -144,8 +144,8 @@ var addr = function (xmlDoc, addr, birthplace) {
.attr({use: acronymize(addr[0]["use"])});
}

if (!birthplace && addr[0]["streetLines"] !== undefined) {
xmlDoc = xmlDoc.node('streetAddressLine', addr[0]["streetLines"][0]).parent()
if (!birthplace && addr[0]["street_lines"] !== undefined) {
xmlDoc = xmlDoc.node('streetAddressLine', addr[0]["street_lines"][0]).parent()
}
xmlDoc = xmlDoc.node('city', addr[0]["city"]).parent()
.node('state', addr[0]["state"]).parent()
Expand All @@ -155,7 +155,7 @@ var addr = function (xmlDoc, addr, birthplace) {
} else {
xmlDoc = xmlDoc.node('addr');
if (!birthplace) {
xmlDoc = xmlDoc.node('streetAddressLine', addr["streetLines"][0]).parent()
xmlDoc = xmlDoc.node('streetAddressLine', addr["street_lines"][0]).parent()
}
xmlDoc = xmlDoc.node('city', addr["city"]).parent()
.node('state', addr["state"]).parent()
Expand Down
2 changes: 1 addition & 1 deletion lib/parser/ccda/shared.js
Expand Up @@ -150,7 +150,7 @@ var IndividualName = exports.IndividualName = Component.define('IndividualName')

var Address = exports.Address = Component.define("Address")
.fields([
["streetLines", "1..4", "h:streetAddressLine/text()"],
["street_lines", "1..4", "h:streetAddressLine/text()"],
["city", "1..1", "h:city/text()", Processor.asString],
["state", "0..1", "h:state/text()"],
["zip", "0..1", "h:postalCode/text()"],
Expand Down
6 changes: 3 additions & 3 deletions lib/parser/cms/cmsSpecificSchema.js
Expand Up @@ -8,7 +8,7 @@ ccda */
var schema = {
"insurance": {
"addresses": [{
"streetLines": [
"street_lines": [
"string"
],
"city": "string",
Expand Down Expand Up @@ -170,7 +170,7 @@ var schema = {
"provider": {
"name": "string",
"address": {
"streetLines": [
"street_lines": [
"string"
],
"city": "string",
Expand All @@ -185,7 +185,7 @@ var schema = {
}],
"organization": {
"address": {
"streetLines": [
"street_lines": [
"string"
],
"city": "string",
Expand Down
12 changes: 6 additions & 6 deletions lib/parser/cms/sections/commonFunctions.js
Expand Up @@ -32,7 +32,7 @@ var commonFunctions = function commonFunctions() {
function cda_line_address(addressString) {
var addressObj = {
"use": "primary",
"streetLines": [],
"street_lines": [],
"city": "",
"state": "",
"zip": "",
Expand Down Expand Up @@ -72,7 +72,7 @@ function cda_line_address(addressString) {
foundCityMatch = foundCityMatch.substring(0, foundCityMatch.length - 1);
if (foundCityIndex >= 1) {
var addressLine = addressString.substring(0, foundCityIndex - 1).trim();
addressObj.streetLines.push(addressLine);
addressObj.street_lines.push(addressLine);
/*TODO: foundCIty, which is the city name obtained from looking up the
zip code table, needs to do something like an longest common substring match
in case there isn't a 1 to 1 match between the city names of the raw string
Expand All @@ -95,7 +95,7 @@ function cda_line_address(addressString) {
var cityBegIndex = addressString.indexOf(foundWord);
var cityEndIndex = cityBegIndex + foundWord.length;
var addressLine = addressString.substring(0, cityEndIndex).trim();
addressObj.streetLines.push(addressLine);
addressObj.street_lines.push(addressLine);

//These might not always be the last and second to last, what if there's just state code? need to make changes forthat later.
addressObj.zip = tempArr[tempArr.length - 1].trim();
Expand All @@ -117,7 +117,7 @@ function cda_line_address(addressString) {
var cityBegIndex = addressString.indexOf(foundWord);
var cityEndIndex = cityBegIndex + foundWord.length;
var addressLine = addressString.substring(cityBegIndex, cityEndIndex).trim();
addressObj.streetLines.push(addressLine);
addressObj.street_lines.push(addressLine);

//These might not always be the last and second to last
addressObj.zip = tempArr[tempArr.length - 1].trim();
Expand Down Expand Up @@ -236,7 +236,7 @@ function cda_line_address(addressString) {
stateAndZip = stateAndZip.split(' ');
var state = stateAndZip[0];
var zip = stateAndZip[1];
addressObj.streetLines.push(street);
addressObj.street_lines.push(street);
addressObj.city = city;
addressObj.state = state;
addressObj.zip = zip;
Expand All @@ -245,7 +245,7 @@ function cda_line_address(addressString) {
}
/*ie. 1111 Address Dr, Hoosville, VA 11111*/
else if (addressArray.length === 3) {
addressObj.streetLines[0] = addressArray[0].trim();
addressObj.street_lines[0] = addressArray[0].trim();
addressObj.city = addressArray[1].trim();
var stateAndZip = addressArray[2].trim().split(' ');
addressObj.state = stateAndZip[0];
Expand Down
6 changes: 3 additions & 3 deletions lib/parser/cms/sections/demographics.js
Expand Up @@ -11,7 +11,7 @@ function parseDemographics(intObj) {

var addressObj = {
"use": "primary",
"streetLines": [],
"street_lines": [],
"city": "",
"state": "",
"zip": "",
Expand All @@ -20,8 +20,8 @@ function parseDemographics(intObj) {

var addressKeys = {
'address type': 'use',
'address line 1': 'streetLines',
'address line 2': 'streetLines',
'address line 1': 'street_lines',
'address line 2': 'street_lines',
'city': 'city',
'state': 'state',
'zip': 'zip'
Expand Down
4 changes: 2 additions & 2 deletions lib/validator/schemas/shared.json
Expand Up @@ -14,7 +14,7 @@
"state": {
"type": "string"
},
"streetLines": {
"street_lines": {
"type": "array",
"items": {
"type": "string"
Expand All @@ -29,7 +29,7 @@
}
},
"required": [
"streetLines",
"street_lines",
"city"
]
},
Expand Down
32 changes: 16 additions & 16 deletions test/ccda-sections/test-demographics.js
Expand Up @@ -147,11 +147,11 @@ describe('Demographics - Schema Conformance', function () {

for (var iaddr in demographics.addresses) {
var currentAddress = demographics.addresses[iaddr];
assert.isArray(currentAddress.streetLines, 'street should be array');
assert.ok(currentAddress.streetLines.length < 4, 'max four street lines');
for (var iline in currentAddress.streetLines) {
assert.isString(currentAddress.streetLines[iline], 'street lines should be string');
assert.ok(currentAddress.streetLines[iline].length > 0, 'street lines should have content');
assert.isArray(currentAddress.street_lines, 'street should be array');
assert.ok(currentAddress.street_lines.length < 4, 'max four street lines');
for (var iline in currentAddress.street_lines) {
assert.isString(currentAddress.street_lines[iline], 'street lines should be string');
assert.ok(currentAddress.street_lines[iline].length > 0, 'street lines should have content');
}
assert.isString(currentAddress.city, 'city should be string');
assert.ok(currentAddress.city.length > 0, 'city should have content');
Expand Down Expand Up @@ -229,12 +229,12 @@ describe('Demographics - Schema Conformance', function () {

if (demographics.birthplace) {
var birthPlace = demographics.birthplace;
if (birthPlace.streetLines) {
assert.isArray(birthPlace.streetLines, 'street should be array');
assert.ok(birthPlace.streetLines.length < 4, 'max four street lines');
for (var iline in birthPlace.streetLines) {
assert.isString(birthPlace.streetLines[iline], 'street lines should be string');
assert.ok(birthPlace.streetLines[iline].length > 0, 'street lines should have content');
if (birthPlace.street_lines) {
assert.isArray(birthPlace.street_lines, 'street should be array');
assert.ok(birthPlace.street_lines.length < 4, 'max four street lines');
for (var iline in birthPlace.street_lines) {
assert.isString(birthPlace.street_lines[iline], 'street lines should be string');
assert.ok(birthPlace.street_lines[iline].length > 0, 'street lines should have content');
}

}
Expand Down Expand Up @@ -276,11 +276,11 @@ describe('Demographics - Schema Conformance', function () {

for (var iguardaddr in currentGuardian.addresses) {
var currentAddress = currentGuardian.addresses[iguardaddr];
assert.isArray(currentAddress.streetLines, 'street should be array');
assert.ok(currentAddress.streetLines.length < 4, 'max four street lines');
for (var iline in currentAddress.streetLines) {
assert.isString(currentAddress.streetLines[iline], 'street lines should be string');
assert.ok(currentAddress.streetLines[iline].length > 0, 'street lines should have content');
assert.isArray(currentAddress.street_lines, 'street should be array');
assert.ok(currentAddress.street_lines.length < 4, 'max four street lines');
for (var iline in currentAddress.street_lines) {
assert.isString(currentAddress.street_lines[iline], 'street lines should be string');
assert.ok(currentAddress.street_lines[iline].length > 0, 'street lines should have content');
}
assert.isString(currentAddress.city, 'city should be string');
assert.ok(currentAddress.city.length > 0, 'city should have content');
Expand Down
10 changes: 5 additions & 5 deletions test/ccda-sections/test-immunizations.js
Expand Up @@ -256,11 +256,11 @@ describe('Immunizations - Schema Conformance', function () {
if (currentImmunization.performer.address) {
for (var iaddr in currentImmunization.performer.address) {
var currentAddress = currentImmunization.performer.address[iaddr];
assert.isArray(currentAddress.streetLines, 'street should be array');
assert.ok(currentAddress.streetLines.length < 4, 'max four street lines');
for (var iline in currentAddress.streetLines) {
assert.isString(currentAddress.streetLines[iline], 'street lines should be string');
assert.ok(currentAddress.streetLines[iline].length > 0, 'street lines should have content');
assert.isArray(currentAddress.street_lines, 'street should be array');
assert.ok(currentAddress.street_lines.length < 4, 'max four street lines');
for (var iline in currentAddress.street_lines) {
assert.isString(currentAddress.street_lines[iline], 'street lines should be string');
assert.ok(currentAddress.street_lines[iline].length > 0, 'street lines should have content');
}
assert.isString(currentAddress.city, 'city should be string');
assert.ok(currentAddress.city.length > 0, 'city should have content');
Expand Down
18 changes: 9 additions & 9 deletions test/fixtures/cms/bbModel.json
Expand Up @@ -26,7 +26,7 @@
"addresses": [
{
"use": "primary",
"streetLines": [
"street_lines": [
"123 ANY ROAD"
],
"city": "ANYTOWN",
Expand Down Expand Up @@ -270,7 +270,7 @@
"addresses": [
{
"use": "primary",
"streetLines": [
"street_lines": [
"123 Any Road"
],
"city": "Anytown",
Expand Down Expand Up @@ -299,7 +299,7 @@
"addresses": [
{
"use": "primary",
"streetLines": [
"street_lines": [
"123 Any Road"
],
"city": "Anytown",
Expand Down Expand Up @@ -350,7 +350,7 @@
"addresses": [
{
"use": "primary",
"streetLines": [
"street_lines": [
"PO BOX 0000"
],
"city": "Anytown",
Expand Down Expand Up @@ -379,7 +379,7 @@
"addresses": [
{
"use": "primary",
"streetLines": [
"street_lines": [
"0000 Any ROAD"
],
"city": "ANYWHERE",
Expand All @@ -405,7 +405,7 @@
"addresses": [
{
"use": "primary",
"streetLines": [
"street_lines": [
"00 Address STREET"
],
"city": "ANYWHERE",
Expand Down Expand Up @@ -898,7 +898,7 @@
"name": "ANY CARE",
"address": {
"use": "primary",
"streetLines": [
"street_lines": [
"123 Any Rd"
],
"city": "Anywhere",
Expand All @@ -915,7 +915,7 @@
"name": "ANY HOSPITAL1",
"address": {
"use": "primary",
"streetLines": [
"street_lines": [
"123 Drive"
],
"city": "Anywhere",
Expand All @@ -931,7 +931,7 @@
"type": "person",
"address": {
"use": "primary",
"streetLines": [
"street_lines": [
"123 Road"
],
"city": "Anywhere",
Expand Down
10 changes: 5 additions & 5 deletions test/fixtures/file-snippets/generatedJSON/CCD_1_payers.json
Expand Up @@ -28,7 +28,7 @@
],
"address": [
{
"streetLines": [
"street_lines": [
"123 Insurance Road"
],
"city": "Blue Bell",
Expand All @@ -51,7 +51,7 @@
],
"address": [
{
"streetLines": [
"street_lines": [
"123 Insurance Road"
],
"city": "Blue Bell",
Expand Down Expand Up @@ -94,7 +94,7 @@
],
"address": [
{
"streetLines": [
"street_lines": [
"17 Daws Rd."
],
"city": "Blue Bell",
Expand Down Expand Up @@ -127,7 +127,7 @@
],
"address": [
{
"streetLines": [
"street_lines": [
"17 Daws Rd."
],
"city": "Blue Bell",
Expand Down Expand Up @@ -159,7 +159,7 @@
],
"address": [
{
"streetLines": [
"street_lines": [
"17 Daws Rd."
],
"city": "Blue Bell",
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/file-snippets/json/CCD_1_Demographics.json
Expand Up @@ -26,7 +26,7 @@
"marital_status": "Married",
"addresses": [
{
"streetLines": [
"street_lines": [
"1357 Amber Drive"
],
"city": "Beaverton",
Expand Down Expand Up @@ -63,7 +63,7 @@
"relation": "Parent",
"addresses": [
{
"streetLines": [
"street_lines": [
"1357 Amber Drive"
],
"city": "Beaverton",
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/file-snippets/json/CCD_1_Encounters.json
Expand Up @@ -24,7 +24,7 @@
"code_system_name": "HealthcareServiceLocation"
},
"addresses": [{
"streetLines": [
"street_lines": [
"17 Daws Rd."
],
"city": "Blue Bell",
Expand Down

0 comments on commit 3938ed0

Please sign in to comment.