lantanagroup / FHIR.js

Node.JS library for serializing/deserializing FHIR resources between JS/JSON and XML using various node.js XML libraries
Apache License 2.0
104 stars 29 forks source link

Dont add meta element if it already exists #37

Closed lschmierer closed 3 years ago

lschmierer commented 3 years ago

A type fix in my last PR made sure that ensurePropertyMetaData is called in the ParseConformance constructor. However, that revealed an issue that additional meta propterties are created for primitives that already have an associated _meta property. That resulted wrong properties with multiple leading underscores like __id, ___id etc.

This resolves this by filtering for leading underscores in ensurePropertyMetaData:

 const primitiveProperties = properties
                .filter(p => Constants.PrimitiveTypes.indexOf(p._type) >= 0)
                // Constants.PrimitiveTypes contains Element so an additional check for leading underscores is necessary
                .filter(p => !p._name.startsWith('_'));

Checking the property._type != 'Element' might work as well, but I think the underscore aproach is more robust.

seanmcilvenna commented 3 years ago

Please resolve the conflicts in this branch, and then I will merge...

lschmierer commented 3 years ago

I have resolved the merge conflicts

seanmcilvenna commented 3 years ago

Merged! Thanks! Are you needing me to push a patch update to NPM?

lschmierer commented 3 years ago

Patch update would be great! Thanks a lot!

seanmcilvenna commented 3 years ago

Done! Released on NPM as 4.8.1