@nsshunt/stsappframework 3.1.149 → 3.1.151

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.
Files changed (110) hide show
  1. package/dist/commonTypes.js +9 -1
  2. package/dist/commonTypes.js.map +1 -1
  3. package/dist/index.js +0 -3
  4. package/dist/index.js.map +1 -1
  5. package/dist/masterprocessbase.js +6 -6
  6. package/dist/masterprocessbase.js.map +1 -1
  7. package/dist/processbase.js +8 -6
  8. package/dist/processbase.js.map +1 -1
  9. package/dist/redisMessageHandler.js.map +1 -1
  10. package/dist/server.js.map +1 -1
  11. package/dist/serverprocessbase.js +6 -6
  12. package/dist/serverprocessbase.js.map +1 -1
  13. package/dist/singleprocessbase.js.map +1 -1
  14. package/dist/workerprocessbase.js.map +1 -1
  15. package/package.json +10 -10
  16. package/src/commonTypes.ts +170 -2
  17. package/src/index.ts +0 -3
  18. package/src/masterprocessbase.ts +1 -2
  19. package/src/processbase.ts +12 -9
  20. package/src/redisMessageHandler.ts +1 -3
  21. package/src/server.ts +1 -3
  22. package/src/serverprocessbase.ts +1 -1
  23. package/src/singleprocessbase.ts +1 -2
  24. package/src/tcpserver/appmaster.ts +1 -1
  25. package/src/workerprocessbase.ts +1 -2
  26. package/types/commonTypes.d.ts +129 -2
  27. package/types/commonTypes.d.ts.map +1 -1
  28. package/types/index.d.ts +0 -3
  29. package/types/index.d.ts.map +1 -1
  30. package/types/masterprocessbase.d.ts +1 -2
  31. package/types/masterprocessbase.d.ts.map +1 -1
  32. package/types/processbase.d.ts +3 -4
  33. package/types/processbase.d.ts.map +1 -1
  34. package/types/redisMessageHandler.d.ts +1 -2
  35. package/types/redisMessageHandler.d.ts.map +1 -1
  36. package/types/server.d.ts +1 -2
  37. package/types/server.d.ts.map +1 -1
  38. package/types/serverprocessbase.d.ts +1 -1
  39. package/types/serverprocessbase.d.ts.map +1 -1
  40. package/types/singleprocessbase.d.ts +1 -2
  41. package/types/singleprocessbase.d.ts.map +1 -1
  42. package/types/tcpserver/appmaster.d.ts +1 -1
  43. package/types/tcpserver/appmaster.d.ts.map +1 -1
  44. package/types/workerprocessbase.d.ts +1 -2
  45. package/types/workerprocessbase.d.ts.map +1 -1
  46. package/dist/fhir/STSFhirTypes.js +0 -11
  47. package/dist/fhir/STSFhirTypes.js.map +0 -1
  48. package/dist/fhir/dalFhirManager.js +0 -34
  49. package/dist/fhir/dalFhirManager.js.map +0 -1
  50. package/dist/fhir/dalFhirManagerBase.js +0 -63
  51. package/dist/fhir/dalFhirManagerBase.js.map +0 -1
  52. package/dist/fhir/dalFhirManagerIORedisJson.js +0 -250
  53. package/dist/fhir/dalFhirManagerIORedisJson.js.map +0 -1
  54. package/dist/fhir/dalFhirManagerIORedisJson.test.js +0 -73
  55. package/dist/fhir/dalFhirManagerIORedisJson.test.js.map +0 -1
  56. package/dist/fhir/dalFhirManagerPGRes.js +0 -133
  57. package/dist/fhir/dalFhirManagerPGRes.js.map +0 -1
  58. package/dist/fhir/dalFhirManagerPGRes.test.js +0 -72
  59. package/dist/fhir/dalFhirManagerPGRes.test.js.map +0 -1
  60. package/dist/fhir/dalFhirManagerPGResEntity.js +0 -166
  61. package/dist/fhir/dalFhirManagerPGResEntity.js.map +0 -1
  62. package/dist/fhir/dalFhirManagerPGResEntity.test.js +0 -73
  63. package/dist/fhir/dalFhirManagerPGResEntity.test.js.map +0 -1
  64. package/dist/fhir/dalFhirManagerRedisJson.js +0 -226
  65. package/dist/fhir/dalFhirManagerRedisJson.js.map +0 -1
  66. package/dist/fhir/dalFhirManagerRedisJson.test.js +0 -73
  67. package/dist/fhir/dalFhirManagerRedisJson.test.js.map +0 -1
  68. package/dist/fhir/dalFhirTestHelpers.js +0 -227
  69. package/dist/fhir/dalFhirTestHelpers.js.map +0 -1
  70. package/dist/processoptions.js +0 -12
  71. package/dist/processoptions.js.map +0 -1
  72. package/src/fhir/STSFhirTypes.ts +0 -541
  73. package/src/fhir/dalFhirManager.ts +0 -33
  74. package/src/fhir/dalFhirManagerBase.ts +0 -77
  75. package/src/fhir/dalFhirManagerIORedisJson.test.ts +0 -94
  76. package/src/fhir/dalFhirManagerIORedisJson.ts +0 -260
  77. package/src/fhir/dalFhirManagerPGRes.test.ts +0 -91
  78. package/src/fhir/dalFhirManagerPGRes.ts +0 -147
  79. package/src/fhir/dalFhirManagerPGResEntity.test.ts +0 -93
  80. package/src/fhir/dalFhirManagerPGResEntity.ts +0 -183
  81. package/src/fhir/dalFhirManagerRedisJson.test.ts +0 -93
  82. package/src/fhir/dalFhirManagerRedisJson.ts +0 -230
  83. package/src/fhir/dalFhirTestHelpers.ts +0 -276
  84. package/src/processoptions.ts +0 -169
  85. package/types/fhir/STSFhirTypes.d.ts +0 -351
  86. package/types/fhir/STSFhirTypes.d.ts.map +0 -1
  87. package/types/fhir/dalFhirManager.d.ts +0 -7
  88. package/types/fhir/dalFhirManager.d.ts.map +0 -1
  89. package/types/fhir/dalFhirManagerBase.d.ts +0 -19
  90. package/types/fhir/dalFhirManagerBase.d.ts.map +0 -1
  91. package/types/fhir/dalFhirManagerIORedisJson.d.ts +0 -18
  92. package/types/fhir/dalFhirManagerIORedisJson.d.ts.map +0 -1
  93. package/types/fhir/dalFhirManagerIORedisJson.test.d.ts +0 -2
  94. package/types/fhir/dalFhirManagerIORedisJson.test.d.ts.map +0 -1
  95. package/types/fhir/dalFhirManagerPGRes.d.ts +0 -14
  96. package/types/fhir/dalFhirManagerPGRes.d.ts.map +0 -1
  97. package/types/fhir/dalFhirManagerPGRes.test.d.ts +0 -2
  98. package/types/fhir/dalFhirManagerPGRes.test.d.ts.map +0 -1
  99. package/types/fhir/dalFhirManagerPGResEntity.d.ts +0 -14
  100. package/types/fhir/dalFhirManagerPGResEntity.d.ts.map +0 -1
  101. package/types/fhir/dalFhirManagerPGResEntity.test.d.ts +0 -2
  102. package/types/fhir/dalFhirManagerPGResEntity.test.d.ts.map +0 -1
  103. package/types/fhir/dalFhirManagerRedisJson.d.ts +0 -15
  104. package/types/fhir/dalFhirManagerRedisJson.d.ts.map +0 -1
  105. package/types/fhir/dalFhirManagerRedisJson.test.d.ts +0 -2
  106. package/types/fhir/dalFhirManagerRedisJson.test.d.ts.map +0 -1
  107. package/types/fhir/dalFhirTestHelpers.d.ts +0 -20
  108. package/types/fhir/dalFhirTestHelpers.d.ts.map +0 -1
  109. package/types/processoptions.d.ts +0 -128
  110. package/types/processoptions.d.ts.map +0 -1
