@mindbill/angular 0.2.1 → 0.4.0

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.
@@ -1,109 +0,0 @@
1
- import { computed, signal } from "@angular/core";
2
- import {
3
- createBillLifecycleClient,
4
- type BillLifecycleClient,
5
- type BillLifecycleClientOptions,
6
- type BillLifecycleData,
7
- type BillReviewDocumentType,
8
- type BillReviewSaveInput,
9
- type CloseBillInput,
10
- type PostBillPaymentInput,
11
- type SubmitBillInput,
12
- type SubmitSecondReviewInput,
13
- } from "@mindbill/browser";
14
-
15
- export class MindBillLifecycleStore {
16
- readonly billId = signal("");
17
- readonly data = signal<BillLifecycleData | null>(null);
18
- readonly error = signal<Error | null>(null);
19
- readonly loading = signal(false);
20
- readonly mutating = signal(false);
21
- readonly ready = computed(() => this.data() !== null && !this.loading());
22
- private client: BillLifecycleClient | null = null;
23
- private refreshTimer: ReturnType<typeof setInterval> | null = null;
24
-
25
- connect(options: BillLifecycleClientOptions, refreshInterval = 60_000): void {
26
- this.disconnect();
27
- this.billId.set(options.billId);
28
- this.client = createBillLifecycleClient(options);
29
- void this.refresh();
30
- if (refreshInterval > 0) {
31
- this.refreshTimer = setInterval(() => void this.refresh(), refreshInterval);
32
- }
33
- }
34
-
35
- disconnect(): void {
36
- if (this.refreshTimer) clearInterval(this.refreshTimer);
37
- this.refreshTimer = null;
38
- this.client?.clearSession();
39
- this.client = null;
40
- }
41
-
42
- async refresh(): Promise<BillLifecycleData | null> {
43
- if (!this.client) return null;
44
- this.loading.set(this.data() === null);
45
- try {
46
- const data = await this.client.getLifecycle();
47
- this.data.set(data);
48
- this.error.set(null);
49
- return data;
50
- } catch (cause) {
51
- this.error.set(cause instanceof Error ? cause : new Error("Bill could not be loaded."));
52
- return null;
53
- } finally {
54
- this.loading.set(false);
55
- }
56
- }
57
-
58
- searchClaimsAdministrators(query: string, claimNumber?: string) {
59
- return this.requireClient().searchClaimsAdministrators(query, claimNumber);
60
- }
61
- getDeliveryOptions() { return this.requireClient().getDeliveryOptions(); }
62
- saveReview(input: BillReviewSaveInput) { return this.mutate(() => this.requireClient().saveReview(input)); }
63
- submitBill(input: BillReviewSaveInput, submission: SubmitBillInput) { return this.mutate(() => this.requireClient().submitBill(input, submission)); }
64
- addAttachment(file: File, type: BillReviewDocumentType, description?: string) { return this.mutate(() => this.requireClient().addAttachment(file, type, description)); }
65
- removeAttachment(id: string) { return this.mutate(() => this.requireClient().removeAttachment(id)); }
66
- getAttachment(id: string) { return this.requireClient().getAttachment(id); }
67
- getEor(id: string) { return this.requireClient().getEor(id); }
68
- closeBill(input: CloseBillInput) { return this.mutate(() => this.requireClient().closeBill(input)); }
69
- postPayment(input: PostBillPaymentInput) { return this.mutate(() => this.requireClient().postPayment(input)); }
70
- submitSecondReview(input: SubmitSecondReviewInput) { return this.mutate(() => this.requireClient().submitSecondReview(input)); }
71
-
72
- async startCorrection(): Promise<BillLifecycleData> {
73
- this.mutating.set(true);
74
- try {
75
- const result = await this.requireClient().startCorrection();
76
- this.billId.set(result.replacementBillId);
77
- this.data.set(result.data);
78
- this.error.set(null);
79
- return result.data;
80
- } catch (cause) {
81
- const error = cause instanceof Error ? cause : new Error("Correction draft could not be created.");
82
- this.error.set(error);
83
- throw error;
84
- } finally {
85
- this.mutating.set(false);
86
- }
87
- }
88
-
89
- private requireClient(): BillLifecycleClient {
90
- if (!this.client) throw new Error("Connect the lifecycle store before using it.");
91
- return this.client;
92
- }
93
-
94
- private async mutate(task: () => Promise<BillLifecycleData>): Promise<BillLifecycleData> {
95
- this.mutating.set(true);
96
- this.error.set(null);
97
- try {
98
- const data = await task();
99
- this.data.set(data);
100
- return data;
101
- } catch (cause) {
102
- const error = cause instanceof Error ? cause : new Error("The billing request could not be completed.");
103
- this.error.set(error);
104
- throw error;
105
- } finally {
106
- this.mutating.set(false);
107
- }
108
- }
109
- }
@@ -1,41 +0,0 @@
1
- export type ProcedureLine = {
2
- id?: string;
3
- code: string;
4
- modifiers: string[];
5
- units: number;
6
- charge: number;
7
- feeSchedule?: number;
8
- serviceDate?: string | null;
9
- serviceDateEnd?: string | null;
10
- diagnosisPointers?: number[];
11
- };
12
-
13
- const EMPTY_PROCEDURE_LINE: ProcedureLine = {
14
- code: "",
15
- modifiers: [],
16
- units: 1,
17
- charge: 0,
18
- };
19
-
20
- export function isEmptyProcedureLine(line: ProcedureLine): boolean {
21
- return !line.code.trim()
22
- && line.modifiers.length === 0
23
- && line.units === 1
24
- && !line.serviceDate
25
- && !line.serviceDateEnd
26
- && !(line.diagnosisPointers?.length)
27
- && !line.charge;
28
- }
29
-
30
- /** Keeps completed/partial lines plus one keyboard-ready empty row. */
31
- export function ensureTrailingProcedureLine(
32
- lines: readonly ProcedureLine[],
33
- ): ProcedureLine[] {
34
- const entered = lines
35
- .filter((line) => !isEmptyProcedureLine(line))
36
- .map((line) => ({ ...line, modifiers: [...line.modifiers] }));
37
-
38
- return entered.length < 50
39
- ? [...entered, { ...EMPTY_PROCEDURE_LINE, modifiers: [] }]
40
- : entered;
41
- }
package/src/public-api.ts DELETED
@@ -1,20 +0,0 @@
1
- export * from "./lib/lifecycle-store";
2
- export * from "./lib/bill-lifecycle.component";
3
- export * from "./lib/procedure-lines";
4
- export type {
5
- BillLifecycleAction,
6
- BillLifecycleActionId,
7
- BillLifecycleClient,
8
- BillLifecycleClientOptions,
9
- BillLifecycleData,
10
- BillLifecycleSession,
11
- BillLifecycleSessionProvider,
12
- BillReviewData,
13
- BillReviewDocumentType,
14
- BillReviewPayer,
15
- BillReviewSaveInput,
16
- BillSubmissionRoute,
17
- CloseBillInput,
18
- PostBillPaymentInput,
19
- SubmitSecondReviewInput,
20
- } from "@mindbill/browser";
package/tsconfig.lib.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "./out-tsc/lib",
5
- "declaration": true,
6
- "declarationMap": true,
7
- "inlineSources": true,
8
- "experimentalDecorators": true,
9
- "useDefineForClassFields": false,
10
- "types": []
11
- },
12
- "angularCompilerOptions": {
13
- "compilationMode": "partial",
14
- "strictTemplates": true
15
- },
16
- "exclude": ["**/*.spec.ts"]
17
- }