Ejemplo n.º 1
0
def patient_short_post(request):
    try:
        msg = ''
        data = {}
        patient_id = int(request.POST['patient_id'])
        if patient_id > 0:
            patientshort = DBSession.query(PatientIdentification).get(patient_id)
        else:
            raise "KeyError"
        patientshort.age = int(request.POST['age'])
        patientshort.medical_history = request.POST['medical_history']
        print "Updating PatientIdentification with patient_id = %d" % (patient_id)
        o = DBSession.merge(patientshort)
        DBSession.flush()
        DBSession.refresh(o)
        patient_id = o.patient_id
        # DBSession.commit() # Not needed since Pyramid uses the Zope transaction manager
        print "Update successful"
    except exc.SQLAlchemyError as e:
        print "In patient_short_post caught exception of type: "
        print type(e)
        msg = str(e)
        print msg
        DBSession.rollback()
    except Exception as e:
        print "In patient_short_post caught exception of type: "
        print type(e)
        msg = str(e)
        DBSession.rollback()
    finally:
        return {'msg': msg, 'patient_id': str(patient_id)}
    return {'msg': msg, 'patient_id': str(patient_id)}
Ejemplo n.º 2
0
def nutritional_status_post(request):
    try:
        msg = ''
        data = {}
        id = int(request.POST['id'])
        if id > 0:
            nutritionalStatus = DBSession.query(NutritionalStatus).get(id)
        else:
            nutritionalStatus = NutritionalStatus()
        data['patient_id'] = int(request.POST['patient_id'])
        data['assessment_date'] = datetime.strptime(request.POST['assessment_date'],"%Y-%m-%d %H:%M:%S")
        data['nutritional_notes'] = request.POST['nutritional_notes']
        nutritionalStatus.setFromData(data)
        print "Updating NutritionalStatus with id = %d" % (id)
        o = DBSession.merge(nutritionalStatus)
        DBSession.flush()
        DBSession.refresh(o)
        id = o.id
        # DBSession.commit() # Not needed since Pyramid uses the Zope transaction manager
        print "Update successful"
    except exc.SQLAlchemyError as e:
        print "In nutritional_status_post caught exception of type: "
        print type(e)
        msg = str(e)
        print msg
        DBSession.rollback()
    except Exception as e:
        print "In nutritional_status_post caught exception of type: "
        print type(e)
        msg = str(e)
        DBSession.rollback()
    finally:
        return {'msg': msg, 'id': str(id)}
    return {'msg': msg, 'id': str(id)}
Ejemplo n.º 3
0
def treatment_plan_post(request):
    try:
        msg = ''
        data = {}
        id = int(request.POST['id'])
        if id > 0:
            treatmentPlan = DBSession.query(TreatmentPlan).get(id)
        else:
            treatmentPlan = TreatmentPlan()
        data['patient_id'] = int(request.POST['patient_id'])
        data['plan_date'] = datetime.strptime(request.POST['plan_date'],"%Y-%m-%d %H:%M:%S")
        data['plan_notes'] = request.POST['plan_notes']
        treatmentPlan.setFromData(data)
        print "Updating TreatmentPlan with id = %d" % (id)
        o = DBSession.merge(treatmentPlan)
        DBSession.flush()
        DBSession.refresh(o)
        id = o.id
        # DBSession.commit() # Not needed since Pyramid uses the Zope transaction manager
        print "Update successful"
    except exc.SQLAlchemyError as e:
        print "In treatment_plan_post caught exception of type: "
        print type(e)
        msg = str(e)
        print msg
        DBSession.rollback()
    except Exception as e:
        print "In treatment_plan_post caught exception of type: "
        print type(e)
        msg = str(e)
        DBSession.rollback()
    finally:
        return {'msg': msg, 'id': str(id)}
    return {'msg': msg, 'id': str(id)}
Ejemplo n.º 4
0
def braden_scores_delete(request):
    try:
        # bradenScores = DBSession.query(BradenScores).get(request.GET['id'])
        msg = ''
        data = {}
        id = int(request.POST['id'])
        if id <= 0:
            msg = 'Illegal row id (' + str(id) + ') passed to delete routine'
            return
        print "Deleting BradenScores with id = %d" % (id)
        bradenScores = DBSession.query(BradenScores).get(id)
        DBSession.delete(bradenScores)
        DBSession.flush()
        # DBSession.commit() # Not needed since Pyramid uses the Zope transaction manager
        print "Delete successful"
    except exc.SQLAlchemyError as e:
        print "In braden_scores_delete caught exception of type: "
        print type(e)
        msg = str(e)
        print msg
        DBSession.rollback()
    except Exception as e:
        print "In braden_scores_post caught exception of type: "
        print type(e)
        msg = str(e)
        DBSession.rollback()
    finally:
        return {'msg': msg, 'id': str(id)}
    return {'msg': msg, 'id': str(id)}
