Skip to content

Commit

Permalink
Add Demis-ID to report as QR code (#167)
Browse files Browse the repository at this point in the history
* Add Demis-ID to Meningo reports
* Add Demis-ID to Haemophilus reports
  • Loading branch information
markusrt authored Oct 1, 2024
1 parent 2353038 commit fb40a9d
Show file tree
Hide file tree
Showing 42 changed files with 10,464 additions and 5 deletions.
3 changes: 2 additions & 1 deletion HaemophilusWeb/App_Start/BundleConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public static void RegisterBundles(BundleCollection bundles)
"~/Scripts/respond.js"));

bundles.Add(new ScriptBundle("~/bundles/site").Include(
"~/Scripts/site.js"));
"~/Scripts/site.js",
"~/Scripts/imagemodule.js"));

bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
Expand Down
5 changes: 5 additions & 0 deletions HaemophilusWeb/Automapper/IsolateViewModelMappingAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public void Process(Isolate source, IsolateViewModel destination)
destination.Comment = interpretationResult.Comment;
destination.Announcement = ConfigurationManager.AppSettings["Announcement"];

if (!string.IsNullOrEmpty(source.Sending.DemisId))
{
destination.DemisIdQrImageUrl = GenerateQrImageUrl(source.Sending.DemisId);
}

var sender = db.Senders.Find(source.Sending.SenderId);
destination.SenderName = sender.Name;
destination.SenderDepartment = sender.Department ?? string.Empty;
Expand Down
21 changes: 21 additions & 0 deletions HaemophilusWeb/Automapper/IsolateViewModelMappingActionBase.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using HaemophilusWeb.Models;
using HaemophilusWeb.Utils;
using HaemophilusWeb.ViewModels;
using QRCoder;

