class PatientInfoView (View): def __init__(self): self.client = IndivoClient(settings.INDIVO_SERVER_PARAMS, settings.INDIVO_CONSUMER_PARAMS, pha_email=settings.INDIVO_USER_EMAIL) def get(self, request, patient_id=None): ctx = RequestContext(request) user = MedintUser.objects.get(id=patient_id) record_id = user.user_info.patientinfo.indivo_record_id ctx['record'] = record_id result = {} for d in ['problem', 'allergy', 'AllergyExclusion', 'equipment', 'immunization', 'LabResult', 'measurement', 'medication', 'procedure', 'SimpleClinicalNote', 'VitalSigns', 'Encounter']: resp, content = self.client.generic_list(record_id=record_id, data_model=d) print '%s:' % d content = json.loads(content) if content: result[d] = content ctx['result'] = result return render_to_response('medint/patient_info.html', ctx) def post(self, request, patient_id=None): print request.FILES.getlist('file') # data = request.FILES['file'].read() user = MedintUser.objects.get(id=patient_id) record_id = user.user_info.patientinfo.indivo_record_id ctx = RequestContext(request) ctx['record'] = record_id for f in request.FILES.getlist('file'): data = f.read() resp, content = self.client.document_create(record_id=record_id, body=data, content_type='application/xml') # print resp # print content return self.get(request, patient_id)
def create_patient(self, username, **extra_fields): print settings.INDIVO_SERVER_PARAMS client = IndivoClient(settings.INDIVO_SERVER_PARAMS, settings.INDIVO_CONSUMER_PARAMS, pha_email=settings.INDIVO_USER_EMAIL) values = {'email': '', 'last_name': '', 'first_name': '', 'phone': '', 'city': '', 'zipcode': '', 'state': '', 'address': ''} values.update(extra_fields) demographics = ('<Demographics xmlns=\"http://indivo.org/vocab/xml/documents#\">' '<dateOfBirth><![CDATA[1965-06-22]]></dateOfBirth>' '<gender><![CDATA[male]]></gender>' '<email><![CDATA[%(email)s]]></email>' '<preferredLanguage>EN</preferredLanguage>' '<Name>' '<familyName><![CDATA[%(last_name)s]]></familyName>' '<givenName><![CDATA[%(first_name)s]]></givenName>' '</Name>' '<Telephone>' '<type>h</type><number><![CDATA[%(phone)s]]></number><preferred>true</preferred>' '</Telephone>' '<Address>' '<country><![CDATA[USA]]></country>' '<city><![CDATA[%(city)s]]></city>' '<postalCode><![CDATA[%(zipcode)s]]></postalCode>' '<region><![CDATA[%(state)s]]></region>' '<street><![CDATA[%(address)s]]></street>' '</Address>' '</Demographics>') % values res, content = client.record_create(body=demographics) if 200 != int(res['status']): raise Exception('Cannot create record in indivo') tree = ET.fromstring(content or '<Record/>') if tree is None: raise Exception('Cannot create user in indivo') record_id = tree.attrib.get('id') res, content = client.record_set_owner(record_id=record_id, body=settings.INDIVO_USER_EMAIL) if 200 != int(res['status']): raise Exception('Cannot change owner in indivo') u = self.create_user(username, role=ROLES['PATIENT']['id'], active=False, **extra_fields) doctor = u.yubikey.parent u.user_info = PatientInfo.objects.create( email=extra_fields['email'], first_name=extra_fields['first_name'], last_name=extra_fields['last_name'], phone=extra_fields['phone'], address=extra_fields['address'], city=extra_fields['city'], state=extra_fields['state'], zipcode=extra_fields['zipcode'], indivo_record_id=record_id, doctor=doctor ) u.save(using=self._db) self.send_confirmation_mail(u) return u
def handle(self, *args, **options): client = IndivoClient(settings.INDIVO_SERVER_PARAMS, settings.INDIVO_CONSUMER_PARAMS, pha_email=settings.INDIVO_USER_EMAIL) for i in PatientInfo.objects.filter(indivo_record_id=None): u = i.user print u values = { 'email': i.email, 'last_name': i.last_name, 'first_name': i.first_name, 'phone': i.phone, 'city': i.city, 'zipcode': i.zipcode, 'state': i.state, 'address': i.address } demographics = ( '<Demographics xmlns=\"http://indivo.org/vocab/xml/documents#\">' '<dateOfBirth><![CDATA[1965-06-22]]></dateOfBirth>' '<gender><![CDATA[male]]></gender>' '<email><![CDATA[%(email)s]]></email>' '<preferredLanguage>EN</preferredLanguage>' '<Name>' '<familyName><![CDATA[%(last_name)s]]></familyName>' '<givenName><![CDATA[%(first_name)s]]></givenName>' '</Name>' '<Telephone>' '<type>h</type><number><![CDATA[%(phone)s]]></number><preferred>true</preferred>' '</Telephone>' '<Address>' '<country><![CDATA[USA]]></country>' '<city><![CDATA[%(city)s]]></city>' '<postalCode><![CDATA[%(zipcode)s]]></postalCode>' '<region><![CDATA[%(state)s]]></region>' '<street><![CDATA[%(address)s]]></street>' '</Address>' '</Demographics>') % values res, content = client.record_create(body=demographics) if 200 != int(res['status']): raise Exception('Cannot create record in indivo') tree = ET.fromstring(content or '<Record/>') if tree is None: raise Exception('Cannot create user in indivo') record_id = tree.attrib.get('id') res, content = client.record_set_owner( record_id=record_id, body=settings.INDIVO_USER_EMAIL) if 200 != int(res['status']): raise Exception('Cannot change owner in indivo') i.indivo_record_id = record_id i.save()
def handle(self, *args, **options): client = IndivoClient(settings.INDIVO_SERVER_PARAMS, settings.INDIVO_CONSUMER_PARAMS, pha_email=settings.INDIVO_USER_EMAIL) for i in PatientInfo.objects.filter(indivo_record_id=None): u = i.user print u values = { 'email': i.email, 'last_name': i.last_name, 'first_name': i.first_name, 'phone': i.phone, 'city': i.city, 'zipcode': i.zipcode, 'state': i.state, 'address': i.address} demographics = ('<Demographics xmlns=\"http://indivo.org/vocab/xml/documents#\">' '<dateOfBirth><![CDATA[1965-06-22]]></dateOfBirth>' '<gender><![CDATA[male]]></gender>' '<email><![CDATA[%(email)s]]></email>' '<preferredLanguage>EN</preferredLanguage>' '<Name>' '<familyName><![CDATA[%(last_name)s]]></familyName>' '<givenName><![CDATA[%(first_name)s]]></givenName>' '</Name>' '<Telephone>' '<type>h</type><number><![CDATA[%(phone)s]]></number><preferred>true</preferred>' '</Telephone>' '<Address>' '<country><![CDATA[USA]]></country>' '<city><![CDATA[%(city)s]]></city>' '<postalCode><![CDATA[%(zipcode)s]]></postalCode>' '<region><![CDATA[%(state)s]]></region>' '<street><![CDATA[%(address)s]]></street>' '</Address>' '</Demographics>') % values res, content = client.record_create(body=demographics) if 200 != int(res['status']): raise Exception('Cannot create record in indivo') tree = ET.fromstring(content or '<Record/>') if tree is None: raise Exception('Cannot create user in indivo') record_id = tree.attrib.get('id') res, content = client.record_set_owner(record_id=record_id, body=settings.INDIVO_USER_EMAIL) if 200 != int(res['status']): raise Exception('Cannot change owner in indivo') i.indivo_record_id=record_id i.save()
class PatientInfoView(View): def __init__(self): self.client = IndivoClient(settings.INDIVO_SERVER_PARAMS, settings.INDIVO_CONSUMER_PARAMS, pha_email=settings.INDIVO_USER_EMAIL) def get(self, request, patient_id=None): ctx = RequestContext(request) user = MedintUser.objects.get(id=patient_id) record_id = user.user_info.patientinfo.indivo_record_id ctx['record'] = record_id result = {} for d in [ 'problem', 'allergy', 'AllergyExclusion', 'equipment', 'immunization', 'LabResult', 'measurement', 'medication', 'procedure', 'SimpleClinicalNote', 'VitalSigns', 'Encounter' ]: resp, content = self.client.generic_list(record_id=record_id, data_model=d) print '%s:' % d content = json.loads(content) if content: result[d] = content ctx['result'] = result return render_to_response('medint/patient_info.html', ctx) def post(self, request, patient_id=None): print request.FILES.getlist('file') # data = request.FILES['file'].read() user = MedintUser.objects.get(id=patient_id) record_id = user.user_info.patientinfo.indivo_record_id ctx = RequestContext(request) ctx['record'] = record_id for f in request.FILES.getlist('file'): data = f.read() resp, content = self.client.document_create( record_id=record_id, body=data, content_type='application/xml') # print resp # print content return self.get(request, patient_id)
class TimeLineView (View): def __init__(self): self.client = IndivoClient(settings.INDIVO_SERVER_PARAMS, settings.INDIVO_CONSUMER_PARAMS, pha_email=settings.INDIVO_USER_EMAIL) def get(self, request, patient_id=None): ctx = RequestContext(request) user = MedintUser.objects.get(id=patient_id) record_id = user.user_info.patientinfo.indivo_record_id ctx['record'] = record_id result = {} for d in ['problem', 'immunization', 'medication']: resp, content = self.client.generic_list(record_id=record_id, data_model=d) print '%s:' % d content = json.loads(content) if content: result[d] = content ctx['result'] = result return render_to_response('medint/patient_timeline.html', ctx)
class TimeLineView(View): def __init__(self): self.client = IndivoClient(settings.INDIVO_SERVER_PARAMS, settings.INDIVO_CONSUMER_PARAMS, pha_email=settings.INDIVO_USER_EMAIL) def get(self, request, patient_id=None): ctx = RequestContext(request) user = MedintUser.objects.get(id=patient_id) record_id = user.user_info.patientinfo.indivo_record_id ctx['record'] = record_id result = {} for d in ['problem', 'immunization', 'medication']: resp, content = self.client.generic_list(record_id=record_id, data_model=d) print '%s:' % d content = json.loads(content) if content: result[d] = content ctx['result'] = result return render_to_response('medint/patient_timeline.html', ctx)
def __init__(self): self.client = IndivoClient(settings.INDIVO_SERVER_PARAMS, settings.INDIVO_CONSUMER_PARAMS, pha_email=settings.INDIVO_USER_EMAIL)
def create_patient(self, username, **extra_fields): print settings.INDIVO_SERVER_PARAMS client = IndivoClient(settings.INDIVO_SERVER_PARAMS, settings.INDIVO_CONSUMER_PARAMS, pha_email=settings.INDIVO_USER_EMAIL) values = { 'email': '', 'last_name': '', 'first_name': '', 'phone': '', 'city': '', 'zipcode': '', 'state': '', 'address': '' } values.update(extra_fields) demographics = ( '<Demographics xmlns=\"http://indivo.org/vocab/xml/documents#\">' '<dateOfBirth><![CDATA[1965-06-22]]></dateOfBirth>' '<gender><![CDATA[male]]></gender>' '<email><![CDATA[%(email)s]]></email>' '<preferredLanguage>EN</preferredLanguage>' '<Name>' '<familyName><![CDATA[%(last_name)s]]></familyName>' '<givenName><![CDATA[%(first_name)s]]></givenName>' '</Name>' '<Telephone>' '<type>h</type><number><![CDATA[%(phone)s]]></number><preferred>true</preferred>' '</Telephone>' '<Address>' '<country><![CDATA[USA]]></country>' '<city><![CDATA[%(city)s]]></city>' '<postalCode><![CDATA[%(zipcode)s]]></postalCode>' '<region><![CDATA[%(state)s]]></region>' '<street><![CDATA[%(address)s]]></street>' '</Address>' '</Demographics>') % values res, content = client.record_create(body=demographics) if 200 != int(res['status']): raise Exception('Cannot create record in indivo') tree = ET.fromstring(content or '<Record/>') if tree is None: raise Exception('Cannot create user in indivo') record_id = tree.attrib.get('id') res, content = client.record_set_owner(record_id=record_id, body=settings.INDIVO_USER_EMAIL) if 200 != int(res['status']): raise Exception('Cannot change owner in indivo') u = self.create_user(username, role=ROLES['PATIENT']['id'], active=False, **extra_fields) doctor = u.yubikey.parent u.user_info = PatientInfo.objects.create( email=extra_fields['email'], first_name=extra_fields['first_name'], last_name=extra_fields['last_name'], phone=extra_fields['phone'], address=extra_fields['address'], city=extra_fields['city'], state=extra_fields['state'], zipcode=extra_fields['zipcode'], indivo_record_id=record_id, doctor=doctor) u.save(using=self._db) self.send_confirmation_mail(u) return u