Ejemplo n.º 5
0
def treatment_plan_delete(request):
    try:
        msg = ''
        data = {}
        id = int(request.POST['id'])
        if id <= 0:
            msg = 'Illegal row id (' + str(id) + ') passed to delete routine'
            return
        print "Deleting TreatmentPlan with id = %d" % (id)
        treatmentPlan = DBSession.query(TreatmentPlan).get(id)
        DBSession.delete(treatmentPlan)
        DBSession.flush()
        # DBSession.commit() # Not needed since Pyramid uses the Zope transaction manager
        print "Delete successful"
    except exc.SQLAlchemyError as e:
        print "In treatment_plan_delete caught exception of type: "
        print type(e)
        msg = str(e)
        print msg
        DBSession.rollback()
    except Exception as e:
        print "In treatment_plan_delete caught exception of type: "
        print type(e)
        msg = str(e)
        DBSession.rollback()
    finally:
        return {'msg': msg, 'id': str(id)}
    return {'msg': msg, 'id': str(id)}
Ejemplo n.º 6
0
def patient_identification_delete(request):
    try:
        msg = ''
        data = {}
        patient_id = int(request.POST['patient_id'])
        if id <= 0:
            msg = 'Illegal row patient_id (' + str(patient_id) + ') passed to delete routine'
            return
        print "Deleting PatientIdentification with id = %d" % (patient_id)
        patient = DBSession.query(PatientIdentification).get(patient_id)
        DBSession.delete(patient)
        DBSession.flush()
        # DBSession.commit() # Not needed since Pyramid uses the Zope transaction manager
        print "Delete successful"
    except exc.SQLAlchemyError as e:
        print "In patient_identification_delete caught exception of type: "
        print type(e)
        msg = str(e)
        print msg
        DBSession.rollback()
    except Exception as e:
        print "In patient_identification_delete caught exception of type: "
        print type(e)
        msg = str(e)
        DBSession.rollback()
    finally:
        return {'msg': msg, 'patient_id': str(patient_id)}
    return {'msg': msg, 'patient_id': str(patient_id)}
Ejemplo n.º 7
0
def assessment_wound_view(request):
    # get other templates that will be included via macros
    footer = get_renderer('../templates/va-footer.pt').implementation()
    logo = get_renderer('../templates/va-logo.pt').implementation()
    nav = get_renderer('../templates/va-navigation.pt').implementation()
    try:
        algorithm_id = DBSession.query(Algorithm.id).filter(func.lower(Algorithm.algorithm_name)=='assessment measure').scalar()
        experiment_id = DBSession.query(Experiment.id).filter(and_(Experiment.algorithm_id==algorithm_id, Experiment.default_flag==True)).scalar()
        patients = DBSession.query(PatientIdentification).all()
    except DBAPIError:
        return Response(conn_err_msg, content_type='text/plain', status_int=500)
    return {'patients': patients, 'algorithm_id':algorithm_id, 'experiment_id':experiment_id, 'project': 'mmpspupc', 'footer': footer, 'logo': logo, 'nav': nav}
Ejemplo n.º 8
0
def braden_scores_post(request):
    try:
        # bradenScores = DBSession.query(BradenScores).get(request.GET['id'])
        msg = ''
        data = {}
        id = int(request.POST['id'])
        if id > 0:
            bradenScores = DBSession.query(BradenScores).get(id)
        else:
            bradenScores = BradenScores()
        data['patient_id'] = int(request.POST['patient_id'])
        data['braden_scoring_date'] = datetime.strptime(request.POST['braden_scoring_date'],"%Y-%m-%d %H:%M:%S")
        data['sensory_perception_score'] = int(request.POST['sensory_perception_score'])
        data['moisture_score'] = int(request.POST['moisture_score'])
        data['activity_score'] = int(request.POST['activity_score'])
        data['mobility_score'] = int(request.POST['mobility_score'])
        data['nutrition_score'] = int(request.POST['nutrition_score'])
        data['friction_shear_score'] = int(request.POST['friction_shear_score'])
        bradenScores.setFromData(data)
        print "Updating BradenScores with id = %d" % (id)
        o = DBSession.merge(bradenScores)
        DBSession.flush()
        DBSession.refresh(o)
        id = o.id
        # msg = "Merged"
        # DBSession.commit() # Not needed since Pyramid uses the Zope transaction manager
        print "Update successful"
    except exc.SQLAlchemyError as e:
        print "In braden_scores_post caught exception of type: "
        print type(e)
        msg = str(e)
        print msg
        DBSession.rollback()
    except Exception as e:
        print "In braden_scores_post caught exception of type: "
        print type(e)
        msg = str(e)
        DBSession.rollback()
    finally:
        return {'msg': msg, 'id': str(id)}
    return {'msg': msg, 'id': str(id)}
