Skip to content

Commit f1958a0

Browse files
author
Rustemsoft
committed
Add project files.
1 parent b126381 commit f1958a0

146 files changed

Lines changed: 95917 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Controllers/AnalyzeController.cs

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using System.Collections.Generic;
3+
using DDxApi.Models;
4+
using Microsoft.AspNetCore.Http;
5+
using Newtonsoft.Json;
6+
using System.Net.Http;
7+
using System;
8+
using System.Net.Http.Json;
9+
using System.Data;
10+
11+
namespace DDxHub.Controllers
12+
{
13+
public class AnalyzeController : Controller
14+
{
15+
// GET: AnalyzeController1
16+
public ActionResult Index()
17+
{
18+
Startup.itemAdded = false;
19+
Startup.itemGotten = false;
20+
21+
// Create a unique number as a client's fingerprinting identifier.
22+
// If you decide to use a constant like itemID = "1", the data
23+
// entered by your different clients can be intercepted and mixed.
24+
string itemID = Startup.uniqueMark;
25+
AddItem(itemID);
26+
27+
// To make async operation as a regular sync - wait for 45 seconds when new data item added to API
28+
for (var i = 1; i <= 90; i++)
29+
if (Startup.itemAdded)
30+
{
31+
GetItem(itemID);
32+
break;
33+
}
34+
else
35+
System.Threading.Thread.Sleep(500);
36+
// Break after 45 seconds attempting to add data item to DiagnosisApi Web API
37+
if (!Startup.itemAdded)
38+
{
39+
ViewBag.Message = "Something went wrong. Please Try Again Later.";
40+
return View();
41+
}
42+
43+
// To make async operation as a regular sync - wait for 45 seconds when new Disorders calculated
44+
for (var i = 1; i <= 90; i++)
45+
if (Startup.itemGotten)
46+
{
47+
List<Disorder> Diss = new List<Disorder>();
48+
foreach (DataRow row in Startup.tblAllDisorders.Rows)
49+
{
50+
Disorder dis = new Disorder();
51+
dis.Id = Convert.ToInt32(row["id"]);
52+
dis.Name = row["name"].ToString();
53+
Diss.Add(dis);
54+
}
55+
if (Diss.Count <= 0)
56+
ViewBag.Message = "Not enough data entered to make analysis...";
57+
return View(Diss);
58+
}
59+
else
60+
System.Threading.Thread.Sleep(500);
61+
// Break after 45 seconds attempting to get Disorders from DiagnosisApi Web API
62+
if (!Startup.itemGotten)
63+
ViewBag.Message = "Something went wrong. Please Try Again Later.";
64+
65+
return View();
66+
}
67+
68+
public async void AddItem(string itemID)
69+
{
70+
Startup.itemAdded = false;
71+
var strTests = JsonConvert.SerializeObject(Startup.tests);
72+
73+
var strSymptoms = JsonConvert.SerializeObject(Startup.symptoms);
74+
75+
var item = new DDxItem()
76+
{
77+
Id = itemID,
78+
Tests = strTests,
79+
Symptoms = strSymptoms
80+
};
81+
82+
using (var client = new HttpClient())
83+
{
84+
client.BaseAddress = new Uri(Startup.baseAddress + Startup.AuthenticationID);
85+
//HTTP POST
86+
var response = await client.PostAsJsonAsync<DDxItem>("", item);
87+
if (response.IsSuccessStatusCode)
88+
Startup.itemAdded = true;
89+
}
90+
}
91+
92+
public async void GetItem(string itemID)
93+
{
94+
Startup.itemGotten = false;
95+
using (HttpClient client = new HttpClient())
96+
{
97+
// Build Url Base Address with AuthenticationID
98+
client.BaseAddress = new Uri(Startup.baseAddress + itemID + Startup.AuthenticationID);
99+
client.DefaultRequestHeaders.Accept.Clear();
100+
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
101+
102+
//HTTP GET
103+
HttpResponseMessage response = await client.GetAsync(client.BaseAddress);
104+
if (response.IsSuccessStatusCode)
105+
{
106+
var data = await response.Content.ReadAsStringAsync();
107+
Startup.tblAllDisorders = JsonConvert.DeserializeObject<DataTable>(data);
108+
Startup.itemGotten = true;
109+
}
110+
}
111+
}
112+
113+
// GET: AnalyzeController1/Details/5
114+
public ActionResult Details(int id)
115+
{
116+
return View();
117+
}
118+
119+
// GET: AnalyzeController1/Create
120+
public ActionResult Create()
121+
{
122+
return View();
123+
}
124+
125+
// POST: AnalyzeController1/Create
126+
[HttpPost]
127+
[ValidateAntiForgeryToken]
128+
public ActionResult Create(IFormCollection collection)
129+
{
130+
try
131+
{
132+
return RedirectToAction(nameof(Index));
133+
}
134+
catch
135+
{
136+
return View();
137+
}
138+
}
139+
140+
// GET: AnalyzeController1/Edit/5
141+
public ActionResult Edit(int id)
142+
{
143+
return View();
144+
}
145+
146+
// POST: AnalyzeController1/Edit/5
147+
[HttpPost]
148+
[ValidateAntiForgeryToken]
149+
public ActionResult Edit(int id, IFormCollection collection)
150+
{
151+
try
152+
{
153+
return RedirectToAction(nameof(Index));
154+
}
155+
catch
156+
{
157+
return View();
158+
}
159+
}
160+
161+
// GET: AnalyzeController1/Delete/5
162+
public ActionResult Delete(int id)
163+
{
164+
return View();
165+
}
166+
167+
// POST: AnalyzeController1/Delete/5
168+
[HttpPost]
169+
[ValidateAntiForgeryToken]
170+
public ActionResult Delete(int id, IFormCollection collection)
171+
{
172+
try
173+
{
174+
return RedirectToAction(nameof(Index));
175+
}
176+
catch
177+
{
178+
return View();
179+
}
180+
}
181+
}
182+
}

