def view_CCD(request): if request.method == "POST": form = PatientForm(request.POST) if form.is_valid(): json_chart = parse_ccda( form.cleaned_data['patient'].chart.file.name) request.session['CurrentPatient'] = json_chart request.session['CurrentPatientXml'] = get_stylish_tables( open(form.cleaned_data['patient'].chart.file.name).read()) xml_root = remove_namespaces(request.session['CurrentPatientXml']) request.session['CurrentPatientTables'] = get_tables(xml_root) suffix_tag = xml_root.find("recordTarget").find( "patientRole").find("patient").find('name').find("suffix") if suffix_tag: request.session['middle'] = xml_root.find("recordTarget").find( "patientRole").find("patient").find('name').find( "suffix").text elif 'middle' in request.session: del request.session['middle'] errors = form.errors or None # form not submitted or it has errors return render(request, 'CCD/patient_summary.html', { 'form': form, 'errors': errors }) form = PatientForm() errors = form.errors or None # form not submitted or it has errors return render(request, 'CCD/patient_summary.html', { 'form': form, 'errors': errors })
def add_patient(self, ccd_file, pref_email): #Because of a chicken-egg problem, we need to write the CCDA to disk then have bluebutton parse it before we can #pass it to a model with NamedTemporaryFile(delete=False) as xml_file: for chunk in ccd_file.chunks(): xml_file.write(chunk) ccda = parse_ccda(xml_file.name) new_user = User.objects.create_user(pref_email, pref_email, 'password') new_user.first_name = ccda['demographics']['name']['given'][0] new_user.last_name = ccda['demographics']['name']['family'] new_user.save() new_patient = Patient(user=new_user, chart=ccd_file) new_patient.save()
def dashboard(request): if request.method == "POST": form = PatientForm(request.POST) if form.is_valid(): json_chart = parse_ccda(form.cleaned_data['patient'].chart.file.name) request.session['CurrentPatient'] = json_chart request.session['CurrentPatientXml'] = open(form.cleaned_data['patient'].chart.file.name).read() xml_root = remove_namespaces(request.session['CurrentPatientXml']) request.session['CurrentPatientTables'] = get_tables(xml_root) errors = form.errors or None # form not submitted or it has errors return render(request, 'CCD/dashboard.html', {'form': form, 'errors': errors, }) form = PatientForm() errors = form.errors or None # form not submitted or it has errors return render(request, 'CCD/dashboard.html',{'form': form, 'errors': errors, })
def view_CCD(request): if request.method == "POST": form = PatientForm(request.POST) if form.is_valid(): json_chart = parse_ccda(form.cleaned_data['patient'].chart.file.name) request.session['CurrentPatient'] = json_chart request.session['CurrentPatientXml'] = get_stylish_tables(open(form.cleaned_data['patient'].chart.file.name).read()) xml_root = remove_namespaces(request.session['CurrentPatientXml']) request.session['CurrentPatientTables'] = get_tables(xml_root) suffix_tag = xml_root.find("recordTarget").find("patientRole").find("patient").find('name').find("suffix") if suffix_tag: request.session['middle'] = xml_root.find("recordTarget").find("patientRole").find("patient").find('name').find("suffix").text elif 'middle' in request.session: del request.session['middle'] errors = form.errors or None # form not submitted or it has errors return render(request, 'CCD/patient_summary.html', {'form': form, 'errors': errors}) form = PatientForm() errors = form.errors or None # form not submitted or it has errors return render(request, 'CCD/patient_summary.html', {'form': form, 'errors': errors})
def dashboard(request): if request.method == "POST": form = PatientForm(request.POST) if form.is_valid(): json_chart = parse_ccda( form.cleaned_data['patient'].chart.file.name) request.session['CurrentPatient'] = json_chart request.session['CurrentPatientXml'] = open( form.cleaned_data['patient'].chart.file.name).read() xml_root = remove_namespaces(request.session['CurrentPatientXml']) request.session['CurrentPatientTables'] = get_tables(xml_root) errors = form.errors or None # form not submitted or it has errors return render(request, 'CCD/dashboard.html', { 'form': form, 'errors': errors, }) form = PatientForm() errors = form.errors or None # form not submitted or it has errors return render(request, 'CCD/dashboard.html', { 'form': form, 'errors': errors, })