Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New API] : ChatBot API #246

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions New_APIs/A_Z_Medicine_API_For_INDIA/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Medicine API for India

## Installation

To use this program, you need to have Node.js installed. Then, install the required `express` library by running:

```sh
npm i express
```

## Method to use the API

1. Run the index.mjs file using the following command:
```sh
node index.mjs
```

OR

```sh
nodemon index.mjs
```

2. Use the enpoints to get your desired service.

3. Endpoint 1 - /searchByName
To get the data of the medicine with the following name

GET - http://localhost:80/searchByName?name=(Enter Medicine Name)

Query Parameter => name

eg - name = Zaling Plus Tablet CR

```bash

{
"result": [
{
"id": 249154,
"name": "Zaling Plus Tablet CR",
"price": 165,
"Is_discontinued": "FALSE",
"manufacturer_name": "Mitis Biomedics Ltd",
"type": "allopathy",
"pack_size_label": "strip of 10 tablet cr",
"short_composition1": "Paroxetine (12.5mg) ",
"short_composition2": " Clonazepam (0.5mg)"
}
]
}

```

4. Endpoint 2 - /searchByManufacturer
To get the data of the medicine with the following manufacturer's name

GET - http://localhost:80/searchByManufacturer?manufacturer=(Enter Manufacturer Name)

Query Parameter => manufacturer

eg - manufacturer = Mitis Biomedics Ltd

```bash

{
"result": [
{
"id": 249154,
"name": "Zaling Plus Tablet CR",
"price": 165,
"Is_discontinued": "FALSE",
"manufacturer_name": "Mitis Biomedics Ltd",
"type": "allopathy",
"pack_size_label": "strip of 10 tablet cr",
"short_composition1": "Paroxetine (12.5mg) ",
"short_composition2": " Clonazepam (0.5mg)"
}
]
}

```

5. Endpoint 3 - /AllDiscontinued
To get the data of the medicines which are discontinued

GET - http://localhost:80/AllDiscontinued

6. Endpoint 4 - /searchByPrice
To get the data of all the medicines with the following price

GET - http://localhost:80/searchByPrice?price=(Enter the price)

Query Parameter => price

eg - price = 90

7. Endpoint 5 - /searchByPriceUnder
To get the data of all the medicines under the following price

GET - http://localhost:80/searchByPriceUnder?price=(Enter the price)

Query Parameter => price

eg - price = 90

8. Endpoint 6 - /searchByPriceAbove
To get the data of all the medicines above the following price

GET - http://localhost:80/searchByPriceAbove?price=(Enter the price)

Query Parameter => price

eg - price = 90

3 changes: 3 additions & 0 deletions New_APIs/A_Z_Medicine_API_For_INDIA/data.mjs

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions New_APIs/A_Z_Medicine_API_For_INDIA/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import express from 'express'
import router from './routes.mjs';
const app = express();
app.use(express.json());
app.use(router);
const PORT = process.env.PORT||80;
app.listen(PORT,()=>{
console.log("Running on port "+PORT);
})
43 changes: 43 additions & 0 deletions New_APIs/A_Z_Medicine_API_For_INDIA/middleware.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module.exports={
searchByNameMiddleware:function(request,response,next){
const {query} = request;
if(!query){
return response.status(400).send({msg:"name field query is required"});
}else{
const name = query.name;
console.log(name);
if(!(typeof name == "string")|| name.length==0){
return response.status(400).send({msg:"Invalid field value"});
}
query.name = name.toLocaleLowerCase().trim().replaceAll(" ","");
}
next();
},
searchByManufacturerMiddleware:function(request,response,next){
const {query} = request;
if(!query){
return response.status(400).send({msg:"manufacturer field query is required"});
}else{
const manufacturer = query.manufacturer;
console.log(manufacturer);
if(!(typeof manufacturer == "string")|| manufacturer.length==0){
return response.status(400).send({msg:"Invalid field value"});
}
query.manufacturer = manufacturer.toLocaleLowerCase().trim().replaceAll(" ","");
}
next();
},
searchByPriceMiddleware:function(request,response,next){
const {query} = request;
if(!query){
return response.status(400).send({msg:"price field query is required"});
}else{
const price = query.price;
console.log(price);
if(!(typeof price == "string")|| price.length==0){
return response.status(400).send({msg:"Invalid field value"});
}
}
next();
}
}
Loading
Loading