Controllers/DisorderController.cs

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
using DDxApi.Models;
2+
using Microsoft.AspNetCore.Http;
3+
using Microsoft.AspNetCore.Mvc;
4+
using Newtonsoft.Json;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Data;
8+
9+
namespace DDxHub.Controllers
10+
{
11+
public class DisorderController : Controller
12+
{
13+
// GET: DisorderController
14+
public ActionResult Index(int id)
15+
{
16+
DisorderTestsSymptomsModel selectedDisorder = new DisorderTestsSymptomsModel();
17+
DataRow row = Startup.tblAllDisorders.Select("id = '" + id.ToString() + "'")[0];
18+
selectedDisorder.disorder = new Disorder()
19+
{
20+
Id = id,
21+
Name = row["Name"].ToString(),
22+
Description = row["Description"].ToString(),
23+
ICD9 = row["ICD9"].ToString(),
24+
ICD10 = row["ICD10"].ToString(),
25+
ICD11 = row["ICD11"].ToString(),
26+
Weight = Convert.ToInt32(row["Weight"]),
27+
Tests = row["Tests"].ToString(),
28+
Symptoms = row["Symptoms"].ToString()
29+
};
30+
31+
selectedDisorder.Tests = JsonConvert.DeserializeObject<List<TestGetType>>(selectedDisorder.disorder.Tests);
32+
selectedDisorder.Symptoms = JsonConvert.DeserializeObject<List<SymptomGetType>>(selectedDisorder.disorder.Symptoms);
33+
34+
return View(selectedDisorder);
35+
}
36+
37+
// GET: DisorderController/Details/5
38+
public ActionResult Details(int id)
39+
{
40+
return View();
41+
}
42+
43+
// GET: DisorderController/Create
44+
public ActionResult Create()
45+
{
46+
return View();
47+
}
48+
49+
// POST: DisorderController/Create
50+
[HttpPost]
51+
[ValidateAntiForgeryToken]
52+
public ActionResult Create(IFormCollection collection)
53+
{
54+
try
55+
{
56+
return RedirectToAction(nameof(Index));
57+
}
58+
catch
59+
{
60+
return View();
61+
}
62+
}
63+
64+
// GET: DisorderController/Edit/5
65+
public ActionResult Edit(int id)
66+
{
67+
return View();
68+
}
69+
70+
// POST: DisorderController/Edit/5
71+
[HttpPost]
72+
[ValidateAntiForgeryToken]
73+
public ActionResult Edit(int id, IFormCollection collection)
74+
{
75+
try
76+
{
77+
return RedirectToAction(nameof(Index));
78+
}
79+
catch
80+
{
81+
return View();
82+
}
83+
}
84+
85+
// GET: DisorderController/Delete/5
86+
public ActionResult Delete(int id)
87+
{
88+
return View();
89+
}
90+
91+
// POST: DisorderController/Delete/5
92+
[HttpPost]
93+
[ValidateAntiForgeryToken]
94+
public ActionResult Delete(int id, IFormCollection collection)
95+
{
96+
try
97+
{
98+
return RedirectToAction(nameof(Index));
99+
}
100+
catch
101+
{
102+
return View();
103+
}
104+
}
105+
}
106+
}

0 commit comments

Comments
 (0)