smart-on-fhir / client-py

Python SMART on FHIR client
http://docs.smarthealthit.org
Other
596 stars 213 forks source link

Superfluous entry in questionnaries #78

Closed jdanion closed 5 years ago

jdanion commented 5 years ago

Hello,

I'm trying to use fhir python class to manage questionnaires.

The idea is to make automated papers forms to enhance physicians reporting and with OMR and OCR to populate fhir ressources.

Questionnaire HAS to be able to manage multiple choice and free entries = list with exception

I tried with https://lhcformbuilder.nlm.nih.gov/ , to start with already approved questionnaire (ex : Major Procedures (Diagnostic, Surgical, and Therapeutic Interventions) [52466-0] )

Then i export as json and used this code : import json import fhirclient.models as m

with open('./form.json', 'r') as h: qjs = json.load(h) ques = m.questionnaire.Questionnaire(qjs) items = ques.item[0]`

that gives me :

FHIRValidationError Traceback (most recent call last)

in 7 print(qjs) 8 ----> 9 ques = m.questionnaire.Questionnaire(qjs) 10 11 print(len(ques.item)) /anaconda3/lib/python3.7/site-packages/fhirclient/models/questionnaire.py in __init__(self, jsondict, strict) 111 Type `str`. """ 112 --> 113 super(Questionnaire, self).__init__(jsondict=jsondict, strict=strict) 114 115 def elementProperties(self): /anaconda3/lib/python3.7/site-packages/fhirclient/models/domainresource.py in __init__(self, jsondict, strict) 40 Type `Narrative` (represented as `dict` in JSON). """ 41 ---> 42 super(DomainResource, self).__init__(jsondict=jsondict, strict=strict) 43 44 def elementProperties(self): /anaconda3/lib/python3.7/site-packages/fhirclient/models/resource.py in __init__(self, jsondict, strict) 40 Type `Meta` (represented as `dict` in JSON). """ 41 ---> 42 super(Resource, self).__init__(jsondict=jsondict, strict=strict) 43 44 def elementProperties(self): /anaconda3/lib/python3.7/site-packages/fhirclient/models/fhirabstractresource.py in __init__(self, jsondict, strict) 23 .format(self.__class__, jsondict['resourceType'])) 24 ---> 25 super(FHIRAbstractResource, self).__init__(jsondict=jsondict, strict=strict) 26 27 @classmethod /anaconda3/lib/python3.7/site-packages/fhirclient/models/fhirabstractbase.py in __init__(self, jsondict, strict) 64 if jsondict is not None: 65 if strict: ---> 66 self.update_with_json(jsondict) 67 else: 68 try: /anaconda3/lib/python3.7/site-packages/fhirclient/models/fhirabstractbase.py in update_with_json(self, jsondict) 229 230 if len(errs) > 0: --> 231 raise FHIRValidationError(errs) 232 233 def as_json(self): FHIRValidationError: {root}: item.3: item.0: Superfluous entry "answerOption" in data for When trying with basic string items questions, it works perfectly. Has someone any clue to handle this ?
jdanion commented 5 years ago

Ok juste a wrong version ...

pip install fhirclient still provides 3.2version

answerOption requires 4.0, which is solve when installing from git sources