Ejemplo n.º 9
0
def patient_assessment_post(request):
    try:
        msg = ''
        data = {}
        id = int(request.POST['id'])
        if id > 0:
            patientAssessment = DBSession.query(PatientAssessment).get(id)
        else:
            patientAssessment = PatientAssessment()
        data['patient_id'] = int(request.POST['patient_id'])
        data['assessment_date'] = datetime.strptime(request.POST['assessment_date'],"%Y-%m-%d %H:%M:%S")
        data['assessment_note'] = request.POST['assessment_note']
        data['education_notes'] = request.POST['education_notes']
        data['education_understanding'] = request.POST['education_understanding']
        data['education_evidenced_by'] = request.POST['education_evidenced_by']
        patientAssessment.setFromData(data)
        print "Updating PatientAssessment with id = %d" % (id)
        o = DBSession.merge(patientAssessment)
        DBSession.flush()
        DBSession.refresh(o)
        id = o.id
        # DBSession.commit() # Not needed since Pyramid uses the Zope transaction manager
        print "Update successful"
    except exc.SQLAlchemyError as e:
        print "In patient_assessment_post caught exception of type: "
        print type(e)
        msg = str(e)
        print msg
        DBSession.rollback()
    except Exception as e:
        print "In patient_assessment_post caught exception of type: "
        print type(e)
        msg = str(e)
        DBSession.rollback()
    finally:
        return {'msg': msg, 'id': str(id)}
    return {'msg': msg, 'id': str(id)}
Ejemplo n.º 10
0
def patient_view(request):
    # get other templates that will be included via macros
    footer = get_renderer('../templates/va-footer.pt').implementation()
    logo = get_renderer('../templates/va-logo.pt').implementation()
    nav = get_renderer('../templates/va-navigation.pt').implementation()
    patientshort = get_renderer('../templates/patient-short.pt').implementation()
    admission = get_renderer('../templates/patient-admission.pt').implementation()
    assessment = get_renderer('../templates/patient-assessment.pt').implementation()
    braden = get_renderer('../templates/braden-scores.pt').implementation()
    nutritional = get_renderer('../templates/nutritional-status.pt').implementation()
    treatment = get_renderer('../templates/treatment-plan.pt').implementation()
    try:
        patients = DBSession.query(PatientIdentification).all()
    except DBAPIError:
        return Response(conn_err_msg, content_type='text/plain', status_int=500)
    return {'patients': patients, 'project': 'mmpspupc', 'footer': footer, 'logo': logo, 'nav': nav,
            'patientshort': patientshort, 'admission': admission, 'assessment': assessment, 'braden': braden, 
            'nutritional': nutritional, 'treatment': treatment}
Ejemplo n.º 11
0
def prevention_event_table(request):
    try:
        turnings = DBSession.query(PatientTurning).filter(and_(PatientTurning.patient_id == request.GET['patient_id'], PatientTurning.experiment_id == request.GET['experiment_id'])).order_by(desc(PatientTurning.turn_time)).all()
    except DBAPIError:
        return Response(conn_err_msg, content_type='text/plain', status_int=500)
    events = []
    for turn in turnings:
        event = turn.__json__(None)
        events.append(event)
    prevTime = None
    for event in reversed(events):
        deltaStr = 'N/A'
        if prevTime:
            delta = datetime.strptime(event['turn_time'],'%Y-%m-%d %H:%M:%S') - datetime.strptime(prevTime,'%Y-%m-%d %H:%M:%S')
            deltaStr = str(delta)
        prevTime = event['turn_time']
        event['interval'] = deltaStr
    return {'events': events}
