@medplum/react 0.9.32 → 0.9.33

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.
@@ -4,6 +4,7 @@ import './QuestionnaireForm.css';
4
4
  export interface QuestionnaireFormProps {
5
5
  questionnaire: Questionnaire | Reference<Questionnaire>;
6
6
  subject?: Reference;
7
+ submitButtonText?: string;
7
8
  onSubmit: (response: QuestionnaireResponse) => void;
8
9
  }
9
10
  export declare function QuestionnaireForm(props: QuestionnaireFormProps): JSX.Element | null;
@@ -1,7 +1,8 @@
1
1
  /// <reference types="react" />
2
- import { Reference, Schedule } from '@medplum/fhirtypes';
2
+ import { Questionnaire, Reference, Schedule } from '@medplum/fhirtypes';
3
3
  import './Scheduler.css';
4
4
  export interface SchedulerProps {
5
5
  schedule: Schedule | Reference<Schedule>;
6
+ questionnaire: Questionnaire | Reference<Questionnaire>;
6
7
  }
7
8
  export declare function Scheduler(props: SchedulerProps): JSX.Element | null;
@@ -6,6 +6,8 @@ export interface AuthenticationFormProps {
6
6
  readonly scope?: string;
7
7
  readonly nonce?: string;
8
8
  readonly googleClientId?: string;
9
+ readonly codeChallenge?: string;
10
+ readonly codeChallengeMethod?: string;
9
11
  readonly onForgotPassword?: () => void;
10
12
  readonly onRegister?: () => void;
11
13
  readonly handleAuthResponse: (response: LoginAuthenticationResponse) => void;
@@ -8,6 +8,8 @@ export interface SignInFormProps {
8
8
  readonly clientId?: string;
9
9
  readonly scope?: string;
10
10
  readonly nonce?: string;
11
+ readonly codeChallenge?: string;
12
+ readonly codeChallengeMethod?: string;
11
13
  readonly onSuccess?: () => void;
12
14
  readonly onForgotPassword?: () => void;
13
15
  readonly onRegister?: () => void;
package/dist/cjs/index.js CHANGED
@@ -518,9 +518,9 @@
518
518
  return clientId;
519
519
  }
520
520
  const origin = window.location.protocol + '//' + window.location.host;
521
- const authorizedOrigins = (_b = (_a = "undefined") === null || _a === void 0 ? void 0 : _a.split(',')) !== null && _b !== void 0 ? _b : [];
521
+ const authorizedOrigins = (_b = (_a = "http://localhost:3000,http://127.0.0.1:3000,http://localhost:6006,http://127.0.0.1:6006,https://app.medplum.com,https://docs.medplum.com") === null || _a === void 0 ? void 0 : _a.split(',')) !== null && _b !== void 0 ? _b : [];
522
522
  if (authorizedOrigins.includes(origin)) {
523
- return "undefined";
523
+ return "921088377005-3j1sa10vr6hj86jgmdfh2l53v3mp7lfi.apps.googleusercontent.com";
524
524
  }
525
525
  return undefined;
526
526
  }
@@ -713,6 +713,8 @@
713
713
  clientId: props.clientId,
714
714
  scope: props.scope,
715
715
  nonce: props.nonce,
716
+ codeChallenge: props.codeChallenge,
717
+ codeChallengeMethod: props.codeChallengeMethod,
716
718
  email: formData.email,
717
719
  password: formData.password,
718
720
  remember: formData.remember === 'true',
@@ -734,6 +736,8 @@
734
736
  clientId: props.clientId,
735
737
  scope: props.scope,
736
738
  nonce: props.nonce,
739
+ codeChallenge: props.codeChallenge,
740
+ codeChallengeMethod: props.codeChallengeMethod,
737
741
  googleClientId: response.clientId,
738
742
  googleCredential: response.credential,
739
743
  })
@@ -887,7 +891,7 @@
887
891
  }
