예제 #1
0
def get_therapy_record(pid, treNum):
    tre_rec = TreRec.query.filter_by(pid=pid, treNum=treNum).first()
    data = {}
    if tre_rec:
        data['parent'] = tre_rec.get_parent()
        data['child'] = tre_rec.get_child()
    return Success(data=data)
예제 #2
0
def add_side_effect(pid, treNum):
    data = request.get_json()
    for _data in data['data']:
        _data['pid'] = pid
        _data['treNum'] = treNum
        json2db(_data, SideEffect)
    return Success()
예제 #3
0
def add_image_exam(pid, treNum):
    data = request.get_json()
    for _data in data['data']:
        _data['pid'] = pid
        _data['treNum'] = treNum
        json2db(_data, ImageExams)
    return Success()
예제 #4
0
def del_record_info(pid):
    tre_rec = TreRec.query.filter_by(pid=pid).order_by(
        TreRec.treNum.desc()).first()
    if tre_rec:
        with db.auto_commit():
            tre_rec.delete()
    return Success()
예제 #5
0
def get_patient_follInfo():
    # id = g.user.user_id
    today = datetime.today().__format__("%Y-%m-%d")
    today = datetime.strptime(today, "%Y-%m-%d")
    tomorrow = today + td(days=3)

    patients = []
    if 'OperateAllCRF' in g.user.scopes:
        patients = Patient.query.filter(
            Patient.nextFollowupTime >= today,
            Patient.nextFollowupTime <= tomorrow, Patient.is_delete == 0,
            Patient.finishFollowup == 0).order_by(
                Patient.nextFollowupTime.asc()).all()
    elif 'CheckCenterCRF' in g.user.scopes:
        centers = ResearchCenterSpider().search_by_uid_project(
            current_app.config['PROJECT_ID'], g.user.user_id)['data']
        center_ids = [center['id'] for center in centers]
        patients = Patient.query.filter(
            Patient.nextFollowupTime >= today,
            Patient.nextFollowupTime <= tomorrow,
            Patient.is_delete == 0, Patient.finishFollowup == 0,
            Patient.researchCenter.in_(center_ids)).order_by(
                Patient.nextFollowupTime.asc()).all()
    else:
        items = Patient.query.filter(Patient.nextFollowupTime >= today,
                                     Patient.nextFollowupTime <= tomorrow,
                                     Patient.is_delete == 0,
                                     Patient.finishFollowup == 0).order_by(
                                         Patient.nextFollowupTime.asc()).all()
        for item in items:
            if item.account and g.user.user_id in item.account:
                patients.append(item)
    # patients = Patient.query.filter(Patient.nextFollowupTime >= today, Patient.nextFollowupTime <= tomorrow,Patient.is_delete == 0,Patient.finishFollowup == 0).order_by(Patient.nextFollowupTime.asc()).all()
    # new_patients = filter(lambda patient: True if patient.account and id in patient.account else False, patients)
    return Success(data=patients if patients else [])
예제 #6
0
def add_signs(pid, treNum):
    data = request.get_json()
    print(data)
    for _data in data['data']:
        _data['pid'] = pid
        _data['treNum'] = treNum
        json2db(_data, Signs)
    return Success()
예제 #7
0
def del_therapy_plan(pid, treNum):
    data = request.get_json()
    items = DetailTrePlan.query.filter(DetailTrePlan.is_delete == 0,
                                       DetailTrePlan.id.in_(
                                           data['ids'])).all()
    delete_array(items)

    return Success()
예제 #8
0
def sample_add_account(pid):
    patient = Patient.query.get_or_404(pid)
    with db.auto_commit():
        account = [id for id in patient.account]
        account.append(g.user.user_id)
        patient.account = list(set(account))

    return Success()
예제 #9
0
def del_hormone_history(pid):
    data = request.get_json()
    items = DrugHistory.query.filter(DrugHistory.is_delete == 0,
                                     DrugHistory.id.in_(data['ids'])).all()
    with db.auto_commit():
        for item in items:
            item.delete()
    return Success()
예제 #10
0
def get_therapy_plan(pid, treNum):
    items = DetailTrePlan.query.filter_by(pid=pid, treNum=treNum).all()
    data = {}
    data['Chemotherapy'], data['TargetedTherapy'], data[
        'ImmunityTherapy'], data['AntivascularTherapy'] = [], [], [], []
    for item in items:
        if item.treSolu:
            data[item.treSolu].append(item)

    return Success(data=data)
예제 #11
0
def update_patient_follInfo(pid, nextFollowupTime):
    patients = Patient.query.filter_by(id=pid,
                                       finishFollowup=0,
                                       nextFollowupTime=datetime.strptime(
                                           nextFollowupTime,
                                           "%Y-%m-%d")).all()
    with db.auto_commit():
        for patient in patients:
            patient.finishFollowup = 1
    return Success()
예제 #12
0
def add_treatment_evaluation(pid, treNum, trement):
    data = request.get_json()
    data['pid'] = pid
    data['treNum'] = treNum
    data['trement'] = trement
    json2db(data, TreRec)
    """
    每一次治疗信息中,疗效评估页面,增加一个字段"PFS/DFS",该字段可以手动录入,也可以系统自动计算填写,自动计算优先于手动填写。
    填写了进展时间之后,系统需要自动计算PFS/DFS,并填写,计算逻辑为:用药开始时间到进展时间之间的时间间隔。如果不自动计算,则可以手动填写
    """
    if 'proDate' in data and 'PFS_DFS' not in data:
        treRec = TreRec.query.filter_by(pid=pid, treNum=treNum).first()
        treRec.compute_FPS_DFS()
    return Success()