Ejemplo n.º 12
0
def patientidentification(request):
    try:
        patient = DBSession.query(PatientIdentification).get(request.GET['patient_id'])
    except DBAPIError:
        return Response(conn_err_msg, content_type='text/plain', status_int=500)
    return {'patient': patient}
Ejemplo n.º 13
0
def patient_list(request):
    try:
        patients = DBSession.query(PatientIdentification).all()
    except DBAPIError:
        return Response(conn_err_msg, content_type='text/plain', status_int=500)
    return {'patients': patients}
Ejemplo n.º 14
0
def populate_wound_dropdown(request):
    try:
        wounds = DBSession.query(WoundAssessment).filter(WoundAssessment.patient_id == request.GET['patient_id']).order_by(WoundAssessment.wound_location_description).all()
    except DBAPIError:
        return Response(conn_err_msg, content_type='text/plain', status_int=500)
    return wounds
Ejemplo n.º 15
0
def assessment_temperature(request):
    try:
        temperatures = DBSession.query(AssessmentTemperature).join(AssessmentSession, AssessmentTemperature.session_id == AssessmentSession.id).filter(and_(AssessmentSession.patient_id == request.GET['patient_id'], AssessmentSession.wound_id == request.GET['wound_id'], AssessmentTemperature.experiment_id == request.GET['experiment_id'])).order_by(desc(AssessmentTemperature.start_time)).all()
    except DBAPIError:
        return Response(conn_err_msg, content_type='text/plain', status_int=500)
    return temperatures
Ejemplo n.º 16
0
def braden_scores_list(request):
    try:
        bradenScores = DBSession.query(BradenScores).filter_by(patient_id = request.GET['patient_id']).order_by(desc(BradenScores.braden_scoring_date)).all()
    except DBAPIError:
        return Response(conn_err_msg, content_type='text/plain', status_int=500)
    return {'bradenScores': bradenScores}
Ejemplo n.º 17
0
def braden_scores_single(request):
    try:
        bradenScores = DBSession.query(BradenScores).get(request.GET['id'])
    except DBAPIError:
        return Response(conn_err_msg, content_type='text/plain', status_int=500)
    return {'bradenScores': bradenScores}
Ejemplo n.º 18
0
def nutritional_status_list(request):
    try:
        nutritionalStatus = DBSession.query(NutritionalStatus).filter_by(patient_id = request.GET['patient_id']).order_by(desc(NutritionalStatus.assessment_date)).all()
    except DBAPIError:
        return Response(conn_err_msg, content_type='text/plain', status_int=500)
    return {'nutritionalStatus': nutritionalStatus}
Ejemplo n.º 19
0
def treatment_plan_single(request):
    try:
        treatmentPlan = DBSession.query(TreatmentPlan).get(request.GET['id'])
    except DBAPIError:
        return Response(conn_err_msg, content_type='text/plain', status_int=500)
    return {'treatmentPlan': treatmentPlan}
Ejemplo n.º 20
0
def treatment_plan_list(request):
    try:
        treatmentPlan = DBSession.query(TreatmentPlan).filter_by(patient_id = request.GET['patient_id']).order_by(desc(TreatmentPlan.plan_date)).all()
    except DBAPIError:
        return Response(conn_err_msg, content_type='text/plain', status_int=500)
    return {'treatmentPlan': treatmentPlan}
Ejemplo n.º 21
0
def nutritional_status_single(request):
    try:
        nutritionalStatus = DBSession.query(NutritionalStatus).get(request.GET['id'])
    except DBAPIError:
        return Response(conn_err_msg, content_type='text/plain', status_int=500)
    return {'nutritionalStatus': nutritionalStatus}
Ejemplo n.º 22
0
def patient_assessment_single(request):
    try:
        patientAssessment = DBSession.query(PatientAssessment).get(request.GET['id'])
    except DBAPIError:
        return Response(conn_err_msg, content_type='text/plain', status_int=500)
    return {'patientAssessment': patientAssessment}
Ejemplo n.º 23
0
def patient_assessment_list(request):
    try:
        patientAssessment = DBSession.query(PatientAssessment).filter_by(patient_id = request.GET['patient_id']).order_by(desc(PatientAssessment.assessment_date)).all()
    except DBAPIError:
        return Response(conn_err_msg, content_type='text/plain', status_int=500)
    return {'patientAssessment': patientAssessment}