888
892
  return (React__default["default"].createElement(Document, { width: 450 }, (() => {
889
893
  if (!login) {
890
- return (React__default["default"].createElement(AuthenticationForm, { projectId: props.projectId, clientId: props.clientId, scope: props.scope, nonce: props.nonce, googleClientId: props.googleClientId, onForgotPassword: props.onForgotPassword, onRegister: props.onRegister, handleAuthResponse: handleAuthResponse }, props.children));
894
+ return (React__default["default"].createElement(AuthenticationForm, { projectId: props.projectId, clientId: props.clientId, scope: props.scope, nonce: props.nonce, googleClientId: props.googleClientId, codeChallenge: props.codeChallenge, codeChallengeMethod: props.codeChallengeMethod, onForgotPassword: props.onForgotPassword, onRegister: props.onRegister, handleAuthResponse: handleAuthResponse }, props.children));
891
895
  }
892
896
  else if (memberships) {
893
897
  return React__default["default"].createElement(ChooseProfileForm, { login: login, memberships: memberships, handleAuthResponse: handleAuthResponse });
@@ -4221,9 +4225,9 @@
4221
4225
  props.onBulk && (React__default["default"].createElement(Button, { size: "small", onClick: () => props.onBulk(Object.keys(state.selected)) }, "Bulk..."))),
4222
4226
  lastResult && (React__default["default"].createElement("div", null,
4223
4227
  React__default["default"].createElement("span", { className: "medplum-search-summary" },
4224
- getStart(search, lastResult.total),
4228
+ getStart$1(search, lastResult.total),
4225
4229
  "-",
4226
- getEnd(search, lastResult.total),
4230
+ getEnd$1(search, lastResult.total),
4227
4231
  " of",
4228
4232
  ' ', (_d = lastResult.total) === null || _d === void 0 ? void 0 :
4229
4233
  _d.toLocaleString()),
@@ -4290,11 +4294,11 @@
4290
4294
  return (React__default["default"].createElement("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "rgba(0, 0, 0, 0.3)", strokeWidth: 2 },
4291
4295
  React__default["default"].createElement("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4 6h16M4 12h16m-7 6h7" })));
4292
4296
  }
4293
- function getStart(search, total) {
4297
+ function getStart$1(search, total) {
4294
4298
  var _a;
4295
4299
  return Math.min(total, ((_a = search.offset) !== null && _a !== void 0 ? _a : 0) + 1);
4296
4300
  }
4297
- function getEnd(search, total) {
4301
+ function getEnd$1(search, total) {
4298
4302
  var _a, _b;
4299
4303
  return Math.min(total, (((_a = search.offset) !== null && _a !== void 0 ? _a : 0) + 1) * ((_b = search.count) !== null && _b !== void 0 ? _b : core.DEFAULT_SEARCH_COUNT));
4300
4304
  }
@@ -5037,7 +5041,7 @@
5037
5041
  } },
5038
5042
  questionnaire.title && React__default["default"].createElement("h1", null, questionnaire.title),
5039
5043
  questionnaire.item && React__default["default"].createElement(QuestionnaireFormItemArray, { items: questionnaire.item, onChange: setItems }),
5040
- React__default["default"].createElement(Button, { type: "submit", size: "large" }, "OK")));
5044
+ React__default["default"].createElement(Button, { type: "submit", size: "large" }, props.submitButtonText || 'OK')));
5041
5045
  }
5042
5046
  function QuestionnaireFormItemArray(props) {
5043
5047
  const [responseItems, setResponseItems] = React.useState(buildInitialResponseItems(props.items));
@@ -5876,22 +5880,23 @@
5876
5880
  var _a;
5877
5881
  const medplum = useMedplum();
5878
5882
  const schedule = useResource(props.schedule);
5883
+ const questionnaire = useResource(props.questionnaire);
5879
5884
  const [slots, setSlots] = React.useState();
5880
5885
  const slotsRef = React.useRef();
5881
5886
  slotsRef.current = slots;
5882
5887
  const [month, setMonth] = React.useState(getStartMonth());
5883
5888
  const [date, setDate] = React.useState();
5884
5889
  const [slot, setSlot] = React.useState();
5885
- const [info, setInfo] = React.useState();
5886
- const [form, setForm] = React.useState();
5890
+ const [response, setResponse] = React.useState();
5887
5891
  React.useEffect(() => {
5888
5892
  if (schedule) {
5889
5893
  setSlots([]);
5890
5894
  medplum
5891
5895
  .searchResources('Slot', new URLSearchParams([
5896
+ ['_count', (30 * 24).toString()],
5892
5897
  ['schedule', core.getReferenceString(schedule)],
5893
- ['start', 'gt' + month.toISOString()],
5894
- ['start', 'lt' + new Date(month.getTime() + 31 * 24 * 60 * 60 * 1000).toISOString()],
5898
+ ['start', 'gt' + getStart(month)],
5899
+ ['start', 'lt' + getEnd(month)],
5895
5900
  ]))
5896
5901
  .then(setSlots)
5897
5902
  .catch(console.log);
@@ -5900,7 +5905,7 @@
5900
5905
  setSlots(undefined);
5901
5906
  }
5902
5907
  }, [medplum, schedule, month]);
5903
- if (!schedule || !slots) {
5908
+ if (!schedule || !slots || !questionnaire) {
5904
5909
  return null;
5905
5910
  }
5906
5911
  const actor = (_a = schedule.actor) === null || _a === void 0 ? void 0 : _a[0];
@@ -5924,26 +5929,20 @@
5924
5929
  slotStart.getTime() < date.getTime() + 24 * 3600 * 1000 && (React__default["default"].createElement("div", { key: s.id },
5925
5930
  React__default["default"].createElement(Button, { style: { width: 150 }, onClick: () => setSlot(s) }, formatTime(slotStart)))));
5926
5931
  }))),
