-
Notifications
You must be signed in to change notification settings - Fork 0
/
US014-PrescribeSupplementaryArticle.cs
252 lines (211 loc) · 10.2 KB
/
US014-PrescribeSupplementaryArticle.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
/***********************************************************************************
* 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.Model.Extensions;
using Lc.Linca.Sdk.Client;
namespace Lc.Linca.Sdk.Specs.ActorDoctor;
internal class US014_PrescribeSupplementaryArticle : Spec
{
public const string UserStory = @"
Practitioner Dr. Silvia Spitzmaus is responsible for the LINCA registered care giver client Günter Gürtelthier.
She has received a LINCA order position requesting medication prescription for him.
She decides that an additional medication is needed for Günter Gürtelthier.
Hence, she creates and submits an additionally prescribed position referring to the LINCA order number
and her software will send that to the LINCA server,
and the ordering care giver organization Haus Vogelsang will be informed that the order has been extended with an additional position,
and that does not change anything about the fact that Dr. Spitzmaus cannot read other positions of that same order where she is not the designated practitioner";
MedicationRequest prescription = new();
MedicationRequest adhoc = new();
public US014_PrescribeSupplementaryArticle(LincaConnection conn) : base(conn)
{
Steps = new Step[]
{
new ("Create one PrescriptionMedicationRequest for a proposal and in addition one adhoc-prescription", CreateAdhocPrescription)
};
}
private bool CreateAdhocPrescription()
{
LinkedCareSampleClient.CareInformationSystemScaffold.PseudoDatabaseRetrieve();
(Bundle orders, bool received) = LincaDataExchange.GetProposalsToPrescribe(Connection);
if (received)
{
List<MedicationRequest> proposals = BundleHelper.FilterProposalsToPrescribe(orders);
MedicationRequest? proposal = proposals.Find(
x =>
x.Subject.Reference.Contains($"{LinkedCareSampleClient.CareInformationSystemScaffold.Data.ClientIdGuenter}")
&& x.Medication.Concept.Coding.First().Display.Contains("Granpidam")
);
if (proposal != null)
{
LinkedCareSampleClient.CareInformationSystemScaffold.Data.OrderProposalIdGuenterGranpidam = proposal.Id;
}
else
{
Console.WriteLine($"Failed to receive Linca ProposalMedicationRequest for Guenter");
return false;
}
LinkedCareSampleClient.CareInformationSystemScaffold.PseudoDatabaseStore();
/******* Create prescription for proposal ******/
prescription.BasedOn.Add(new ResourceReference()
{
Reference = $"LINCAProposalMedicationRequest/{LinkedCareSampleClient.CareInformationSystemScaffold.Data.OrderProposalIdGuenterGranpidam}"
});
prescription.Status = MedicationRequest.MedicationrequestStatus.Active; // REQUIRED
prescription.Intent = MedicationRequest.MedicationRequestIntent.Order; // REQUIRED
prescription.Subject = new ResourceReference() // REQUIRED
{
Reference = $"HL7ATCorePatient/{LinkedCareSampleClient.CareInformationSystemScaffold.Data.ClientIdGuenter}" // relative path to Linca Fhir patient resource, copy from order
};
prescription.SupportingInformation = proposal.SupportingInformation;
prescription.Medication = new()
{
Concept = new()
{
Coding = new()
{
new Coding()
{
Code = "4460951",
System = "https://termgit.elga.gv.at/CodeSystem/asp-liste",
Display = "Granpidam 20 mg Filmtabletten"
}
}
}
};
prescription.DosageInstruction.Add(new Dosage()
{
Text = "1-0-1-0"
});
// prescription.InformationSource.Add(new ResourceReference() // will be copied from reference in basedOn
// prescription.Requester = new ResourceReference() //will be copied from reference in basedOn
// prescription.DispenseRequest.Dispenser // will be copied from reference in basedOn, if available
prescription.Performer.Add(new ResourceReference() // REQUIRED, cardinality 1..1 in LINCA
{
Identifier = new()
{
Value = "2.999.40.0.34.3.1.3", // OID of designated practitioner
System = "urn:ietf:rfc:3986" // Code-System: eHVD
},
Display = "Dr. Silvia Spitzmaus" // optional
});
prescription.DispenseRequest = new()
{
Dispenser = new()
{
Identifier = new()
{
Value = "2.999.40.0.34.5.1.2", // OID of designated pharmacy
System = "urn:ietf:rfc:3986" // Code-System: eHVD
},
Display = "Apotheke 'Zum frühen Vogel'"
},
Quantity = new() { Value = 1 }
};
prescription.Identifier.Add(new Identifier()
{
Value = "CVF123ER12VV",
System = "urn:oid:1.2.40.0.10.1.4.3.4.2.1" // OID: eMed-Id
});
prescription.GroupIdentifier = new()
{
Value = "1A2B3C4D5E6F",
System = "urn:oid:1.2.40.0.10.1.4.3.3" // OID: Rezeptnummer
};
/****** Create Adhoc prescription ******/
adhoc.Status = MedicationRequest.MedicationrequestStatus.Active; // REQUIRED
adhoc.Intent = MedicationRequest.MedicationRequestIntent.OriginalOrder; // REQUIRED
adhoc.Subject = new ResourceReference() // REQUIRED
{
Reference = $"HL7ATCorePatient/{LinkedCareSampleClient.CareInformationSystemScaffold.Data.ClientIdGuenter}" // relative path to Linca Fhir patient resource, copy from order
};
adhoc.SupportingInformation = proposal.SupportingInformation;
adhoc.Medication = new()
{
Concept = new()
{
Coding = new()
{
new Coding()
{
Code = "1292648",
System = "https://termgit.elga.gv.at/CodeSystem/asp-liste",
Display = "Pantoloc 40 mg Filmtabletten"
}
}
}
};
adhoc.DosageInstruction.Add(new Dosage()
{
Text = "1-0-1-0"
});
adhoc.InformationSource.Add(new ResourceReference() // in adhoc prescriptions the informationSource is the prescribing practitioner
{
Identifier = new()
{
Value = "2.999.40.0.34.3.1.3", // OID of designated practitioner
System = "urn:ietf:rfc:3986" // Code-System: eHVD
},
Display = "Dr. Silvia Spitzmaus" // optional
});
adhoc.Performer.Add(new ResourceReference() // REQUIRED, cardinality 1..1 in LINCA
{
Identifier = new()
{
Value = "2.999.40.0.34.3.1.3", // OID of designated practitioner
System = "urn:ietf:rfc:3986" // Code-System: eHVD
},
Display = "Dr. Silvia Spitzmaus" // optional
});
adhoc.Identifier.Add(new Identifier()
{
Value = "CVF123ER12VV",
System = "urn:oid:1.2.40.0.10.1.4.3.4.2.1" // OID: eMed-Id
});
adhoc.GroupIdentifier = new()
{
Value = "1A2B3C4D5E6F",
System = "urn:oid:1.2.40.0.10.1.4.3.3" // OID: Rezeptnummer
};
adhoc.DispenseRequest = new() { Quantity = new() { Value = 1 } };
/***** Add both to one Bundle ******/
Bundle prescriptions = new()
{
Type = Bundle.BundleType.Transaction,
Entry = new()
};
prescriptions.AddResourceEntry(prescription, $"{Connection.ServerBaseUrl}/{LincaEndpoints.LINCAPrescriptionMedicationRequest}");
prescriptions.AddResourceEntry(adhoc, $"{Connection.ServerBaseUrl}/{LincaEndpoints.LINCAPrescriptionMedicationRequest}");
(Bundle results, var canCue, var outcome) = LincaDataExchange.CreatePrescriptionBundle(Connection, prescriptions);
if (canCue)
{
Console.WriteLine($"Linca PrescriptionMedicationRequestBundle transmitted, created Linca PrescriptionMedicationRequests");
BundleHelper.ShowOrderChains(results);
}
else
{
Console.WriteLine($"Failed to transmit Linca PrescriptionMedicationRequest");
}
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
{
Console.WriteLine($"Failed to receive Linca ProposalMedicationRequest for Guenter");
return false;
}
}
}