Ejemplo n.º 1
0
def confirm(event, context):
    event['response']['autoConfirmUser'] = True

    if 'email' in event['request']['userAttributes']:
        event['response']['autoVerifyEmail'] = True

    if 'phone_number' in event['request']['userAttributes']:
        event['response']['autoVerifyPhone'] = True

    lambda_utils.invoke('NotifyNewUser', event)

    return event
    
Ejemplo n.º 2
0
def delete(event, context):
    _data = json.loads(json.dumps(event['body']))
    _patientid = _data['patientid']

    _patientsClassifications = PATIENT_CLASSIFICATION_TABLE.scan(
        FilterExpression=Attr('patientid').eq(_patientid))

    for classfication in _patientsClassifications['Items']:
        PATIENT_CLASSIFICATION_TABLE.delete_item(
            Key={'id': classfication['id']})

        lambda_utils.invoke('ExecutationDelete',
                            {'predictid': classfication['executationid']})

    return {'statusCode': 200}
Ejemplo n.º 3
0
def delete(event, context):
    _id = event['pathParameters']['id']
    _delete_patient_file(_id)
    
    PATIENT_TABLE.delete_item(
        Key={
            'id': _id
        }
    )
    
    lambda_utils.invoke('PatientClassificationDelete', {
        'patientid': _id
    })
    return {
        'statusCode': 200
    }
Ejemplo n.º 4
0
def delete_all(event, context):
    _data = json.loads(json.dumps(event['body']))
    _userid = _data['userid']

    _patiens = PATIENT_TABLE.scan(
        FilterExpression=Attr('userid').eq(_userid)
    )

    for patient in _patiens['Items']:
        PATIENT_TABLE.delete_item(
            Key={
                'id': patient['id']
            }
        )
        
        lambda_utils.invoke('PatientClassificationDelete', {
            'patientid': patient['id']
        })

    return {
        'statusCode': 200
    }
Ejemplo n.º 5
0
def get_data(event, context):
    _report = ReportModel(json.loads(event['body']))
    
    _report_data = DYNAMODB_RESOURCE.Table(_report.tableName).scan(
        FilterExpression=Attr(_report.filterExpression).eq(_report.additional[_report.filterExpression]),
        ProjectionExpression=_report.projectionExpression
    )

    return invoke('GeneratePdf', {
        'userid': _report.userid,
        'title': _report.name,
        'items': _report_data['Items']
    })
        
Ejemplo n.º 6
0
def clean_data(event, context):
    _userid = event['pathParameters']['userid']
    lambda_utils.invoke('PatientDeleteAll', {'userid': _userid})
    return {'statusCode': 200}
Ejemplo n.º 7
0
def terminate_prediction(event, context):
    _data = json.loads(json.dumps(event['body']))
    _id = _data['predictid']

    _percentage_parkinson, _percentage_others = _get_percentages(_id)

    _patientName = lambda_utils.invoke('PatientGetName', {
        'patientid': _data['patientid'],
    })

    if _percentage_parkinson == _percentage_others == 0:
        _notification_data = {
            'title':
            DEFAULT_NOTIFICATION_TITLE,
            'body':
            DEFAULT_NOTIFICATION_MESSAGE_NO_RESULTS.format(
                patient=_patientName),
            'userid':
            _data['userid'],
            'additional':
            None,
            'payload':
            'alert'
        }

        lambda_utils.invoke('NotificationCreate', _notification_data)

    else:
        _percentage, _is_parkinson = (
            _percentage_parkinson,
            1) if _percentage_parkinson > _percentage_others else (
                _percentage_others, 0)

        _classification = lambda_utils.invoke(
            'PatientClassificationCreate', {
                'patientid': _data['patientid'],
                'executationid': _id,
                'percentage': str(_percentage),
                'isParkinson': _is_parkinson
            })

        if ('statusCode' in _classification
                and _classification['statusCode'] == 200):
            _conclusion = '' if _is_parkinson else ' não'

            _notification_data = {
                'title':
                DEFAULT_NOTIFICATION_TITLE,
                'body':
                DEFAULT_NOTIFICATION_MESSAGE.format(patient=_patientName,
                                                    percentage=_percentage,
                                                    conclusion=_conclusion),
                'userid':
                _data['userid'],
                'additional':
                _id,
                'payload':
                'classification'
            }

            lambda_utils.invoke('NotificationCreate', _notification_data)
        else:
            return {
                'statusCode': 500,
                'error':
                'it was not possible to create the final classification'
            }

    return {'statusCode': 200}