5927
- date && slot && !info && (React__default["default"].createElement("div", null,
5928
- React__default["default"].createElement("h3", null, "Enter your info"),
5929
- React__default["default"].createElement(FormSection, { title: "Name", htmlFor: "name" },
5930
- React__default["default"].createElement(Input, { name: "name" })),
5931
- React__default["default"].createElement(FormSection, { title: "Email", htmlFor: "email" },
5932
- React__default["default"].createElement(Input, { name: "email" })),
5933
- React__default["default"].createElement(Button, { primary: true, onClick: () => setInfo('info') }, "Next"))),
5934
- date && slot && info && !form && (React__default["default"].createElement("div", null,
5935
- React__default["default"].createElement("h3", null, "Custom questions"),
5936
- React__default["default"].createElement(FormSection, { title: "Question 1", htmlFor: "q1" },
5937
- React__default["default"].createElement(Input, { name: "q1" })),
5938
- React__default["default"].createElement(FormSection, { title: "Question 2", htmlFor: "q2" },
5939
- React__default["default"].createElement(Input, { name: "email" })),
5940
- React__default["default"].createElement(FormSection, { title: "Question 3", htmlFor: "q3" },
5941
- React__default["default"].createElement(Input, { name: "email" })),
5942
- React__default["default"].createElement(Button, { primary: true, onClick: () => setForm('form') }, "Next"))),
5943
- date && slot && info && form && (React__default["default"].createElement("div", null,
5932
+ date && slot && !response && (React__default["default"].createElement(QuestionnaireForm, { questionnaire: questionnaire, submitButtonText: 'Next', onSubmit: setResponse })),
5933
+ date && slot && response && (React__default["default"].createElement("div", null,
5944
5934
  React__default["default"].createElement("h3", null, "You're all set!"),
5945
5935
  React__default["default"].createElement("p", null, "Check your email for a calendar invite."))))));
5946
5936
  }
5937
+ function getStart(month) {
5938
+ return formatSlotInstant(month.getTime());
5939
+ }
5940
+ function getEnd(month) {
5941
+ return formatSlotInstant(month.getTime() + 31 * 24 * 60 * 60 * 1000);
5942
+ }
5943
+ function formatSlotInstant(time) {
5944
+ return new Date(Math.max(Date.now(), time)).toISOString();
5945
+ }
5947
5946
  function formatTime(date) {
5948
5947
  return date.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' });
5949
5948
  }
@@ -5962,19 +5961,19 @@
5962
5961
  {
5963
5962
  request: {
5964
5963
  method: 'GET',
5965
- url: `Communication?based-on=${core.getReferenceString(resource)}`,
5964
+ url: `Communication?based-on=${core.getReferenceString(resource)}&_sort=-_lastUpdated`,
5966
5965
  },
5967
5966
  },
5968
5967
  {
5969
5968
  request: {
5970
5969
  method: 'GET',
5971
- url: `Media?_count=100&based-on=${core.getReferenceString(resource)}`,
5970
+ url: `Media?_count=100&based-on=${core.getReferenceString(resource)}&_sort=-_lastUpdated`,
5972
5971
  },
5973
5972
  },
5974
5973
  {
5975
5974
  request: {
5976
5975
  method: 'GET',
5977
- url: `DiagnosticReport?based-on=${core.getReferenceString(resource)}`,
5976
+ url: `DiagnosticReport?based-on=${core.getReferenceString(resource)}&_sort=-_lastUpdated`,
5978
5977
  },
5979
5978
  },
5980
5979
  ],