@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.
- package/dist/cjs/QuestionnaireForm.d.ts +1 -0
- package/dist/cjs/Scheduler.d.ts +2 -1
- package/dist/cjs/auth/AuthenticationForm.d.ts +2 -0
- package/dist/cjs/auth/SignInForm.d.ts +2 -0
- package/dist/cjs/index.js +32 -33
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.min.js +1 -1
- package/dist/cjs/index.min.js.map +1 -1
- package/dist/esm/GoogleButton.js +2 -2
- package/dist/esm/GoogleButton.js.map +1 -1
- package/dist/esm/QuestionnaireForm.d.ts +1 -0
- package/dist/esm/QuestionnaireForm.js +1 -1
- package/dist/esm/QuestionnaireForm.js.map +1 -1
- package/dist/esm/Scheduler.d.ts +2 -1
- package/dist/esm/Scheduler.js +18 -24
- package/dist/esm/Scheduler.js.map +1 -1
- package/dist/esm/ServiceRequestTimeline.js +3 -3
- package/dist/esm/ServiceRequestTimeline.js.map +1 -1
- package/dist/esm/auth/AuthenticationForm.d.ts +2 -0
- package/dist/esm/auth/AuthenticationForm.js +4 -0
- package/dist/esm/auth/AuthenticationForm.js.map +1 -1
- package/dist/esm/auth/SignInForm.d.ts +2 -0
- package/dist/esm/auth/SignInForm.js +1 -1
- package/dist/esm/auth/SignInForm.js.map +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/package.json +11 -11
- package/stats.html +4034 -0
package/dist/esm/GoogleButton.js
CHANGED
|
@@ -37,9 +37,9 @@ function getGoogleClientId(clientId) {
|
|
|
37
37
|
return clientId;
|
|
38
38
|
}
|
|
39
39
|
const origin = window.location.protocol + '//' + window.location.host;
|
|
40
|
-
const authorizedOrigins = (_b = (_a = "
|
|
40
|
+
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 : [];
|
|
41
41
|
if (authorizedOrigins.includes(origin)) {
|
|
42
|
-
return "
|
|
42
|
+
return "921088377005-3j1sa10vr6hj86jgmdfh2l53v3mp7lfi.apps.googleusercontent.com";
|
|
43
43
|
}
|
|
44
44
|
return undefined;
|
|
45
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleButton.js","sources":["../../src/GoogleButton.tsx"],"sourcesContent":["import { GoogleCredentialResponse } from '@medplum/core';\nimport React, { useEffect, useRef, useState } from 'react';\nimport { useMedplum } from './MedplumProvider';\nimport { createScriptTag } from './utils';\n\ninterface GoogleApi {\n accounts: {\n id: {\n initialize: (args: any) => void;\n renderButton: (parent: HTMLElement, args: any) => void;\n };\n };\n}\n\ndeclare const google: GoogleApi;\n\nexport interface GoogleButtonProps {\n readonly googleClientId?: string;\n readonly handleGoogleCredential: (response: GoogleCredentialResponse) => void;\n}\n\nexport function GoogleButton(props: GoogleButtonProps): JSX.Element | null {\n const medplum = useMedplum();\n const { googleClientId, handleGoogleCredential } = props;\n const parentRef = useRef<HTMLDivElement>(null);\n const [scriptLoaded, setScriptLoaded] = useState<boolean>(typeof google !== 'undefined');\n const [initialized, setInitialized] = useState<boolean>(false);\n const [buttonRendered, setButtonRendered] = useState<boolean>(false);\n\n useEffect(() => {\n if (typeof google === 'undefined') {\n createScriptTag('https://accounts.google.com/gsi/client', () => setScriptLoaded(true));\n return;\n }\n\n if (!initialized) {\n google.accounts.id.initialize({\n client_id: googleClientId,\n callback: handleGoogleCredential,\n });\n setInitialized(true);\n }\n\n if (parentRef.current && !buttonRendered) {\n google.accounts.id.renderButton(parentRef.current, {});\n setButtonRendered(true);\n }\n }, [medplum, googleClientId, initialized, scriptLoaded, parentRef, buttonRendered, handleGoogleCredential]);\n\n if (!googleClientId) {\n return null;\n }\n\n return <div ref={parentRef} />;\n}\n\nexport function getGoogleClientId(clientId: string | undefined): string | undefined {\n if (clientId) {\n return clientId;\n }\n\n const origin = window.location.protocol + '//' + window.location.host;\n const authorizedOrigins = process.env.GOOGLE_AUTH_ORIGINS?.split(',') ?? [];\n if (authorizedOrigins.includes(origin)) {\n return process.env.GOOGLE_CLIENT_ID;\n }\n\n return undefined;\n}\n"],"names":[],"mappings":";;;;AAqBM,SAAU,YAAY,CAAC,KAAwB,EAAA;AACnD,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;AAC7B,IAAA,MAAM,EAAE,cAAc,EAAE,sBAAsB,EAAE,GAAG,KAAK,CAAC;AACzD,IAAA,MAAM,SAAS,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;AAC/C,IAAA,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAU,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC;IACzF,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IAC/D,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IAErE,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;YACjC,eAAe,CAAC,wCAAwC,EAAE,MAAM,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;YACvF,OAAO;AACR,SAAA;QAED,IAAI,CAAC,WAAW,EAAE;AAChB,YAAA,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,UAAU,CAAC;AAC5B,gBAAA,SAAS,EAAE,cAAc;AACzB,gBAAA,QAAQ,EAAE,sBAAsB;AACjC,aAAA,CAAC,CAAC;YACH,cAAc,CAAC,IAAI,CAAC,CAAC;AACtB,SAAA;AAED,QAAA,IAAI,SAAS,CAAC,OAAO,IAAI,CAAC,cAAc,EAAE;AACxC,YAAA,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACvD,iBAAiB,CAAC,IAAI,CAAC,CAAC;AACzB,SAAA;AACH,KAAC,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,sBAAsB,CAAC,CAAC,CAAC;IAE5G,IAAI,CAAC,cAAc,EAAE;AACnB,QAAA,OAAO,IAAI,CAAC;AACb,KAAA;AAED,IAAA,OAAO,KAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,GAAG,EAAE,SAAS,GAAI,CAAC;AACjC,CAAC;AAEK,SAAU,iBAAiB,CAAC,QAA4B,EAAA;;AAC5D,IAAA,IAAI,QAAQ,EAAE;AACZ,QAAA,OAAO,QAAQ,CAAC;AACjB,KAAA;AAED,IAAA,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,GAAG,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;AACtE,IAAA,MAAM,iBAAiB,GAAG,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,
|
|
1
|
+
{"version":3,"file":"GoogleButton.js","sources":["../../src/GoogleButton.tsx"],"sourcesContent":["import { GoogleCredentialResponse } from '@medplum/core';\nimport React, { useEffect, useRef, useState } from 'react';\nimport { useMedplum } from './MedplumProvider';\nimport { createScriptTag } from './utils';\n\ninterface GoogleApi {\n accounts: {\n id: {\n initialize: (args: any) => void;\n renderButton: (parent: HTMLElement, args: any) => void;\n };\n };\n}\n\ndeclare const google: GoogleApi;\n\nexport interface GoogleButtonProps {\n readonly googleClientId?: string;\n readonly handleGoogleCredential: (response: GoogleCredentialResponse) => void;\n}\n\nexport function GoogleButton(props: GoogleButtonProps): JSX.Element | null {\n const medplum = useMedplum();\n const { googleClientId, handleGoogleCredential } = props;\n const parentRef = useRef<HTMLDivElement>(null);\n const [scriptLoaded, setScriptLoaded] = useState<boolean>(typeof google !== 'undefined');\n const [initialized, setInitialized] = useState<boolean>(false);\n const [buttonRendered, setButtonRendered] = useState<boolean>(false);\n\n useEffect(() => {\n if (typeof google === 'undefined') {\n createScriptTag('https://accounts.google.com/gsi/client', () => setScriptLoaded(true));\n return;\n }\n\n if (!initialized) {\n google.accounts.id.initialize({\n client_id: googleClientId,\n callback: handleGoogleCredential,\n });\n setInitialized(true);\n }\n\n if (parentRef.current && !buttonRendered) {\n google.accounts.id.renderButton(parentRef.current, {});\n setButtonRendered(true);\n }\n }, [medplum, googleClientId, initialized, scriptLoaded, parentRef, buttonRendered, handleGoogleCredential]);\n\n if (!googleClientId) {\n return null;\n }\n\n return <div ref={parentRef} />;\n}\n\nexport function getGoogleClientId(clientId: string | undefined): string | undefined {\n if (clientId) {\n return clientId;\n }\n\n const origin = window.location.protocol + '//' + window.location.host;\n const authorizedOrigins = process.env.GOOGLE_AUTH_ORIGINS?.split(',') ?? [];\n if (authorizedOrigins.includes(origin)) {\n return process.env.GOOGLE_CLIENT_ID;\n }\n\n return undefined;\n}\n"],"names":[],"mappings":";;;;AAqBM,SAAU,YAAY,CAAC,KAAwB,EAAA;AACnD,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;AAC7B,IAAA,MAAM,EAAE,cAAc,EAAE,sBAAsB,EAAE,GAAG,KAAK,CAAC;AACzD,IAAA,MAAM,SAAS,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;AAC/C,IAAA,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAU,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC;IACzF,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IAC/D,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IAErE,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;YACjC,eAAe,CAAC,wCAAwC,EAAE,MAAM,eAA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A,KAAA,CAAA,GAAA,EAAA,GAAI,EAAE,CAAC;AAC5E,IAAA,IAAI,iBAAiB,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;AACtC,QAAA,OAAO,0EAA4B,CAAC;AACrC,KAAA;AAED,IAAA,OAAO,SAAS,CAAC;AACnB;;;;"}
|
|
@@ -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;
|
|
@@ -44,7 +44,7 @@ function QuestionnaireForm(props) {
|
|
|
44
44
|
} },
|
|
45
45
|
questionnaire.title && React.createElement("h1", null, questionnaire.title),
|
|
46
46
|
questionnaire.item && React.createElement(QuestionnaireFormItemArray, { items: questionnaire.item, onChange: setItems }),
|
|
47
|
-
React.createElement(Button, { type: "submit", size: "large" },
|
|
47
|
+
React.createElement(Button, { type: "submit", size: "large" }, props.submitButtonText || 'OK')));
|
|
48
48
|
}
|
|
49
49
|
function QuestionnaireFormItemArray(props) {
|
|
50
50
|
const [responseItems, setResponseItems] = useState(buildInitialResponseItems(props.items));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuestionnaireForm.js","sources":["../../src/QuestionnaireForm.tsx"],"sourcesContent":["import {\n capitalize,\n createReference,\n getReferenceString,\n getTypedPropertyValue,\n globalSchema,\n IndexedStructureDefinition,\n ProfileResource,\n PropertyType,\n stringify,\n TypedValue,\n} from '@medplum/core';\nimport {\n Questionnaire,\n QuestionnaireItem,\n QuestionnaireItemAnswerOption,\n QuestionnaireItemInitial,\n QuestionnaireResponse,\n QuestionnaireResponseItem,\n QuestionnaireResponseItemAnswer,\n Reference,\n} from '@medplum/fhirtypes';\nimport React, { ChangeEvent, useEffect, useState } from 'react';\nimport { AttachmentInput } from './AttachmentInput';\nimport { Button } from './Button';\nimport { Checkbox } from './Checkbox';\nimport { CheckboxFormSection } from './CheckboxFormSection';\nimport { DateTimeInput } from './DateTimeInput';\nimport { Form } from './Form';\nimport { FormSection } from './FormSection';\nimport { Input } from './Input';\nimport { useMedplum } from './MedplumProvider';\nimport { QuantityInput } from './QuantityInput';\nimport { QuestionnaireItemType } from './QuestionnaireUtils';\nimport { ReferenceInput } from './ReferenceInput';\nimport { ResourcePropertyDisplay } from './ResourcePropertyDisplay';\nimport { TextArea } from './TextArea';\nimport { useResource } from './useResource';\nimport './QuestionnaireForm.css';\n\nexport interface QuestionnaireFormProps {\n questionnaire: Questionnaire | Reference<Questionnaire>;\n subject?: Reference;\n onSubmit: (response: QuestionnaireResponse) => void;\n}\n\nexport function QuestionnaireForm(props: QuestionnaireFormProps): JSX.Element | null {\n const medplum = useMedplum();\n const source = medplum.getProfile();\n const [schema, setSchema] = useState<IndexedStructureDefinition | undefined>();\n const questionnaire = useResource(props.questionnaire);\n const [response, setResponse] = useState<QuestionnaireResponse | undefined>();\n\n useEffect(() => {\n medplum.requestSchema('Questionnaire').then(setSchema).catch(console.log);\n }, [medplum]);\n\n useEffect(() => {\n setResponse(questionnaire ? buildInitialResponse(questionnaire) : undefined);\n }, [questionnaire]);\n\n function setItems(newResponseItems: QuestionnaireResponseItem[]): void {\n setResponse({\n resourceType: 'QuestionnaireResponse',\n item: newResponseItems,\n });\n }\n\n if (!schema || !questionnaire) {\n return null;\n }\n\n return (\n <Form\n testid=\"questionnaire-form\"\n onSubmit={() => {\n if (props.onSubmit && response) {\n props.onSubmit({\n ...response,\n questionnaire: getReferenceString(questionnaire),\n subject: props.subject,\n source: createReference(source as ProfileResource),\n authored: new Date().toISOString(),\n });\n }\n }}\n >\n {questionnaire.title && <h1>{questionnaire.title}</h1>}\n {questionnaire.item && <QuestionnaireFormItemArray items={questionnaire.item} onChange={setItems} />}\n <Button type=\"submit\" size=\"large\">\n OK\n </Button>\n </Form>\n );\n}\n\ninterface QuestionnaireFormItemArrayProps {\n items: QuestionnaireItem[];\n onChange: (newResponseItems: QuestionnaireResponseItem[]) => void;\n}\n\nfunction QuestionnaireFormItemArray(props: QuestionnaireFormItemArrayProps): JSX.Element {\n const [responseItems, setResponseItems] = useState<QuestionnaireResponseItem[]>(\n buildInitialResponseItems(props.items)\n );\n\n function setResponseItem(index: number, newResponseItem: QuestionnaireResponseItem): void {\n const newResponseItems = responseItems.slice();\n newResponseItems[index] = newResponseItem;\n setResponseItems(newResponseItems);\n props.onChange(newResponseItems);\n }\n\n return (\n <>\n {props.items.map((item, index) => {\n if (item.type === QuestionnaireItemType.display) {\n return <p key={item.linkId}>{item.text}</p>;\n }\n if (item.type === QuestionnaireItemType.group) {\n return (\n <QuestionnaireFormItem\n key={item.linkId}\n item={item}\n onChange={(newResponseItem) => setResponseItem(index, newResponseItem)}\n />\n );\n }\n if (item.type === QuestionnaireItemType.boolean) {\n const initial = item.initial && item.initial.length > 0 ? item.initial[0] : undefined;\n return (\n <CheckboxFormSection key={item.linkId} title={item.text} htmlFor={item.linkId}>\n <Checkbox\n name={item.linkId}\n defaultValue={initial?.valueBoolean}\n onChange={(newValue) =>\n setResponseItem(index, {\n linkId: item.linkId,\n text: item.text,\n answer: [{ valueBoolean: newValue }],\n })\n }\n />\n </CheckboxFormSection>\n );\n }\n return (\n <FormSection key={item.linkId} htmlFor={item.linkId} title={item.text || ''}>\n <QuestionnaireFormItem\n item={item}\n onChange={(newResponseItem) => setResponseItem(index, newResponseItem)}\n />\n </FormSection>\n );\n })}\n </>\n );\n}\n\nexport interface QuestionnaireFormItemProps {\n item: QuestionnaireItem;\n onChange: (newResponseItem: QuestionnaireResponseItem) => void;\n}\n\nexport function QuestionnaireFormItem(props: QuestionnaireFormItemProps): JSX.Element | null {\n const item = props.item;\n\n const type = item.type as QuestionnaireItemType;\n if (!type) {\n return null;\n }\n\n const name = item.linkId;\n if (!name) {\n return null;\n }\n\n const initial = item.initial && item.initial.length > 0 ? item.initial[0] : undefined;\n\n function onChangeItem(newResponseItems: QuestionnaireResponseItem[]): void {\n props.onChange({\n linkId: item.linkId,\n text: item.text,\n item: newResponseItems,\n });\n }\n\n function onChangeAnswer(newResponseAnswer: QuestionnaireResponseItemAnswer): void {\n props.onChange({\n linkId: item.linkId,\n text: item.text,\n answer: [newResponseAnswer],\n });\n }\n\n switch (type) {\n case QuestionnaireItemType.group:\n return (\n <div>\n <h3>{item.text}</h3>\n {item.item && <QuestionnaireFormItemArray items={item.item} onChange={onChangeItem} />}\n </div>\n );\n case QuestionnaireItemType.boolean:\n return (\n <Checkbox\n name={name}\n defaultValue={initial?.valueBoolean}\n onChange={(newValue) => onChangeAnswer({ valueBoolean: newValue })}\n />\n );\n case QuestionnaireItemType.decimal:\n return (\n <Input\n type=\"number\"\n step=\"any\"\n name={name}\n defaultValue={initial?.valueDecimal}\n onChange={(newValue) => onChangeAnswer({ valueDecimal: parseFloat(newValue) })}\n />\n );\n case QuestionnaireItemType.integer:\n return (\n <Input\n type=\"number\"\n step={1}\n name={name}\n defaultValue={initial?.valueInteger}\n onChange={(newValue) => onChangeAnswer({ valueInteger: parseInt(newValue) })}\n />\n );\n case QuestionnaireItemType.date:\n return (\n <Input\n type=\"date\"\n name={name}\n defaultValue={initial?.valueDate}\n onChange={(newValue) => onChangeAnswer({ valueDate: newValue })}\n />\n );\n case QuestionnaireItemType.dateTime:\n return (\n <DateTimeInput\n type=\"datetime-local\"\n name={name}\n defaultValue={initial?.valueDateTime}\n onChange={(newValue) => onChangeAnswer({ valueDateTime: newValue })}\n />\n );\n case QuestionnaireItemType.time:\n return (\n <Input\n type=\"time\"\n name={name}\n defaultValue={initial?.valueTime}\n onChange={(newValue) => onChangeAnswer({ valueTime: newValue })}\n />\n );\n case QuestionnaireItemType.string:\n return (\n <Input\n type=\"text\"\n name={name}\n defaultValue={initial?.valueString}\n onChange={(newValue) => onChangeAnswer({ valueString: newValue })}\n />\n );\n case QuestionnaireItemType.text:\n return (\n <TextArea\n name={name}\n defaultValue={initial?.valueString}\n onChange={(newValue) => onChangeAnswer({ valueString: newValue })}\n />\n );\n case QuestionnaireItemType.url:\n return (\n <Input\n type=\"url\"\n name={name}\n defaultValue={initial?.valueUri}\n onChange={(newValue) => onChangeAnswer({ valueUri: newValue })}\n />\n );\n case QuestionnaireItemType.attachment:\n return (\n <AttachmentInput\n name={name}\n defaultValue={initial?.valueAttachment}\n onChange={(newValue) => onChangeAnswer({ valueAttachment: newValue })}\n />\n );\n case QuestionnaireItemType.reference:\n return (\n <ReferenceInput\n name={name}\n defaultValue={initial?.valueReference}\n onChange={(newValue) => onChangeAnswer({ valueReference: newValue })}\n />\n );\n case QuestionnaireItemType.quantity:\n return (\n <QuantityInput\n name={name}\n defaultValue={initial?.valueQuantity}\n onChange={(newValue) => onChangeAnswer({ valueQuantity: newValue })}\n />\n );\n case QuestionnaireItemType.choice:\n case QuestionnaireItemType.openChoice:\n if (isDropDownChoice(item)) {\n return (\n <QuestionnaireChoiceDropDownInput name={name} item={item} initial={initial} onChangeAnswer={onChangeAnswer} />\n );\n } else {\n return (\n <QuestionnaireChoiceRadioInput name={name} item={item} initial={initial} onChangeAnswer={onChangeAnswer} />\n );\n }\n }\n\n return null;\n}\n\ninterface QuestionnaireChoiceInputProps {\n name: string;\n item: QuestionnaireItem;\n initial: QuestionnaireItemInitial | undefined;\n onChangeAnswer: (newResponseAnswer: QuestionnaireResponseItemAnswer) => void;\n}\n\nfunction QuestionnaireChoiceDropDownInput(props: QuestionnaireChoiceInputProps): JSX.Element {\n const { name, item, initial } = props;\n const valueElementDefinition = globalSchema.types['QuestionnaireItemAnswerOption'].properties['value[x]'];\n const initialValue = getTypedPropertyValue({ type: 'QuestionnaireItemInitial', value: initial }, 'value') as\n | TypedValue\n | undefined;\n\n return (\n <select\n id={name}\n name={name}\n className=\"medplum-select\"\n onChange={(e: ChangeEvent<HTMLSelectElement>) => {\n const index = e.currentTarget.selectedIndex;\n if (index === 0) {\n props.onChangeAnswer({});\n return;\n }\n const option = (item.answerOption as QuestionnaireItemAnswerOption[])[index - 1];\n const optionValue = getTypedPropertyValue(\n { type: 'QuestionnaireItemAnswerOption', value: option },\n 'value'\n ) as TypedValue;\n const propertyName = 'value' + capitalize(optionValue.type);\n props.onChangeAnswer({ [propertyName]: optionValue.value });\n }}\n >\n <option></option>\n {item.answerOption &&\n item.answerOption.map((option: QuestionnaireItemAnswerOption, index: number) => {\n const optionValue = getTypedPropertyValue(\n { type: 'QuestionnaireItemAnswerOption', value: option },\n 'value'\n ) as TypedValue;\n const optionName = `${name}-option-${index}`;\n return (\n <option\n key={optionName}\n value={optionValue.value}\n selected={initialValue && stringify(optionValue) === stringify(initialValue)}\n >\n <ResourcePropertyDisplay\n property={valueElementDefinition}\n propertyType={optionValue.type as PropertyType}\n value={optionValue.value}\n />\n </option>\n );\n })}\n </select>\n );\n}\n\nfunction QuestionnaireChoiceRadioInput(props: QuestionnaireChoiceInputProps): JSX.Element {\n const { name, item, initial, onChangeAnswer } = props;\n const valueElementDefinition = globalSchema.types['QuestionnaireItemAnswerOption'].properties['value[x]'];\n const initialValue = getTypedPropertyValue({ type: 'QuestionnaireItemInitial', value: initial }, 'value') as\n | TypedValue\n | undefined;\n return (\n <>\n {item.answerOption &&\n item.answerOption.map((option: QuestionnaireItemAnswerOption, index: number) => {\n const optionValue = getTypedPropertyValue(\n { type: 'QuestionnaireItemAnswerOption', value: option },\n 'value'\n ) as TypedValue;\n const propertyName = 'value' + capitalize(optionValue.type);\n const optionName = `${name}-option-${index}`;\n return (\n <div key={optionName} className=\"medplum-questionnaire-option-row\">\n <div className=\"medplum-questionnaire-option-checkbox\">\n <input\n type=\"radio\"\n id={optionName}\n name={name}\n value={optionValue.value}\n defaultChecked={initialValue && stringify(optionValue) === stringify(initialValue)}\n onChange={() => onChangeAnswer({ [propertyName]: optionValue.value })}\n />\n </div>\n <div>\n <label htmlFor={optionName}>\n <ResourcePropertyDisplay\n property={valueElementDefinition}\n propertyType={optionValue.type as PropertyType}\n value={optionValue.value}\n />\n </label>\n </div>\n </div>\n );\n })}\n </>\n );\n}\n\nfunction buildInitialResponse(questionnaire: Questionnaire): QuestionnaireResponse {\n const response: QuestionnaireResponse = {\n resourceType: 'QuestionnaireResponse',\n questionnaire: getReferenceString(questionnaire),\n item: buildInitialResponseItems(questionnaire.item),\n };\n\n return response;\n}\n\nfunction buildInitialResponseItems(items: QuestionnaireItem[] | undefined): QuestionnaireResponseItem[] {\n return items?.map(buildInitialResponseItem) ?? [];\n}\n\nfunction buildInitialResponseItem(item: QuestionnaireItem): QuestionnaireResponseItem {\n return {\n linkId: item.linkId,\n text: item.text,\n item: buildInitialResponseItems(item.item),\n answer: item.initial?.map(buildInitialResponseAnswer) ?? [],\n };\n}\n\nfunction buildInitialResponseAnswer(answer: QuestionnaireItemInitial): QuestionnaireResponseItemAnswer {\n // This works because QuestionnaireItemInitial and QuestionnaireResponseItemAnswer\n // have the same properties.\n return { ...answer };\n}\n\nfunction isDropDownChoice(item: QuestionnaireItem): boolean {\n return !!item.extension?.some(\n (e) =>\n e.url === 'http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl' &&\n e.valueCodeableConcept?.coding?.[0]?.code === 'drop-down'\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AA8CM,SAAU,iBAAiB,CAAC,KAA6B,EAAA;AAC7D,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;AAC7B,IAAA,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IACpC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,EAA0C,CAAC;IAC/E,MAAM,aAAa,GAAG,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IACvD,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,EAAqC,CAAC;IAE9E,SAAS,CAAC,MAAK;AACb,QAA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naireForm.js","sources":["../../src/QuestionnaireForm.tsx"],"sourcesContent":["import {\n capitalize,\n createReference,\n getReferenceString,\n getTypedPropertyValue,\n globalSchema,\n IndexedStructureDefinition,\n ProfileResource,\n PropertyType,\n stringify,\n TypedValue,\n} from '@medplum/core';\nimport {\n Questionnaire,\n QuestionnaireItem,\n QuestionnaireItemAnswerOption,\n QuestionnaireItemInitial,\n QuestionnaireResponse,\n QuestionnaireResponseItem,\n QuestionnaireResponseItemAnswer,\n Reference,\n} from '@medplum/fhirtypes';\nimport React, { ChangeEvent, useEffect, useState } from 'react';\nimport { AttachmentInput } from './AttachmentInput';\nimport { Button } from './Button';\nimport { Checkbox } from './Checkbox';\nimport { CheckboxFormSection } from './CheckboxFormSection';\nimport { DateTimeInput } from './DateTimeInput';\nimport { Form } from './Form';\nimport { FormSection } from './FormSection';\nimport { Input } from './Input';\nimport { useMedplum } from './MedplumProvider';\nimport { QuantityInput } from './QuantityInput';\nimport { QuestionnaireItemType } from './QuestionnaireUtils';\nimport { ReferenceInput } from './ReferenceInput';\nimport { ResourcePropertyDisplay } from './ResourcePropertyDisplay';\nimport { TextArea } from './TextArea';\nimport { useResource } from './useResource';\nimport './QuestionnaireForm.css';\n\nexport interface QuestionnaireFormProps {\n questionnaire: Questionnaire | Reference<Questionnaire>;\n subject?: Reference;\n submitButtonText?: string;\n onSubmit: (response: QuestionnaireResponse) => void;\n}\n\nexport function QuestionnaireForm(props: QuestionnaireFormProps): JSX.Element | null {\n const medplum = useMedplum();\n const source = medplum.getProfile();\n const [schema, setSchema] = useState<IndexedStructureDefinition | undefined>();\n const questionnaire = useResource(props.questionnaire);\n const [response, setResponse] = useState<QuestionnaireResponse | undefined>();\n\n useEffect(() => {\n medplum.requestSchema('Questionnaire').then(setSchema).catch(console.log);\n }, [medplum]);\n\n useEffect(() => {\n setResponse(questionnaire ? buildInitialResponse(questionnaire) : undefined);\n }, [questionnaire]);\n\n function setItems(newResponseItems: QuestionnaireResponseItem[]): void {\n setResponse({\n resourceType: 'QuestionnaireResponse',\n item: newResponseItems,\n });\n }\n\n if (!schema || !questionnaire) {\n return null;\n }\n\n return (\n <Form\n testid=\"questionnaire-form\"\n onSubmit={() => {\n if (props.onSubmit && response) {\n props.onSubmit({\n ...response,\n questionnaire: getReferenceString(questionnaire),\n subject: props.subject,\n source: createReference(source as ProfileResource),\n authored: new Date().toISOString(),\n });\n }\n }}\n >\n {questionnaire.title && <h1>{questionnaire.title}</h1>}\n {questionnaire.item && <QuestionnaireFormItemArray items={questionnaire.item} onChange={setItems} />}\n <Button type=\"submit\" size=\"large\">\n {props.submitButtonText || 'OK'}\n </Button>\n </Form>\n );\n}\n\ninterface QuestionnaireFormItemArrayProps {\n items: QuestionnaireItem[];\n onChange: (newResponseItems: QuestionnaireResponseItem[]) => void;\n}\n\nfunction QuestionnaireFormItemArray(props: QuestionnaireFormItemArrayProps): JSX.Element {\n const [responseItems, setResponseItems] = useState<QuestionnaireResponseItem[]>(\n buildInitialResponseItems(props.items)\n );\n\n function setResponseItem(index: number, newResponseItem: QuestionnaireResponseItem): void {\n const newResponseItems = responseItems.slice();\n newResponseItems[index] = newResponseItem;\n setResponseItems(newResponseItems);\n props.onChange(newResponseItems);\n }\n\n return (\n <>\n {props.items.map((item, index) => {\n if (item.type === QuestionnaireItemType.display) {\n return <p key={item.linkId}>{item.text}</p>;\n }\n if (item.type === QuestionnaireItemType.group) {\n return (\n <QuestionnaireFormItem\n key={item.linkId}\n item={item}\n onChange={(newResponseItem) => setResponseItem(index, newResponseItem)}\n />\n );\n }\n if (item.type === QuestionnaireItemType.boolean) {\n const initial = item.initial && item.initial.length > 0 ? item.initial[0] : undefined;\n return (\n <CheckboxFormSection key={item.linkId} title={item.text} htmlFor={item.linkId}>\n <Checkbox\n name={item.linkId}\n defaultValue={initial?.valueBoolean}\n onChange={(newValue) =>\n setResponseItem(index, {\n linkId: item.linkId,\n text: item.text,\n answer: [{ valueBoolean: newValue }],\n })\n }\n />\n </CheckboxFormSection>\n );\n }\n return (\n <FormSection key={item.linkId} htmlFor={item.linkId} title={item.text || ''}>\n <QuestionnaireFormItem\n item={item}\n onChange={(newResponseItem) => setResponseItem(index, newResponseItem)}\n />\n </FormSection>\n );\n })}\n </>\n );\n}\n\nexport interface QuestionnaireFormItemProps {\n item: QuestionnaireItem;\n onChange: (newResponseItem: QuestionnaireResponseItem) => void;\n}\n\nexport function QuestionnaireFormItem(props: QuestionnaireFormItemProps): JSX.Element | null {\n const item = props.item;\n\n const type = item.type as QuestionnaireItemType;\n if (!type) {\n return null;\n }\n\n const name = item.linkId;\n if (!name) {\n return null;\n }\n\n const initial = item.initial && item.initial.length > 0 ? item.initial[0] : undefined;\n\n function onChangeItem(newResponseItems: QuestionnaireResponseItem[]): void {\n props.onChange({\n linkId: item.linkId,\n text: item.text,\n item: newResponseItems,\n });\n }\n\n function onChangeAnswer(newResponseAnswer: QuestionnaireResponseItemAnswer): void {\n props.onChange({\n linkId: item.linkId,\n text: item.text,\n answer: [newResponseAnswer],\n });\n }\n\n switch (type) {\n case QuestionnaireItemType.group:\n return (\n <div>\n <h3>{item.text}</h3>\n {item.item && <QuestionnaireFormItemArray items={item.item} onChange={onChangeItem} />}\n </div>\n );\n case QuestionnaireItemType.boolean:\n return (\n <Checkbox\n name={name}\n defaultValue={initial?.valueBoolean}\n onChange={(newValue) => onChangeAnswer({ valueBoolean: newValue })}\n />\n );\n case QuestionnaireItemType.decimal:\n return (\n <Input\n type=\"number\"\n step=\"any\"\n name={name}\n defaultValue={initial?.valueDecimal}\n onChange={(newValue) => onChangeAnswer({ valueDecimal: parseFloat(newValue) })}\n />\n );\n case QuestionnaireItemType.integer:\n return (\n <Input\n type=\"number\"\n step={1}\n name={name}\n defaultValue={initial?.valueInteger}\n onChange={(newValue) => onChangeAnswer({ valueInteger: parseInt(newValue) })}\n />\n );\n case QuestionnaireItemType.date:\n return (\n <Input\n type=\"date\"\n name={name}\n defaultValue={initial?.valueDate}\n onChange={(newValue) => onChangeAnswer({ valueDate: newValue })}\n />\n );\n case QuestionnaireItemType.dateTime:\n return (\n <DateTimeInput\n type=\"datetime-local\"\n name={name}\n defaultValue={initial?.valueDateTime}\n onChange={(newValue) => onChangeAnswer({ valueDateTime: newValue })}\n />\n );\n case QuestionnaireItemType.time:\n return (\n <Input\n type=\"time\"\n name={name}\n defaultValue={initial?.valueTime}\n onChange={(newValue) => onChangeAnswer({ valueTime: newValue })}\n />\n );\n case QuestionnaireItemType.string:\n return (\n <Input\n type=\"text\"\n name={name}\n defaultValue={initial?.valueString}\n onChange={(newValue) => onChangeAnswer({ valueString: newValue })}\n />\n );\n case QuestionnaireItemType.text:\n return (\n <TextArea\n name={name}\n defaultValue={initial?.valueString}\n onChange={(newValue) => onChangeAnswer({ valueString: newValue })}\n />\n );\n case QuestionnaireItemType.url:\n return (\n <Input\n type=\"url\"\n name={name}\n defaultValue={initial?.valueUri}\n onChange={(newValue) => onChangeAnswer({ valueUri: newValue })}\n />\n );\n case QuestionnaireItemType.attachment:\n return (\n <AttachmentInput\n name={name}\n defaultValue={initial?.valueAttachment}\n onChange={(newValue) => onChangeAnswer({ valueAttachment: newValue })}\n />\n );\n case QuestionnaireItemType.reference:\n return (\n <ReferenceInput\n name={name}\n defaultValue={initial?.valueReference}\n onChange={(newValue) => onChangeAnswer({ valueReference: newValue })}\n />\n );\n case QuestionnaireItemType.quantity:\n return (\n <QuantityInput\n name={name}\n defaultValue={initial?.valueQuantity}\n onChange={(newValue) => onChangeAnswer({ valueQuantity: newValue })}\n />\n );\n case QuestionnaireItemType.choice:\n case QuestionnaireItemType.openChoice:\n if (isDropDownChoice(item)) {\n return (\n <QuestionnaireChoiceDropDownInput name={name} item={item} initial={initial} onChangeAnswer={onChangeAnswer} />\n );\n } else {\n return (\n <QuestionnaireChoiceRadioInput name={name} item={item} initial={initial} onChangeAnswer={onChangeAnswer} />\n );\n }\n }\n\n return null;\n}\n\ninterface QuestionnaireChoiceInputProps {\n name: string;\n item: QuestionnaireItem;\n initial: QuestionnaireItemInitial | undefined;\n onChangeAnswer: (newResponseAnswer: QuestionnaireResponseItemAnswer) => void;\n}\n\nfunction QuestionnaireChoiceDropDownInput(props: QuestionnaireChoiceInputProps): JSX.Element {\n const { name, item, initial } = props;\n const valueElementDefinition = globalSchema.types['QuestionnaireItemAnswerOption'].properties['value[x]'];\n const initialValue = getTypedPropertyValue({ type: 'QuestionnaireItemInitial', value: initial }, 'value') as\n | TypedValue\n | undefined;\n\n return (\n <select\n id={name}\n name={name}\n className=\"medplum-select\"\n onChange={(e: ChangeEvent<HTMLSelectElement>) => {\n const index = e.currentTarget.selectedIndex;\n if (index === 0) {\n props.onChangeAnswer({});\n return;\n }\n const option = (item.answerOption as QuestionnaireItemAnswerOption[])[index - 1];\n const optionValue = getTypedPropertyValue(\n { type: 'QuestionnaireItemAnswerOption', value: option },\n 'value'\n ) as TypedValue;\n const propertyName = 'value' + capitalize(optionValue.type);\n props.onChangeAnswer({ [propertyName]: optionValue.value });\n }}\n >\n <option></option>\n {item.answerOption &&\n item.answerOption.map((option: QuestionnaireItemAnswerOption, index: number) => {\n const optionValue = getTypedPropertyValue(\n { type: 'QuestionnaireItemAnswerOption', value: option },\n 'value'\n ) as TypedValue;\n const optionName = `${name}-option-${index}`;\n return (\n <option\n key={optionName}\n value={optionValue.value}\n selected={initialValue && stringify(optionValue) === stringify(initialValue)}\n >\n <ResourcePropertyDisplay\n property={valueElementDefinition}\n propertyType={optionValue.type as PropertyType}\n value={optionValue.value}\n />\n </option>\n );\n })}\n </select>\n );\n}\n\nfunction QuestionnaireChoiceRadioInput(props: QuestionnaireChoiceInputProps): JSX.Element {\n const { name, item, initial, onChangeAnswer } = props;\n const valueElementDefinition = globalSchema.types['QuestionnaireItemAnswerOption'].properties['value[x]'];\n const initialValue = getTypedPropertyValue({ type: 'QuestionnaireItemInitial', value: initial }, 'value') as\n | TypedValue\n | undefined;\n return (\n <>\n {item.answerOption &&\n item.answerOption.map((option: QuestionnaireItemAnswerOption, index: number) => {\n const optionValue = getTypedPropertyValue(\n { type: 'QuestionnaireItemAnswerOption', value: option },\n 'value'\n ) as TypedValue;\n const propertyName = 'value' + capitalize(optionValue.type);\n const optionName = `${name}-option-${index}`;\n return (\n <div key={optionName} className=\"medplum-questionnaire-option-row\">\n <div className=\"medplum-questionnaire-option-checkbox\">\n <input\n type=\"radio\"\n id={optionName}\n name={name}\n value={optionValue.value}\n defaultChecked={initialValue && stringify(optionValue) === stringify(initialValue)}\n onChange={() => onChangeAnswer({ [propertyName]: optionValue.value })}\n />\n </div>\n <div>\n <label htmlFor={optionName}>\n <ResourcePropertyDisplay\n property={valueElementDefinition}\n propertyType={optionValue.type as PropertyType}\n value={optionValue.value}\n />\n </label>\n </div>\n </div>\n );\n })}\n </>\n );\n}\n\nfunction buildInitialResponse(questionnaire: Questionnaire): QuestionnaireResponse {\n const response: QuestionnaireResponse = {\n resourceType: 'QuestionnaireResponse',\n questionnaire: getReferenceString(questionnaire),\n item: buildInitialResponseItems(questionnaire.item),\n };\n\n return response;\n}\n\nfunction buildInitialResponseItems(items: QuestionnaireItem[] | undefined): QuestionnaireResponseItem[] {\n return items?.map(buildInitialResponseItem) ?? [];\n}\n\nfunction buildInitialResponseItem(item: QuestionnaireItem): QuestionnaireResponseItem {\n return {\n linkId: item.linkId,\n text: item.text,\n item: buildInitialResponseItems(item.item),\n answer: item.initial?.map(buildInitialResponseAnswer) ?? [],\n };\n}\n\nfunction buildInitialResponseAnswer(answer: QuestionnaireItemInitial): QuestionnaireResponseItemAnswer {\n // This works because QuestionnaireItemInitial and QuestionnaireResponseItemAnswer\n // have the same properties.\n return { ...answer };\n}\n\nfunction isDropDownChoice(item: QuestionnaireItem): boolean {\n return !!item.extension?.some(\n (e) =>\n e.url === 'http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl' &&\n e.valueCodeableConcept?.coding?.[0]?.code === 'drop-down'\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AA+CM,SAAU,iBAAiB,CAAC,KAA6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A,EAAA,GAAA,CAAC,CAAC,oBAAoB,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,MAAM,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAG,CAAC,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAE,IAAI,MAAK,WAAW,CAAA;AAAA,KAAA,CAC5D,CAAA,CAAC;AACJ;;;;"}
|
package/dist/esm/Scheduler.d.ts
CHANGED
|
@@ -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;
|
package/dist/esm/Scheduler.js
CHANGED
|
@@ -3,9 +3,8 @@ import React, { useState, useRef, useEffect } from 'react';
|
|
|
3
3
|
import { Avatar } from './Avatar.js';
|
|
4
4
|
import { Button } from './Button.js';
|
|
5
5
|
import { getStartMonth, CalendarInput } from './CalendarInput.js';
|
|
6
|
-
import { FormSection } from './FormSection.js';
|
|
7
|
-
import { Input } from './Input.js';
|
|
8
6
|
import { useMedplum } from './MedplumProvider.js';
|
|
7
|
+
import { QuestionnaireForm } from './QuestionnaireForm.js';
|
|
9
8
|
import { ResourceName } from './ResourceName.js';
|
|
10
9
|
import { useResource } from './useResource.js';
|
|
11
10
|
|
|
@@ -13,22 +12,23 @@ function Scheduler(props) {
|
|
|
13
12
|
var _a;
|
|
14
13
|
const medplum = useMedplum();
|
|
15
14
|
const schedule = useResource(props.schedule);
|
|
15
|
+
const questionnaire = useResource(props.questionnaire);
|
|
16
16
|
const [slots, setSlots] = useState();
|
|
17
17
|
const slotsRef = useRef();
|
|
18
18
|
slotsRef.current = slots;
|
|
19
19
|
const [month, setMonth] = useState(getStartMonth());
|
|
20
20
|
const [date, setDate] = useState();
|
|
21
21
|
const [slot, setSlot] = useState();
|
|
22
|
-
const [
|
|
23
|
-
const [form, setForm] = useState();
|
|
22
|
+
const [response, setResponse] = useState();
|
|
24
23
|
useEffect(() => {
|
|
25
24
|
if (schedule) {
|
|
26
25
|
setSlots([]);
|
|
27
26
|
medplum
|
|
28
27
|
.searchResources('Slot', new URLSearchParams([
|
|
28
|
+
['_count', (30 * 24).toString()],
|
|
29
29
|
['schedule', getReferenceString(schedule)],
|
|
30
|
-
['start', 'gt' + month
|
|
31
|
-
['start', 'lt' +
|
|
30
|
+
['start', 'gt' + getStart(month)],
|
|
31
|
+
['start', 'lt' + getEnd(month)],
|
|
32
32
|
]))
|
|
33
33
|
.then(setSlots)
|
|
34
34
|
.catch(console.log);
|
|
@@ -37,7 +37,7 @@ function Scheduler(props) {
|
|
|
37
37
|
setSlots(undefined);
|
|
38
38
|
}
|
|
39
39
|
}, [medplum, schedule, month]);
|
|
40
|
-
if (!schedule || !slots) {
|
|
40
|
+
if (!schedule || !slots || !questionnaire) {
|
|
41
41
|
return null;
|
|
42
42
|
}
|
|
43
43
|
const actor = (_a = schedule.actor) === null || _a === void 0 ? void 0 : _a[0];
|
|
@@ -61,26 +61,20 @@ function Scheduler(props) {
|
|
|
61
61
|
slotStart.getTime() < date.getTime() + 24 * 3600 * 1000 && (React.createElement("div", { key: s.id },
|
|
62
62
|
React.createElement(Button, { style: { width: 150 }, onClick: () => setSlot(s) }, formatTime(slotStart)))));
|
|
63
63
|
}))),
|
|
64
|
-
date && slot && !
|
|
65
|
-
|
|
66
|
-
React.createElement(FormSection, { title: "Name", htmlFor: "name" },
|
|
67
|
-
React.createElement(Input, { name: "name" })),
|
|
68
|
-
React.createElement(FormSection, { title: "Email", htmlFor: "email" },
|
|
69
|
-
React.createElement(Input, { name: "email" })),
|
|
70
|
-
React.createElement(Button, { primary: true, onClick: () => setInfo('info') }, "Next"))),
|
|
71
|
-
date && slot && info && !form && (React.createElement("div", null,
|
|
72
|
-
React.createElement("h3", null, "Custom questions"),
|
|
73
|
-
React.createElement(FormSection, { title: "Question 1", htmlFor: "q1" },
|
|
74
|
-
React.createElement(Input, { name: "q1" })),
|
|
75
|
-
React.createElement(FormSection, { title: "Question 2", htmlFor: "q2" },
|
|
76
|
-
React.createElement(Input, { name: "email" })),
|
|
77
|
-
React.createElement(FormSection, { title: "Question 3", htmlFor: "q3" },
|
|
78
|
-
React.createElement(Input, { name: "email" })),
|
|
79
|
-
React.createElement(Button, { primary: true, onClick: () => setForm('form') }, "Next"))),
|
|
80
|
-
date && slot && info && form && (React.createElement("div", null,
|
|
64
|
+
date && slot && !response && (React.createElement(QuestionnaireForm, { questionnaire: questionnaire, submitButtonText: 'Next', onSubmit: setResponse })),
|
|
65
|
+
date && slot && response && (React.createElement("div", null,
|
|
81
66
|
React.createElement("h3", null, "You're all set!"),
|
|
82
67
|
React.createElement("p", null, "Check your email for a calendar invite."))))));
|
|
83
68
|
}
|
|
69
|
+
function getStart(month) {
|
|
70
|
+
return formatSlotInstant(month.getTime());
|
|
71
|
+
}
|
|
72
|
+
function getEnd(month) {
|
|
73
|
+
return formatSlotInstant(month.getTime() + 31 * 24 * 60 * 60 * 1000);
|
|
74
|
+
}
|
|
75
|
+
function formatSlotInstant(time) {
|
|
76
|
+
return new Date(Math.max(Date.now(), time)).toISOString();
|
|
77
|
+
}
|
|
84
78
|
function formatTime(date) {
|
|
85
79
|
return date.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' });
|
|
86
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scheduler.js","sources":["../../src/Scheduler.tsx"],"sourcesContent":["import { getReferenceString } from '@medplum/core';\nimport { Reference, Schedule, Slot } from '@medplum/fhirtypes';\nimport React, { useEffect, useRef, useState } from 'react';\nimport { Avatar } from './Avatar';\nimport { Button } from './Button';\nimport { CalendarInput, getStartMonth } from './CalendarInput';\nimport {
|
|
1
|
+
{"version":3,"file":"Scheduler.js","sources":["../../src/Scheduler.tsx"],"sourcesContent":["import { getReferenceString } from '@medplum/core';\nimport { Questionnaire, QuestionnaireResponse, Reference, Schedule, Slot } from '@medplum/fhirtypes';\nimport React, { useEffect, useRef, useState } from 'react';\nimport { Avatar } from './Avatar';\nimport { Button } from './Button';\nimport { CalendarInput, getStartMonth } from './CalendarInput';\nimport { useMedplum } from './MedplumProvider';\nimport { QuestionnaireForm } from './QuestionnaireForm';\nimport { ResourceName } from './ResourceName';\nimport { useResource } from './useResource';\nimport './Scheduler.css';\n\nexport interface SchedulerProps {\n schedule: Schedule | Reference<Schedule>;\n questionnaire: Questionnaire | Reference<Questionnaire>;\n}\n\nexport function Scheduler(props: SchedulerProps): JSX.Element | null {\n const medplum = useMedplum();\n const schedule = useResource(props.schedule);\n const questionnaire = useResource(props.questionnaire);\n\n const [slots, setSlots] = useState<Slot[]>();\n const slotsRef = useRef<Slot[]>();\n slotsRef.current = slots;\n\n const [month, setMonth] = useState<Date>(getStartMonth());\n const [date, setDate] = useState<Date>();\n const [slot, setSlot] = useState<Slot>();\n const [response, setResponse] = useState<QuestionnaireResponse>();\n\n useEffect(() => {\n if (schedule) {\n setSlots([]);\n medplum\n .searchResources(\n 'Slot',\n new URLSearchParams([\n ['_count', (30 * 24).toString()],\n ['schedule', getReferenceString(schedule)],\n ['start', 'gt' + getStart(month)],\n ['start', 'lt' + getEnd(month)],\n ])\n )\n .then(setSlots)\n .catch(console.log);\n } else {\n setSlots(undefined);\n }\n }, [medplum, schedule, month]);\n\n if (!schedule || !slots || !questionnaire) {\n return null;\n }\n\n const actor = schedule.actor?.[0];\n\n return (\n <div className=\"medplum-calendar-container\" data-testid=\"scheduler\">\n <div className=\"medplum-calendar-info-pane\">\n {actor && <Avatar value={actor} size=\"large\" />}\n {actor && (\n <h1>\n <ResourceName value={actor} />\n </h1>\n )}\n <p>1 hour</p>\n {date && <p>{date.toLocaleDateString()}</p>}\n {slot && <p>{formatTime(new Date(slot.start as string))}</p>}\n </div>\n <div className=\"medplum-calendar-selection-pane\">\n {!date && (\n <div>\n <h3>Select date</h3>\n <CalendarInput slots={slots} onChangeMonth={setMonth} onClick={setDate} />\n </div>\n )}\n {date && !slot && (\n <div>\n <h3>Select time</h3>\n {slots.map((s) => {\n const slotStart = new Date(s.start as string);\n return (\n slotStart.getTime() > date.getTime() &&\n slotStart.getTime() < date.getTime() + 24 * 3600 * 1000 && (\n <div key={s.id}>\n <Button style={{ width: 150 }} onClick={() => setSlot(s)}>\n {formatTime(slotStart)}\n </Button>\n </div>\n )\n );\n })}\n </div>\n )}\n {date && slot && !response && (\n <QuestionnaireForm questionnaire={questionnaire} submitButtonText={'Next'} onSubmit={setResponse} />\n )}\n {date && slot && response && (\n <div>\n <h3>You're all set!</h3>\n <p>Check your email for a calendar invite.</p>\n </div>\n )}\n </div>\n </div>\n );\n}\n\nfunction getStart(month: Date): string {\n return formatSlotInstant(month.getTime());\n}\n\nfunction getEnd(month: Date): string {\n return formatSlotInstant(month.getTime() + 31 * 24 * 60 * 60 * 1000);\n}\n\nfunction formatSlotInstant(time: number): string {\n return new Date(Math.max(Date.now(), time)).toISOString();\n}\n\nfunction formatTime(date: Date): string {\n return date.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' });\n}\n"],"names":[],"mappings":";;;;;;;;;;AAiBM,SAAU,SAAS,CAAC,KAAqB,EAAA;;AAC7C,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC7C,MAAM,aAAa,GAAG,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAEvD,MAAM,CAAC,KAAK,EA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KAAW,EAAA;AAC3B,IAAA,OAAO,iBAAiB,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,MAAM,CAAC,KAAW,EAAA;AACzB,IAAA,OAAO,iBAAiB,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;AACvE,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAY,EAAA;AACrC,IAAA,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;AAC5D,CAAC;AAED,SAAS,UAAU,CAAC,IAAU,EAAA;AAC5B,IAAA,OAAO,IAAI,CAAC,kBAAkB,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;AAC7E;;;;"}
|
|
@@ -16,19 +16,19 @@ function ServiceRequestTimeline(props) {
|
|
|
16
16
|
{
|
|
17
17
|
request: {
|
|
18
18
|
method: 'GET',
|
|
19
|
-
url: `Communication?based-on=${getReferenceString(resource)}`,
|
|
19
|
+
url: `Communication?based-on=${getReferenceString(resource)}&_sort=-_lastUpdated`,
|
|
20
20
|
},
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
23
|
request: {
|
|
24
24
|
method: 'GET',
|
|
25
|
-
url: `Media?_count=100&based-on=${getReferenceString(resource)}`,
|
|
25
|
+
url: `Media?_count=100&based-on=${getReferenceString(resource)}&_sort=-_lastUpdated`,
|
|
26
26
|
},
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
request: {
|
|
30
30
|
method: 'GET',
|
|
31
|
-
url: `DiagnosticReport?based-on=${getReferenceString(resource)}`,
|
|
31
|
+
url: `DiagnosticReport?based-on=${getReferenceString(resource)}&_sort=-_lastUpdated`,
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
34
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceRequestTimeline.js","sources":["../../src/ServiceRequestTimeline.tsx"],"sourcesContent":["import { createReference, getReferenceString, ProfileResource } from '@medplum/core';\nimport { Attachment, Group, Patient, Reference, Resource, ServiceRequest } from '@medplum/fhirtypes';\nimport React from 'react';\nimport { ResourceTimeline } from './ResourceTimeline';\n\nexport interface ServiceRequestTimelineProps {\n serviceRequest: ServiceRequest | Reference<ServiceRequest>;\n}\n\nexport function ServiceRequestTimeline(props: ServiceRequestTimelineProps): JSX.Element {\n return (\n <ResourceTimeline\n value={props.serviceRequest}\n buildSearchRequests={(resource: Resource) => ({\n resourceType: 'Bundle',\n type: 'batch',\n entry: [\n {\n request: {\n method: 'GET',\n url: `${getReferenceString(resource)}/_history`,\n },\n },\n {\n request: {\n method: 'GET',\n url: `Communication?based-on=${getReferenceString(resource)}`,\n },\n },\n {\n request: {\n method: 'GET',\n url: `Media?_count=100&based-on=${getReferenceString(resource)}`,\n },\n },\n {\n request: {\n method: 'GET',\n url: `DiagnosticReport?based-on=${getReferenceString(resource)}`,\n },\n },\n ],\n })}\n createCommunication={(resource: ServiceRequest, sender: ProfileResource, text: string) => ({\n resourceType: 'Communication',\n basedOn: [createReference(resource)],\n subject: resource.subject as Reference<Group | Patient>,\n sender: createReference(sender),\n sent: new Date().toISOString(),\n payload: [{ contentString: text }],\n })}\n createMedia={(resource: ServiceRequest, operator: ProfileResource, content: Attachment) => ({\n resourceType: 'Media',\n basedOn: [createReference(resource)],\n subject: resource.subject,\n operator: createReference(operator),\n issued: new Date().toISOString(),\n content,\n })}\n />\n );\n}\n"],"names":[],"mappings":";;;;AASM,SAAU,sBAAsB,CAAC,KAAkC,EAAA;AACvE,IAAA,QACE,KAAC,CAAA,aAAA,CAAA,gBAAgB,EACf,EAAA,KAAK,EAAE,KAAK,CAAC,cAAc,EAC3B,mBAAmB,EAAE,CAAC,QAAkB,MAAM;AAC5C,YAAA,YAAY,EAAE,QAAQ;AACtB,YAAA,IAAI,EAAE,OAAO;AACb,YAAA,KAAK,EAAE;AACL,gBAAA;AACE,oBAAA,OAAO,EAAE;AACP,wBAAA,MAAM,EAAE,KAAK;AACb,wBAAA,GAAG,EAAE,CAAG,EAAA,kBAAkB,CAAC,QAAQ,CAAC,CAAW,SAAA,CAAA;AAChD,qBAAA;AACF,iBAAA;AACD,gBAAA;AACE,oBAAA,OAAO,EAAE;AACP,wBAAA,MAAM,EAAE,KAAK;AACb,wBAAA,GAAG,EAAE,CAA0B,uBAAA,EAAA,kBAAkB,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"ServiceRequestTimeline.js","sources":["../../src/ServiceRequestTimeline.tsx"],"sourcesContent":["import { createReference, getReferenceString, ProfileResource } from '@medplum/core';\nimport { Attachment, Group, Patient, Reference, Resource, ServiceRequest } from '@medplum/fhirtypes';\nimport React from 'react';\nimport { ResourceTimeline } from './ResourceTimeline';\n\nexport interface ServiceRequestTimelineProps {\n serviceRequest: ServiceRequest | Reference<ServiceRequest>;\n}\n\nexport function ServiceRequestTimeline(props: ServiceRequestTimelineProps): JSX.Element {\n return (\n <ResourceTimeline\n value={props.serviceRequest}\n buildSearchRequests={(resource: Resource) => ({\n resourceType: 'Bundle',\n type: 'batch',\n entry: [\n {\n request: {\n method: 'GET',\n url: `${getReferenceString(resource)}/_history`,\n },\n },\n {\n request: {\n method: 'GET',\n url: `Communication?based-on=${getReferenceString(resource)}&_sort=-_lastUpdated`,\n },\n },\n {\n request: {\n method: 'GET',\n url: `Media?_count=100&based-on=${getReferenceString(resource)}&_sort=-_lastUpdated`,\n },\n },\n {\n request: {\n method: 'GET',\n url: `DiagnosticReport?based-on=${getReferenceString(resource)}&_sort=-_lastUpdated`,\n },\n },\n ],\n })}\n createCommunication={(resource: ServiceRequest, sender: ProfileResource, text: string) => ({\n resourceType: 'Communication',\n basedOn: [createReference(resource)],\n subject: resource.subject as Reference<Group | Patient>,\n sender: createReference(sender),\n sent: new Date().toISOString(),\n payload: [{ contentString: text }],\n })}\n createMedia={(resource: ServiceRequest, operator: ProfileResource, content: Attachment) => ({\n resourceType: 'Media',\n basedOn: [createReference(resource)],\n subject: resource.subject,\n operator: createReference(operator),\n issued: new Date().toISOString(),\n content,\n })}\n />\n );\n}\n"],"names":[],"mappings":";;;;AASM,SAAU,sBAAsB,CAAC,KAAkC,EAAA;AACvE,IAAA,QACE,KAAC,CAAA,aAAA,CAAA,gBAAgB,EACf,EAAA,KAAK,EAAE,KAAK,CAAC,cAAc,EAC3B,mBAAmB,EAAE,CAAC,QAAkB,MAAM;AAC5C,YAAA,YAAY,EAAE,QAAQ;AACtB,YAAA,IAAI,EAAE,OAAO;AACb,YAAA,KAAK,EAAE;AACL,gBAAA;AACE,oBAAA,OAAO,EAAE;AACP,wBAAA,MAAM,EAAE,KAAK;AACb,wBAAA,GAAG,EAAE,CAAG,EAAA,kBAAkB,CAAC,QAAQ,CAAC,CAAW,SAAA,CAAA;AAChD,qBAAA;AACF,iBAAA;AACD,gBAAA;AACE,oBAAA,OAAO,EAAE;AACP,wBAAA,MAAM,EAAE,KAAK;AACb,wBAAA,GAAG,EAAE,CAA0B,uBAAA,EAAA,kBAAkB,CAAC,QAAQ,CAAC,CAAsB,oBAAA,CAAA;AAClF,qBAAA;AACF,iBAAA;AACD,gBAAA;AACE,oBAAA,OAAO,EAAE;AACP,wBAAA,MAAM,EAAE,KAAK;AACb,wBAAA,GAAG,EAAE,CAA6B,0BAAA,EAAA,kBAAkB,CAAC,QAAQ,CAAC,CAAsB,oBAAA,CAAA;AACrF,qBAAA;AACF,iBAAA;AACD,gBAAA;AACE,oBAAA,OAAO,EAAE;AACP,wBAAA,MAAM,EAAE,KAAK;AACb,wBAAA,GAAG,EAAE,CAA6B,0BAAA,EAAA,kBAAkB,CAAC,QAAQ,CAAC,CAAsB,oBAAA,CAAA;AACrF,qBAAA;AACF,iBAAA;AACF,aAAA;AACF,SAAA,CAAC,EACF,mBAAmB,EAAE,CAAC,QAAwB,EAAE,MAAuB,EAAE,IAAY,MAAM;AACzF,YAAA,YAAY,EAAE,eAAe;AAC7B,YAAA,OAAO,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;YACpC,OAAO,EAAE,QAAQ,CAAC,OAAqC;AACvD,YAAA,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC;AAC/B,YAAA,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;AAC9B,YAAA,OAAO,EAAE,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;AACnC,SAAA,CAAC,EACF,WAAW,EAAE,CAAC,QAAwB,EAAE,QAAyB,EAAE,OAAmB,MAAM;AAC1F,YAAA,YAAY,EAAE,OAAO;AACrB,YAAA,OAAO,EAAE,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;YACpC,OAAO,EAAE,QAAQ,CAAC,OAAO;AACzB,YAAA,QAAQ,EAAE,eAAe,CAAC,QAAQ,CAAC;AACnC,YAAA,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YAChC,OAAO;SACR,CAAC,EAAA,CACF,EACF;AACJ;;;;"}
|
|
@@ -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;
|
|
@@ -20,6 +20,8 @@ function AuthenticationForm(props) {
|
|
|
20
20
|
clientId: props.clientId,
|
|
21
21
|
scope: props.scope,
|
|
22
22
|
nonce: props.nonce,
|
|
23
|
+
codeChallenge: props.codeChallenge,
|
|
24
|
+
codeChallengeMethod: props.codeChallengeMethod,
|
|
23
25
|
email: formData.email,
|
|
24
26
|
password: formData.password,
|
|
25
27
|
remember: formData.remember === 'true',
|
|
@@ -41,6 +43,8 @@ function AuthenticationForm(props) {
|
|
|
41
43
|
clientId: props.clientId,
|
|
42
44
|
scope: props.scope,
|
|
43
45
|
nonce: props.nonce,
|
|
46
|
+
codeChallenge: props.codeChallenge,
|
|
47
|
+
codeChallengeMethod: props.codeChallengeMethod,
|
|
44
48
|
googleClientId: response.clientId,
|
|
45
49
|
googleCredential: response.credential,
|
|
46
50
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthenticationForm.js","sources":["../../../src/auth/AuthenticationForm.tsx"],"sourcesContent":["import { GoogleCredentialResponse, LoginAuthenticationResponse } from '@medplum/core';\nimport { OperationOutcome } from '@medplum/fhirtypes';\nimport React, { useState } from 'react';\nimport { Button } from '../Button';\nimport { Form } from '../Form';\nimport { FormSection } from '../FormSection';\nimport { getGoogleClientId, GoogleButton } from '../GoogleButton';\nimport { Input } from '../Input';\nimport { MedplumLink } from '../MedplumLink';\nimport { useMedplum } from '../MedplumProvider';\nimport { getIssuesForExpression } from '../utils/outcomes';\n\nexport interface AuthenticationFormProps {\n readonly projectId?: string;\n readonly clientId?: string;\n readonly scope?: string;\n readonly nonce?: string;\n readonly googleClientId?: string;\n readonly onForgotPassword?: () => void;\n readonly onRegister?: () => void;\n readonly handleAuthResponse: (response: LoginAuthenticationResponse) => void;\n readonly children?: React.ReactNode;\n}\n\nexport function AuthenticationForm(props: AuthenticationFormProps): JSX.Element {\n const medplum = useMedplum();\n const googleClientId = getGoogleClientId(props.googleClientId);\n const [outcome, setOutcome] = useState<OperationOutcome>();\n const issues = getIssuesForExpression(outcome, undefined);\n\n return (\n <Form\n style={{ maxWidth: 400 }}\n onSubmit={(formData: Record<string, string>) => {\n medplum\n .startLogin({\n projectId: props.projectId,\n clientId: props.clientId,\n scope: props.scope,\n nonce: props.nonce,\n email: formData.email,\n password: formData.password,\n remember: formData.remember === 'true',\n })\n .then(props.handleAuthResponse)\n .catch(setOutcome);\n }}\n >\n <div className=\"medplum-center\">{props.children}</div>\n {issues && (\n <div className=\"medplum-input-error\">\n {issues.map((issue) => (\n <div data-testid=\"text-field-error\" key={issue.details?.text}>\n {issue.details?.text}\n </div>\n ))}\n </div>\n )}\n {googleClientId && (\n <>\n <div className=\"medplum-signin-google-container\">\n <GoogleButton\n googleClientId={googleClientId}\n handleGoogleCredential={(response: GoogleCredentialResponse) => {\n medplum\n .startGoogleLogin({\n projectId: props.projectId,\n clientId: props.clientId,\n scope: props.scope,\n nonce: props.nonce,\n googleClientId: response.clientId,\n googleCredential: response.credential,\n })\n .then(props.handleAuthResponse)\n .catch(setOutcome);\n }}\n />\n </div>\n <div className=\"medplum-signin-separator\">or</div>\n </>\n )}\n <FormSection title=\"Email\" htmlFor=\"email\" outcome={outcome}>\n <Input name=\"email\" type=\"email\" testid=\"email\" required={true} autoFocus={true} outcome={outcome} />\n </FormSection>\n <FormSection title=\"Password\" htmlFor=\"password\" outcome={outcome}>\n <Input name=\"password\" type=\"password\" testid=\"password\" autoComplete=\"off\" required={true} outcome={outcome} />\n </FormSection>\n <div className=\"medplum-signin-buttons\">\n {(props.onForgotPassword || props.onRegister) && (\n <div>\n {props.onForgotPassword && (\n <MedplumLink testid=\"forgotpassword\" onClick={props.onForgotPassword}>\n Forgot password\n </MedplumLink>\n )}\n {props.onRegister && (\n <MedplumLink testid=\"register\" onClick={props.onRegister}>\n Register\n </MedplumLink>\n )}\n </div>\n )}\n <div>\n <input type=\"checkbox\" id=\"remember\" name=\"remember\" value=\"true\" />\n <label htmlFor=\"remember\">Remember me</label>\n </div>\n <div>\n <Button type=\"submit\" testid=\"submit\">\n Sign in\n </Button>\n </div>\n </div>\n </Form>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"AuthenticationForm.js","sources":["../../../src/auth/AuthenticationForm.tsx"],"sourcesContent":["import { GoogleCredentialResponse, LoginAuthenticationResponse } from '@medplum/core';\nimport { OperationOutcome } from '@medplum/fhirtypes';\nimport React, { useState } from 'react';\nimport { Button } from '../Button';\nimport { Form } from '../Form';\nimport { FormSection } from '../FormSection';\nimport { getGoogleClientId, GoogleButton } from '../GoogleButton';\nimport { Input } from '../Input';\nimport { MedplumLink } from '../MedplumLink';\nimport { useMedplum } from '../MedplumProvider';\nimport { getIssuesForExpression } from '../utils/outcomes';\n\nexport interface AuthenticationFormProps {\n readonly projectId?: string;\n readonly clientId?: string;\n readonly scope?: string;\n readonly nonce?: string;\n readonly googleClientId?: string;\n readonly codeChallenge?: string;\n readonly codeChallengeMethod?: string;\n readonly onForgotPassword?: () => void;\n readonly onRegister?: () => void;\n readonly handleAuthResponse: (response: LoginAuthenticationResponse) => void;\n readonly children?: React.ReactNode;\n}\n\nexport function AuthenticationForm(props: AuthenticationFormProps): JSX.Element {\n const medplum = useMedplum();\n const googleClientId = getGoogleClientId(props.googleClientId);\n const [outcome, setOutcome] = useState<OperationOutcome>();\n const issues = getIssuesForExpression(outcome, undefined);\n\n return (\n <Form\n style={{ maxWidth: 400 }}\n onSubmit={(formData: Record<string, string>) => {\n medplum\n .startLogin({\n projectId: props.projectId,\n clientId: props.clientId,\n scope: props.scope,\n nonce: props.nonce,\n codeChallenge: props.codeChallenge,\n codeChallengeMethod: props.codeChallengeMethod,\n email: formData.email,\n password: formData.password,\n remember: formData.remember === 'true',\n })\n .then(props.handleAuthResponse)\n .catch(setOutcome);\n }}\n >\n <div className=\"medplum-center\">{props.children}</div>\n {issues && (\n <div className=\"medplum-input-error\">\n {issues.map((issue) => (\n <div data-testid=\"text-field-error\" key={issue.details?.text}>\n {issue.details?.text}\n </div>\n ))}\n </div>\n )}\n {googleClientId && (\n <>\n <div className=\"medplum-signin-google-container\">\n <GoogleButton\n googleClientId={googleClientId}\n handleGoogleCredential={(response: GoogleCredentialResponse) => {\n medplum\n .startGoogleLogin({\n projectId: props.projectId,\n clientId: props.clientId,\n scope: props.scope,\n nonce: props.nonce,\n codeChallenge: props.codeChallenge,\n codeChallengeMethod: props.codeChallengeMethod,\n googleClientId: response.clientId,\n googleCredential: response.credential,\n })\n .then(props.handleAuthResponse)\n .catch(setOutcome);\n }}\n />\n </div>\n <div className=\"medplum-signin-separator\">or</div>\n </>\n )}\n <FormSection title=\"Email\" htmlFor=\"email\" outcome={outcome}>\n <Input name=\"email\" type=\"email\" testid=\"email\" required={true} autoFocus={true} outcome={outcome} />\n </FormSection>\n <FormSection title=\"Password\" htmlFor=\"password\" outcome={outcome}>\n <Input name=\"password\" type=\"password\" testid=\"password\" autoComplete=\"off\" required={true} outcome={outcome} />\n </FormSection>\n <div className=\"medplum-signin-buttons\">\n {(props.onForgotPassword || props.onRegister) && (\n <div>\n {props.onForgotPassword && (\n <MedplumLink testid=\"forgotpassword\" onClick={props.onForgotPassword}>\n Forgot password\n </MedplumLink>\n )}\n {props.onRegister && (\n <MedplumLink testid=\"register\" onClick={props.onRegister}>\n Register\n </MedplumLink>\n )}\n </div>\n )}\n <div>\n <input type=\"checkbox\" id=\"remember\" name=\"remember\" value=\"true\" />\n <label htmlFor=\"remember\">Remember me</label>\n </div>\n <div>\n <Button type=\"submit\" testid=\"submit\">\n Sign in\n </Button>\n </div>\n </div>\n </Form>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;AA0BM,SAAU,kBAAkB,CAAC,KAA8B,EAAA;AAC/D,IAAA,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,MAAM,cAAc,GAAG,iBAAiB,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAC/D,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,EAAoB,CAAC;IAC3D,MAAM,MAAM,GAAG,sBAAsB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AAE1D,IAAA,QACE,KAAC,CAAA,aAAA,CAAA,IAAI,EACH,EAAA,KAAK,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,EACxB,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ce?: string;
|
|
11
|
+
readonly codeChallenge?: string;
|
|
12
|
+
readonly codeChallengeMethod?: string;
|
|
11
13
|
readonly onSuccess?: () => void;
|
|
12
14
|
readonly onForgotPassword?: () => void;
|
|
13
15
|
readonly onRegister?: () => void;
|
|
@@ -34,7 +34,7 @@ function SignInForm(props) {
|
|
|
34
34
|
}
|
|
35
35
|
return (React.createElement(Document, { width: 450 }, (() => {
|
|
36
36
|
if (!login) {
|
|
37
|
-
return (React.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));
|
|
37
|
+
return (React.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));
|
|
38
38
|
}
|
|
39
39
|
else if (memberships) {
|
|
40
40
|
return React.createElement(ChooseProfileForm, { login: login, memberships: memberships, handleAuthResponse: handleAuthResponse });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignInForm.js","sources":["../../../src/auth/SignInForm.tsx"],"sourcesContent":["import { LoginAuthenticationResponse } from '@medplum/core';\nimport { ProjectMembership } from '@medplum/fhirtypes';\nimport React, { useState } from 'react';\nimport { Document } from '../Document';\nimport { useMedplum } from '../MedplumProvider';\nimport { AuthenticationForm } from './AuthenticationForm';\nimport { ChooseProfileForm } from './ChooseProfileForm';\nimport { NewProjectForm } from './NewProjectForm';\nimport '
|
|
1
|
+
{"version":3,"file":"SignInForm.js","sources":["../../../src/auth/SignInForm.tsx"],"sourcesContent":["import { LoginAuthenticationResponse } from '@medplum/core';\nimport { ProjectMembership } from '@medplum/fhirtypes';\nimport React, { useState } from 'react';\nimport { Document } from '../Document';\nimport { useMedplum } from '../MedplumProvider';\nimport '../util.css';\nimport { AuthenticationForm } from './AuthenticationForm';\nimport { ChooseProfileForm } from './ChooseProfileForm';\nimport { NewProjectForm } from './NewProjectForm';\nimport './SignInForm.css';\n\nexport interface SignInFormProps {\n readonly remember?: boolean;\n readonly projectId?: string;\n readonly googleClientId?: string;\n readonly clientId?: string;\n readonly scope?: string;\n readonly nonce?: string;\n readonly codeChallenge?: string;\n readonly codeChallengeMethod?: string;\n readonly onSuccess?: () => void;\n readonly onForgotPassword?: () => void;\n readonly onRegister?: () => void;\n readonly onCode?: (code: string) => void;\n readonly children?: React.ReactNode;\n}\n\nexport function SignInForm(props: SignInFormProps): JSX.Element {\n const medplum = useMedplum();\n const [login, setLogin] = useState<string | undefined>(undefined);\n const [memberships, setMemberships] = useState<ProjectMembership[] | undefined>(undefined);\n\n function handleAuthResponse(response: LoginAuthenticationResponse): void {\n if (response.login) {\n setLogin(response.login);\n }\n\n if (response.memberships) {\n setMemberships(response.memberships);\n }\n\n if (response.code) {\n if (props.onCode) {\n props.onCode(response.code);\n } else {\n medplum\n .processCode(response.code)\n .then(() => {\n if (props.onSuccess) {\n props.onSuccess();\n }\n })\n .catch(console.log);\n }\n }\n }\n\n return (\n <Document width={450}>\n {(() => {\n if (!login) {\n return (\n <AuthenticationForm\n projectId={props.projectId}\n clientId={props.clientId}\n scope={props.scope}\n nonce={props.nonce}\n googleClientId={props.googleClientId}\n codeChallenge={props.codeChallenge}\n codeChallengeMethod={props.codeChallengeMethod}\n onForgotPassword={props.onForgotPassword}\n onRegister={props.onRegister}\n handleAuthResponse={handleAuthResponse}\n >\n {props.children}\n </AuthenticationForm>\n );\n } else if (memberships) {\n return <ChooseProfileForm login={login} memberships={memberships} handleAuthResponse={handleAuthResponse} />;\n } else if (props.projectId === 'new') {\n return <NewProjectForm login={login} handleAuthResponse={handleAuthResponse} />;\n } else {\n return <div>Success</div>;\n }\n })()}\n </Document>\n );\n}\n"],"names":[],"mappings":";;;;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