Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit c07aa53
Author: annemarie.goldmann <annemarie.goldmann@steszgal.at>
Date:   Tue Dec 12 11:56:29 2023 +0100

    #-wip-samples

commit 090dee9
Author: dlatikay <latikaynen@loidl-consulting.at>
Date:   Tue Dec 12 09:52:07 2023 +0100

    # - WIP samples

commit f8aa66f
Author: annemarie.goldmann <annemarie.goldmann@steszgal.at>
Date:   Mon Dec 11 18:12:54 2023 +0100

    #-wip-samples added operation outcome and filter functions

commit 4c278ab
Author: annemarie.goldmann <annemarie.goldmann@steszgal.at>
Date:   Thu Nov 30 18:06:49 2023 +0100

    #-wip-samples test put patient with external id

commit f8814a0
Author: annemarie.goldmann <annemarie.goldmann@steszgal.at>
Date:   Thu Nov 30 15:37:01 2023 +0100

    #-wip-samples-ready

commit 8d05f9b
Author: annemarie.goldmann <annemarie.goldmann@steszgal.at>
Date:   Wed Nov 29 18:35:57 2023 +0100

    #-wip-samples-view order chains, etc

commit ced04c4
Author: annemarie.goldmann <annemarie.goldmann@steszgal.at>
Date:   Tue Nov 28 17:59:27 2023 +0100

    #-wip-samples-us015, 016, 019

commit 0528413
Author: annemarie.goldmann <annemarie.goldmann@steszgal.at>
Date:   Mon Nov 27 18:25:58 2023 +0100

    #-wip-samples-completed US for actor care

commit 1834a27
Author: annemarie.goldmann <annemarie.goldmann@steszgal.at>
Date:   Thu Nov 23 18:38:09 2023 +0100

    #-wip-samples use scaffold to connect multiple user stories

commit 2e8ae75
Author: annemarie.goldmann <annemarie.goldmann@steszgal.at>
Date:   Tue Nov 21 15:19:38 2023 +0100

    #-wip-samples fixes after rebase

commit 2409e90
Author: annemarie.goldmann <annemarie.goldmann@steszgal.at>
Date:   Thu Nov 16 14:17:41 2023 +0100

    #-wip-samples-dispense

commit 7273afb
Author: annemarie.goldmann <annemarie.goldmann@steszgal.at>
Date:   Wed Nov 15 17:26:34 2023 +0100

    #-wip-samples RequestOrchestration with new constraints

commit a42cdd3
Author: annemarie.goldmann <annemarie.goldmann@steszgal.at>
Date:   Tue Nov 7 17:43:11 2023 +0100

    #-wip-samples added tests for operations

commit 43fce47
Author: annemarie.goldmann <annemarie.goldmann@steszgal.at>
Date:   Wed Nov 1 13:59:15 2023 +0100

    #-wip-samples-test US006 delete RequestOrchestration

commit 12454bd
Author: annemarie.goldmann <annemarie.goldmann@steszgal.at>
Date:   Thu Oct 26 11:49:12 2023 +0200

    #-wip-samples- replaced endpoint LINCAOrder... by LINCAProposal...

commit 5f92403
Author: annemarie.goldmann <annemarie.goldmann@steszgal.at>
Date:   Mon Oct 16 18:32:04 2023 +0200

    #added DoseAndRate

commit 5c3f469
Author: annemarie.goldmann <annemarie.goldmann@steszgal.at>
Date:   Thu Oct 12 20:38:52 2023 +0200

    Samples, work in progress
  • Loading branch information
dlatikay committed Dec 12, 2023
1 parent 7d782c5 commit dff7d24
Show file tree
Hide file tree
Showing 35 changed files with 2,886 additions and 250 deletions.
22 changes: 19 additions & 3 deletions Lc.Linca.Sdk.Sample/LinkedCareSampleClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ internal static class LinkedCareSampleClient
/// <summary>
/// In SDK, this always points to the development system
/// </summary>
internal const string FhirServerBaseUrl = "https://fhir5-d.linkedcare.at";
//internal const string FhirServerBaseUrl = "https://localhost:8084";
//internal const string FhirServerBaseUrl = "https://fhir5-d.linkedcare.at";
internal const string FhirServerBaseUrl = "https://localhost:8084";