@@ -1,183 +0,0 @@
1
- /* eslint @typescript-eslint/no-unused-vars: 0 */ // --> OFF
2
- import { IDBAccessLayer, IDBResource, IDBEntity } from '@nsshunt/stsdatamanagement'
3
-
4
- import { IDomainResource, IFHIRResource, IDALFhirDataAccessManager, IFhirManagerPGResEntityOptions } from './STSFhirTypes'
5
- import { DALFhirManagerBase } from './dalFhirManagerBase';
6
-
7
- export class DALFhirManagerPGResEntity<T> extends DALFhirManagerBase<T> implements IDALFhirDataAccessManager<T> {
8
- #fhirResource: IDBResource<IFHIRResource> | undefined;
9
- #accessLayer: IDBAccessLayer;
10
-
11
- constructor(options: IFhirManagerPGResEntityOptions) {
12
- super(options);
13
- this.#accessLayer = (this.options as IFhirManagerPGResEntityOptions).accessLayer;
14
- }
15
-
16
- async Start() {
17
-
18
- }
19
-
20
- async Stop() {
21
-
22
- }
23
-
24
- #GetSTSFhirBaseResource = async (): Promise<IDBResource<IFHIRResource>> => {
25
- if (!this.#fhirResource) {
26
- this.#fhirResource = ((await this.#accessLayer.GetResource<IFHIRResource>({
27
- filters: {
28
- resname: this.options.resourceName
29
- }
30
- })).detail as IDBResource<IFHIRResource>);
31
-
32
- if (!this.#fhirResource) {
33
- const fhirResourceType: IFHIRResource = {
34
- name: this.options.resourceName,
35
- description: `${this.options.resourceName} description`,
36
- notes: `${this.options.resourceName} notes`,
37
- }
38
- this.#fhirResource = ((await this.#accessLayer.CreateResource<IFHIRResource>({
39
- filters: {
40
- dbactionuser: this.options.dbactionuser,
41
- resname: this.options.resourceName
42
- }
43
- }, fhirResourceType)).detail as IDBResource<IFHIRResource>);
44
- }
45
- }
46
-
47
- return this.#fhirResource;
48
- }
49
-
50
- async GetFhirResource(fhir: Partial<T>, ecb?: (fhir: Partial<T>, error: Error) => void): Promise<T | null> {
51
- if (!this.#accessLayer) {
52
- return null;
53
- }
54
-
55
- const fhirResource = await this.#GetSTSFhirBaseResource();
56
- const retVal = await this.#accessLayer.GetEntity<T>({
57
- filters: {
58
- resname: fhirResource.resname,
59
- entname: (fhir as Partial<IDomainResource>).id
60
- }
61
- });
62
- if (retVal.error) {
63
- if (ecb) {
64
- ecb(fhir, retVal.error.error);
65
- }
66
- return null;
67
- } else {
68
- return (retVal.detail as IDBEntity<T>).entvalue;
69
- }
70
- }
71
-
72
- async CreateFhirResource(fhir: T, ecb?: (fhir: T, error: Error) => void): Promise<T | null> {
73
- if (!this.#accessLayer) {
74
- return null;
75
- }
76
-
77
- const fhirResource = await this.#GetSTSFhirBaseResource();
78
- const retVal = await this.#accessLayer.CreateEntity<T>({
79
- filters: {
80
- dbactionuser: this.options.dbactionuser,
81
- resname: fhirResource.resname,
82
- entname: (fhir as Partial<IDomainResource>).id
83
- }
84
- }, fhir);
85
- if (retVal.error) {
86
- if (ecb) {
87
- ecb(fhir, retVal.error.error);
88
- }
89
- return null;
90
- } else {
91
- return (retVal.detail as IDBEntity<T>).entvalue;
92
- }
93
- }
94
-
95
- async UpdateFhirResource(fhir: T, ecb?: (fhir: T, error: Error) => void): Promise<T | null> {
96
- if (!this.#accessLayer) {
97
- return null;
98
- }
99
-
100
- const fhirResource = await this.#GetSTSFhirBaseResource();
101
- const retVal = await this.#accessLayer.UpdateEntity<T>({
102
- filters: {
103
- dbactionuser: this.options.dbactionuser,
104
- resname: fhirResource.resname,
105
- entname: (fhir as Partial<IDomainResource>).id
106
- }
107
- }, fhir);
108
- if (retVal.error) {
109
- if (ecb) {
110
- ecb(fhir, retVal.error.error);
111
- }
112
- return null;
113
- } else {
114
- return (retVal.detail as IDBEntity<T>).entvalue;
115
- }
116
- }
117
-
118
- async DeleteFhirResource(fhir: Partial<T>, ecb?: (fhir: Partial<T>, error: Error) => void): Promise<T | null> {
119
- if (!this.#accessLayer) {
120
- return null;
121
- }
122
-
123
- const fhirResource = await this.#GetSTSFhirBaseResource();
124
- const retVal = await this.#accessLayer.DeleteEntity<T>({
125
- filters: {
126
- dbactionuser: this.options.dbactionuser,
127
- resname: fhirResource.resname,
128
- entname: (fhir as Partial<IDomainResource>).id
129
- }
130
- });
131
- if (retVal.error) {
132
- if (ecb) {
133
- ecb(fhir, retVal.error.error);
134
- }
135
- return null;
136
- } else {
137
- return (retVal.detail as IDBEntity<T>).entvalue;
138
- }
139
- }
140
-
141
- async GetFhirResources(filters: string[], ecb?: (filters: string[], error: Error) => void): Promise<T[] | null> {
142
- if (!this.#accessLayer) {
143
- return null;
144
- }
145
-
146
- try {
147
- const fhirResource = await this.#GetSTSFhirBaseResource();
148
- const promArray: Promise<T[]>[] = [ ];
149
- filters.forEach(filter => {
150
- const prom = async (): Promise<T[]> => {
151
- const retVal: T[] = [ ];
152
-
153
- const entities = await this.#accessLayer.GetEntities<T>({
154
- filters: {
155
- resname: fhirResource.resname,
156
- filter: `${filter}%`
157
- }
158
- })
159
-
160
- const dbResources = (entities.detail as IDBEntity<T>[]);
161
-
162
- dbResources.forEach(dbResource => {
163
- retVal.push(dbResource.entvalue);
164
- });
165
-
166
- return retVal;
167
- }
168
- promArray.push(prom());
169
- })
170
- const promRetVal = await Promise.all(promArray);
171
- let retVal: T[] = [ ];
172
- promRetVal.forEach(prv => {
173
- retVal = retVal.concat(prv);
174
- });
175
- return retVal;
176
- } catch (error) {
177
- if (ecb) {
178
- ecb(filters, error as Error);
179
- }
180
- return null;
181
- }
182
- }
183
- }
@@ -1,93 +0,0 @@
1
- /* eslint @typescript-eslint/no-explicit-any: 0 */ // --> OFF
2
- import { beforeAll, afterAll, test, describe, expect } from 'vitest';
3
-
4
- import { IPerson, IFhirPersistenceType } from './STSFhirTypes'
5
-
6
- import { TestHelpers } from './dalFhirTestHelpers'
7
-
8
- import { JestSleep } from '@nsshunt/stsutils'
9
-
10
- import { DALFhirManager } from './dalFhirManager'
11
- import chalk from 'chalk'
12
-
13
- import { SYSTEM_USER_ID } from '@nsshunt/stsdatamanagement'
14
-
15
- describe.skip("Test hl7 fhir resource data access layer - RedisJson", () =>
16
- {
17
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
- let testHelpers: TestHelpers;
19
- let fhirManager: DALFhirManager<IPerson>
20
-
21
- beforeAll(async () =>
22
- {
23
- testHelpers = new TestHelpers();
24
- await testHelpers.StartRedis();
25
-
26
- fhirManager = new DALFhirManager({
27
- persistenceType: IFhirPersistenceType.redisJson,
28
- persistenceTypeOptions: {
29
- resourceName: 'STSFhirPerson',
30
- dbactionuser: SYSTEM_USER_ID,
31
- redisUrl: testHelpers.ioRedisMessageProcessorUrl
32
- }
33
- });
34
-
35
- await fhirManager.fhirDataAccessManager.Start();
36
- }, 30000);
37
-
38
- test('Testing Person', async () => {
39
- expect.assertions(6);
40
- await testHelpers.TestFhirPerson(fhirManager.fhirDataAccessManager);
41
- }, 30000);
42
-
43
- test('Testing Persons with Search', async () => {
44
- const iterations = 10;
45
- expect.assertions(iterations + 1);
46
- await testHelpers.AddFhirPersons(fhirManager.fhirDataAccessManager, iterations);
47
-
48
- const fhirResources = await fhirManager.fhirDataAccessManager.GetFhirResources(['']);
49
- expect(fhirResources?.length).toEqual(iterations);
50
-
51
- console.log(chalk.green(JSON.stringify(fhirResources)));
52
- }, 30000);
53
-
54
- test('Testing Persons with Bulk Insert', async () => {
55
- const iterations = 10;
56
- expect.assertions(2);
57
- await testHelpers.AddFhirPersonsByArray(fhirManager.fhirDataAccessManager, iterations);
58
-
59
- const fhirResources = await fhirManager.fhirDataAccessManager.GetFhirResources(['bulk_']);
60
- expect(fhirResources?.length).toEqual(iterations);
61
-
62
- console.log(chalk.rgb(133, 161, 142)(JSON.stringify(fhirResources)));
63
- }, 30000);
64
-
65
- test('Testing Persons with Bulk Update', async () => {
66
- const iterations = 10;
67
- expect.assertions(2);
68
- await testHelpers.UpdateFhirPersonsByArray(fhirManager.fhirDataAccessManager, iterations);
69
-
70
- const fhirResources = await fhirManager.fhirDataAccessManager.GetFhirResources(['bulk_']);
71
- expect(fhirResources?.length).toEqual(iterations);
72
-
73
- console.log(chalk.rgb(157, 133, 161)(JSON.stringify(fhirResources)));
74
- }, 30000);
75
-
76
- test('Testing Persons with Bulk Delete', async () => {
77
- const iterations = 7;
78
- expect.assertions(2);
79
- await testHelpers.DeleteFhirPersonsByArray(fhirManager.fhirDataAccessManager, iterations);
80
-
81
- const fhirResources = await fhirManager.fhirDataAccessManager.GetFhirResources(['bulk_']);
82
- expect(fhirResources?.length).toEqual(10 - iterations);
83
-
84
- console.log(chalk.rgb(105, 97, 50)(JSON.stringify(fhirResources)));
85
- }, 30000);
86
-
87
- afterAll(async () =>
88
- {
89
- await fhirManager.fhirDataAccessManager.Stop();
90
- await JestSleep();
91
- await testHelpers.StopRedis();
92
- }, 5000);
93
- });
@@ -1,230 +0,0 @@
1
- /* eslint @typescript-eslint/no-unused-vars: 0 */ // --> OFF
2
- /* eslint @typescript-eslint/no-explicit-any: 0 */ // --> OFF
3
- import { IDomainResource, IDALFhirDataAccessManager, IFhirManagerRedisJsonOptions } from './STSFhirTypes'
4
-
5
- import { SchemaFieldTypes, createClient, RedisClientType, AggregateSteps, AggregateGroupByReducers } from 'redis';
6
- import { DALFhirManagerBase } from './dalFhirManagerBase';
7
-
8
- import chalk from 'chalk'
9
-
10
- export class DALFhirManagerRedisJson<T> extends DALFhirManagerBase<T> implements IDALFhirDataAccessManager<T> {
11
- #redis: RedisClientType | null = null;
12
- #indexName: string = 'idx:stsfhirresindex';
13
-
14
- constructor(options: IFhirManagerRedisJsonOptions) {
15
- super(options);
16
- }
17
-
18
- #CreateIndex = async () => {
19
- if (!this.#redis) {
20
- return;
21
- }
22
-
23
- try {
24
- const retVal = await this.#redis.ft.dropIndex(this.#indexName);
25
- console.log(retVal);
26
- } catch (error) {
27
- console.log(chalk.red(error))
28
- }
29
-
30
- try {
31
- const retVal = await this.#redis.ft.create(this.#indexName, { // serviceIndexInstant
32
- 'id': { type: SchemaFieldTypes.TEXT, SORTABLE: true }
33
- }, {
34
- ON: 'HASH',
35
- PREFIX: `${this.options.resourceName}_`
36
- });
37
- console.log(retVal);
38
- } catch (error) {
39
- console.log(chalk.red(error))
40
- }
41
- }
42
-
43
- #SearchBy = async (id: string) => {
44
- if (!this.#redis) {
45
- return null;
46
- }
47
-
48
- const queryOptions = {
49
- RETURN: [ 'id', 'data' ],
50
- LIMIT: {
51
- from: 0,
52
- size: 100
53
- },
54
- SORTBY: {
55
- BY: 'id',
56
- DIRECTION: 'DESC'
57
- }
58
- } as any;
59
-
60
- const query = `@id:${this.options.resourceName}_${id}*`;
61
-
62
- const retVal = await this.#redis.ft.search(this.#indexName, query, queryOptions);
63
-
64
- return retVal;
65
- }
66
-
67
- async Start() {
68
- this.#redis = await createClient({url: (this.options as IFhirManagerRedisJsonOptions).redisUrl})
69
- .on('error', error => console.error(chalk.red(`Error connecting to redis. Error: [${error}]`)))
70
- .connect() as any
71
-
72
- if (this.#redis) {
73
- await this.#CreateIndex();
74
- } else {
75
- console.error(chalk.red(`this.#redis instance not created.`))
76
- }
77
- }
78
-
79
- async Stop() {
80
- if (this.#redis) {
81
- //await this.#redis.quit();
82
- await this.#redis.disconnect();
83
- }
84
- }
85
-
86
- GetResourceType(fhir: Partial<T>): string {
87
- return `${this.options.resourceName}_${(fhir as Partial<IDomainResource>).id}`;
88
- }
89
-
90
- async GetFhirResource(fhir: Partial<T>, ecb?: (fhir: Partial<T>, error: Error) => void): Promise<T | null> {
91
- try {
92
- if (this.#redis) {
93
- const retValRaw = await this.#redis.HGETALL(this.GetResourceType(fhir))
94
- if (retValRaw) {
95
- try {
96
- const { id, data } = retValRaw;
97
- return JSON.parse(data) as T;
98
- } catch (error: unknown) {
99
- if (ecb) {
100
- ecb(fhir, error as Error);
101
- }
102
- return null;
103
- }
104
- } else {
105
- return null;
106
- }
107
- } else {
108
- return null;
109
- }
110
- } catch (error) {
111
- if (ecb) {
112
- ecb(fhir, error as Error);
113
- }
114
- return null;
115
- }
116
- }
117
-
118
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
119
- async CreateFhirResource(fhir: T, ecb?: (fhir: T, error: Error) => void): Promise<T | null> {
120
- try {
121
- if (this.#redis) {
122
- const record = {
123
- id: this.GetResourceType(fhir),
124
- data: JSON.stringify(fhir)
125
- } as any;
126
-
127
- const keyValuePairs: any = Object.entries(record).flat();
128
-
129
- const retVal = await this.#redis.HSET(this.GetResourceType(fhir), keyValuePairs);
130
-
131
- if (retVal) {
132
- return fhir;
133
- } else {
134
- return null;
135
- }
136
- } else {
137
- console.error(chalk.red(`this.#redis not defined.`))
138
- return null;
139
- }
140
- } catch (error) {
141
- if (ecb) {
142
- ecb(fhir, error as Error);
143
- }
144
- return null;
145
- }
146
- }
147
-
148
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
149
- async UpdateFhirResource(fhir: T, ecb?: (fhir: T, error: Error) => void): Promise<T | null> {
150
- try {
151
- if (this.#redis) {
152
- const record = {
153
- id: this.GetResourceType(fhir),
154
- data: JSON.stringify(fhir)
155
- } as any;
156
-
157
- const keyValuePairs: any = Object.entries(record).flat();
158
-
159
- const retVal = await this.#redis.HSET(this.GetResourceType(fhir), keyValuePairs);
160
- if (retVal >= 0) {
161
- return fhir;
162
- } else {
163
- return null;
164
- }
165
- } else {
166
- return null;
167
- }
168
- } catch (error) {
169
- if (ecb) {
170
- ecb(fhir, error as Error);
171
- }
172
- return null;
173
- }
174
- }
175
-
176
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
177
- async DeleteFhirResource(fhir: Partial<T>, ecb?: (fhir: Partial<T>, error: Error) => void): Promise<T | null> {
178
- try {
179
- if (this.#redis) {
180
- const deleteResource = await this.GetFhirResource(fhir);
181
- if (deleteResource) {
182
- const retVal = await this.#redis.del(this.GetResourceType(fhir));
183
- if (retVal > 0) {
184
- return deleteResource;
185
- } else {
186
- return null;
187
- }
188
- } else {
189
- return null;
190
- }
191
- } else {
192
- return null;
193
- }
194
- } catch (error) {
195
- if (ecb) {
196
- ecb(fhir, error as Error);
197
- }
198
- return null;
199
- }
200
- }
201
-
202
- async GetFhirResources(filters: string[], ecb?: (filters: string[], error: Error) => void): Promise<T[] | null> {
203
- try {
204
- const promArray: Promise<T[]>[] = [ ];
205
- filters.forEach(filter => {
206
- const prom = async (): Promise<T[]> => {
207
- const retValArray: T[] = [ ];
208
- const retVal = await this.#SearchBy(filter);
209
- retVal?.documents.forEach(doc => {
210
- retValArray.push(JSON.parse(doc.value.data as string) as T);
211
- })
212
- return retValArray;
213
- }
214
- promArray.push(prom());
215
- });
216
-
217
- const promRetVal = await Promise.all(promArray);
218
- let retVal: T[] = [ ];
219
- promRetVal.forEach(prv => {
220
- retVal = retVal.concat(prv);
221
- });
222
- return retVal;
223
- } catch (error) {
224
- if (ecb) {
225
- ecb(filters, error as Error);
226
- }
227
- return null;
228
- }
229
- }
230
- }