@openmrs/esm-api 4.0.0-pre.0 → 4.0.0-pre.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/.turbo/turbo-build.log +2 -2
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-test.log +10 -10
- package/.turbo/turbo-typescript.log +2 -2
- package/dist/environment.d.ts +1 -0
- package/dist/fhir.d.ts +18 -0
- package/dist/index.d.ts +10 -0
- package/dist/openmrs-backend-dependencies.d.ts +4 -0
- package/dist/openmrs-esm-api.js +0 -0
- package/dist/openmrs-esm-api.js.map +0 -0
- package/dist/openmrs-fetch.d.ts +115 -0
- package/dist/openmrs-fetch.test.d.ts +1 -0
- package/dist/public.d.ts +9 -0
- package/dist/setup.d.ts +4 -0
- package/dist/shared-api-objects/current-patient.d.ts +18 -0
- package/dist/shared-api-objects/current-patient.test.d.ts +1 -0
- package/dist/shared-api-objects/current-user.d.ts +80 -0
- package/dist/shared-api-objects/location.d.ts +5 -0
- package/dist/shared-api-objects/visit-type.d.ts +5 -0
- package/dist/shared-api-objects/visit-utils.d.ts +25 -0
- package/dist/types/fetch.d.ts +7 -0
- package/dist/types/fhir-resource.d.ts +40 -0
- package/dist/types/fhir.d.ts +88 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/openmrs-resource.d.ts +5 -0
- package/dist/types/user-resource.d.ts +48 -0
- package/dist/types/visit-resource.d.ts +32 -0
- package/package.json +5 -5
- package/src/types/fhir-resource.ts +3 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[33m@openmrs/esm-api:build: [0mcache hit, replaying output [
|
|
1
|
+
[33m@openmrs/esm-api:build: [0mcache hit, replaying output [2md06da1e868c409be[0m
|
|
2
2
|
[33m@openmrs/esm-api:build: [0m$ webpack --mode=production
|
|
3
3
|
[33m@openmrs/esm-api:build: [0masset openmrs-esm-api.js 49.5 KiB [emitted] [minimized] (name: main) 1 related asset
|
|
4
4
|
[33m@openmrs/esm-api:build: [0morphan modules 369 KiB [orphan] 226 modules
|
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
[33m@openmrs/esm-api:build: [0m external "@openmrs/esm-error-handling" 42 bytes [built] [code generated]
|
|
16
16
|
[33m@openmrs/esm-api:build: [0m ./src/index.ts + 44 modules 80.9 KiB [built] [code generated]
|
|
17
17
|
[33m@openmrs/esm-api:build: [0m ../esm-state/dist/openmrs-esm-state.js 7.52 KiB [built] [code generated]
|
|
18
|
-
[33m@openmrs/esm-api:build: [0mwebpack 5.70.0 compiled successfully in
|
|
18
|
+
[33m@openmrs/esm-api:build: [0mwebpack 5.70.0 compiled successfully in 15910 ms
|
package/.turbo/turbo-lint.log
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
[33m@openmrs/esm-api:lint: [0mcache hit, replaying output [
|
|
1
|
+
[33m@openmrs/esm-api:lint: [0mcache hit, replaying output [2mfb791d3f24afca66[0m
|
|
2
2
|
[33m@openmrs/esm-api:lint: [0m$ eslint src --ext ts,tsx
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
[
|
|
2
|
-
[
|
|
3
|
-
[
|
|
4
|
-
[
|
|
5
|
-
[
|
|
6
|
-
[
|
|
7
|
-
[
|
|
8
|
-
[
|
|
9
|
-
[
|
|
10
|
-
[
|
|
1
|
+
[36m@openmrs/esm-api:test: [0mcache hit, replaying output [2m7d1ce0a34fe1a30c[0m
|
|
2
|
+
[36m@openmrs/esm-api:test: [0m$ jest --config jest.config.js --passWithNoTests
|
|
3
|
+
[36m@openmrs/esm-api:test: [0mPASS src/shared-api-objects/current-patient.test.ts
|
|
4
|
+
[36m@openmrs/esm-api:test: [0mPASS src/openmrs-fetch.test.ts (5.308 s)
|
|
5
|
+
[36m@openmrs/esm-api:test: [0m
|
|
6
|
+
[36m@openmrs/esm-api:test: [0mTest Suites: 2 passed, 2 total
|
|
7
|
+
[36m@openmrs/esm-api:test: [0mTests: 17 passed, 17 total
|
|
8
|
+
[36m@openmrs/esm-api:test: [0mSnapshots: 0 total
|
|
9
|
+
[36m@openmrs/esm-api:test: [0mTime: 15.189 s
|
|
10
|
+
[36m@openmrs/esm-api:test: [0mRan all test suites.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
[
|
|
2
|
-
[
|
|
1
|
+
[33m@openmrs/esm-api:typescript: [0mcache hit, replaying output [2mdab07e3e47e5a8d3[0m
|
|
2
|
+
[33m@openmrs/esm-api:typescript: [0m$ tsc
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isDevEnabled(): boolean;
|
package/dist/fhir.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** @module @category API */
|
|
2
|
+
import { FetchHeaders } from "./openmrs-fetch";
|
|
3
|
+
import type { FhirClient } from "./types/fhir";
|
|
4
|
+
export declare const fhirBaseUrl = "/ws/fhir2/R4";
|
|
5
|
+
/**
|
|
6
|
+
* The `fhir` object is [an instance of fhir.js](https://github.com/FHIR/fhir.js)
|
|
7
|
+
* that can be used to call FHIR-compliant OpenMRS APIs. See
|
|
8
|
+
* [the docs for fhir.js](https://github.com/FHIR/fhir.js) for more info
|
|
9
|
+
* and example usage.
|
|
10
|
+
*
|
|
11
|
+
* @category API
|
|
12
|
+
*/
|
|
13
|
+
export declare const fhir: FhirClient;
|
|
14
|
+
export interface FHIRRequestObj {
|
|
15
|
+
url: string;
|
|
16
|
+
method: string;
|
|
17
|
+
headers: FetchHeaders;
|
|
18
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./types";
|
|
2
|
+
export * from "./openmrs-fetch";
|
|
3
|
+
export * from "./fhir";
|
|
4
|
+
export * from "./setup";
|
|
5
|
+
export * from "./shared-api-objects/current-user";
|
|
6
|
+
export * from "./shared-api-objects/current-patient";
|
|
7
|
+
export * from "./shared-api-objects/visit-utils";
|
|
8
|
+
export * from "./shared-api-objects/visit-type";
|
|
9
|
+
export * from "./shared-api-objects/location";
|
|
10
|
+
export * from "./openmrs-backend-dependencies";
|
package/dist/openmrs-esm-api.js
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/** @module @category API */
|
|
2
|
+
import { Observable } from "rxjs";
|
|
3
|
+
import { FetchResponse } from "./types";
|
|
4
|
+
export declare const sessionEndpoint = "/ws/rest/v1/session";
|
|
5
|
+
/**
|
|
6
|
+
* Append `path` to the OpenMRS SPA base.
|
|
7
|
+
*
|
|
8
|
+
* #### Example
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* makeUrl('/foo/bar');
|
|
12
|
+
* // => '/openmrs/foo/bar'
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function makeUrl(path: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* The openmrsFetch function is a wrapper around the
|
|
18
|
+
* [browser's built-in fetch function](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch),
|
|
19
|
+
* with extra handling for OpenMRS-specific API behaviors, such as
|
|
20
|
+
* request headers, authentication, authorization, and the API urls.
|
|
21
|
+
*
|
|
22
|
+
* @param path A string url to make the request to. Note that the
|
|
23
|
+
* openmrs base url (by default `/openmrs`) will be automatically
|
|
24
|
+
* prepended to the URL, so there is no need to include it.
|
|
25
|
+
* @param fetchInit A [fetch init object](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Syntax).
|
|
26
|
+
* Note that the `body` property does not need to be `JSON.stringify()`ed
|
|
27
|
+
* because openmrsFetch will do that for you.
|
|
28
|
+
* @returns A [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
|
|
29
|
+
* that resolves with a [Response object](https://developer.mozilla.org/en-US/docs/Web/API/Response).
|
|
30
|
+
* Note that the openmrs version of the Response object has already
|
|
31
|
+
* downloaded the HTTP response body as json, and has an additional
|
|
32
|
+
* `data` property with the HTTP response json as a javascript object.
|
|
33
|
+
*
|
|
34
|
+
* #### Example
|
|
35
|
+
* ```js
|
|
36
|
+
* import { openmrsFetch } from '@openmrs/esm-api'
|
|
37
|
+
* const abortController = new AbortController();
|
|
38
|
+
* openmrsFetch('/ws/rest/v1/session', {signal: abortController.signal})
|
|
39
|
+
* .then(response => {
|
|
40
|
+
* console.log(response.data.authenticated)
|
|
41
|
+
* })
|
|
42
|
+
* .catch(err => {
|
|
43
|
+
* console.error(err.status);
|
|
44
|
+
* })
|
|
45
|
+
* abortController.abort();
|
|
46
|
+
* openmrsFetch('/ws/rest/v1/session', {
|
|
47
|
+
* method: 'POST',
|
|
48
|
+
* body: {
|
|
49
|
+
* username: 'hi',
|
|
50
|
+
* password: 'there',
|
|
51
|
+
* }
|
|
52
|
+
* })
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* #### Cancellation
|
|
56
|
+
*
|
|
57
|
+
* To cancel a network request, use an
|
|
58
|
+
* [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort).
|
|
59
|
+
* It is best practice to cancel your network requests when the user
|
|
60
|
+
* navigates away from a page while the request is pending request, to
|
|
61
|
+
* free up memory and network resources and to prevent race conditions.
|
|
62
|
+
*
|
|
63
|
+
* @category API
|
|
64
|
+
*/
|
|
65
|
+
export declare function openmrsFetch<T = any>(path: string, fetchInit?: FetchConfig): Promise<FetchResponse<T>>;
|
|
66
|
+
/**
|
|
67
|
+
* The openmrsObservableFetch function is a wrapper around openmrsFetch
|
|
68
|
+
* that returns an [Observable](https://rxjs-dev.firebaseapp.com/guide/observable)
|
|
69
|
+
* instead of a promise. It exists in case using an Observable is
|
|
70
|
+
* preferred or more convenient than a promise.
|
|
71
|
+
*
|
|
72
|
+
* @param url See [[openmrsFetch]]
|
|
73
|
+
* @param fetchInit See [[openmrsFetch]]
|
|
74
|
+
* @returns An Observable that produces exactly one Response object.
|
|
75
|
+
* The response object is exactly the same as for [[openmrsFetch]].
|
|
76
|
+
*
|
|
77
|
+
* #### Example
|
|
78
|
+
*
|
|
79
|
+
* ```js
|
|
80
|
+
* import { openmrsObservableFetch } from '@openmrs/esm-api'
|
|
81
|
+
* const subscription = openmrsObservableFetch('/ws/rest/v1/session').subscribe(
|
|
82
|
+
* response => console.log(response.data),
|
|
83
|
+
* err => {throw err},
|
|
84
|
+
* () => console.log('finished')
|
|
85
|
+
* )
|
|
86
|
+
* subscription.unsubscribe()
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* #### Cancellation
|
|
90
|
+
*
|
|
91
|
+
* To cancel the network request, simply call `subscription.unsubscribe();`
|
|
92
|
+
*
|
|
93
|
+
* @category API
|
|
94
|
+
*/
|
|
95
|
+
export declare function openmrsObservableFetch<T>(url: string, fetchInit?: FetchConfig): Observable<FetchResponse<T>>;
|
|
96
|
+
export declare class OpenmrsFetchError extends Error {
|
|
97
|
+
constructor(url: string, response: Response, responseBody: ResponseBody | null, requestStacktrace: Error);
|
|
98
|
+
response: Response;
|
|
99
|
+
responseBody: string | FetchResponseJson | null;
|
|
100
|
+
}
|
|
101
|
+
interface FetchConfig extends Omit<Omit<RequestInit, "body">, "headers"> {
|
|
102
|
+
headers?: FetchHeaders;
|
|
103
|
+
body?: FetchBody | string;
|
|
104
|
+
}
|
|
105
|
+
declare type ResponseBody = string | FetchResponseJson;
|
|
106
|
+
export interface FetchHeaders {
|
|
107
|
+
[key: string]: string | null;
|
|
108
|
+
}
|
|
109
|
+
interface FetchBody {
|
|
110
|
+
[key: string]: any;
|
|
111
|
+
}
|
|
112
|
+
interface FetchResponseJson {
|
|
113
|
+
[key: string]: any;
|
|
114
|
+
}
|
|
115
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/public.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./types";
|
|
2
|
+
export * from "./openmrs-fetch";
|
|
3
|
+
export * from "./fhir";
|
|
4
|
+
export * from "./shared-api-objects/current-user";
|
|
5
|
+
export * from "./shared-api-objects/current-patient";
|
|
6
|
+
export * from "./shared-api-objects/visit-utils";
|
|
7
|
+
export * from "./shared-api-objects/visit-type";
|
|
8
|
+
export * from "./shared-api-objects/location";
|
|
9
|
+
export * from "./openmrs-backend-dependencies";
|
package/dist/setup.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="fhir" />
|
|
2
|
+
/** @module @category API */
|
|
3
|
+
import { fhir } from "../fhir";
|
|
4
|
+
import { FetchResponse } from "../types";
|
|
5
|
+
export declare type CurrentPatient = fhir.Patient | FetchResponse<fhir.Patient>;
|
|
6
|
+
export interface CurrentPatientOptions {
|
|
7
|
+
includeConfig?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface PatientWithFullResponse extends CurrentPatientOptions {
|
|
10
|
+
includeConfig: true;
|
|
11
|
+
}
|
|
12
|
+
export interface OnlyThePatient extends CurrentPatientOptions {
|
|
13
|
+
includeConfig: false;
|
|
14
|
+
}
|
|
15
|
+
export declare type PatientUuid = string | null;
|
|
16
|
+
export declare function fetchCurrentPatient(patientUuid: PatientUuid, contentOverrides?: Partial<Parameters<typeof fhir.read>[0]>): Promise<null> | Promise<{
|
|
17
|
+
data: fhir.Patient;
|
|
18
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
import type { LoggedInUser, SessionLocation, Privilege, Role, Session } from "../types";
|
|
3
|
+
export declare type SessionStore = LoadedSessionStore | UnloadedSessionStore;
|
|
4
|
+
export declare type LoadedSessionStore = {
|
|
5
|
+
loaded: true;
|
|
6
|
+
session: Session;
|
|
7
|
+
};
|
|
8
|
+
export declare type UnloadedSessionStore = {
|
|
9
|
+
loaded: false;
|
|
10
|
+
session: null;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The getCurrentUser function returns an observable that produces
|
|
14
|
+
* **zero or more values, over time**. It will produce zero values
|
|
15
|
+
* by default if the user is not logged in. And it will provide a
|
|
16
|
+
* first value when the logged in user is fetched from the server.
|
|
17
|
+
* Subsequent values will be produced whenever the user object is
|
|
18
|
+
* updated.
|
|
19
|
+
*
|
|
20
|
+
* @param options An object with `includeAuthStatus` boolean
|
|
21
|
+
* property that defaults to `false`. When `includeAuthStatus` is set
|
|
22
|
+
* to `true`, the entire response object from the API will be provided.
|
|
23
|
+
* When `includeAuthStatus` is set to `false`, only the `user` property
|
|
24
|
+
* of the response object will be provided.
|
|
25
|
+
*
|
|
26
|
+
* @returns An Observable that produces zero or more values (as
|
|
27
|
+
* described above). The values produced will be a user object (if
|
|
28
|
+
* `includeAuthStatus` is set to `false`) or an object with a session
|
|
29
|
+
* and authenticated property (if `includeAuthStatus` is set to `true`).
|
|
30
|
+
*
|
|
31
|
+
* #### Example
|
|
32
|
+
*
|
|
33
|
+
* ```js
|
|
34
|
+
* import { getCurrentUser } from '@openmrs/esm-api'
|
|
35
|
+
* const subscription = getCurrentUser().subscribe(
|
|
36
|
+
* user => console.log(user)
|
|
37
|
+
* )
|
|
38
|
+
* subscription.unsubscribe()
|
|
39
|
+
* getCurrentUser({includeAuthStatus: true}).subscribe(
|
|
40
|
+
* data => console.log(data.authenticated)
|
|
41
|
+
* )
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* #### Be sure to unsubscribe when your component unmounts
|
|
45
|
+
*
|
|
46
|
+
* Otherwise your code will continue getting updates to the user object
|
|
47
|
+
* even after the UI component is gone from the screen. This is a memory
|
|
48
|
+
* leak and source of bugs.
|
|
49
|
+
*/
|
|
50
|
+
declare function getCurrentUser(): Observable<Session>;
|
|
51
|
+
declare function getCurrentUser(opts: {
|
|
52
|
+
includeAuthStatus: true;
|
|
53
|
+
}): Observable<Session>;
|
|
54
|
+
declare function getCurrentUser(opts: {
|
|
55
|
+
includeAuthStatus: false;
|
|
56
|
+
}): Observable<LoggedInUser>;
|
|
57
|
+
export { getCurrentUser };
|
|
58
|
+
export declare function getSessionStore(): import("unistore").Store<SessionStore>;
|
|
59
|
+
/**
|
|
60
|
+
* The `refetchCurrentUser` function causes a network request to redownload
|
|
61
|
+
* the user. All subscribers to the current user will be notified of the
|
|
62
|
+
* new users once the new version of the user object is downloaded.
|
|
63
|
+
*
|
|
64
|
+
* @returns The same observable as returned by [[getCurrentUser]].
|
|
65
|
+
*
|
|
66
|
+
* #### Example
|
|
67
|
+
* ```js
|
|
68
|
+
* import { refetchCurrentUser } from '@openmrs/esm-api'
|
|
69
|
+
* refetchCurrentUser()
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare function refetchCurrentUser(): Promise<unknown>;
|
|
73
|
+
export declare function clearCurrentUser(): void;
|
|
74
|
+
export declare function userHasAccess(requiredPrivilege: string, user: {
|
|
75
|
+
privileges: Array<Privilege>;
|
|
76
|
+
roles: Array<Role>;
|
|
77
|
+
}): Privilege | undefined;
|
|
78
|
+
export declare function getLoggedInUser(): Promise<LoggedInUser>;
|
|
79
|
+
export declare function getSessionLocation(): Promise<SessionLocation | undefined>;
|
|
80
|
+
export declare function setSessionLocation(locationUuid: string, abortController: AbortController): Promise<any>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** @module @category API */
|
|
2
|
+
import { Observable, BehaviorSubject } from "rxjs";
|
|
3
|
+
import { FetchResponse, NewVisitPayload, UpdateVisitPayload, Visit } from "../types";
|
|
4
|
+
export declare const defaultVisitCustomRepresentation: string;
|
|
5
|
+
export declare function getVisitsForPatient(patientUuid: string, abortController: AbortController, v?: string): Observable<FetchResponse<{
|
|
6
|
+
results: Array<Visit>;
|
|
7
|
+
}>>;
|
|
8
|
+
export declare function saveVisit(payload: NewVisitPayload, abortController: AbortController): Observable<FetchResponse<any>>;
|
|
9
|
+
export declare function updateVisit(uuid: string, payload: UpdateVisitPayload, abortController: AbortController): Observable<any>;
|
|
10
|
+
export declare const getStartedVisit: BehaviorSubject<VisitItem | null>;
|
|
11
|
+
export interface VisitItem {
|
|
12
|
+
mode: VisitMode;
|
|
13
|
+
visitData?: Visit;
|
|
14
|
+
status: VisitStatus;
|
|
15
|
+
anythingElse?: any;
|
|
16
|
+
}
|
|
17
|
+
export declare enum VisitMode {
|
|
18
|
+
NEWVISIT = "startVisit",
|
|
19
|
+
EDITVISIT = "editVisit",
|
|
20
|
+
LOADING = "loadingVisit"
|
|
21
|
+
}
|
|
22
|
+
export declare enum VisitStatus {
|
|
23
|
+
NOTSTARTED = "notStarted",
|
|
24
|
+
ONGOING = "ongoing"
|
|
25
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface FHIRResource {
|
|
2
|
+
resource: {
|
|
3
|
+
code: {
|
|
4
|
+
coding: Array<FHIRCode>;
|
|
5
|
+
};
|
|
6
|
+
effectiveDateTime: Date;
|
|
7
|
+
encounter: {
|
|
8
|
+
reference: string;
|
|
9
|
+
type: string;
|
|
10
|
+
};
|
|
11
|
+
id: string;
|
|
12
|
+
issued: Date;
|
|
13
|
+
referenceRange: any;
|
|
14
|
+
resourceType: string;
|
|
15
|
+
status: string;
|
|
16
|
+
subject: {
|
|
17
|
+
display: string;
|
|
18
|
+
identifier: {
|
|
19
|
+
id: string;
|
|
20
|
+
system: string;
|
|
21
|
+
use: string;
|
|
22
|
+
value: string;
|
|
23
|
+
};
|
|
24
|
+
reference: string;
|
|
25
|
+
type: string;
|
|
26
|
+
};
|
|
27
|
+
valueQuantity: {
|
|
28
|
+
value: number;
|
|
29
|
+
};
|
|
30
|
+
valueString: string;
|
|
31
|
+
valueCodeableConcept: {
|
|
32
|
+
coding: Array<FHIRCode>;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export interface FHIRCode {
|
|
37
|
+
code: string;
|
|
38
|
+
system: string;
|
|
39
|
+
display?: string;
|
|
40
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/// <reference types="fhir" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { FetchHeaders } from "../openmrs-fetch";
|
|
4
|
+
declare type ClientFn = (...args: any[]) => Promise<{
|
|
5
|
+
data: any;
|
|
6
|
+
}>;
|
|
7
|
+
declare type ResourceName = "DomainResource" | "Organization" | "Location" | "HealthcareService" | "Practitioner" | "Patient" | "RelatedPerson" | "Device" | "Account" | "AllergyIntolerance" | "Schedule" | "Slot" | "Appointment" | "AppointmentResponse" | "AuditEvent" | "Basic" | "BodySite" | "Substance" | "Medication" | "Group" | "Specimen" | "DeviceComponent" | "DeviceMetric" | "ValueSet" | "Questionnaire" | "QuestionnaireResponse" | "Observation" | "FamilyMemberHistory" | "DocumentReference" | "DiagnosticOrder" | "ProcedureRequest" | "ReferralRequest" | "Procedure" | "ImagingStudy" | "ImagingObjectSelection" | "Media" | "DiagnosticReport" | "CommunicationRequest" | "DeviceUseRequest" | "MedicationOrder" | "NutritionOrder" | "Order" | "ProcessRequest" | "SupplyRequest" | "VisionPrescription" | "ClinicalImpression" | "Condition" | "EpisodeOfCare" | "Encounter" | "MedicationStatement" | "RiskAssessment" | "Goal" | "CarePlan" | "Composition" | "Contract" | "Coverage" | "ClaimResponse" | "Claim" | "Communication" | "StructureDefinition" | "ConceptMap" | "OperationDefinition" | "Conformance" | "DataElement" | "DetectedIssue" | "DeviceUseStatement" | "DocumentManifest" | "EligibilityRequest" | "EligibilityResponse" | "EnrollmentRequest" | "EnrollmentResponse" | "ExplanationOfBenefit" | "Flag" | "Immunization" | "ImmunizationRecommendation" | "ImplementationGuide" | "List" | "MedicationAdministration" | "MedicationDispense" | "OperationOutcome" | "MessageHeader" | "NamingSystem" | "OrderResponse" | "PaymentNotice" | "PaymentReconciliation" | "Person" | "ProcessResponse" | "Provenance" | "SearchParameter" | "Subscription" | "SupplyDelivery" | "TestScript" | "Binary" | "Bundle" | "Parameters";
|
|
8
|
+
interface QueryOptions {
|
|
9
|
+
$include?: {
|
|
10
|
+
[key: string]: string | string[];
|
|
11
|
+
};
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}
|
|
14
|
+
declare function Create<T extends fhir.DomainResource>(content: {
|
|
15
|
+
resource: T;
|
|
16
|
+
}): Promise<{
|
|
17
|
+
data: T;
|
|
18
|
+
}>;
|
|
19
|
+
declare function Create(content: {
|
|
20
|
+
type: "Binary";
|
|
21
|
+
data: Buffer;
|
|
22
|
+
}): Promise<{
|
|
23
|
+
data: fhir.Binary;
|
|
24
|
+
}>;
|
|
25
|
+
declare function Create<T extends fhir.DomainResource>(content: {
|
|
26
|
+
type: ResourceName;
|
|
27
|
+
data: T;
|
|
28
|
+
}): Promise<{
|
|
29
|
+
data: T;
|
|
30
|
+
}>;
|
|
31
|
+
declare function Read<T extends fhir.DomainResource>(content: {
|
|
32
|
+
type: ResourceName;
|
|
33
|
+
id?: string;
|
|
34
|
+
patient?: string;
|
|
35
|
+
headers?: FetchHeaders;
|
|
36
|
+
}): Promise<{
|
|
37
|
+
data: T;
|
|
38
|
+
}>;
|
|
39
|
+
declare function Patch(content: {
|
|
40
|
+
type: ResourceName;
|
|
41
|
+
id: string;
|
|
42
|
+
data: Array<{
|
|
43
|
+
op: "replace" | "add" | "remove";
|
|
44
|
+
path: string;
|
|
45
|
+
value: string | object;
|
|
46
|
+
}>;
|
|
47
|
+
}): Promise<{
|
|
48
|
+
data: fhir.OperationOutcome;
|
|
49
|
+
}>;
|
|
50
|
+
declare function Update<T extends fhir.DomainResource>(content: {
|
|
51
|
+
resource: T;
|
|
52
|
+
}): Promise<{
|
|
53
|
+
data: T;
|
|
54
|
+
}>;
|
|
55
|
+
declare function Search(content: {
|
|
56
|
+
type: ResourceName;
|
|
57
|
+
count?: number;
|
|
58
|
+
query?: QueryOptions;
|
|
59
|
+
}): Promise<{
|
|
60
|
+
data: fhir.Bundle;
|
|
61
|
+
}>;
|
|
62
|
+
declare function NextPage(content: {
|
|
63
|
+
type: ResourceName;
|
|
64
|
+
bundle: fhir.Bundle;
|
|
65
|
+
}): Promise<{
|
|
66
|
+
data: fhir.Bundle;
|
|
67
|
+
}>;
|
|
68
|
+
export interface FhirClient {
|
|
69
|
+
conformance: ClientFn;
|
|
70
|
+
document: ClientFn;
|
|
71
|
+
profile: ClientFn;
|
|
72
|
+
transaction: ClientFn;
|
|
73
|
+
history: ClientFn;
|
|
74
|
+
typeHistory: ClientFn;
|
|
75
|
+
resourceHistory: ClientFn;
|
|
76
|
+
read: typeof Read;
|
|
77
|
+
vread: ClientFn;
|
|
78
|
+
delete: ClientFn;
|
|
79
|
+
create: typeof Create;
|
|
80
|
+
validate: ClientFn;
|
|
81
|
+
search: typeof Search;
|
|
82
|
+
update: typeof Update;
|
|
83
|
+
nextPage: typeof NextPage;
|
|
84
|
+
prevPage: ClientFn;
|
|
85
|
+
resolve: ClientFn;
|
|
86
|
+
patch: typeof Patch;
|
|
87
|
+
}
|
|
88
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface Session {
|
|
2
|
+
allowedLocales?: Array<string>;
|
|
3
|
+
authenticated: boolean;
|
|
4
|
+
locale?: string;
|
|
5
|
+
sessionId: string;
|
|
6
|
+
user?: LoggedInUser;
|
|
7
|
+
currentProvider?: {
|
|
8
|
+
uuid: string;
|
|
9
|
+
identifier: string;
|
|
10
|
+
};
|
|
11
|
+
sessionLocation?: SessionLocation;
|
|
12
|
+
}
|
|
13
|
+
export interface LoggedInUser {
|
|
14
|
+
uuid: string;
|
|
15
|
+
display: string;
|
|
16
|
+
username: string;
|
|
17
|
+
systemId: string;
|
|
18
|
+
userProperties: {
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
} | null;
|
|
21
|
+
person: Person;
|
|
22
|
+
privileges: Array<Privilege>;
|
|
23
|
+
roles: Array<Role>;
|
|
24
|
+
retired: boolean;
|
|
25
|
+
locale: string;
|
|
26
|
+
allowedLocales: Array<string>;
|
|
27
|
+
[anythingElse: string]: any;
|
|
28
|
+
}
|
|
29
|
+
export interface SessionLocation {
|
|
30
|
+
uuid: string;
|
|
31
|
+
display: string;
|
|
32
|
+
links: Array<any>;
|
|
33
|
+
}
|
|
34
|
+
export interface Person {
|
|
35
|
+
uuid: string;
|
|
36
|
+
display: string;
|
|
37
|
+
links: Array<any>;
|
|
38
|
+
}
|
|
39
|
+
export interface Privilege {
|
|
40
|
+
uuid: string;
|
|
41
|
+
display: string;
|
|
42
|
+
links?: Array<any>;
|
|
43
|
+
}
|
|
44
|
+
export interface Role {
|
|
45
|
+
uuid: string;
|
|
46
|
+
display: string;
|
|
47
|
+
links: Array<any>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { OpenmrsResource } from "./openmrs-resource";
|
|
2
|
+
export interface NewVisitPayload {
|
|
3
|
+
uuid?: string;
|
|
4
|
+
location: string;
|
|
5
|
+
patient?: string;
|
|
6
|
+
startDatetime: Date;
|
|
7
|
+
visitType: string;
|
|
8
|
+
stopDatetime?: Date;
|
|
9
|
+
}
|
|
10
|
+
export declare type UpdateVisitPayload = NewVisitPayload & {};
|
|
11
|
+
export interface Visit {
|
|
12
|
+
uuid: string;
|
|
13
|
+
display?: string;
|
|
14
|
+
encounters: Array<OpenmrsResource>;
|
|
15
|
+
patient?: OpenmrsResource;
|
|
16
|
+
visitType: VisitType;
|
|
17
|
+
location?: Location;
|
|
18
|
+
startDatetime: string;
|
|
19
|
+
stopDatetime?: string;
|
|
20
|
+
attributes?: Array<OpenmrsResource>;
|
|
21
|
+
[anythingElse: string]: any;
|
|
22
|
+
}
|
|
23
|
+
export interface Location {
|
|
24
|
+
uuid: string;
|
|
25
|
+
display?: string;
|
|
26
|
+
name?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface VisitType {
|
|
29
|
+
uuid: string;
|
|
30
|
+
display: string;
|
|
31
|
+
name?: string;
|
|
32
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-api",
|
|
3
|
-
"version": "4.0.0-pre.
|
|
3
|
+
"version": "4.0.0-pre.1",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "The javascript module for interacting with the OpenMRS API",
|
|
6
6
|
"browser": "dist/openmrs-esm-api.js",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"@openmrs/esm-error-handling": "4.x"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@openmrs/esm-config": "^4.0.0-pre.
|
|
48
|
-
"@openmrs/esm-error-handling": "^4.0.0-pre.
|
|
49
|
-
"@openmrs/esm-state": "^4.0.0-pre.
|
|
47
|
+
"@openmrs/esm-config": "^4.0.0-pre.1",
|
|
48
|
+
"@openmrs/esm-error-handling": "^4.0.0-pre.1",
|
|
49
|
+
"@openmrs/esm-state": "^4.0.0-pre.1",
|
|
50
50
|
"@types/fhir": "0.0.31",
|
|
51
51
|
"rxjs": "^6.5.3"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "9f58b801f07526083a9edc1cc5a1e58660d71eb0"
|
|
54
54
|
}
|
|
@@ -20,10 +20,13 @@ export interface FHIRResource {
|
|
|
20
20
|
valueQuantity: {
|
|
21
21
|
value: number;
|
|
22
22
|
};
|
|
23
|
+
valueString: string;
|
|
24
|
+
valueCodeableConcept: { coding: Array<FHIRCode> };
|
|
23
25
|
};
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
export interface FHIRCode {
|
|
27
29
|
code: string;
|
|
28
30
|
system: string;
|
|
31
|
+
display?: string;
|
|
29
32
|
}
|