internal static CareInformationSystem CareInformationSystemScaffold = new();
internal static PractitionerInformationSystem PractitionerInformationSystemScaffold = new();
Expand All @@ -41,6 +41,7 @@ static int Main(string[] _)
{
do
{
PrintConnectedSequences();
var specToRun = SelectSpecToRun();
if (specToRun == null)
{
Expand Down Expand Up @@ -201,7 +202,7 @@ private static bool TestReauthentication(LincaConnection connection)
Console.SetCursorPosition(caretLeft, Console.CursorTop);
var selectedNumber = Console.ReadLine();
Console.Clear();
if (short.TryParse(selectedNumber, out var storyNumber) && storyNumber > 0 && storyNumber <= availableSpecs.Count)
if (short.TryParse(selectedNumber, out var storyNumber) && storyNumber >= 0 && storyNumber <= availableSpecs.Count)
{
return availableSpecs.FirstOrDefault(s => s.number == storyNumber).spec;
}
Expand All @@ -224,4 +225,19 @@ private static bool KeepGoing()

return false;
}

private static void PrintConnectedSequences()
{
Console.WriteLine("Aufeinander abgestimmte Sequenzen von [User Stories] und (Testzertifikaten):");
Console.WriteLine("[01](Pflege Immerdar) ->[11](Dr. Würm) ->[18](Apo 'Klappernder Storch)");
Console.WriteLine("[00](Pflege Immerdar) ->[02](Pflege Immerdar) ->[10](Dr. Kreuzotter)");
Console.WriteLine("[15](Dr. Würm) ->[08](Pflege Immerdar) ->[19](Apotheke 'Zum frühen Vogel') ->[08](Pflege Immerdar)");
Console.WriteLine("[03](Haus Vogelsang) ->[04](Haus Vogelsang) ->[12](Ordination Dr. Spitzmaus) ->[13](Dr. Spitzmaus) ->[17](Apo 'Zum frühen Vogel') ->[07](Haus Vogelsang)");
Console.WriteLine("[03](Haus Vogelsang) ->[14](Dr. Spitzmaus) ->[07](Haus Vogelsang)");
Console.WriteLine("[03](Haus Vogelsang) ->[09](Dr. Spitzmaus) ->[12](Dr. Spitzmaus) ->[13](Dr. Spitzmaus) ->[07](Haus Vogelsang) ->[16](Apo Zum frühen Vogel') ->[07](Haus Vogelsang)");
Console.WriteLine("[03](Haus Vogelsang) ->[06](Haus Vogelsang) ->[07](Haus Vogelsang)");
Console.WriteLine("[03](Haus Vogelsang) ->[04](Haus Vogelsang) ->[06](Haus Vogelsang) ->[07](Haus Vogelsang)");
Console.WriteLine("[03](Haus Vogelsang) ->[04](Haus Vogelsang) ->[05](Haus Vogelsang) ->[06](Haus Vogelsang) ->[07](Haus Vogelsang)");
Console.WriteLine("");
}
}
11 changes: 10 additions & 1 deletion Lc.Linca.Sdk.Sample/Scaffolds/ActorSoftwareScaffold.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,18 @@ internal class PseudoStore
public string ClientIdRenate { get; set; } = string.Empty;
public string ClientIdGuenter { get; set; } = string.Empty;
public string ClientIdPatrizia { get; set; } = string.Empty;
public string LcIdImmerdar { get; set; } = string.Empty;
public string LcIdImmerdar001 { get; set; } = string.Empty;
public string LcIdImmerdar002 { get; set; } = string.Empty;
public string LcIdVogelsang { get; set; } = string.Empty;
public string OrderProposalIdRenateAtKreuzotter { get; set; } = string.Empty;
public string OrderProposalIdRenateLasix { get; set; } = string.Empty;
public string OrderProposalIdGuenter { get; set; } = string.Empty;
public string OrderProposalIdGuenterGranpidam { get; set; } = string.Empty;
public string OrderProposalIdPatrizia { get; set; } = string.Empty;
public string UpdateOrderProposalGuenter { get; set; } = string.Empty;
public string CancelledOrderProposalPatricia { get; set; } = string.Empty;
public string PrescriptionWithChangesGuenter { get; set; } = string.Empty;
public string PrescriptionIdRenateLasix { get; set; } = string.Empty;
public string PrescriptionIdRenateLuxerm { get; set; } = string.Empty;
}
}
156 changes: 156 additions & 0 deletions Lc.Linca.Sdk.Sample/Specs/ActorCare/US000-InternalTestPutPatient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
/***********************************************************************************
* Project: Linked Care AP5
* Component: LINCA FHIR SDK and Demo Client
* Copyright: 2023 LOIDL Consulting & IT Services GmbH
* Authors: Annemarie Goldmann, Daniel Latikaynen
* Purpose: Sample code to test LINCA and template for client prototypes
* Licence: BSD 3-Clause
* ---------------------------------------------------------------------------------
* The Linked Care project is co-funded by the Austrian FFG
***********************************************************************************/

using Hl7.Fhir.Model;
using Hl7.Fhir.Support;
using Lc.Linca.Sdk.Client;
using Lc.Linca.Sdk.Scaffolds;
using System.Globalization;

namespace Lc.Linca.Sdk.Specs.ActorCare;

