Ejemplo n.º 1
0
    def _get_pet_schedule(self, id_pet_schedule):
        pet_schedule = PetScheduleModel.get_by_id(id_pet_schedule)
        provider = ProviderModel.get_by_id(pet_schedule.provider_id)

        pacient = select_pet_by_proposal_id(pet_schedule.proposal_id)
        provider_associated = {
            'id':
            provider.id,
            'fantasy_name':
            provider.fantasy_name,
            'provider_details':
            f'http://127.0.0.1:8080/api/user/{provider.user_id}'
        }

        if pet_schedule is None:
            return {'message': 'Plan not found'}, 404

        return {
            'id': pet_schedule.id,
            'name': pet_schedule.name,
            'date': pet_schedule.date,
            'time': pet_schedule.time,
            'email': pet_schedule.email,
            'status': pet_schedule.status,
            'created_date': pet_schedule.created_date.strftime("%d/%m/%Y"),
            'provider': provider_associated,
            'pacient': pacient
        }
Ejemplo n.º 2
0
    def put(self):
        provider = ObjectDict(json_decode(self.request.body))

        _provider = ProviderModel.get_by_id(self.db, provider.id)
        if _provider:
            try:
                _provider = ProviderModel.update(self.db, provider.id, provider.chain_id, provider.name,
                        provider.contact, provider.phone, provider.email)
                self.finish_json(result=_provider.tojson())
            except Exception, e:
                print e
                self.finish_json(errcode=507, errmsg=str(e))
Ejemplo n.º 3
0
def select_emergency_pet_by_proposal(proposal_number):
    proposal = ProposalModel.get_by_number(proposal_number)
    emergency = EmergencyPetModel.get_by_proposal(proposal.id)
    pet = PetModel.get_by_proposal(emergency.proposal_id)

    if emergency.provider_id != 0:

        provider = ProviderModel.get_by_id(emergency.provider_id)
        provider_associated = {
            'id':
            provider.id,
            'fantasy_name':
            provider.fantasy_name,
            'provider_details':
            f'http://127.0.0.1:8080/api/user/{provider.user_id}'
        }
    else:
        provider_associated = ''

    insured_pacient = {
        'id': pet.id,
        'name': pet.name,
        'species': pet.species,
        'breed': pet.breed,
        'size': pet.size,
        'weight': pet.weight,
        'proposal': {
            'id': proposal.id,
            'number': proposal.number,
            'status': proposal.status,
            'created_date': proposal.created_date.strftime("%d/%m/%Y"),
            'plan': select_plan_proposal_by_id(proposal.plan_proposal_id)
        }
    }

    return {
        'id': emergency.id,
        'label': emergency.label,
        'call_type': emergency.call_type,
        'call': emergency.call,
        'latitude': emergency.latitude,
        'longitude': emergency.longitude,
        'status_emergency': emergency.status,
        'created_date': emergency.created_date.strftime("%d/%m/%Y"),
        'provider': provider_associated,
        'insured_pacient': insured_pacient
    }
Ejemplo n.º 4
0
def select_emergency_insured_by_policy(policy_number):
    policy = PolicyModel.get_by_number(policy_number)
    emergency = EmergencyInsuredModel.get_by_policy(policy.id)

    insured = InsuredModel.get_by_policy_id(emergency.policy_id)
    if emergency.provider_id != 0:

        provider = ProviderModel.get_by_id(emergency.provider_id)
        provider_associated = {
            'id':
            provider.id,
            'fantasy_name':
            provider.fantasy_name,
            'provider_details':
            f'http://127.0.0.1:8080/api/user/{provider.user_id}'
        }
    else:
        provider_associated = ''

    insured_pacient = {
        'id': insured.id,
        'first_name': insured.first_name,
        'last_name': insured.last_name,
        'cpf': insured.cpf,
        'policy': {
            'id': policy.id,
            'number': policy.number,
            'status': policy.status,
            'created_date': policy.created_date.strftime("%d/%m/%Y"),
            'plan': select_plan_policy_by_id(policy.plan_policy_id)
        }
    }

    return {
        'id': emergency.id,
        'label': emergency.label,
        'call_type': emergency.call_type,
        'call': emergency.call,
        'latitude': emergency.latitude,
        'longitude': emergency.longitude,
        'status_emergency': emergency.status,
        'created_date': emergency.created_date.strftime("%d/%m/%Y"),
        'provider': provider_associated,
        'insured_pacient': insured_pacient
    }
Ejemplo n.º 5
0
def select_provider_by_id(id):
    try:
        provider = ProviderModel.get_by_id(id)

        if provider is None:
            return {'success': False, 'message': 'Provider not found'}
        else:
            return {
                'id': provider.id,
                'business_name': provider.business_name,
                'fantasy_name': provider.fantasy_name,
                'cnpj': provider.cnpj,
                'address': provider.address,
                'type_provider': provider.type_provider
            }
            return {"succes": True, "message": 'Provider found'}

    except Exception as e:
        return {"succes": False, "message": f'{e} invalid payload'}
Ejemplo n.º 6
0
def select_emergency_pet_by_id(id_emergency):
    emergency = EmergencyPetModel.get_by_id(id_emergency)
    provider = ProviderModel.get_by_id(emergency.provider_id)

    provider_associated = {
        'id': provider.id,
        'fantasy_name': provider.fantasy_name,
        'provider_details':
        f'http://127.0.0.1:8080/api/user/{provider.user_id}'
    }

    return {
        'id': emergency.id,
        'name': emergency.name,
        'date': emergency.date,
        'time': emergency.time,
        'email': emergency.email,
        'status_emergency': emergency.status,
        'created_date': emergency.created_date.strftime("%d/%m/%Y"),
        'provider': provider_associated,
        'pet_pacient': select_pet_by_proposal_id(emergency.proposal_id)
    }
Ejemplo n.º 7
0
def select_emergency_insured_by_id(id_emergency):
    emergency = EmergencyInsuredModel.get_by_id(id_emergency)
    provider = ProviderModel.get_by_id(emergency.provider_id)
    insured = InsuredModel.get_by_proposal(emergency.policy_id)
    policy = PolicyModel.get_by_id(emergency.policy_id)

    insured_pacient = {
        'id': insured.id,
        'first_name': insured.first_name,
        'last_name': insured.last_name,
        'cpf': insured.cpf,
        'policy': {
            'id': policy.id,
            'number': policy.number,
            'status': policy.status,
            'created_date': policy.created_date.strftime("%d/%m/%Y"),
            'plan': select_plan_policy_by_id(policy.plan_policy_id)
        }
    }
    provider_associated = {
        'id': provider.id,
        'fantasy_name': provider.fantasy_name,
        'provider_details':
        f'http://127.0.0.1:8080/api/user/{provider.user_id}'
    }

    return {
        'id': emergency.id,
        'name': emergency.name,
        'date': emergency.date,
        'time': emergency.time,
        'email': emergency.email,
        'status_emergency': emergency.status,
        'created_date': emergency.created_date.strftime("%d/%m/%Y"),
        'provider': provider_associated,
        'insured_pacient': insured_pacient
    }