@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.js CHANGED
@@ -53266,6 +53266,8 @@ const ListPharmaciesQuery = gql`
53266
53266
  }
53267
53267
  `;
53268
53268
 
53269
+ const formatPatientWeight = (weight, weightUnit = "lb") => `Patient weight: ${weight} ${weightUnit}`;
53270
+
53269
53271
  const DraftPrescriptionsContext = createContext();
53270
53272
  const transformPrescriptionFormData = (prescription, patientId) => ({
53271
53273
  externalId: prescription.externalId,
@@ -53286,16 +53288,24 @@ function isTreatmentInDraftPrescriptions(treatmentId, draftedPrescriptions) {
53286
53288
  }
53287
53289
  const createPrefillPrescriptionsOnApi = async ({
53288
53290
  client,
53289
- props
53291
+ props,
53292
+ rxNotesPrefill
53290
53293
  }) => {
53291
53294
  let rxToCreate = [];
53292
53295
  if (props.templateIdsPrefill.length > 0) {
53293
53296
  const dedupedTemplateIds = Array.from(new Set(props.templateIdsPrefill));
53294
- const templatedCreateRxList = dedupedTemplateIds.map((templateId) => ({
53295
- ...props.templateOverrides?.[templateId],
53296
- patientId: props.patientId,
53297
- templateId
53298
- }));
53297
+ const templatedCreateRxList = dedupedTemplateIds.map((templateId) => {
53298
+ const templateOverrideNotes = props.templateOverrides?.[templateId]?.notes;
53299
+ const notes = templateOverrideNotes ? `${templateOverrideNotes}
53300
+
53301
+ ${rxNotesPrefill}` : rxNotesPrefill;
53302
+ return {
53303
+ ...props.templateOverrides?.[templateId],
53304
+ patientId: props.patientId,
53305
+ templateId,
53306
+ notes
53307
+ };
53308
+ });
53299
53309
  rxToCreate = rxToCreate.concat(templatedCreateRxList);
53300
53310
  }
53301
53311
  if (props.prescriptionIdsPrefill.length > 0) {
@@ -53335,6 +53345,14 @@ const DraftPrescriptionsProvider = (props) => {
53335
53345
  const [isLoadingPrefills, setIsLoadingPrefills] = createSignal(false);
53336
53346
  const [draftPrescriptions, setDraftPrescriptions] = createSignal([]);
53337
53347
  const prescriptionIds = createMemo(() => draftPrescriptions().map((prescription) => prescription.id));
53348
+ const rxNotesPrefill = createMemo(() => {
53349
+ let notesPrefill = "";
53350
+ if (props.additionalNotes) notesPrefill = `${props.additionalNotes}
53351
+
53352
+ `;
53353
+ if (props.weight) notesPrefill = `${notesPrefill}${formatPatientWeight(props.weight, props.weightUnit)}`;
53354
+ return notesPrefill || void 0;
53355
+ });
53338
53356
  createEffect(async () => {
53339
53357
  if (
53340
53358
  // must have templateIds or prescriptionIds to create prescriptions
@@ -53347,7 +53365,8 @@ const DraftPrescriptionsProvider = (props) => {
53347
53365
  try {
53348
53366
  const newRxs = await createPrefillPrescriptionsOnApi({
53349
53367
  client,
53350
- props
53368
+ props,
53369
+ rxNotesPrefill: rxNotesPrefill()
53351
53370
  });
53352
53371
  if (newRxs) {
53353
53372
  setDraftPrescriptions((prev) => [...prev, ...newRxs]);
@@ -53486,6 +53505,7 @@ const DraftPrescriptionsProvider = (props) => {
53486
53505
  draftPrescriptions,
53487
53506
  prescriptionIds,
53488
53507
  isLoadingPrefills,
53508
+ rxNotesPrefill,
53489
53509
  // actions
53490
53510
  setDraftPrescriptions,
53491
53511
  tryCreatePrescription,
@@ -58384,7 +58404,7 @@ function checkHasPermission(subset, superset) {
58384
58404
  return subset.every((permission) => superset.includes(permission));
58385
58405
  }
58386
58406
 
58387
- const version$1 = "0.23.1";
58407
+ const version$1 = "0.23.2";
58388
58408
  const pkg = {
58389
58409
  version: version$1};
58390
58410
 
@@ -67101,8 +67121,6 @@ const clearForm = (actions, overrides) => {
67101
67121
  });
67102
67122
  };
67103
67123
 
67104
- const formatPatientWeight = (weight, weightUnit = "lb") => `Patient weight: ${weight} ${weightUnit}`;
67105
-
67106
67124
  var PrescriptionState = /* @__PURE__ */ ((PrescriptionState2) => {
67107
67125
  PrescriptionState2["Draft"] = "DRAFT";
67108
67126
  PrescriptionState2["Active"] = "ACTIVE";
@@ -76638,7 +76656,8 @@ function PrescribeWorkflow(props) {
76638
76656
  draftPrescriptions,
76639
76657
  prescriptionIds,
76640
76658
  tryUpdatePrescriptionStates,
76641
- isLoadingPrefills
76659
+ isLoadingPrefills,
76660
+ rxNotesPrefill
76642
76661
  } = useDraftPrescriptions();
76643
76662
  const pharmacySelectionContext = usePharmacySelectionContext();
76644
76663
  const {
@@ -76673,15 +76692,6 @@ function PrescribeWorkflow(props) {
76673
76692
  return fulfillmentNeedsAddress$1(pharmacySelectionContext.fulfillmentType()) && !hasPatientAddress();
76674
76693
  });
76675
76694
  const [isScreeningAlertWarningOpen, setIsScreeningAlertWarningOpen] = createSignal(false);
76676
- let prefillNotes = "";
76677
- if (props.additionalNotes) {
76678
- prefillNotes = `${props.additionalNotes}
76679
-
76680
- `;
76681
- }
76682
- if (props.weight) {
76683
- prefillNotes = `${prefillNotes}${formatPatientWeight(props.weight, props.weightUnit)}`;
76684
- }
76685
76695
  onMount(async () => {
76686
76696
  if (props.address) {
76687
76697
  props.formActions.updateFormValue({
@@ -76691,7 +76701,7 @@ function PrescribeWorkflow(props) {
76691
76701
  }
76692
76702
  ref.addEventListener("photon-ticket-created-duplicate", () => {
76693
76703
  clearForm(props.formActions, {
76694
- notes: prefillNotes
76704
+ notes: rxNotesPrefill()
76695
76705
  });
76696
76706
  pharmacySelectionContext.setFulfillmentType(void 0);
76697
76707
  pharmacySelectionContext.setPharmacyId(void 0);
@@ -77123,7 +77133,9 @@ function PrescribeWorkflow(props) {
77123
77133
  get weightUnit() {
77124
77134
  return props.weightUnit;
77125
77135
  },
77126
- prefillNotes,
77136
+ get prefillNotes() {
77137
+ return rxNotesPrefill();
77138
+ },
77127
77139
  screenDraftedPrescriptions,
77128
77140
  get screeningAlerts() {
77129
77141
  return screeningAlerts();
@@ -78074,6 +78086,15 @@ const PhotonPrescribeWorkflowComponent = (props) => {
78074
78086
  get enableCombineAndDuplicate() {
78075
78087
  return props.enableCombineAndDuplicate;
78076
78088
  },
78089
+ get additionalNotes() {
78090
+ return props.additionalNotes;
78091
+ },
78092
+ get weight() {
78093
+ return props.weight;
78094
+ },
78095
+ get weightUnit() {
78096
+ return props.weightUnit;
78097
+ },
78077
78098
  get children() {
78078
78099
  return createComponent(PharmacySelectionProvider, {
78079
78100
  get pharmacyIdProp() {