internal class US000_InternalTestPutPatient : Spec
{
public const string UserStory = @"
Caregivers can create patients with externally assigned ids by sending them with http put";

protected MedicationRequest medReq = new();

public US000_InternalTestPutPatient(LincaConnection conn) : base(conn)
{


Steps = new Step[]
{
new("Create client record with externally assigned id", CreateClientRecord),
new("Update client record", UpdateClientRecord)
};
}

/// <summary>
/// As an actor who is an order placer,
/// it is necessary to ensure that all patient records
/// which later occur in the order position(s), are present
/// as FHIR resources on the linked care server.
///
/// This is where an actual care information system
/// would fetch the client data from its database,
/// and convert it into a FHIR R5 resource
/// </summary>
private bool CreateClientRecord()
{
LinkedCareSampleClient.CareInformationSystemScaffold.PseudoDatabaseRetrieve();
var client = new CareInformationSystem.Client();
var patient = new Patient
{
Id = Guid.NewGuid().ToFhirId(),
BirthDate = DateTime.ParseExact(
client.DoB,
Constants.DobFormat,
CultureInfo.InvariantCulture
).ToFhirDate()
};

patient.Name.Add(new()
{
Family = client.Lastname,
Given = new[] { client.Firstname },
Text = client.Firstname + " " + client.Lastname
});

patient.Identifier.Add(new Identifier(
system: Constants.WellknownOidSocialInsuranceNr,
value: client.SocInsNumber
));

patient.Gender = AdministrativeGender.Female;
(var createdPatient, var canCue, var outcome) = LincaDataExchange.CreatePatient(Connection, patient);

if (canCue)
{
Console.WriteLine($"Client information with external id transmitted, id {createdPatient.Id}");

LinkedCareSampleClient.CareInformationSystemScaffold.Data.ClientIdRenate = createdPatient.Id;
LinkedCareSampleClient.CareInformationSystemScaffold.PseudoDatabaseStore();
}
else
{
Console.WriteLine($"Failed to transmit client information with external id");
}

if (outcome != null)
{
foreach (var item in outcome.Issue)
{
Console.WriteLine($"Outcome Issue Code: '{item.Details.Coding?.FirstOrDefault()?.Code}', Text: '{item.Details.Text}'");
}
}

return canCue;
}

private bool UpdateClientRecord()
{
LinkedCareSampleClient.CareInformationSystemScaffold.PseudoDatabaseRetrieve();
var client = new CareInformationSystem.Client();
var patient = new Patient
{
Id = LinkedCareSampleClient.CareInformationSystemScaffold.Data.ClientIdRenate,
BirthDate = DateTime.ParseExact(
client.DoB,
Constants.DobFormat,
CultureInfo.InvariantCulture
).ToFhirDate()
};

patient.Name.Add(new()
{
Family = client.Lastname,
Given = new[] { client.Firstname },
Text = client.Firstname + " " + client.Lastname
});

patient.Identifier.Add(new Identifier(
system: Constants.WellknownOidSocialInsuranceNr,
value: client.SocInsNumber
));

patient.Gender = AdministrativeGender.Other;

(var updatedPatient, var canCue, var outcome) = LincaDataExchange.CreatePatient(Connection, patient);

if (canCue)
{
if (updatedPatient.Id == patient.Id)
{
Console.WriteLine($"Updated client, id {updatedPatient.Id}");
}
else
{
Console.WriteLine($"Client update information for id {patient.Id} transmitted, but the server assigned the id {updatedPatient.Id}");
}
}
else
{
Console.WriteLine($"Failed to transmit client information");
}

if (outcome != null)
{
foreach (var item in outcome.Issue)
{
Console.WriteLine($"Outcome Issue Code: '{item.Details.Coding?.FirstOrDefault()?.Code}', Text: '{item.Details.Text}'");
}
}

return canCue;
}
}
32 changes: 27 additions & 5 deletions Lc.Linca.Sdk.Sample/Specs/ActorCare/US001-MedOrderSingleArticle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ private bool CreateClientRecord()
));

patient.Gender = AdministrativeGender.Female;
(var createdPatient, var canCue) = LincaDataExchange.CreatePatient(Connection, patient);

(var createdPatient, var canCue, var outcome) = LincaDataExchange.CreatePatient(Connection, patient);

if(canCue)
{
Expand All @@ -87,7 +88,15 @@ private bool CreateClientRecord()
}
else
{
Console.WriteLine("Failed to transmit client information");
Console.WriteLine($"Failed to transmit client information");
}

if (outcome != null)
{
foreach (var item in outcome.Issue)
{
Console.WriteLine($"Outcome Issue Code: '{item.Details.Coding?.FirstOrDefault()?.Code}', Text: '{item.Details.Text}'");
}
}

