@openmrs/esm-emr-api 6.3.1-pre.2986
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/.swcrc +16 -0
- package/.turbo/turbo-build.log +3 -0
- package/README.md +7 -0
- package/dist/attachments.d.ts +6 -0
- package/dist/attachments.js +35 -0
- package/dist/current-patient.d.ts +15 -0
- package/dist/current-patient.js +26 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/location.d.ts +4 -0
- package/dist/location.js +23 -0
- package/dist/public.d.ts +6 -0
- package/dist/public.js +6 -0
- package/dist/types/attachments-types.d.ts +26 -0
- package/dist/types/attachments-types.js +1 -0
- package/dist/types/diagnosis-resource.d.ts +22 -0
- package/dist/types/diagnosis-resource.js +2 -0
- package/dist/types/encounter-resource.d.ts +31 -0
- package/dist/types/encounter-resource.js +1 -0
- package/dist/types/fhir-resource.d.ts +40 -0
- package/dist/types/fhir-resource.js +1 -0
- package/dist/types/fhir.d.ts +1 -0
- package/dist/types/fhir.js +5 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.js +9 -0
- package/dist/types/location-resource.d.ts +47 -0
- package/dist/types/location-resource.js +1 -0
- package/dist/types/obs-resource.d.ts +22 -0
- package/dist/types/obs-resource.js +1 -0
- package/dist/types/patient-resource.d.ts +24 -0
- package/dist/types/patient-resource.js +1 -0
- package/dist/types/visit-resource.d.ts +39 -0
- package/dist/types/visit-resource.js +1 -0
- package/dist/visit-type.d.ts +4 -0
- package/dist/visit-type.js +15 -0
- package/dist/visit-utils.d.ts +44 -0
- package/dist/visit-utils.js +75 -0
- package/mock-jest.ts +10 -0
- package/mock.ts +12 -0
- package/package.json +77 -0
- package/src/attachments.ts +43 -0
- package/src/current-patient.test.ts +53 -0
- package/src/current-patient.ts +58 -0
- package/src/index.ts +6 -0
- package/src/location.ts +36 -0
- package/src/public.ts +6 -0
- package/src/types/attachments-types.ts +28 -0
- package/src/types/diagnosis-resource.ts +24 -0
- package/src/types/encounter-resource.ts +36 -0
- package/src/types/fhir-resource.ts +32 -0
- package/src/types/fhir.ts +102 -0
- package/src/types/index.ts +9 -0
- package/src/types/location-resource.ts +49 -0
- package/src/types/obs-resource.ts +23 -0
- package/src/types/patient-resource.ts +27 -0
- package/src/types/visit-resource.ts +43 -0
- package/src/visit-type.ts +24 -0
- package/src/visit-utils.ts +127 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +5 -0
- package/vitest.config.ts +8 -0
package/mock.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
export const setCurrentVisit = vi.fn();
|
|
4
|
+
export const attachmentUrl = '/ws/rest/v1/attachment';
|
|
5
|
+
export const getAttachmentByUuid = vi.fn();
|
|
6
|
+
export const getAttachments = vi.fn();
|
|
7
|
+
export const createAttachment = vi.fn();
|
|
8
|
+
export const deleteAttachmentPermanently = vi.fn();
|
|
9
|
+
export const updateVisit = vi.fn();
|
|
10
|
+
export const saveVisit = vi.fn();
|
|
11
|
+
export const getVisitsForPatient = vi.fn();
|
|
12
|
+
export const getStartedVisit = vi.fn();
|
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openmrs/esm-emr-api",
|
|
3
|
+
"version": "6.3.1-pre.2986",
|
|
4
|
+
"license": "MPL-2.0",
|
|
5
|
+
"description": "The javascript module for interacting with the OpenMRS API",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./src/index.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./src/public": {
|
|
15
|
+
"types": "./src/public.ts",
|
|
16
|
+
"default": "./dist/public.js"
|
|
17
|
+
},
|
|
18
|
+
"./mock": {
|
|
19
|
+
"import": "./mock.ts",
|
|
20
|
+
"require": "./mock-jest.ts"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"source": true,
|
|
24
|
+
"scripts": {
|
|
25
|
+
"test": "cross-env TZ=UTC vitest run --passWithNoTests",
|
|
26
|
+
"test:watch": "cross-env TZ=UTC vitest watch --passWithNoTests",
|
|
27
|
+
"build": "rimraf dist && concurrently \"swc --strip-leading-paths src -d dist\" \"tsc --project tsconfig.build.json\"",
|
|
28
|
+
"build:development": "rimraf dist && concurrently \"swc --strip-leading-paths src -d dist\" \"tsc --project tsconfig.build.json\"",
|
|
29
|
+
"typescript": "tsc --project tsconfig.build.json",
|
|
30
|
+
"lint": "eslint src --ext ts,tsx"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"openmrs",
|
|
34
|
+
"microfrontends"
|
|
35
|
+
],
|
|
36
|
+
"directories": {
|
|
37
|
+
"lib": "dist",
|
|
38
|
+
"src": "src"
|
|
39
|
+
},
|
|
40
|
+
"browserslist": [
|
|
41
|
+
"extends browserslist-config-openmrs"
|
|
42
|
+
],
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "git+https://github.com/openmrs/openmrs-esm-core.git"
|
|
46
|
+
},
|
|
47
|
+
"bugs": {
|
|
48
|
+
"url": "https://github.com/openmrs/openmrs-esm-core/issues"
|
|
49
|
+
},
|
|
50
|
+
"homepage": "https://github.com/openmrs/openmrs-esm-core#readme",
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@types/fhir": "0.0.31",
|
|
56
|
+
"lodash-es": "^4.17.21"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"@openmrs/esm-api": "6.x",
|
|
60
|
+
"@openmrs/esm-offline": "6.x",
|
|
61
|
+
"@openmrs/esm-state": "6.x"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@openmrs/esm-api": "6.3.1-pre.2986",
|
|
65
|
+
"@openmrs/esm-offline": "6.3.1-pre.2986",
|
|
66
|
+
"@openmrs/esm-state": "6.3.1-pre.2986",
|
|
67
|
+
"@swc/cli": "^0.7.7",
|
|
68
|
+
"@swc/core": "^1.11.29",
|
|
69
|
+
"concurrently": "^9.1.2",
|
|
70
|
+
"cross-env": "^7.0.3",
|
|
71
|
+
"happy-dom": "^17.4.7",
|
|
72
|
+
"rimraf": "^6.0.1",
|
|
73
|
+
"rxjs": "^6.5.3",
|
|
74
|
+
"vitest": "^3.1.4"
|
|
75
|
+
},
|
|
76
|
+
"stableVersion": "6.2.0"
|
|
77
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** @module @category API */
|
|
2
|
+
import { openmrsFetch, restBaseUrl } from '@openmrs/esm-api';
|
|
3
|
+
import type { UploadedFile } from './types';
|
|
4
|
+
|
|
5
|
+
export const attachmentUrl = `${restBaseUrl}/attachment`;
|
|
6
|
+
|
|
7
|
+
export function getAttachmentByUuid(attachmentUuid: string, abortController: AbortController) {
|
|
8
|
+
return openmrsFetch(`${attachmentUrl}/${attachmentUuid}`, {
|
|
9
|
+
signal: abortController.signal,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function getAttachments(patientUuid: string, includeEncounterless: boolean, abortController: AbortController) {
|
|
14
|
+
return openmrsFetch(`${attachmentUrl}?patient=${patientUuid}&includeEncounterless=${includeEncounterless}`, {
|
|
15
|
+
signal: abortController.signal,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function createAttachment(patientUuid: string, fileToUpload: UploadedFile) {
|
|
20
|
+
const formData = new FormData();
|
|
21
|
+
|
|
22
|
+
formData.append('fileCaption', fileToUpload.fileDescription);
|
|
23
|
+
formData.append('patient', patientUuid);
|
|
24
|
+
|
|
25
|
+
if (fileToUpload.file) {
|
|
26
|
+
formData.append('file', fileToUpload.file, fileToUpload.fileName);
|
|
27
|
+
} else {
|
|
28
|
+
formData.append('file', new File([''], fileToUpload.fileName), fileToUpload.fileName);
|
|
29
|
+
formData.append('base64Content', fileToUpload.base64Content);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return openmrsFetch(`${attachmentUrl}`, {
|
|
33
|
+
method: 'POST',
|
|
34
|
+
body: formData,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function deleteAttachmentPermanently(attachmentUuid: string, abortController: AbortController) {
|
|
39
|
+
return openmrsFetch(`${attachmentUrl}/${attachmentUuid}`, {
|
|
40
|
+
method: 'DELETE',
|
|
41
|
+
signal: abortController.signal,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { openmrsFetch, type FetchResponse } from '@openmrs/esm-api';
|
|
3
|
+
import { getSynchronizationItems } from '@openmrs/esm-offline';
|
|
4
|
+
import { fetchCurrentPatient } from './current-patient';
|
|
5
|
+
|
|
6
|
+
vi.mock('@openmrs/esm-api');
|
|
7
|
+
|
|
8
|
+
const mockOpenmrsFetch = vi.mocked(openmrsFetch);
|
|
9
|
+
const mockGetSynchronizationItems = vi.mocked(getSynchronizationItems);
|
|
10
|
+
|
|
11
|
+
vi.mock('../openmrs-fetch', () => ({
|
|
12
|
+
openmrsFetch: vi.fn(),
|
|
13
|
+
fhirBaseUrl: '/ws/fhir2/R4',
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
vi.mock('@openmrs/esm-offline', () => ({
|
|
17
|
+
getSynchronizationItems: vi.fn(),
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
describe('fetchPatientData', () => {
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
mockGetSynchronizationItems.mockResolvedValue([]);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should return null when patientUuid is falsy', async () => {
|
|
26
|
+
const result = await fetchCurrentPatient('');
|
|
27
|
+
expect(result).toBeNull();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should return online patient data when available', async () => {
|
|
31
|
+
const mockPatient = { id: '123', name: [{ given: ['John'], family: 'Doe' }] };
|
|
32
|
+
mockOpenmrsFetch.mockResolvedValue({ data: mockPatient, ok: true } as Partial<FetchResponse> as FetchResponse);
|
|
33
|
+
|
|
34
|
+
const result = await fetchCurrentPatient('123');
|
|
35
|
+
expect(result).toEqual(mockPatient);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should return offline patient data when online fetch fails', async () => {
|
|
39
|
+
const mockOfflinePatient = { id: '123', name: [{ given: ['Jane'], family: 'Doe' }] };
|
|
40
|
+
mockOpenmrsFetch.mockRejectedValue(new Error('Network error'));
|
|
41
|
+
mockGetSynchronizationItems.mockResolvedValue([{ fhirPatient: mockOfflinePatient }]);
|
|
42
|
+
|
|
43
|
+
const result = await fetchCurrentPatient('123');
|
|
44
|
+
expect(result).toEqual(mockOfflinePatient);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('should throw an error when both online and offline fetches fail', async () => {
|
|
48
|
+
mockOpenmrsFetch.mockRejectedValue(new Error('Network error'));
|
|
49
|
+
mockGetSynchronizationItems.mockResolvedValue([]);
|
|
50
|
+
|
|
51
|
+
await expect(fetchCurrentPatient('123')).rejects.toThrow('Network error');
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** @module @category API */
|
|
2
|
+
import { fhirBaseUrl, openmrsFetch, type FetchConfig, type FetchResponse } from '@openmrs/esm-api';
|
|
3
|
+
import { getSynchronizationItems } from '@openmrs/esm-offline';
|
|
4
|
+
|
|
5
|
+
export type CurrentPatient = fhir.Patient | FetchResponse<fhir.Patient>;
|
|
6
|
+
|
|
7
|
+
export interface CurrentPatientOptions {
|
|
8
|
+
includeConfig?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface PatientWithFullResponse extends CurrentPatientOptions {
|
|
12
|
+
includeConfig: true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface OnlyThePatient extends CurrentPatientOptions {
|
|
16
|
+
includeConfig: false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type PatientUuid = string | null;
|
|
20
|
+
|
|
21
|
+
export async function fetchCurrentPatient(
|
|
22
|
+
patientUuid: PatientUuid,
|
|
23
|
+
fetchInit?: FetchConfig,
|
|
24
|
+
includeOfflinePatients: boolean = true,
|
|
25
|
+
): Promise<fhir.Patient | null> {
|
|
26
|
+
if (patientUuid) {
|
|
27
|
+
let err: Error | null = null;
|
|
28
|
+
const [onlinePatient, offlinePatient] = await Promise.all([
|
|
29
|
+
openmrsFetch<fhir.Patient>(`${fhirBaseUrl}/Patient/${patientUuid}`, fetchInit).catch<FetchResponse<fhir.Patient>>(
|
|
30
|
+
(e) => (err = e),
|
|
31
|
+
),
|
|
32
|
+
includeOfflinePatients ? getOfflineRegisteredPatientAsFhirPatient(patientUuid) : Promise.resolve(null),
|
|
33
|
+
]);
|
|
34
|
+
|
|
35
|
+
if (onlinePatient.ok) {
|
|
36
|
+
return onlinePatient.data;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (offlinePatient) {
|
|
40
|
+
return offlinePatient;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (err) {
|
|
44
|
+
throw err;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function getOfflineRegisteredPatientAsFhirPatient(patientUuid: string): Promise<fhir.Patient | null> {
|
|
52
|
+
const patientRegistrationSyncItems = await getSynchronizationItems<{
|
|
53
|
+
fhirPatient: fhir.Patient;
|
|
54
|
+
}>('patient-registration');
|
|
55
|
+
const patientSyncItem = patientRegistrationSyncItems.find((item) => item.fhirPatient.id === patientUuid);
|
|
56
|
+
|
|
57
|
+
return patientSyncItem?.fhirPatient ?? null;
|
|
58
|
+
}
|
package/src/index.ts
ADDED
package/src/location.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** @module @category API */
|
|
2
|
+
import { openmrsObservableFetch, restBaseUrl } from '@openmrs/esm-api';
|
|
3
|
+
import type { Observable } from 'rxjs';
|
|
4
|
+
import { map, take } from 'rxjs/operators/index.js';
|
|
5
|
+
import type { Location } from './types';
|
|
6
|
+
|
|
7
|
+
export function toLocationObject(openmrsRestForm: any): Location {
|
|
8
|
+
return {
|
|
9
|
+
uuid: openmrsRestForm.uuid,
|
|
10
|
+
display: openmrsRestForm.display,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function getLocations(
|
|
15
|
+
tagUuidOrName: string | null = null,
|
|
16
|
+
query: string | null = null,
|
|
17
|
+
): Observable<Array<Location>> {
|
|
18
|
+
const params = new URLSearchParams();
|
|
19
|
+
if (tagUuidOrName) {
|
|
20
|
+
params.set('tag', tagUuidOrName);
|
|
21
|
+
}
|
|
22
|
+
if (query) {
|
|
23
|
+
params.set('q', query);
|
|
24
|
+
}
|
|
25
|
+
const queryString = params.toString();
|
|
26
|
+
const url = `${restBaseUrl}/location${queryString ? '?' + queryString : ''}`;
|
|
27
|
+
|
|
28
|
+
return openmrsObservableFetch<{ results: Array<Location> }>(url)
|
|
29
|
+
.pipe(
|
|
30
|
+
map((results) => {
|
|
31
|
+
const locations: Array<Location> = results.data.results.map(toLocationObject);
|
|
32
|
+
return locations;
|
|
33
|
+
}),
|
|
34
|
+
)
|
|
35
|
+
.pipe(take(1));
|
|
36
|
+
}
|
package/src/public.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface UploadedFile {
|
|
2
|
+
file?: File;
|
|
3
|
+
base64Content: string;
|
|
4
|
+
fileName: string;
|
|
5
|
+
fileType: string;
|
|
6
|
+
fileDescription: string;
|
|
7
|
+
status?: 'uploading' | 'complete';
|
|
8
|
+
capturedFromWebcam?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface Attachment {
|
|
12
|
+
id: string;
|
|
13
|
+
src: string;
|
|
14
|
+
filename: string;
|
|
15
|
+
dateTime: string;
|
|
16
|
+
bytesMimeType: string;
|
|
17
|
+
bytesContentFamily: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface AttachmentResponse {
|
|
22
|
+
bytesContentFamily: string;
|
|
23
|
+
bytesMimeType: string;
|
|
24
|
+
comment: string;
|
|
25
|
+
dateTime: string;
|
|
26
|
+
uuid: string;
|
|
27
|
+
filename?: string;
|
|
28
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Concept, type ConceptClass, type OpenmrsResource } from '@openmrs/esm-api';
|
|
2
|
+
import { type Encounter } from './encounter-resource';
|
|
3
|
+
import { type Patient } from './patient-resource';
|
|
4
|
+
|
|
5
|
+
// TODO: make this extends OpenmrsResourceStrict
|
|
6
|
+
export interface Diagnosis extends OpenmrsResource {
|
|
7
|
+
diagnosis?: {
|
|
8
|
+
coded?: {
|
|
9
|
+
uuid: string;
|
|
10
|
+
display?: string;
|
|
11
|
+
name?: Concept;
|
|
12
|
+
datatype?: OpenmrsResource;
|
|
13
|
+
conceptClass?: ConceptClass;
|
|
14
|
+
};
|
|
15
|
+
nonCoded?: string;
|
|
16
|
+
};
|
|
17
|
+
patient?: Patient;
|
|
18
|
+
encounter?: Encounter;
|
|
19
|
+
certainty?: string;
|
|
20
|
+
rank?: number;
|
|
21
|
+
formFieldNamespace?: string;
|
|
22
|
+
formFieldPath?: string;
|
|
23
|
+
voided?: boolean;
|
|
24
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type OpenmrsResource } from '@openmrs/esm-api';
|
|
2
|
+
import { type Diagnosis } from './diagnosis-resource';
|
|
3
|
+
import { type Location } from './location-resource';
|
|
4
|
+
import { type Obs } from './obs-resource';
|
|
5
|
+
import { type Patient } from './patient-resource';
|
|
6
|
+
import { type Visit } from './visit-resource';
|
|
7
|
+
|
|
8
|
+
// TODO: make this extends OpenmrsResourceStrict
|
|
9
|
+
export interface Encounter extends OpenmrsResource {
|
|
10
|
+
encounterDatetime?: string;
|
|
11
|
+
patient?: Patient;
|
|
12
|
+
location?: Location;
|
|
13
|
+
encounterType?: EncounterType;
|
|
14
|
+
obs?: Array<Obs>;
|
|
15
|
+
visit?: Visit;
|
|
16
|
+
encounterProviders?: Array<EncounterProvider>;
|
|
17
|
+
diagnoses?: Array<Diagnosis>;
|
|
18
|
+
form?: OpenmrsResource;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface EncounterType extends OpenmrsResource {
|
|
22
|
+
name?: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
retired?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface EncounterProvider extends OpenmrsResource {
|
|
28
|
+
provider?: OpenmrsResource;
|
|
29
|
+
encounterRole?: EncounterRole;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface EncounterRole extends OpenmrsResource {
|
|
33
|
+
name?: string;
|
|
34
|
+
description?: string;
|
|
35
|
+
retired?: boolean;
|
|
36
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface FHIRResource {
|
|
2
|
+
resource: {
|
|
3
|
+
code: { coding: Array<FHIRCode> };
|
|
4
|
+
effectiveDateTime: Date;
|
|
5
|
+
encounter: {
|
|
6
|
+
reference: string;
|
|
7
|
+
type: string;
|
|
8
|
+
};
|
|
9
|
+
id: string;
|
|
10
|
+
issued: Date;
|
|
11
|
+
referenceRange: any;
|
|
12
|
+
resourceType: string;
|
|
13
|
+
status: string;
|
|
14
|
+
subject: {
|
|
15
|
+
display: string;
|
|
16
|
+
identifier: { id: string; system: string; use: string; value: string };
|
|
17
|
+
reference: string;
|
|
18
|
+
type: string;
|
|
19
|
+
};
|
|
20
|
+
valueQuantity: {
|
|
21
|
+
value: number;
|
|
22
|
+
};
|
|
23
|
+
valueString: string;
|
|
24
|
+
valueCodeableConcept: { coding: Array<FHIRCode> };
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface FHIRCode {
|
|
29
|
+
code: string;
|
|
30
|
+
system: string;
|
|
31
|
+
display?: string;
|
|
32
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Originally taken from https://github.com/FHIR/fhir.js/blob/ec82ccfc125e05dbb645f47c100fe60f2c34bb73/src/fhir.d.ts
|
|
3
|
+
Has been adapted to be even better - if we can get fhir.js to publish a good version to npm with better typedefs,
|
|
4
|
+
we can remove this file in favor of the one they maintain
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export type ResourceName =
|
|
8
|
+
| 'DomainResource'
|
|
9
|
+
| 'Organization'
|
|
10
|
+
| 'Location'
|
|
11
|
+
| 'HealthcareService'
|
|
12
|
+
| 'Practitioner'
|
|
13
|
+
| 'Patient'
|
|
14
|
+
| 'RelatedPerson'
|
|
15
|
+
| 'Device'
|
|
16
|
+
| 'Account'
|
|
17
|
+
| 'AllergyIntolerance'
|
|
18
|
+
| 'Schedule'
|
|
19
|
+
| 'Slot'
|
|
20
|
+
| 'Appointment'
|
|
21
|
+
| 'AppointmentResponse'
|
|
22
|
+
| 'AuditEvent'
|
|
23
|
+
| 'Basic'
|
|
24
|
+
| 'BodySite'
|
|
25
|
+
| 'Substance'
|
|
26
|
+
| 'Medication'
|
|
27
|
+
| 'Group'
|
|
28
|
+
| 'Specimen'
|
|
29
|
+
| 'DeviceComponent'
|
|
30
|
+
| 'DeviceMetric'
|
|
31
|
+
| 'ValueSet'
|
|
32
|
+
| 'Questionnaire'
|
|
33
|
+
| 'QuestionnaireResponse'
|
|
34
|
+
| 'Observation'
|
|
35
|
+
| 'FamilyMemberHistory'
|
|
36
|
+
| 'DocumentReference'
|
|
37
|
+
| 'DiagnosticOrder'
|
|
38
|
+
| 'ProcedureRequest'
|
|
39
|
+
| 'ReferralRequest'
|
|
40
|
+
| 'Procedure'
|
|
41
|
+
| 'ImagingStudy'
|
|
42
|
+
| 'ImagingObjectSelection'
|
|
43
|
+
| 'Media'
|
|
44
|
+
| 'DiagnosticReport'
|
|
45
|
+
| 'CommunicationRequest'
|
|
46
|
+
| 'DeviceUseRequest'
|
|
47
|
+
| 'MedicationOrder'
|
|
48
|
+
| 'NutritionOrder'
|
|
49
|
+
| 'Order'
|
|
50
|
+
| 'ProcessRequest'
|
|
51
|
+
| 'SupplyRequest'
|
|
52
|
+
| 'VisionPrescription'
|
|
53
|
+
| 'ClinicalImpression'
|
|
54
|
+
| 'Condition'
|
|
55
|
+
| 'EpisodeOfCare'
|
|
56
|
+
| 'Encounter'
|
|
57
|
+
| 'MedicationStatement'
|
|
58
|
+
| 'RiskAssessment'
|
|
59
|
+
| 'Goal'
|
|
60
|
+
| 'CarePlan'
|
|
61
|
+
| 'Composition'
|
|
62
|
+
| 'Contract'
|
|
63
|
+
| 'Coverage'
|
|
64
|
+
| 'ClaimResponse'
|
|
65
|
+
| 'Claim'
|
|
66
|
+
| 'Communication'
|
|
67
|
+
| 'StructureDefinition'
|
|
68
|
+
| 'ConceptMap'
|
|
69
|
+
| 'OperationDefinition'
|
|
70
|
+
| 'Conformance'
|
|
71
|
+
| 'DataElement'
|
|
72
|
+
| 'DetectedIssue'
|
|
73
|
+
| 'DeviceUseStatement'
|
|
74
|
+
| 'DocumentManifest'
|
|
75
|
+
| 'EligibilityRequest'
|
|
76
|
+
| 'EligibilityResponse'
|
|
77
|
+
| 'EnrollmentRequest'
|
|
78
|
+
| 'EnrollmentResponse'
|
|
79
|
+
| 'ExplanationOfBenefit'
|
|
80
|
+
| 'Flag'
|
|
81
|
+
| 'Immunization'
|
|
82
|
+
| 'ImmunizationRecommendation'
|
|
83
|
+
| 'ImplementationGuide'
|
|
84
|
+
| 'List'
|
|
85
|
+
| 'MedicationAdministration'
|
|
86
|
+
| 'MedicationDispense'
|
|
87
|
+
| 'OperationOutcome'
|
|
88
|
+
| 'MessageHeader'
|
|
89
|
+
| 'NamingSystem'
|
|
90
|
+
| 'OrderResponse'
|
|
91
|
+
| 'PaymentNotice'
|
|
92
|
+
| 'PaymentReconciliation'
|
|
93
|
+
| 'Person'
|
|
94
|
+
| 'ProcessResponse'
|
|
95
|
+
| 'Provenance'
|
|
96
|
+
| 'SearchParameter'
|
|
97
|
+
| 'Subscription'
|
|
98
|
+
| 'SupplyDelivery'
|
|
99
|
+
| 'TestScript'
|
|
100
|
+
| 'Binary'
|
|
101
|
+
| 'Bundle'
|
|
102
|
+
| 'Parameters';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './attachments-types';
|
|
2
|
+
export * from './diagnosis-resource';
|
|
3
|
+
export * from './encounter-resource';
|
|
4
|
+
export * from './fhir';
|
|
5
|
+
export * from './fhir-resource';
|
|
6
|
+
export * from './location-resource';
|
|
7
|
+
export * from './obs-resource';
|
|
8
|
+
export * from './patient-resource';
|
|
9
|
+
export * from './visit-resource';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type OpenmrsResource } from '@openmrs/esm-api';
|
|
2
|
+
|
|
3
|
+
export interface Location extends OpenmrsResource {
|
|
4
|
+
name?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
cityVillage?: string;
|
|
7
|
+
stateProvince?: string;
|
|
8
|
+
country?: string;
|
|
9
|
+
postalCode?: string;
|
|
10
|
+
countyDistrict?: string;
|
|
11
|
+
latitude?: string;
|
|
12
|
+
longitude?: string;
|
|
13
|
+
address1?: string;
|
|
14
|
+
address2?: string;
|
|
15
|
+
address3?: string;
|
|
16
|
+
address4?: string;
|
|
17
|
+
address5?: string;
|
|
18
|
+
address6?: string;
|
|
19
|
+
address7?: string;
|
|
20
|
+
address8?: string;
|
|
21
|
+
address9?: string;
|
|
22
|
+
address10?: string;
|
|
23
|
+
address11?: string;
|
|
24
|
+
address12?: string;
|
|
25
|
+
address13?: string;
|
|
26
|
+
address14?: string;
|
|
27
|
+
address15?: string;
|
|
28
|
+
tags?: Array<OpenmrsResource>;
|
|
29
|
+
attributes?: Array<OpenmrsResource>;
|
|
30
|
+
parentLocation?: Location;
|
|
31
|
+
childLocation?: Location;
|
|
32
|
+
retired?: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface FHIRLocationResource {
|
|
36
|
+
resource: {
|
|
37
|
+
id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
resourceType: string;
|
|
40
|
+
status: 'active' | 'inactive';
|
|
41
|
+
meta?: {
|
|
42
|
+
tag?: Array<{
|
|
43
|
+
code: string;
|
|
44
|
+
display: string;
|
|
45
|
+
system: string;
|
|
46
|
+
}>;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Concept, type OpenmrsResource, type Person } from '@openmrs/esm-api';
|
|
2
|
+
import { type Encounter } from './encounter-resource';
|
|
3
|
+
import { type Location } from './location-resource';
|
|
4
|
+
|
|
5
|
+
export interface Obs extends OpenmrsResource {
|
|
6
|
+
concept?: Concept;
|
|
7
|
+
person?: Person;
|
|
8
|
+
obsDatetime?: string;
|
|
9
|
+
accessionNumber?: string;
|
|
10
|
+
obsGroup?: Obs;
|
|
11
|
+
valueCodedName?: OpenmrsResource;
|
|
12
|
+
groupMembers?: Array<Obs>;
|
|
13
|
+
comment?: string;
|
|
14
|
+
location?: Location;
|
|
15
|
+
order?: OpenmrsResource;
|
|
16
|
+
encounter?: Encounter;
|
|
17
|
+
value?: number | string | boolean | OpenmrsResource;
|
|
18
|
+
valueModifier?: string;
|
|
19
|
+
formFilePath?: string;
|
|
20
|
+
formFiledNamespace?: string;
|
|
21
|
+
status?: 'PRELIMINARY' | 'FINAL' | 'AMENDED';
|
|
22
|
+
interpretation?: string;
|
|
23
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type OpenmrsResourceStrict, type Person } from '@openmrs/esm-api';
|
|
2
|
+
|
|
3
|
+
export interface PatientIdentifierType extends OpenmrsResourceStrict {
|
|
4
|
+
name?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
format?: string;
|
|
7
|
+
formatDescription?: string;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
validator?: string;
|
|
10
|
+
locationBehavior?: string;
|
|
11
|
+
uniquenessBehavior?: string;
|
|
12
|
+
retired?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface Patient extends OpenmrsResourceStrict {
|
|
16
|
+
identifiers?: PatientIdentifier[];
|
|
17
|
+
person?: Person;
|
|
18
|
+
voided?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface PatientIdentifier extends OpenmrsResourceStrict {
|
|
22
|
+
identifier?: string;
|
|
23
|
+
identifierType?: PatientIdentifierType;
|
|
24
|
+
location?: Location;
|
|
25
|
+
preferred?: boolean;
|
|
26
|
+
voided?: boolean;
|
|
27
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type OpenmrsResource } from '@openmrs/esm-api';
|
|
2
|
+
import { type Encounter } from './encounter-resource';
|
|
3
|
+
import { type Patient } from './patient-resource';
|
|
4
|
+
|
|
5
|
+
export interface NewVisitPayload {
|
|
6
|
+
uuid?: string;
|
|
7
|
+
location: string;
|
|
8
|
+
patient?: string;
|
|
9
|
+
startDatetime: Date;
|
|
10
|
+
visitType: string;
|
|
11
|
+
stopDatetime?: Date;
|
|
12
|
+
attributes?: Array<{
|
|
13
|
+
attributeType: string;
|
|
14
|
+
value: string;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type UpdateVisitPayload = Partial<NewVisitPayload> & {};
|
|
19
|
+
|
|
20
|
+
export interface Visit {
|
|
21
|
+
uuid: string;
|
|
22
|
+
display?: string;
|
|
23
|
+
encounters?: Array<Encounter>;
|
|
24
|
+
patient?: Patient;
|
|
25
|
+
visitType: VisitType;
|
|
26
|
+
location?: Location;
|
|
27
|
+
startDatetime: string;
|
|
28
|
+
stopDatetime?: string;
|
|
29
|
+
attributes?: Array<OpenmrsResource>;
|
|
30
|
+
[anythingElse: string]: any;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface Location {
|
|
34
|
+
uuid: string;
|
|
35
|
+
display?: string;
|
|
36
|
+
name?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface VisitType {
|
|
40
|
+
uuid: string;
|
|
41
|
+
display: string;
|
|
42
|
+
name?: string;
|
|
43
|
+
}
|