@openmrs/esm-form-entry-app 13.0.2-pre.12995 → 13.0.2-pre.13005

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.
@@ -18,6 +18,12 @@ interface ConceptReferenceRangeResponse {
18
18
  */
19
19
  const conceptsPerRequest = 25;
20
20
 
21
+ export interface ReferenceRangeContext {
22
+ date?: string;
23
+ encounter?: string;
24
+ obs?: string;
25
+ }
26
+
21
27
  @Injectable()
22
28
  export class ConceptReferenceRangeResourceService {
23
29
  constructor(
@@ -42,13 +48,16 @@ export class ConceptReferenceRangeResourceService {
42
48
  public getConceptReferenceRanges(
43
49
  patientUuid: string,
44
50
  concepts: Array<string>,
51
+ context: ReferenceRangeContext = {},
45
52
  ): Observable<Map<string, ConceptReferenceRange>> {
46
53
  if (!patientUuid || !concepts?.length) {
47
54
  return of(new Map<string, ConceptReferenceRange>());
48
55
  }
49
56
 
50
57
  return forkJoin(
51
- chunk(concepts, conceptsPerRequest).map((batch) => this.getConceptReferenceRangesOfBatch(patientUuid, batch)),
58
+ chunk(concepts, conceptsPerRequest).map((batch) =>
59
+ this.getConceptReferenceRangesOfBatch(patientUuid, batch, context),
60
+ ),
52
61
  ).pipe(
53
62
  map(
54
63
  (batches) =>
@@ -73,12 +82,19 @@ export class ConceptReferenceRangeResourceService {
73
82
  private getConceptReferenceRangesOfBatch(
74
83
  patientUuid: string,
75
84
  concepts: Array<string>,
85
+ context: ReferenceRangeContext,
76
86
  ): Observable<Array<ConceptReferenceRange>> {
77
- const params: HttpParams = new HttpParams()
87
+ let params: HttpParams = new HttpParams()
78
88
  .set('patient', patientUuid)
79
89
  .set('concept', concepts.join(','))
80
90
  .set('v', 'full');
81
91
 
92
+ for (const [name, value] of Object.entries(context)) {
93
+ if (value) {
94
+ params = params.set(name, value);
95
+ }
96
+ }
97
+
82
98
  return this.http.get<ConceptReferenceRangeResponse>(this.getUrl(), { params }).pipe(
83
99
  expand((response) => {
84
100
  const nextPage = response?.links?.find((link) => link.rel === 'next');
@@ -1,3 +1,5 @@
1
+ import type { ConceptReferenceRange as FormEngineConceptReferenceRange } from '@openmrs/ngx-formentry';
2
+
1
3
  interface OpenmrsResource {
2
4
  display: string;
3
5
  uuid: string;
@@ -199,18 +201,11 @@ interface QuestionOptions {
199
201
  * is evaluated by the backend against patient factors such as age or gender, which is why these
200
202
  * are fetched per patient.
201
203
  */
202
- export interface ConceptReferenceRange {
204
+ export interface ConceptReferenceRange extends FormEngineConceptReferenceRange {
203
205
  uuid: string;
204
206
  display?: string;
205
207
  /** The UUID of the concept the range belongs to. */
206
208
  concept: string;
207
- hiNormal?: number | null;
208
- hiAbsolute?: number | null;
209
- hiCritical?: number | null;
210
- lowNormal?: number | null;
211
- lowAbsolute?: number | null;
212
- lowCritical?: number | null;
213
- units?: string | null;
214
209
  }
215
210
 
216
211
  interface QuestionOptionsAnswer {