Skip to content

Commit f259395

Browse files
Pratigyan PattanayakPratigyan Pattanayak
authored andcommitted
Added Disease Diagnosis API in C# for Keploy Samples
Signed-off-by: Pratigyan Pattanayak <pratigyan1609@example.com>
1 parent 9006aed commit f259395

11 files changed

+381
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using System.Collections.Generic;
3+
4+
namespace DiseaseDiagnosisAPI.Controllers
5+
{
6+
[ApiController]
7+
[Route("[controller]")]
8+
public class DiseaseDiagnosisController : ControllerBase
9+
{
10+
[HttpPost]
11+
public IActionResult Diagnose([FromBody] SymptomInput input)
12+
{
13+
string result = GetDiagnosis(input.Symptoms);
14+
return Ok(new { diagnosis = result });
15+
}
16+
17+
private string GetDiagnosis(string? symptoms)
18+
{
19+
if (string.IsNullOrWhiteSpace(symptoms))
20+
return "No symptoms provided.";
21+
22+
symptoms = symptoms.ToLower();
23+
24+
if (symptoms.Contains("fever") && symptoms.Contains("cough"))
25+
return "Possibly Flu or COVID-19. Consult a physician.";
26+
else if (symptoms.Contains("headache") && symptoms.Contains("nausea"))
27+
return "Possibly Migraine.";
28+
else if (symptoms.Contains("abdominal pain"))
29+
return "Possibly Gastroenteritis.";
30+
else
31+
return "Symptoms not conclusive. Further testing needed.";
32+
}
33+
34+
}
35+
36+
public class SymptomInput
37+
{
38+
public string Symptoms { get; set; }
39+
}
40+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.6" />
11+
</ItemGroup>
12+
13+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@DiseaseDiagnosisAPI_HostAddress = http://localhost:5140
2+
3+
GET {{DiseaseDiagnosisAPI_HostAddress}}/weatherforecast/
4+
Accept: application/json
5+
6+
###
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
var builder = WebApplication.CreateBuilder(args);
2+
3+
// Add services to the container.
4+
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
5+
builder.Services.AddOpenApi();
6+
7+
var app = builder.Build();
8+
9+
// Configure the HTTP request pipeline.
10+
if (app.Environment.IsDevelopment())
11+
{
12+
app.MapOpenApi();
13+
}
14+
15+
app.UseHttpsRedirection();
16+
17+
var summaries = new[]
18+
{
19+
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
20+
};
21+
22+
app.MapGet("/weatherforecast", () =>
23+
{
24+
var forecast = Enumerable.Range(1, 5).Select(index =>
25+
new WeatherForecast
26+
(
27+
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
28+
Random.Shared.Next(-20, 55),
29+
summaries[Random.Shared.Next(summaries.Length)]
30+
))
31+
.ToArray();
32+
return forecast;
33+
})
34+
.WithName("GetWeatherForecast");
35+
36+
app.Run();
37+
38+
record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
39+
{
40+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
41+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"http": {
5+
"commandName": "Project",
6+
"dotnetRunMessages": true,
7+
"launchBrowser": false,
8+
"applicationUrl": "http://localhost:5140",
9+
"environmentVariables": {
10+
"ASPNETCORE_ENVIRONMENT": "Development"
11+
}
12+
},
13+
"https": {
14+
"commandName": "Project",
15+
"dotnetRunMessages": true,
16+
"launchBrowser": false,
17+
"applicationUrl": "https://localhost:7106;http://localhost:5140",
18+
"environmentVariables": {
19+
"ASPNETCORE_ENVIRONMENT": "Development"
20+
}
21+
}
22+
}
23+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
}
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
},
8+
"AllowedHosts": "*"
9+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"format": 1,
3+
"restore": {
4+
"C:\\Users\\KIIT\\Desktop\\keyploy api\\samples-csharp\\DiseaseDiagnosisAPI\\DiseaseDiagnosisAPI\\DiseaseDiagnosisAPI.csproj": {}
5+
},
6+
"projects": {
7+
"C:\\Users\\KIIT\\Desktop\\keyploy api\\samples-csharp\\DiseaseDiagnosisAPI\\DiseaseDiagnosisAPI\\DiseaseDiagnosisAPI.csproj": {
8+
"version": "1.0.0",
9+
"restore": {
10+
"projectUniqueName": "C:\\Users\\KIIT\\Desktop\\keyploy api\\samples-csharp\\DiseaseDiagnosisAPI\\DiseaseDiagnosisAPI\\DiseaseDiagnosisAPI.csproj",
11+
"projectName": "DiseaseDiagnosisAPI",
12+
"projectPath": "C:\\Users\\KIIT\\Desktop\\keyploy api\\samples-csharp\\DiseaseDiagnosisAPI\\DiseaseDiagnosisAPI\\DiseaseDiagnosisAPI.csproj",
13+
"packagesPath": "C:\\Users\\KIIT\\.nuget\\packages\\",
14+
"outputPath": "C:\\Users\\KIIT\\Desktop\\keyploy api\\samples-csharp\\DiseaseDiagnosisAPI\\DiseaseDiagnosisAPI\\obj\\",
15+
"projectStyle": "PackageReference",
16+
"configFilePaths": [
17+
"C:\\Users\\KIIT\\AppData\\Roaming\\NuGet\\NuGet.Config"
18+
],
19+
"originalTargetFrameworks": [
20+
"net9.0"
21+
],
22+
"sources": {
23+
"https://api.nuget.org/v3/index.json": {}
24+
},
25+
"frameworks": {
26+
"net9.0": {
27+
"targetAlias": "net9.0",
28+
"projectReferences": {}
29+
}
30+
},
31+
"warningProperties": {
32+
"warnAsError": [
33+
"NU1605"
34+
]
35+
},
36+
"restoreAuditProperties": {
37+
"enableAudit": "true",
38+
"auditLevel": "low",
39+
"auditMode": "direct"
40+
},
41+
"SdkAnalysisLevel": "9.0.300"
42+
},
43+
"frameworks": {
44+
"net9.0": {
45+
"targetAlias": "net9.0",
46+
"dependencies": {
47+
"Microsoft.AspNetCore.OpenApi": {
48+
"target": "Package",
49+
"version": "[9.0.6, )"
50+
}
51+
},
52+
"imports": [
53+
"net461",
54+
"net462",
55+
"net47",
56+
"net471",
57+
"net472",
58+
"net48",
59+
"net481"
60+
],
61+
"assetTargetFallback": true,
62+
"warn": true,
63+
"frameworkReferences": {
64+
"Microsoft.AspNetCore.App": {
65+
"privateAssets": "none"
66+
},
67+
"Microsoft.NETCore.App": {
68+
"privateAssets": "all"
69+
}
70+
},
71+
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\9.0.301/PortableRuntimeIdentifierGraph.json"
72+
}
73+
}
74+
}
75+
}
76+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="no"?>
2+
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
4+
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
5+
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
6+
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
7+
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
8+
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\KIIT\.nuget\packages\</NuGetPackageFolders>
9+
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
10+
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.14.0</NuGetToolVersion>
11+
</PropertyGroup>
12+
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
13+
<SourceRoot Include="C:\Users\KIIT\.nuget\packages\" />
14+
</ItemGroup>
15+
</Project>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="no"?>
2+
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />

0 commit comments

Comments
 (0)