smart fhir client - resource schema validation mainly for writing purpose

279 views
Skip to first unread message

Vijay T

unread,
Feb 18, 2016, 1:35:55 PM2/18/16
to SMART on FHIR
Team,

I am trying to use smart-fhir javascript client(https://github.com/smart-on-fhir/client-js/blob/master/dist/fhir-client.js) to communicate to our existing fhir-service.

I am able to retrieve FHIR resource and I could also save or update the fhir resource with the help of below tutorial


My Question here is (its based on write example above),

When we try to do write operation (create new resource), we have to build the whole resource object explicitly with javascript object (eg: patient resource in json) and there is no way to validate the json structure unless the fhir service validate it and throw the exception. 

Unlike python library we don't have models for FHIR resources in javascript library, Is there any approach like creating a Patient resource from a schema or validating against it?

I know this is not a blocking issue or an use case, just trying to understand the best practice here, any suggestion will be great.

below code is example of a Patient resource, 
var resource = {
             "resourceType": "Patient",
             "id": "12345",
             "text": {
               "status": "generated",
               "div": "<div><p>Test Patient</p></div>"
             },
             "identifier": [
               {
                 "use": "usual",
                 "type": {
                   "coding": [
                     {
                       "system": "http://hl7.org/fhir/v2/0203",
                       "code": "MR",
                       "display": "Medical record number"
                     }
                   ],
                   "text": "Medical record number"
                 },
                 "system": "http://hospital.smarthealthit.org",
                 "value": "12345"
               }
             ],
             "active": false,
             "name": [
               {
                 "use": "official",
                 "family": [
                   "Patient"
                 ],
                 "given": [
                   "Test"
                 ]
               }
             ],
             "gender": "female",
             "birthDate": "2007-03-20",
           };


Thanks,
Vijay

Nikolai Schwertner

unread,
Feb 18, 2016, 3:40:51 PM2/18/16
to smart-...@googlegroups.com
Hi Vijay,

Unfortunately, the JS client cannot validate a FHIR resource. Take a look at https://www.hl7.org/fhir/validation.html for some of the options for validating your resource. Some FHIR servers may support the $validate operation as well (ours does not).

Best,
Nikolai


On 2/18/16 13:35, Vijay T wrote:
Team,

I am trying to use smart-fhir javascript client(https://github.com/smart-on-fhir/client-js/blob/master/dist/fhir-client.js) to communicate to our existing fhir-service.

I am able to retrieve FHIR resource and I could also save or update the fhir resource with the help of below tutorial


My Question here is (its based on write example above),

When we try to do write operation (create new resource), we have to build the whole resource object explicitly with javascript object (eg: patient resource in json) and there is no way to validate the json structure unless the fhir service validate it and throw the exception. 

Unlike python library we don't have models for FHIR resources in javascript library, Is there any approach like creating a Patient resource from a schema or validating against it?

I know this is not a blocking issue or an use case, just trying to understand the best practice here, any suggestion will be great.

below code is example of a Patient resource, 
var resource = {

             "resourceType": "Patient",

             "id": "12345",

             "text":< /span> {

               "status": "generated",

               "div" : "<div><p>Test Patient</p></div>"

             },

             "identifier": [

               {

                 "use": "usual",

                 "type": {

                   "coding": [

                     {

                       "system": "http://hl7.org/fhir/v2/0203",

                       "code": "MR",

                       "display": "Medical record number"

                     }

                   ],

                   "text": "Medical record number"

                 },

                 "system": "http://hospital.smarthealthit.org",

                 "value": "12345"

               }

             ],

             "active" : false,

             "name":< /span> [

               {

                 "use": "official",

                 "family": [

                   "Patient"

                 ],

                 "given": [

                   "Test"

                 ]

               }

             ],

             "gender" : "female",

             "birthDate": "2007-03-20",

           };


Thanks,
Vijay
--
You received this message because you are subscribed to the Google Groups "SMART on FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to smart-on-fhi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages