Skip to content

Commit

Permalink
# US019 extended: FFP and RFC dispense
Browse files Browse the repository at this point in the history
  • Loading branch information
annemgold committed May 28, 2024
1 parent 156daea commit 811fb08
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ private bool CreatePrescriptionRecord()
System = "urn:oid:1.2.40.0.10.1.4.3.3" // OID: Rezeptnummer
};

prescription.DispenseRequest = new() { Quantity = new() { Value = 3 } };

Bundle prescriptions = new()
{
Type = Bundle.BundleType.Transaction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ private bool CreatePrescriptionRecord()
System = "urn:oid:1.2.40.0.10.1.4.3.3" // OID: Rezeptnummer
};

prescription.DispenseRequest = new() { Quantity = new() { Value = 2 } };

Bundle prescriptions = new()
{
Type = Bundle.BundleType.Transaction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ private bool CreatePrescriptionRecord()
System = "urn:oid:1.2.40.0.10.1.4.3.3" // OID: Rezeptnummer
};

prescription.DispenseRequest = new() { Quantity = new() { Value = 2 } };

(var postedPMR, var canCue, var outcome) = LincaDataExchange.CreatePrescriptionMedicationRequest(Connection, prescription);

if (canCue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ private bool CreateAdhocPrescription()
System = "urn:ietf:rfc:3986" // Code-System: eHVD
},
Display = "Apotheke 'Zum frühen Vogel'"
}
},
Quantity = new() { Value = 1 }
};

prescription.Identifier.Add(new Identifier()
Expand Down Expand Up @@ -205,6 +206,8 @@ private bool CreateAdhocPrescription()
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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ private bool CreateInitialPrescriptionRecord()
System = "urn:oid:1.2.40.0.10.1.4.3.3" // OID: Rezeptnummer
};

initialPresc1.DispenseRequest = new() { Quantity = new() { Value = 2 } };

// Linca Prescription Medication Request for drug 2
initialPresc2.Status = MedicationRequest.MedicationrequestStatus.Active; // REQUIRED
initialPresc2.Intent = MedicationRequest.MedicationRequestIntent.OriginalOrder; // REQUIRED
Expand Down Expand Up @@ -189,6 +191,7 @@ private bool CreateInitialPrescriptionRecord()
System = "urn:oid:1.2.40.0.10.1.4.3.3" // OID: Rezeptnummer
};

initialPresc2.DispenseRequest = new() { Quantity = new() { Value = 3 } };

/***** add the Linca Prescription Medication Requests to a Bundle for transaction ****************/
Bundle prescriptions = new()
Expand Down
2 changes: 2 additions & 0 deletions Lc.Linca.Sdk.Sample/Specs/ActorPharmacy/US018-Dispense.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ private bool CreateMedicationDispenseRecord()
}
};

dispense.Quantity = new() { Value = 1 };

