Skip to content

School-of-IoT/healthconnect-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

HealthConnect-Server

Base URL: https://healthconnect-server.onrender.com


API Endpoints

1. Request All Patient Data

GET - /<adminkey>

Description: Master Data
Parameter: Admin Key - accessible and regenerated by maintainer 
Response: All Patient data in JSON

Example - https://healthconnect-server.onrender.com/xxxxxxxxxxxxxxx

{
  "patient": [
    {
      "_id": "12j31k2j3lxxxxfe7d234d261",
      "Name": "txxxxxa",
      "Address": "xxxxxx",
      "Age": 21
    },
    {
      "_id": "6d3ff17xxxxfe72d421",
      "Name": "qxxxxxa",
      "Address": "xxxxxx",
      "Age": 24
    },
    {
      "_id": "54g656ff3xxxxfe7d234d2e661",
      "Name": "pAxxxxxa",
      "Address": "xxxxxx",
      "Age": 35
    }
  ]
}

2. Request Patient Data with 'id'

GET - /patient/<id>

Description: To get Patient data with 'id'
Parameter: ID - accessible by patient after login
Response: Patient data with particular ID

Example - https://healthconnect-server.onrender.com/patient/xxxxxxxxxxxxxxxxxxx

{
 "patient": 
 {
     "_id": "2cdgdxxxxxxxxxxxx83da84",
     "Name": "Elon Musk",
     "Address": "Texas",
     "Age": 24,
     "Ambulation": false
   }
}

3. Request Geo Locate API-Key

GET - /geo_locate/:user

Description: To get Geo-API key, used for third party API service
Parameter: user - track number of uses and auto-update API accordingly
Response: geo_api - secret key in JSON

Example - https://healthconnect-server.onrender.com/geo_locate/elon

{
  "geo_api": "93h4hd3xxxxxxwe9w382295a"
}

4. Request JIT token with 'user' & 'pass'

GET - /login?user=<user>&pass=<pass>

Description: To get JIT token with 'user' & 'pass'
Parameter: user & pass - original client key
Response: JIT Token

Example - https://healthconnect-server.onrender.com/login?user=elon&pass=xxxx

{
 "token":"56d67fb18d4c07e851c29896172797a75bbc32ec2b0f3931ad5521218c3131e4"
}

5. Request Patient information using JIT Token

GET - /data?user=<user>&token=<JIT_token>

Description: To get patient data with 'user' & 'token'
Parameter: user & token (generated by respose during login)
Response: Patient Information with provided username - authenticated by token

Example - https://healthconnect-server.onrender.com/data?user=elon&token=xxxxxxxxxxxxxxxx

{
 "patient": 
 {
     "_id": "2cdgdxxxxxxxxxxxx83da84",
     "Name": "Elon Musk",
     "Address": "Texas",
     "Age": 24,
     "Ambulation": false
   }
}

6. Create new Patient Account

POST - /patient/signup

Description: To create new patient - Using schema model, add new entry on mongoDB
Request: JSON Body with Patient Information
Response: Patient Created

Request Body -

{
  "newpatient": {
      "Name": "Axxxxxa",
      "Email": "abc@gog.com",
      "DOB": "1/12/1999"
      "Address": "xxxxxx",
      "Age": 21,
      "Ambulation": false,
      "BMI": 24.7,
      "Chills": false,
      "Contacts": "8xxxxxx828",
      "DBP": 74,
      "DecreasedMood": false,
      "FiO2": 78,
      "GeneralizedFatigue": false,
      "HeartRate": 65,
      "HistoryFever": "Yes",
      "RR": 20,
      "RecentHospitalStay": "05/04/2019",
      "SBP": 78,
      "SpO2": 95,
      "Temp": 37,
      "WeightGain": 5,
      "WeightLoss": 0,
      "BGroup": "O+",
      "Sex": "Male",
      "pass": "xxxx",
      "user": "elon"
  }
}

Response -

{
  "message": "Patient Created"
}

7. Update Patient data with 'ID'

PUT - /patient/update/<id>

Description: To Update a Patient Information
Parameter: ID - accessible by patient after login
Request: JSON Body with new data
Response: New Patient Information

Request Body -

{
    "patientData":{
        "SBP":	78
    }
}

Response -

{
  "patient": 
  {
      "_id": "2cdgdxxxxxxxxxxxx83da84",
      "Name": "Elon Musk",
      "Address": "Texas",
      "Age": 24,
      "SBP":	78
    }
}

8. Delete Patient Account with 'ID'

DELETE - /patient/delete/<id>

Description: To Update a Patient Information
Parameter: ID - accessible by patient after login

Response -

{
  "message": "Patient Deleted πŸ”ͺ"
}

9. Generate New Device Token

GET - /devtkn/create?user=<user>&pass=<pass>

Description: To Create New Device token
Parameter: user and pass for authentication

Response -

{
  "device_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 
  "time": "D/MM/YYYY HH:MM:SS AM/PM",
}

10. Request MQTT server Info (On Portal)

GET - /devtkn/portal?user=<user>&token=<session_token>

Description: To Request MQTT server Information
Parameter: user & session_token - session token is used as API key for the user (generated upon JIT Token)

Response -

{
  "mqttserver": "xxxxx.xxxxx.xxxxx", 
  "mqttUser": "xxxxxxxxxxx", 
  "mqttPass": "xxxxxxxxxxx"
}

11. Request MQTT server Info (On Device)

GET - /devtkn/device?user=<user>&token=<dev_token>

Description: To Request MQTT server Information
Parameter: user & dev_token - device token is used as API key for the user

Response -

{
  "mqttserver": "xxxxx.xxxxx.xxxxx", 
  "mqttUser": "xxxxxxxxxxx", 
  "mqttPass": "xxxxxxxxxxx"
}

12. Generate New Device Node

POST - /node/create?user=<user>&token=<dev_token>

Description:  To create NEW node device, node-xxxxxxx to be stored and used for data-exchange
Parameter: user & dev_token - device token is used as API key for the user
Request: JSON Body with new data
Response: Node Created message  

Request Body -

{
  "nodeData":
    {
      "devices":
        { 
          "node": "node-xxxxxx",
          "type": "xxxxxx",
          "attribute": "xxxx, xxxx", 
          "lastUp": "xx/xx/xx"
        }
    }
}

Response -

{
  "message": "Node Created πŸŽ†"
}

13. Get Device Node Information

GET - /node/device?user=<user>&token=<dev_token>&node=<device_id>

Description: To view node data
Parameter: user, dev_token & node device
Response: Node Information

Response -

{
  "node": "node-xxxxxxx",
  "attribute": "xxxx, xxxx"
}

14. Delete Device Node

DELETR - /node/delete?user=<user>&token=<dev_token>&node=<device_id>

Description: To delete Node Data
Parameter: user, dev_token & node device
Response: Node Deleted 

Response -

{
  "message": "Node Deleted πŸ”ͺ"
}