Question: Oracle, Online Assessment (IIT Roorkee) | REST API: Fit Count | REST API : Pulse Rate | 26th October 2022
2
Entering edit mode

ADD COMMENTlink 15 months ago PoGo 2.4k
0
Entering edit mode

import requests,json

 

def pulseRate(diagnosisName,doctorId):

    url='https://jsonmock.hackerrank.com/api/medical_records'

    response=requests.get(url,params={'page':1}).json()

    data=response['total_pages']

    resul=0

    k=0

    for i in range(1,data+1):

        response=requests.get(url,params={'page':i}).json()

        res=response['data']

        pageres,count=fetchdata(res,diagnosisName,doctorId)

        resul=resul+pageres

        k=k+count

    if count == 0:

        return 0  # Handle case when no matching records are found

    else:

        return (int(resul/k))

 

# k=0

def fetchdata(data,diagnosisName,doctorId):

    result=0

    k=0

    for i in data:

        if(i['diagnosis']['name']==diagnosisName and i['doctor']['id']==doctorId):

            result+=int(i['vitals']['pulse'])

            k=k+1

    # if(k==0):

    #     return 0

    # else:

    return result,k

   



 

diagnosisName=str(input())

doctorId=int(input())

print(pulseRate(diagnosisName,doctorId))

ADD COMMENTlink 10 weeks ago rameh • 0

Login before adding your answer.

Similar Posts
Loading Similar Posts