def get(self, request, *args, **kwargs): data = [] try: url = '{}/catalogo/cie/lista/?q={}'.format( settings.API_MPI_URL, self.request.GET.get('q', '')) c = MPIClient(settings.MPI_API_TOKEN).get(url=url) if c.status_code == 200: data = c.json().get('data', []) except Exception as e: logger.warning(str(e)) return Response(data)
def get_cita(uuid): data = dict() params = { 'dominio': settings.API_CITA_URL, 'uuid': uuid, } url = '{dominio}/citas/get_cita_uuid/{uuid}/'.format(**params) try: c = CITAClient(settings.CITAS_API_TOKEN).get(url=url) if c.status_code == 200: data = c.json() paciente = data.get('id_phr_paciente', False) if paciente: data.get('paciente').update(get_ciudadano(paciente)) url = '{}/servicio/{}/'.format(settings.API_MPI_URL, data.get('cod_ups')) u = MPIClient(settings.MPI_API_TOKEN).get(url=url) if u.status_code == 200: data.update({'ups': u.json()}) except Exception as e: logger.warning(str(e)) return data