예제 #13
0
def add_sample():
    data = request.get_json()
    user = UserInfo().search_by_uid(g.user.user_id)['data']
    patients = None
    if 'idNumber' in data:
        patients = Patient.query.filter_by(idNumber=data['idNumber'], researchCenter=user['research_center_id']).all()
    if 'hospitalNumber' in data:
        patients = Patient.query.filter_by(hospitalNumber=data['hospitalNumber'],
                                           researchCenter=user['research_center_id']).all()
    if 'patientName' in data:
        patients = Patient.query.filter_by(patientName=data['patientName'],
                                           researchCenter=user['research_center_id']).all()
    return_data = {
        "status": 0,
        "pid": None,
        "samples": []
    }
    if patients:
        return_data['status'] = 1
        for patient in patients:
            return_data['samples'].append(patient)
            if g.user.user_id in patient.account:
                return_data['status'] = -1
        return Success(data=return_data)

    model_data = {
        'account': [user['id']],
        'researchCenter': user['research_center_id'],
        'idNumber': data.get('idNumber'),
        'hospitalNumber': data.get('hospitalNumber'),
        'patientName': data.get('patientName'),
        'birthday': data.get('birthday')
    }
    patient = json2db_add(model_data, Patient)
    return_data['pid'] = patient.id
    return Success(data=return_data)
예제 #14
0
파일: patient.py 프로젝트: WXYwxy12390/-
def add_patient(pid):
    data = request.get_json()
    patient = Patient.query.get_or_404(pid)
    if 'idNumber' in data:
        item = Patient.query.filter(Patient.is_delete == 0, Patient.idNumber == data['idNumber'],
                                       Patient.id != pid, Patient.researchCenter == patient.researchCenter).first()
        if item:
            raise ParameterException(msg='已经存在相同身份证号码。')
    if 'hospitalNumber' in data and patient.hospitalNumber is not None:
        item = Patient.query.filter(Patient.is_delete == 0, Patient.hospitalNumber == data['hospitalNumber'],
                                       Patient.id != pid, Patient.researchCenter == patient.researchCenter).first()
        if item:
            raise ParameterException(msg='已经存在相同住院号。')
    json2db(data, Patient)
    return Success()
예제 #15
0
def add_therapy_record(pid, treNum):
    data = request.get_json()
    if 'parent' in data:
        data['parent']['pid'] = pid
        data['parent']['treNum'] = treNum
        json2db(data['parent'], TreRec)
    if 'child' in data:
        tre_rec = TreRec.query.filter_by(pid=pid, treNum=treNum).first_or_404()
        trement = tre_rec.trement
        data['child']['pid'] = pid
        data['child']['treNum'] = treNum
        if trement in ['one', 'two', 'three', 'four', 'five', 'other']:
            json2db(data['child'], OneToFive)
        elif trement == 'surgery':
            json2db(data['child'], Surgery)
        elif trement == 'radiotherapy':
            json2db(data['child'], Radiotherapy)
    return Success()
예제 #16
0
def get_other_exam(pid, treNum):
    data = OtherExams.query.filter_by(pid=pid, treNum=treNum).first()
    return Success(data=data if data else {})
예제 #17
0
def add_lung_function(pid, treNum):
    data = request.get_json()
    data['pid'] = pid
    data['treNum'] = treNum
    json2db(data, Lung)
    return Success()
예제 #18
0
def get_lung_function(pid, treNum):
    data = Lung.query.filter_by(pid=pid, treNum=treNum).first()
    return Success(data=data if data else {})
예제 #19
0
def get_side_effect(pid, treNum):
    side_effect = SideEffect.query.filter_by(pid=pid, treNum=treNum).all()
    return Success(data=side_effect if side_effect else [])
예제 #20
0
def del_follInfo(pid, fid):
    follInfo = FollInfo.query.filter_by(id=fid).all()
    delete_array(follInfo)
    return Success()
예제 #21
0
def get_signs(pid, treNum):
    signs = Signs.query.filter_by(pid=pid, treNum=treNum).all()
    return Success(data=signs if signs else [])
예제 #22
0
def get_treatment_evaluation(pid, treNum, trement):
    treRec = TreRec.query.filter_by(pid=pid, treNum=treNum,
                                    trement=trement).first()
    return Success(data=treRec if treRec else {})
예제 #23
0
def get_follInfo(pid):
    follInfo = FollInfo.query.filter_by(pid=pid).all()
    return Success(data=follInfo if follInfo else [])
예제 #24
0
def add_patient_follInfo(pid):
    data = request.get_json()
    data['id'] = pid
    data['finishFollowup'] = 0
    json2db(data, Patient)
    return Success()
예제 #25
0
def add_other_exam(pid, treNum):
    data = request.get_json()
    data['pid'] = pid
    data['treNum'] = treNum
    json2db(data, OtherExams)
    return Success()
예제 #26
0
def del_side_effect(pid, se_id):
    side_effect = SideEffect.query.filter_by(id=se_id).all()
    delete_array(side_effect)
    return Success()
예제 #27
0
def get_image_exam(pid, treNum):
    data = ImageExams.query.filter_by(pid=pid, treNum=treNum).all()
    return Success(data=data if data else [])
예제 #28
0
def del_signs(pid, sign_id):
    sign = Signs.query.filter_by(id=sign_id).all()
    delete_array(sign)
    return Success()
예제 #29
0
def del_image_exam(pid, treNum):
    data = request.get_json()
    items = ImageExams.query.filter(ImageExams.is_delete == 0,
                                    ImageExams.id.in_(data['ids'])).all()
    delete_array(items)
    return Success()
예제 #30
0
def add_follInfo(pid):
    data = request.get_json()
    for _data in data['data']:
        _data['pid'] = pid
        json2db(_data, FollInfo)
    return Success()