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
102 stars 29 forks source link

Error: Cannot read property 'split' of undefined #53

Closed dsoegijono closed 2 years ago

dsoegijono commented 2 years ago

Sometimes I'm getting an exception when passing in invalid payload:

error: TypeError: Cannot read property 'split' of undefined
      at Validator.validateNext (/var/task/node_modules/fhir/validator.js:285:54)
      at Validator.validateProperties (/var/task/node_modules/fhir/validator.js:355:26)
      at Validator.validateNext (/var/task/node_modules/fhir/validator.js:268:36)
      at Validator.validateProperties (/var/task/node_modules/fhir/validator.js:347:34)
      at Validator.validateNext (/var/task/node_modules/fhir/validator.js:251:40)
      at Validator.validateProperties (/var/task/node_modules/fhir/validator.js:355:26)
      at Validator.validateNext (/var/task/node_modules/fhir/validator.js:303:18)
      at Validator.validateProperties (/var/task/node_modules/fhir/validator.js:347:34)
      at Validator.validate (/var/task/node_modules/fhir/validator.js:48:18)
      at Fhir.validate (/var/task/node_modules/fhir/fhir.js:42:26)

Is there a specific condition that causes this?

I'm using version 4.9.0

dsoegijono commented 2 years ago

It might be because of identifier assigner missing reference. I have a Patient resource that has identifier which validates fine:

"identifier": [
    {
        "type": {
            "text": "MR"
        },
        "value": "1000011131",
        "assigner": {
            "reference": "Organizeation/1",
            "type": "Organization",
            "display": "TEST"
        }
    }
]

If I remove the reference, it will throw the error mentioned above:

"identifier": [
    {
        "type": {
            "text": "MR"
        },
        "value": "1000011131",
        "assigner": {
            "type": "Organization",
            "display": "TEST"
        }
    }
]
seanmcilvenna commented 2 years ago

Fixed in commit https://github.com/lantanagroup/FHIR.js/commit/be1a74cab134cff959fb0dc723c470a3e5443343 Published to NPM as 4.10.3