@documedis/react-components 1.0.0-RC.1

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/LICENSE.md ADDED
@@ -0,0 +1,37 @@
1
+ Copyright (c) 2025 Galenica AG. All rights reserved.
2
+
3
+ PROPRIETARY SOFTWARE LICENSE
4
+
5
+ This software and associated documentation files (the "Software") are the proprietary
6
+ and confidential property of Galenica AG ("Licensor").
7
+
8
+ NOTICE: This Software contains trade secrets and confidential information of Licensor.
9
+ Use, reproduction, disclosure, or distribution of any portion of this Software is
10
+ strictly prohibited without the express written permission of Licensor.
11
+
12
+ NO LICENSE GRANTED
13
+ No license, express or implied, by estoppel or otherwise, to any intellectual property
14
+ rights is granted by this notice. The Software may not be copied, modified, distributed,
15
+ published, uploaded, posted, transmitted, reproduced, or used in any way without
16
+ Licensor's prior written consent.
17
+
18
+ RESTRICTIONS
19
+ You may not:
20
+
21
+ 1. Use the Software for any purpose without a valid license agreement with Licensor
22
+ 2. Modify, adapt, translate, or create derivative works based upon the Software
23
+ 3. Reverse engineer, disassemble, decompile, or otherwise attempt to derive the source code
24
+ 4. Remove, alter, or obscure any proprietary notices on the Software
25
+ 5. Transfer, sell, rent, lease, or sublicense the Software to any third party
26
+
27
+ LIABILITY DISCLAIMER
28
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
29
+ IN NO EVENT SHALL LICENSOR BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY ARISING
30
+ FROM THE USE OR INABILITY TO USE THE SOFTWARE.
31
+
32
+ GOVERNING LAW
33
+ This notice shall be governed by and construed in accordance with the laws of Switzerland.
34
+
35
+ For licensing inquiries, please contact:
36
+ Galenica AG
37
+ sales@hcisolutions.ch
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # @documedis/react-components
2
+
3
+ React components for Documedis healthcare applications, providing seamless integration with electronic prescription workflows and pharmacy services.
4
+
5
+ ## Full Documentation
6
+
7
+ For complete API reference, advanced usage examples, error handling, and interactive demos:
8
+
9
+ **https://documentation.apps.documedis.ch**
10
+
11
+ ## License
12
+
13
+ Copyright (c) 2025 Galenica AG. All rights reserved.
14
+
15
+ This software is proprietary and confidential. Unauthorized copying, modification, distribution, or use of this software, via any medium, is strictly prohibited without the express written permission of Galenica AG.
16
+
17
+ ## Support
18
+
19
+ Issues: Please contact your Documedis support representative
@@ -0,0 +1,9 @@
1
+ import { Environment, Pharmacy } from '../..';
2
+ export interface PharmacySelectorProps {
3
+ accessToken: string;
4
+ environment: Environment;
5
+ enabledGalenicaChains?: string[];
6
+ className?: string;
7
+ onPharmacySelected: (pharmacy: Pharmacy | null) => void;
8
+ }
9
+ export declare const PharmacySelector: ({ accessToken, environment, enabledGalenicaChains, onPharmacySelected, className, }: PharmacySelectorProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ export { PharmacySelector } from './PharmacySelector';
2
+ export type { PharmacySelectorProps } from './PharmacySelector';
3
+ export { usePharmacySelector } from './usePharmacySelector';
4
+ export type { UsePharmacySelectorConfig, UsePharmacySelectorReturn, } from './usePharmacySelector';
@@ -0,0 +1,14 @@
1
+ import { Environment, Pharmacy } from '../..';
2
+ export interface UsePharmacySelectorConfig {
3
+ accessToken: string;
4
+ environment: Environment;
5
+ enabledGalenicaChains?: string[];
6
+ }
7
+ export interface UsePharmacySelectorReturn {
8
+ onQueryChange: (input: string) => void;
9
+ queriedPharmacies: Pharmacy[];
10
+ selectPharmacy: (pharmacy: Pharmacy) => void;
11
+ selectedPharmacy: Pharmacy | null;
12
+ isLoading: boolean;
13
+ }
14
+ export declare const usePharmacySelector: (config: UsePharmacySelectorConfig) => UsePharmacySelectorReturn;
@@ -0,0 +1,2 @@
1
+ import { PrescriptionSignProps } from './types';
2
+ export declare const PrescriptionSign: ({ onSuccess, onError, onSessionTokenUpdate, className, ...props }: PrescriptionSignProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ export { PrescriptionSign } from './PrescriptionSign';
2
+ export type { PrescriptionSignProps, UsePrescriptionSigningProps, } from './types';
3
+ export { usePrescriptionSign } from './usePrescriptionSign';
4
+ export type { UsePrescriptionSignReturn } from './usePrescriptionSign';
@@ -0,0 +1,77 @@
1
+ import { DomainError, Environment } from '../..';
2
+ interface PrescriptionSignReactProps {
3
+ accessToken: string;
4
+ environment: Environment;
5
+ chmed: string;
6
+ sessionToken?: string;
7
+ shouldGeneratePdf?: boolean;
8
+ }
9
+ /**
10
+ * Props for the usePrescriptionSign hook
11
+ */
12
+ export type UsePrescriptionSigningProps = {
13
+ /**
14
+ * Environment configuration for the prescription service
15
+ * - 'local': Development environment (localhost:52247)
16
+ * - 'dev': Development Azure Container Apps
17
+ * - 'int': Integration Azure Container Apps
18
+ * - 'prod': Production Azure Container Apps
19
+ */
20
+ environment: Environment;
21
+ /** Access token for authenticating with the backend service */
22
+ accessToken: string;
23
+ /**
24
+ * Optional existing session token to reuse authentication state.
25
+ * If provided, the hook will attempt to use existing authentication.
26
+ */
27
+ sessionToken?: string;
28
+ /**
29
+ * Optional callback invoked when the session token is updated.
30
+ * Use this to persist the session token for reuse across hook instances.
31
+ */
32
+ onSessionTokenUpdate?: (token: string) => void;
33
+ /**
34
+ * Optional callback invoked when prescription signing succeeds.
35
+ * Receives the signed CHMED data as a base64-encoded string.
36
+ * Optionally receives the generatedPdf if the option
37
+ * shouldGeneratePdf is set to true.
38
+ *
39
+ * @see shouldGeneratePdf
40
+ */
41
+ onSuccess?: (signedCHMED: string, generatedPdf?: string) => void;
42
+ /**
43
+ * Optional callback invoked when prescription signing fails.
44
+ * Receives a specific error type indicating what went wrong.
45
+ */
46
+ onError?: (error: DomainError) => void;
47
+ /**
48
+ * Flag to generate PDF after signing.
49
+ */
50
+ shouldGeneratePdf: boolean;
51
+ };
52
+ /**
53
+ * Props for the PrescriptionSign React component
54
+ * Uses camelCase (React convention) - internally converted to kebab-case for web component
55
+ */
56
+ export interface PrescriptionSignProps extends PrescriptionSignReactProps {
57
+ /** Optional additional CSS class names to apply to the component */
58
+ className?: string;
59
+ /**
60
+ * Optional callback invoked when the session token is updated.
61
+ * Use this to persist the session token for reuse across components.
62
+ */
63
+ onSessionTokenUpdate?: (sessionToken: string) => void;
64
+ /**
65
+ * Optional callback invoked when prescription signing succeeds.
66
+ * Receives the signed CHMED data as a base64-encoded string.
67
+ * Optionally receives the generatedPdf if the option
68
+ * generatePdf is set to true.
69
+ */
70
+ onSuccess?: (signedCHMED: string, generatedPdf?: string) => void;
71
+ /**
72
+ * Optional callback invoked when prescription signing fails.
73
+ * Receives a specific error type indicating what went wrong.
74
+ */
75
+ onError?: (error: DomainError) => void;
76
+ }
77
+ export {};
@@ -0,0 +1 @@
1
+ export declare function useDocumentEvent<T>(eventType: string, handler: ((detail: T) => void) | undefined): void;
@@ -0,0 +1,46 @@
1
+ import { UsePrescriptionSigningProps } from './types';
2
+ /**
3
+ * Return type for the usePrescriptionSign hook
4
+ */
5
+ export interface UsePrescriptionSignReturn {
6
+ /** Function to initiate the signing process with CHMED data */
7
+ start: (encodedCHMED: string, shouldGeneratePdf: boolean) => void;
8
+ /** Function to terminate the signing process at any time */
9
+ interrupt: () => void;
10
+ /** Raw XState machine state (for advanced usage) */
11
+ state: any;
12
+ /** True when ready to start signing (initial state) */
13
+ isIdle: boolean;
14
+ /** True when actively processing (excludes error/success states) */
15
+ isActive: boolean;
16
+ /** True when in error state (persists until retry) */
17
+ isError: boolean;
18
+ /** True when signing completed successfully */
19
+ isSuccess: boolean;
20
+ /** True during the actual signature operation */
21
+ isSigning: boolean;
22
+ /** The signed prescription data (available after success) */
23
+ signedCHMED: string | undefined;
24
+ }
25
+ /**
26
+ * Hook to manage the ePrescription signature process
27
+ *
28
+ * This is a standalone hook that can be shipped in a library.
29
+ * It handles the complete HIN authentication and signing flow.
30
+ *
31
+ * Required peer dependencies:
32
+ * - next-auth/react (for session management)
33
+ * - xstate and @xstate/react
34
+ *
35
+ * @returns Object containing:
36
+ * - start: Function to initiate the signing process with CHMED data
37
+ * - interrupt: Function to terminate the signing process at any time
38
+ * - state: Raw XState machine state (for advanced usage)
39
+ * - isIdle: true when ready to start signing (initial state)
40
+ * - isActive: true when actively processing (excludes error/success states)
41
+ * - isError: true when in error state (persists until retry)
42
+ * - isSuccess: true when signing completed successfully
43
+ * - isSigning: true during the actual signature operation
44
+ * - signedCHMED: The signed prescription data (available after success)
45
+ */
46
+ export declare function usePrescriptionSign(props: UsePrescriptionSigningProps): UsePrescriptionSignReturn;
package/index.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ export * from './components/PharmacySelector';
2
+ export * from './components/PrescriptionSign';
3
+ export type Environment = 'local' | 'int' | 'demo' | 'prod';
4
+ export interface Pharmacy {
5
+ id: string;
6
+ gln: string;
7
+ name: string;
8
+ hinEmail?: string;
9
+ galenicaChain?: string;
10
+ }
11
+ export interface DomainError extends Error {
12
+ readonly id: string;
13
+ readonly timestamp: Date;
14
+ readonly code: string;
15
+ readonly userMessage: string;
16
+ readonly cause?: unknown;
17
+ toJSON(): {
18
+ type: string;
19
+ code: string;
20
+ message: string;
21
+ };
22
+ toHttpStatus(): number;
23
+ }