@photonhealth/elements 0.23.1 → 0.23.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -53264,6 +53264,8 @@ const ListPharmaciesQuery = gql`
53264
53264
  }
53265
53265
  `;
53266
53266
 
53267
+ const formatPatientWeight = (weight, weightUnit = "lb") => `Patient weight: ${weight} ${weightUnit}`;
53268
+
53267
53269
  const DraftPrescriptionsContext = createContext();
53268
53270
  const transformPrescriptionFormData = (prescription, patientId) => ({
53269
53271
  externalId: prescription.externalId,
@@ -53284,16 +53286,24 @@ function isTreatmentInDraftPrescriptions(treatmentId, draftedPrescriptions) {
53284
53286
  }
53285
53287
  const createPrefillPrescriptionsOnApi = async ({
53286
53288
  client,
53287
- props
53289
+ props,
53290
+ rxNotesPrefill
53288
53291
  }) => {
53289
53292
  let rxToCreate = [];
53290
53293
  if (props.templateIdsPrefill.length > 0) {
53291
53294
  const dedupedTemplateIds = Array.from(new Set(props.templateIdsPrefill));
53292
- const templatedCreateRxList = dedupedTemplateIds.map((templateId) => ({
53293
- ...props.templateOverrides?.[templateId],
53294
- patientId: props.patientId,
53295
- templateId
53296
- }));
53295
+ const templatedCreateRxList = dedupedTemplateIds.map((templateId) => {
53296
+ const templateOverrideNotes = props.templateOverrides?.[templateId]?.notes;
53297
+ const notes = templateOverrideNotes ? `${templateOverrideNotes}
53298
+
53299
+ ${rxNotesPrefill}` : rxNotesPrefill;
53300
+ return {
53301
+ ...props.templateOverrides?.[templateId],
53302
+ patientId: props.patientId,
53303
+ templateId,
53304
+ notes
53305
+ };
53306
+ });
53297
53307
  rxToCreate = rxToCreate.concat(templatedCreateRxList);
53298
53308
  }
53299
53309
  if (props.prescriptionIdsPrefill.length > 0) {
@@ -53333,6 +53343,14 @@ const DraftPrescriptionsProvider = (props) => {
53333
53343
  const [isLoadingPrefills, setIsLoadingPrefills] = createSignal(false);
53334
53344
  const [draftPrescriptions, setDraftPrescriptions] = createSignal([]);
53335
53345
  const prescriptionIds = createMemo(() => draftPrescriptions().map((prescription) => prescription.id));
53346
+ const rxNotesPrefill = createMemo(() => {
53347
+ let notesPrefill = "";
53348
+ if (props.additionalNotes) notesPrefill = `${props.additionalNotes}
53349
+
53350
+ `;
53351
+ if (props.weight) notesPrefill = `${notesPrefill}${formatPatientWeight(props.weight, props.weightUnit)}`;
53352
+ return notesPrefill || void 0;
53353
+ });
53336
53354
  createEffect(async () => {
53337
53355
  if (
53338
53356
  // must have templateIds or prescriptionIds to create prescriptions
@@ -53345,7 +53363,8 @@ const DraftPrescriptionsProvider = (props) => {
53345
53363
  try {
53346
53364
  const newRxs = await createPrefillPrescriptionsOnApi({
53347
53365
  client,
53348
- props
53366
+ props,
53367
+ rxNotesPrefill: rxNotesPrefill()
53349
53368
  });
53350
53369
  if (newRxs) {
53351
53370
  setDraftPrescriptions((prev) => [...prev, ...newRxs]);
@@ -53484,6 +53503,7 @@ const DraftPrescriptionsProvider = (props) => {
53484
53503
  draftPrescriptions,
53485
53504
  prescriptionIds,
53486
53505
  isLoadingPrefills,
53506
+ rxNotesPrefill,
53487
53507
  // actions
53488
53508
  setDraftPrescriptions,
53489
53509
  tryCreatePrescription,
@@ -58382,7 +58402,7 @@ function checkHasPermission(subset, superset) {
58382
58402
  return subset.every((permission) => superset.includes(permission));
58383
58403
  }
58384
58404
 
58385
- const version$1 = "0.23.1";
58405
+ const version$1 = "0.23.2";
58386
58406
  const pkg = {
58387
58407
  version: version$1};
58388
58408
 
@@ -67099,8 +67119,6 @@ const clearForm = (actions, overrides) => {
67099
67119
  });
67100
67120
  };
67101
67121
 
67102
- const formatPatientWeight = (weight, weightUnit = "lb") => `Patient weight: ${weight} ${weightUnit}`;
67103
-
67104
67122
  var PrescriptionState = /* @__PURE__ */ ((PrescriptionState2) => {
67105
67123
  PrescriptionState2["Draft"] = "DRAFT";
67106
67124
  PrescriptionState2["Active"] = "ACTIVE";
@@ -76636,7 +76654,8 @@ function PrescribeWorkflow(props) {
76636
76654
  draftPrescriptions,
76637
76655
  prescriptionIds,
76638
76656
  tryUpdatePrescriptionStates,
76639
- isLoadingPrefills
76657
+ isLoadingPrefills,
76658
+ rxNotesPrefill
76640
76659
  } = useDraftPrescriptions();
76641
76660
  const pharmacySelectionContext = usePharmacySelectionContext();
76642
76661
  const {
@@ -76671,15 +76690,6 @@ function PrescribeWorkflow(props) {
76671
76690
  return fulfillmentNeedsAddress$1(pharmacySelectionContext.fulfillmentType()) && !hasPatientAddress();
76672
76691
  });
76673
76692
  const [isScreeningAlertWarningOpen, setIsScreeningAlertWarningOpen] = createSignal(false);
76674
- let prefillNotes = "";
76675
- if (props.additionalNotes) {
76676
- prefillNotes = `${props.additionalNotes}
76677
-
76678
- `;
76679
- }
76680
- if (props.weight) {
76681
- prefillNotes = `${prefillNotes}${formatPatientWeight(props.weight, props.weightUnit)}`;
76682
- }
76683
76693
  onMount(async () => {
76684
76694
  if (props.address) {
76685
76695
  props.formActions.updateFormValue({
@@ -76689,7 +76699,7 @@ function PrescribeWorkflow(props) {
76689
76699
  }
76690
76700
  ref.addEventListener("photon-ticket-created-duplicate", () => {
76691
76701
  clearForm(props.formActions, {
76692
- notes: prefillNotes
76702
+ notes: rxNotesPrefill()
76693
76703
  });
76694
76704
  pharmacySelectionContext.setFulfillmentType(void 0);
76695
76705
  pharmacySelectionContext.setPharmacyId(void 0);
@@ -77121,7 +77131,9 @@ function PrescribeWorkflow(props) {
77121
77131
  get weightUnit() {
77122
77132
  return props.weightUnit;
77123
77133
  },
77124
- prefillNotes,
77134
+ get prefillNotes() {
77135
+ return rxNotesPrefill();
77136
+ },
77125
77137
  screenDraftedPrescriptions,
77126
77138
  get screeningAlerts() {
77127
77139
  return screeningAlerts();
@@ -78072,6 +78084,15 @@ const PhotonPrescribeWorkflowComponent = (props) => {
78072
78084
  get enableCombineAndDuplicate() {
78073
78085
  return props.enableCombineAndDuplicate;
78074
78086
  },
78087
+ get additionalNotes() {
78088
+ return props.additionalNotes;
78089
+ },
78090
+ get weight() {
78091
+ return props.weight;
78092
+ },
78093
+ get weightUnit() {
78094
+ return props.weightUnit;
78095
+ },
78075
78096
  get children() {
78076
78097
  return createComponent(PharmacySelectionProvider, {
78077
78098
  get pharmacyIdProp() {