return canCue;
Expand Down Expand Up @@ -161,7 +170,7 @@ private bool CreateRequestOrchestrationRecord ()
RequestOrchestration ro = new()
{
Status = RequestStatus.Active, // REQUIRED
Intent = RequestIntent.Proposal, // REQUIRED
Intent = RequestIntent.Proposal, // REQUIRED
Subject = new ResourceReference() // REQUIRED
{
Identifier = new()
Expand All @@ -177,24 +186,37 @@ private bool CreateRequestOrchestrationRecord ()

var action = new RequestOrchestration.ActionComponent()
{
//Type =
Type = new(),
Resource = new ResourceReference($"#{medReq.Id}")
};

action.Type.Coding.Add(new() { Code = "create" });

ro.Action.Add( action );


(var createdRO, var canCue) = LincaDataExchange.CreateRequestOrchestration(Connection, ro);
(var createdRO, var canCue, var outcome) = LincaDataExchange.CreateRequestOrchestration(Connection, ro);

if (canCue)
{
LinkedCareSampleClient.CareInformationSystemScaffold.Data.LcIdImmerdar001 = createdRO.Id;
LinkedCareSampleClient.CareInformationSystemScaffold.PseudoDatabaseStore();

Console.WriteLine($"Linca Request Orchestration transmitted, id {createdRO.Id}");
}
else
{
Console.WriteLine($"Failed to transmit Linca Request Orchestration");
}

if (outcome != null)
{
foreach (var item in outcome.Issue)
{
Console.WriteLine($"Outcome Issue Code: '{item.Details.Coding?.FirstOrDefault()?.Code}', Text: '{item.Details.Text}'");
}
}

return canCue;
}
}
29 changes: 21 additions & 8 deletions Lc.Linca.Sdk.Sample/Specs/ActorCare/US002-MedOrderRepeat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ record of Renate Rüssel-Olifant.
public US002_MedOrderRepeat(LincaConnection conn) : base(conn)
{
Steps = new Step[]
{
{
new("Place order with pharmacy specified", CreateRequestOrchestrationRecord)
};
};
}

private bool CreateRequestOrchestrationRecord()
Expand Down Expand Up @@ -69,23 +69,36 @@ private bool CreateRequestOrchestrationRecord()

var action = new RequestOrchestration.ActionComponent()
{
// Type =
Type = new(),
Resource = new ResourceReference($"#{medReq.Id}")
};

action.Type.Coding.Add(new() { Code = "create" });

ro.Action.Add(action);

(var createdRO, var canCue) = LincaDataExchange.CreateRequestOrchestration(Connection, ro);
(var createdRO, var canCue, var outcome) = LincaDataExchange.CreateRequestOrchestration(Connection, ro);

if (canCue)
{
LinkedCareSampleClient.CareInformationSystemScaffold.Data.LcIdImmerdar002 = createdRO.Id;
LinkedCareSampleClient.CareInformationSystemScaffold.PseudoDatabaseStore();

Console.WriteLine($"Linca Request Orchestration transmitted, id {createdRO.Id}");
}
else
{
Console.WriteLine($"Failed to transmit Linca Request Orchestration");
}

if (outcome != null)
{
foreach (var item in outcome.Issue)
{
Console.WriteLine($"Outcome Issue Code: '{item.Details.Coding?.FirstOrDefault()?.Code}', Text: '{item.Details.Text}'");
}
}

return canCue;
}
else
Expand All @@ -98,13 +111,13 @@ private bool CreateRequestOrchestrationRecord()

private void PrepareOrderMedicationRequest(string patientId)
{
medReq.Id = Guid.NewGuid().ToFhirId();
medReq.Id = Guid.NewGuid().ToFhirId(); // REQUIRED
medReq.Status = MedicationRequest.MedicationrequestStatus.Unknown; // REQUIRED
medReq.Intent = MedicationRequest.MedicationRequestIntent.Proposal; // REQUIRED
medReq.Subject = new ResourceReference() // REQUIRED
{
// relative path to Linca Fhir patient resource
Reference = $"HL7ATCorePatient/{patientId}"
Reference = $"HL7ATCorePatient/{LinkedCareSampleClient.CareInformationSystemScaffold.Data.ClientIdRenate}"
};

medReq.Medication = new()
Expand Down Expand Up @@ -147,10 +160,10 @@ private void PrepareOrderMedicationRequest(string patientId)
{
Identifier = new()
{
Value = "2.999.40.0.34.3.1.1", // OID of designated practitioner
Value = "2.999.40.0.34.3.1.2", // OID of designated practitioner
System = "urn:oid:1.2.40.0.34.5.2" // Code-System: eHVD
},
Display = "Dr. Wibke Würm" // optional
Display = "Dr. Kunibert Kreuzotter" // optional
});

medReq.DispenseRequest = new()
Expand Down
Loading

0 comments on commit dff7d24

Please sign in to comment.