dispense.DosageInstruction.Add(new Dosage()
{
Sequence = 1,
Expand Down
142 changes: 131 additions & 11 deletions Lc.Linca.Sdk.Sample/Specs/ActorPharmacy/US019-PartialDispense.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ internal class US019_PartialDispense : Spec
and his software will send that to the LINCA server,
and notify the ordering organization, Pflegedienst Immerdar, about the partial dispense.";

protected MedicationDispense dispense = new();
protected MedicationDispense dispenseP = new();
protected MedicationDispense dispenseC = new();


public US019_PartialDispense(LincaConnection conn) : base(conn)
{
Steps = new Step[]
{
new ("Dispense prescription partially", CreatePartialDispense)
new ("Dispense prescription partially", CreatePartialDispense),
new ("Complete the partial dispense", CreateCompleteDispense)
};
}

Expand Down Expand Up @@ -61,13 +64,13 @@ private bool CreatePartialDispense()

if (!string.IsNullOrEmpty(LinkedCareSampleClient.CareInformationSystemScaffold.Data.PrescriptionIdRenateLuxerm))
{
dispense.AuthorizingPrescription.Add(new()
dispenseP.AuthorizingPrescription.Add(new()
{
Reference = $"LINCAPrescriptionMedicationRequest/{LinkedCareSampleClient.CareInformationSystemScaffold.Data.PrescriptionIdRenateLuxerm}"
});

dispense.Status = MedicationDispense.MedicationDispenseStatusCodes.Completed;
dispense.Subject = new ResourceReference()
dispenseP.Status = MedicationDispense.MedicationDispenseStatusCodes.Completed;
dispenseP.Subject = new ResourceReference()
{
Identifier = new Identifier()
{
Expand All @@ -77,7 +80,7 @@ private bool CreatePartialDispense()
Display = "Renate Rüssel-Olifant"
};

dispense.Medication = new()
dispenseP.Medication = new()
{
Concept = new()
{
Expand All @@ -93,12 +96,14 @@ private bool CreatePartialDispense()
}
};

dispense.DosageInstruction.Add(new Dosage()
dispenseP.Quantity = new() { Value = 1 };

dispenseP.DosageInstruction.Add(new Dosage()
{
Text = "morgens und abends auf die betroffene Stelle auftragen",
});

dispense.Performer.Add(new()
dispenseP.Performer.Add(new()
{
Actor = new()
{
Expand All @@ -111,19 +116,19 @@ private bool CreatePartialDispense()
}
});

dispense.Type = new()
dispenseP.Type = new()
{
Coding = new()
{
new Coding(system: "http://terminology.hl7.org/CodeSystem/v3-ActCode", code: "FFP")
}
};

(var postedMD, var canCue, var outcome) = LincaDataExchange.CreateMedicationDispense(Connection, dispense);
(var postedMD, var canCue, var outcome) = LincaDataExchange.CreateMedicationDispense(Connection, dispenseP);

if (canCue)
{
Console.WriteLine($"Linca MedicationDispense (type partial dispense) transmitted, id {postedMD.Id}");
Console.WriteLine($"Linca MedicationDispense (type FFP) transmitted, id {postedMD.Id}");
}
else
{
Expand Down Expand Up @@ -154,4 +159,119 @@ private bool CreatePartialDispense()
return false;
}
}

private bool CreateCompleteDispense()
{
(Bundle results, bool received) = LincaDataExchange.GetPrescriptionToDispense(Connection, "WABI0001VVCC");

if (received)
{
List<MedicationRequest> prescriptions = BundleHelper.FilterPrescriptionsToDispense(results);
MedicationRequest? prescription = prescriptions.Find(x => x.Id == LinkedCareSampleClient.CareInformationSystemScaffold.Data.PrescriptionIdRenateLuxerm);

// Check if the partially dispensed prescription is still in the result list
if (prescription == null)
{
Console.WriteLine("Prescription for Renate Rüssel-Olifant not found any more, cannot complete dispense");

return false;
}

if (!string.IsNullOrEmpty(LinkedCareSampleClient.CareInformationSystemScaffold.Data.PrescriptionIdRenateLuxerm))
{
dispenseC.AuthorizingPrescription.Add(new()
{
Reference = $"LINCAPrescriptionMedicationRequest/{LinkedCareSampleClient.CareInformationSystemScaffold.Data.PrescriptionIdRenateLuxerm}"
});

dispenseC.Status = MedicationDispense.MedicationDispenseStatusCodes.Completed;
dispenseC.Subject = new ResourceReference()
{
Identifier = new Identifier()
{
Value = "1238100866",
System = Constants.WellknownOidSocialInsuranceNr
},
Display = "Renate Rüssel-Olifant"
};

dispenseC.Medication = new()
{
Concept = new()
{
Coding = new()
{
new Coding()
{
Code = "4450562",
System = "https://termgit.elga.gv.at/CodeSystem/asp-liste",
Display = "Luxerm 160 mg/g Creme"
}
}
}
};

dispenseC.Quantity = new() { Value = 1 }; // 1 remaining package

dispenseC.DosageInstruction.Add(new Dosage()
{
Text = "morgens und abends auf die betroffene Stelle auftragen",
});

dispenseC.Performer.Add(new()
{
Actor = new()
{
Identifier = new()
{
Value = "2.999.40.0.34.5.1.2", // OID of dispensing pharmacy
System = "urn:ietf:rfc:3986" // Code-System: eHVD
},
Display = "Apotheke 'Zum frühen Vogel'"
}
});

dispenseC.Type = new()
{
Coding = new()
{
new Coding(system: "http://terminology.hl7.org/CodeSystem/v3-ActCode", code: "RFC")
}
};

(var postedMD, var canCue, var outcome) = LincaDataExchange.CreateMedicationDispense(Connection, dispenseC);

if (canCue)
{
Console.WriteLine($"Linca MedicationDispense (type RFC) transmitted, id {postedMD.Id}");
}
else
{
Console.WriteLine($"Failed to transmit Linca MedicationDispense (type partial dispense)");
}

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($"Initial prescription (Luxerm for Renate Rüssel-Oilfant) not found");

return false;
}
}
else
{
Console.WriteLine($"Get prescription-to-dispense failed");

return false;
}
}
}
6 changes: 4 additions & 2 deletions Lc.Linca.Sdk.Sample/Util/BundleViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ public static List<MedicationRequest> FilterPrescriptionsToDispense(Bundle order

foreach (var item in prescriptions)
{
if(prescriptions.Find(x => x.PriorPrescription != null && x.PriorPrescription.Reference.Contains(item.Id)) == null
&& dispenses.Find(x => !x.AuthorizingPrescription.IsNullOrEmpty() && x.AuthorizingPrescription.First().Reference.Contains(item.Id)) == null)
if (prescriptions.Find(x => x.PriorPrescription != null && x.PriorPrescription.Reference.Contains(item.Id)) == null
&& dispenses.Find(x => !x.AuthorizingPrescription.IsNullOrEmpty()
&& x.AuthorizingPrescription.First().Reference.Contains(item.Id)
&& x.Type.Coding.First().Code.EndsWith("C")) == null)
{
openPrescriptions.Add(item);
}
Expand Down

0 comments on commit 811fb08

Please sign in to comment.