AdjustPrescriptionCommand silently no-ops when the patient's matched Medication has no prior Prescription record #1714
nara-falconeer
announced in
General
Replies: 1 comment
|
@nara-falconeer Looks like the AdjustPrescription command was not enabled as an SDK command in your dev environment (it is in your production environment though). I have enabled it now, can you please try your plugin out and see if you are good to go now? |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Repro
MedicationStatementCommand(sig "500 mg BID"). This produces aMedicationrow with FDB coding, noPrescriptionrow.AdjustPrescriptionCommandagainst that patient + note:quantity_to_dispenseandtype_to_dispenseset per Prescribe conventions..originate()succeeds. Plugin logs show the effect was emitted. No error incanvas logsat any level.Expected
Either:
Adjust Prescriptiondraft card appears on the note (in whichever section is appropriate for Sendable / Refill-family commands), ORCOMMAND_VALIDATION_ERRORSeffect comes back with a clear reason (e.g. "no prior Prescription to adjust"), so the plugin can surface a useful error or fall back toChangeMedicationCommand.The current "accepted-but-invisible" behavior is the worst of both — no feedback, no UI.
Hypothesis
AdjustPrescriptionCommandextendsRefillCommand, which models "refill an existing prescription with adjusted parameters." Server-side rendering presumably anchors on a realPrescriptionrow, and silently drops the effect when none exists for the(patient, fdb_code)pair — even thoughRefillCommand._get_error_detailsonly checksMedication.objects.active().filter(codings__code=fdb_code, patient=...).Why it matters
For any clinic whose meds come primarily from intake / med-rec (not their own e-Rx history),
AdjustPrescriptionwill silently no-op on most patients. The SDK is misleading here:RefillCommandonly looks at theMedicationtable, implying any active med is adjustable.Prescriptionrow to actually render anything.Suggested fixes (any one would unblock us)
Prescription.objects.filter(patient=..., medication__codings__code=fdb_code).exists()is false at originate time — push the existing tighter check intoRefillCommand._get_error_details.AdjustPrescriptionCommanddocstring +class Meta(e.g. "requires an existing Canvas-originated Prescription; for sig-only updates to Statement-sourced meds useChangeMedicationCommand").Prescriptionrow tied to the existingMedicationwhen none exists — but that changes semantics and is probably out of scope.Workaround we're using
Dispatch at the plugin level:
AdjustPrescriptionCommandwhenmed.prescriptions.exists(), elseChangeMedicationCommand. This works but every plugin author will need to learn this the hard way; would prefer at least (1) or (2) upstream.All reactions