namespace HaemophilusWeb.Automapper
{
Expand Down Expand Up @@ -124,5 +128,22 @@ internal static void ParseAndMapLaboratoryNumber(IsolateCommon source, IsolateCo
destination.YearlySequentialIsolateNumber = yearlySequentialIsolateNumber;
}

protected string GenerateQrImageUrl(string sendingDemisId)
{
var qrGenerator = new QRCodeGenerator();
var qrCodeData = qrGenerator.CreateQrCode(sendingDemisId, QRCodeGenerator.ECCLevel.Q);
var qrCode = new QRCode(qrCodeData);
var qrCodeAsBitmap = qrCode.GetGraphic(10);
var base64String = Convert.ToBase64String(ImageToByteArray(qrCodeAsBitmap));
var qrImageUrl = "data:image/png;base64," + base64String;
return qrImageUrl;
}

private byte[] ImageToByteArray(Image image)
{
using var memoryStream = new MemoryStream();
image.Save(memoryStream, ImageFormat.Png);
return memoryStream.ToArray();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using System.Configuration;
using System;
using System.Configuration;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Net;
using AutoMapper;
using HaemophilusWeb.Domain;
Expand All @@ -7,6 +11,7 @@
using HaemophilusWeb.Utils;
using HaemophilusWeb.ViewModels;
using HaemophilusWeb.Views.Utils;
using QRCoder;

namespace HaemophilusWeb.Automapper
{
Expand Down Expand Up @@ -48,6 +53,11 @@ public void Process(MeningoIsolate source, MeningoIsolateViewModel destination)
destination.Comment = isolateInterpretation.Result.Comment;
destination.Announcement = ConfigurationManager.AppSettings["Announcement"];

if (!string.IsNullOrEmpty(source.Sending.DemisId))
{
destination.DemisIdQrImageUrl = GenerateQrImageUrl(source.Sending.DemisId);
}

var sender = db.Senders.Find(source.Sending.SenderId);
if (sender != null) // special case for Meningo as old senders were not imported
{
Expand Down
6 changes: 6 additions & 0 deletions HaemophilusWeb/HaemophilusWeb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@
<Reference Include="OAuth, Version=1.0.0.0, Culture=neutral, PublicKeyToken=75b3c62967edc2a2, processorArchitecture=MSIL">
<HintPath>..\packages\OAuth.1.0.3\lib\net40\OAuth.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="QRCoder, Version=1.6.0.0, Culture=neutral, PublicKeyToken=c4ed5b9ae8358a28, processorArchitecture=MSIL">
<HintPath>..\packages\QRCoder.1.6.0\lib\net40\QRCoder.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Text, Version=4.5.14.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ServiceStack.Text.4.5.14\lib\net45\ServiceStack.Text.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -990,6 +995,7 @@
<Content Include="ReportTemplates\Kein Wachstum v1.docx" />
<Content Include="ReportTemplates\Nicht Invasiv v1.docx" />
<None Include="Scripts\jquery-3.7.1.intellisense.js" />
<Content Include="Scripts\imagemodule.js" />
<Content Include="Scripts\jquery-3.7.1.js" />
<Content Include="Scripts\jquery-3.7.1.min.js" />
<Content Include="Scripts\jquery-3.7.1.slim.js" />
Expand Down
Binary file modified HaemophilusWeb/ReportTemplates/BLNAR v10.docx
Binary file not shown.
Binary file modified HaemophilusWeb/ReportTemplates/BLNAS v10.docx
Binary file not shown.
Binary file modified HaemophilusWeb/ReportTemplates/BLPACR v10.docx
Binary file not shown.
Binary file modified HaemophilusWeb/ReportTemplates/BLPACS v10.docx
Binary file not shown.
Binary file modified HaemophilusWeb/ReportTemplates/Fax - BLNAR v10.docx
Binary file not shown.
Binary file modified HaemophilusWeb/ReportTemplates/Fax - BLNAS v10.docx
Binary file not shown.
Binary file modified HaemophilusWeb/ReportTemplates/Fax - BLPACR v10.docx
Binary file not shown.
Binary file modified HaemophilusWeb/ReportTemplates/Fax - BLPACS v10.docx
Binary file not shown.
Binary file modified HaemophilusWeb/ReportTemplates/Fax - Kein Wachstum v1.docx
Binary file not shown.
Binary file modified HaemophilusWeb/ReportTemplates/Fax - Nicht Invasiv v1.docx
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified HaemophilusWeb/ReportTemplates/Fax - Teilbefund - Serotyp v4.docx
Binary file not shown.
Binary file modified HaemophilusWeb/ReportTemplates/Kein Wachstum v1.docx
Binary file not shown.
Binary file modified HaemophilusWeb/ReportTemplates/Meningo/Fax - Nativmaterial v2.docx
Binary file not shown.
Binary file modified HaemophilusWeb/ReportTemplates/Meningo/Fax - Teilbefund - v2.docx
Binary file not shown.
Binary file not shown.
Binary file modified HaemophilusWeb/ReportTemplates/Meningo/Nativmaterial v2.docx
Binary file not shown.
Binary file modified HaemophilusWeb/ReportTemplates/Meningo/Untersuchungsbefund v2.docx
Binary file not shown.
Binary file modified HaemophilusWeb/ReportTemplates/Nicht Invasiv v1.docx
Binary file not shown.
Binary file modified HaemophilusWeb/ReportTemplates/Sonstige - Ampi-S Cipro-R v3.docx
Binary file not shown.
Binary file modified HaemophilusWeb/ReportTemplates/Sonstige - Ampi-S Imi-R v3.docx
Binary file not shown.
Binary file modified HaemophilusWeb/ReportTemplates/Sonstige - Kein Haemophilus v3.docx
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified HaemophilusWeb/ReportTemplates/includes/Seite 1 - Kurz.docx
Binary file not shown.
Binary file modified HaemophilusWeb/ReportTemplates/includes/Seite 1.docx
Binary file not shown.
Loading

0 comments on commit fb40a9d

Please sign in to comment.