Skip to content

Commit

Permalink
TMH | Zafar, Veena | Resolves codacy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Veena-tw committed Aug 28, 2020
1 parent f055fcc commit c9b5ee3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
43 changes: 21 additions & 22 deletions src/In.ProjectEKA.TMHHip/DataFlow/Collect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,30 +169,32 @@ private static async Task<Option<DiagnosticReportResponse>> FetchDiagnosticRepor
private static async Task<Option<DiagnosticReportResponse>> FetchDiagnosticReportPdfsData(
DataRequest dataRequest, List<DiagnosticReportAsPdf> diagnosticReportAsPdfs, string patientName)
{
LogDataRequest(dataRequest);
var uuid = Uuid.Generate().Value;
var id = uuid.Split(":").Last();
var representations = new List<DiagnosticReportPdfRepresentation>();
foreach (var reportAsPdf in diagnosticReportAsPdfs)
{
var pdfText = new Text("additional",
"<div xmlns=\"http://www.w3.org/1999/xhtml\">Unstructured data can be sent here</div>");
var code = new Code(reportAsPdf.ReportText);
var subject = new Subject(patientName);
var performer = new Performer(reportAsPdf.Performer);
var presentedForm = new PresentedForm(reportAsPdf.ContentType, PdfToBase64(reportAsPdf.ReportUrl),
reportAsPdf.ReportTitle);
var pdfResource = new DiagnosticReportPDFResource(HiType.DiagnosticReport, id, pdfText, "final", code,
subject, reportAsPdf.EffectiveDateTime, reportAsPdf.Issued, new List<Performer> {performer},
new List<PresentedForm> {presentedForm}, reportAsPdf.ReportConclusion);
representations.Add(new DiagnosticReportPdfRepresentation(uuid, pdfResource));
}
var representations = (from reportAsPdf in diagnosticReportAsPdfs
where WithinRange(dataRequest.DateRange, reportAsPdf.EffectiveDateTime)
let pdfText =
new Text("additional",
"<div xmlns=\"http://www.w3.org/1999/xhtml\">Unstructured data can be sent here</div>")
let code = new Code(reportAsPdf.ReportText)
let subject = new Subject(patientName)
let performer = new Performer(reportAsPdf.Performer)
let presentedForm =
new PresentedForm(reportAsPdf.ContentType, PdfToBase64(reportAsPdf.ReportUrl),
reportAsPdf.ReportTitle)
select new DiagnosticReportPDFResource(HiType.DiagnosticReport, id, pdfText, "final", code, subject,
reportAsPdf.EffectiveDateTime, reportAsPdf.Issued, new List<Performer> {performer},
new List<PresentedForm> {presentedForm}, reportAsPdf.ReportConclusion)
into pdfResource
select new DiagnosticReportPdfRepresentation(uuid, pdfResource)).ToList();

if (!representations.Any())
{
return Option.None<DiagnosticReportResponse>();
}

var diagnosticReportResponse = new DiagnosticReportResponse()
var diagnosticReportResponse = new DiagnosticReportResponse
{
Entry = representations,
Id = Uuid.Generate().Value.Split(":").Last(),
Expand Down Expand Up @@ -649,12 +651,9 @@ private static void LogDataRequest(DataRequest request)

private static string PdfToBase64(string pdfUrl)
{
string base64String;
using (WebClient client = new WebClient())
{
var bytes = client.DownloadData(pdfUrl);
base64String = Convert.ToBase64String(bytes);
}
using var webClient = new WebClient();
var bytes = webClient.DownloadData(pdfUrl);
var base64String = Convert.ToBase64String(bytes);

return base64String;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class PayloadType
{
private string Text { get; set; }

private PayloadType(string text)
public PayloadType(string text)
{
Text = text;
}
Expand Down
2 changes: 1 addition & 1 deletion test/In.ProjectEKA.TMHHipTest/DataFlow/CollectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private async void ReturnDiagnosticReportAsPdf()
var diagReports = new List<DiagnosticReportAsPdf> {diagReport};

var patientDataResponse =
JsonConvert.SerializeObject(new PatientData() {DiagnosticReportAsPdf = diagReports});
JsonConvert.SerializeObject(new PatientData {DiagnosticReportAsPdf = diagReports});

var patient = new Patient
{
Expand Down

0 comments on commit c9b5ee3

Please sign in to comment.