@kenyaemr/esm-patient-clinical-view-app 5.4.2-pre.2189 → 5.4.2-pre.2191
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 +91 -84
- package/dist/40.js +1 -0
- package/dist/40.js.map +1 -0
- package/dist/574.js +1 -1
- package/dist/685.js +2 -0
- package/dist/685.js.map +1 -0
- package/dist/{156.js → 700.js} +2 -2
- package/dist/{156.js.map → 700.js.map} +1 -1
- package/dist/kenyaemr-esm-patient-clinical-view-app.js +1 -1
- package/dist/kenyaemr-esm-patient-clinical-view-app.js.buildmanifest.json +67 -67
- package/dist/kenyaemr-esm-patient-clinical-view-app.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/contact-list/contact-list.component.tsx +12 -6
- package/src/contact-list/contact-list.resource.tsx +88 -2
- package/src/contact-list/forms/contact-list-update.scss +79 -0
- package/src/contact-list/forms/contact-list-update.workspace.tsx +554 -0
- package/src/family-partner-history/family-history.component.tsx +17 -20
- package/src/index.ts +2 -2
- package/src/relationships/forms/baseline-info-form-section.component.tsx +61 -34
- package/src/routes.json +3 -3
- package/src/types/index.ts +7 -0
- package/translations/en.json +1 -0
- package/dist/66.js +0 -2
- package/dist/66.js.map +0 -1
- package/dist/825.js +0 -1
- package/dist/825.js.map +0 -1
- package/src/relationships/forms/relationships-update-form.workspace.tsx +0 -183
- /package/dist/{66.js.LICENSE.txt → 685.js.LICENSE.txt} +0 -0
- /package/dist/{156.js.LICENSE.txt → 700.js.LICENSE.txt} +0 -0
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Button,
|
|
3
|
-
ButtonSet,
|
|
4
|
-
Column,
|
|
5
|
-
DatePicker,
|
|
6
|
-
DatePickerInput,
|
|
7
|
-
Dropdown,
|
|
8
|
-
Form,
|
|
9
|
-
InlineLoading,
|
|
10
|
-
Stack,
|
|
11
|
-
Tile,
|
|
12
|
-
} from '@carbon/react';
|
|
13
|
-
import { zodResolver } from '@hookform/resolvers/zod';
|
|
14
|
-
import { DefaultWorkspaceProps, showSnackbar } from '@openmrs/esm-framework';
|
|
15
|
-
import React, { useEffect } from 'react';
|
|
16
|
-
import { Controller, useForm } from 'react-hook-form';
|
|
17
|
-
import { useTranslation } from 'react-i18next';
|
|
18
|
-
import { mutate } from 'swr';
|
|
19
|
-
import { z } from 'zod';
|
|
20
|
-
import useRelationship from '../../hooks/useRelationship';
|
|
21
|
-
import useRelationshipTypes from '../../hooks/useRelationshipTypes';
|
|
22
|
-
import { relationshipUpdateFormSchema, updateRelationship } from '../relationship.resources';
|
|
23
|
-
import styles from './form.scss';
|
|
24
|
-
import PatientInfo from '../../case-management/workspace/patient-info.component';
|
|
25
|
-
|
|
26
|
-
interface RelationshipUpdateFormProps extends DefaultWorkspaceProps {
|
|
27
|
-
relationShipUuid: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
type RelationshipUpdateFormType = z.infer<typeof relationshipUpdateFormSchema>;
|
|
31
|
-
|
|
32
|
-
const RelationshipUpdateForm: React.FC<RelationshipUpdateFormProps> = ({ closeWorkspace, relationShipUuid }) => {
|
|
33
|
-
const { error, isLoading, relationship } = useRelationship(relationShipUuid);
|
|
34
|
-
const { isLoading: typesLoading, error: typesError, relationshipTypes } = useRelationshipTypes();
|
|
35
|
-
const { t } = useTranslation();
|
|
36
|
-
const form = useForm<RelationshipUpdateFormType>({
|
|
37
|
-
defaultValues: {
|
|
38
|
-
endDate: relationship?.endDate ? new Date(relationship.endDate) : undefined,
|
|
39
|
-
startDate: relationship?.startDate ? new Date(relationship.startDate) : undefined,
|
|
40
|
-
relationshipType: relationship?.relationshipType?.uuid,
|
|
41
|
-
},
|
|
42
|
-
resolver: zodResolver(relationshipUpdateFormSchema),
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
if (relationship && !form.watch('endDate')) {
|
|
47
|
-
relationship.endDate && form.setValue('endDate', new Date(relationship.endDate));
|
|
48
|
-
relationship.startDate && form.setValue('startDate', new Date(relationship.startDate));
|
|
49
|
-
relationship.relationshipType && form.setValue('relationshipType', relationship.relationshipType.uuid);
|
|
50
|
-
}
|
|
51
|
-
}, [relationship, form]);
|
|
52
|
-
|
|
53
|
-
const onSubmit = async (values: RelationshipUpdateFormType) => {
|
|
54
|
-
try {
|
|
55
|
-
await updateRelationship(relationShipUuid, values);
|
|
56
|
-
closeWorkspace();
|
|
57
|
-
showSnackbar({ title: 'Success', subtitle: 'Relationship updated succesfully!', kind: 'success' });
|
|
58
|
-
mutate((key) => {
|
|
59
|
-
return typeof key === 'string' && key.startsWith('/ws/rest/v1/relationship');
|
|
60
|
-
});
|
|
61
|
-
} catch (error) {
|
|
62
|
-
showSnackbar({
|
|
63
|
-
title: 'Success',
|
|
64
|
-
subtitle: 'Failure updating relationship!' + JSON.stringify(error),
|
|
65
|
-
kind: 'error',
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
if (isLoading || typesLoading) {
|
|
71
|
-
return (
|
|
72
|
-
<div className={styles.loading}>
|
|
73
|
-
<InlineLoading
|
|
74
|
-
status="active"
|
|
75
|
-
iconDescription="Loading"
|
|
76
|
-
description="Loading form..."
|
|
77
|
-
style={{ justifyContent: 'center' }}
|
|
78
|
-
/>
|
|
79
|
-
</div>
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (error || typesError) {
|
|
84
|
-
return (
|
|
85
|
-
<div className={styles.error}>
|
|
86
|
-
<Tile id="error">
|
|
87
|
-
<strong>Error:</strong>
|
|
88
|
-
<p>{error?.message ?? typesError?.message}</p>
|
|
89
|
-
</Tile>
|
|
90
|
-
</div>
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return (
|
|
95
|
-
<Form onSubmit={form.handleSubmit(onSubmit)}>
|
|
96
|
-
<Stack gap={4} className={styles.grid}>
|
|
97
|
-
<Column>
|
|
98
|
-
<PatientInfo patientUuid={relationship.personB.uuid} />
|
|
99
|
-
</Column>
|
|
100
|
-
<Column>
|
|
101
|
-
<Controller
|
|
102
|
-
control={form.control}
|
|
103
|
-
name="startDate"
|
|
104
|
-
render={({ field }) => (
|
|
105
|
-
<DatePicker
|
|
106
|
-
value={field.value}
|
|
107
|
-
onChange={field.onChange}
|
|
108
|
-
dateFormat="d/m/Y"
|
|
109
|
-
id="startDate"
|
|
110
|
-
datePickerType="single"
|
|
111
|
-
invalid={form.formState.errors[field.name]?.message}
|
|
112
|
-
invalidText={form.formState.errors[field.name]?.message}>
|
|
113
|
-
<DatePickerInput
|
|
114
|
-
invalid={form.formState.errors[field.name]?.message}
|
|
115
|
-
invalidText={form.formState.errors[field.name]?.message}
|
|
116
|
-
placeholder="mm/dd/yyyy"
|
|
117
|
-
labelText={t('startDate', 'Start Date')}
|
|
118
|
-
size={'xl'}
|
|
119
|
-
/>
|
|
120
|
-
</DatePicker>
|
|
121
|
-
)}
|
|
122
|
-
/>
|
|
123
|
-
</Column>
|
|
124
|
-
<Column>
|
|
125
|
-
<Controller
|
|
126
|
-
control={form.control}
|
|
127
|
-
name="endDate"
|
|
128
|
-
render={({ field }) => (
|
|
129
|
-
<DatePicker
|
|
130
|
-
value={field.value}
|
|
131
|
-
onChange={field.onChange}
|
|
132
|
-
dateFormat="d/m/Y"
|
|
133
|
-
id="endDate"
|
|
134
|
-
datePickerType="single"
|
|
135
|
-
invalid={form.formState.errors[field.name]?.message}
|
|
136
|
-
invalidText={form.formState.errors[field.name]?.message}>
|
|
137
|
-
<DatePickerInput
|
|
138
|
-
invalid={form.formState.errors[field.name]?.message}
|
|
139
|
-
invalidText={form.formState.errors[field.name]?.message}
|
|
140
|
-
placeholder="mm/dd/yyyy"
|
|
141
|
-
labelText={t('endDate', 'End Date')}
|
|
142
|
-
size="xl"
|
|
143
|
-
/>
|
|
144
|
-
</DatePicker>
|
|
145
|
-
)}
|
|
146
|
-
/>
|
|
147
|
-
</Column>
|
|
148
|
-
<Column>
|
|
149
|
-
<Controller
|
|
150
|
-
control={form.control}
|
|
151
|
-
name="relationshipType"
|
|
152
|
-
render={({ field }) => (
|
|
153
|
-
<Dropdown
|
|
154
|
-
ref={field.ref}
|
|
155
|
-
invalid={form.formState.errors[field.name]?.message}
|
|
156
|
-
invalidText={form.formState.errors[field.name]?.message}
|
|
157
|
-
id="relationship"
|
|
158
|
-
titleText={t('relationshipType', 'Relationship Type')}
|
|
159
|
-
onChange={(e) => {
|
|
160
|
-
field.onChange(e.selectedItem);
|
|
161
|
-
}}
|
|
162
|
-
selectedItem={field.value}
|
|
163
|
-
label="Choose option"
|
|
164
|
-
items={relationshipTypes.map((r) => r.uuid)}
|
|
165
|
-
itemToString={(item) => relationshipTypes.find((r) => r.uuid === item)?.displayBIsToA ?? ''}
|
|
166
|
-
/>
|
|
167
|
-
)}
|
|
168
|
-
/>
|
|
169
|
-
</Column>
|
|
170
|
-
</Stack>
|
|
171
|
-
<ButtonSet className={styles.buttonSet}>
|
|
172
|
-
<Button className={styles.button} kind="secondary" onClick={closeWorkspace}>
|
|
173
|
-
{t('discard', 'Discard')}
|
|
174
|
-
</Button>
|
|
175
|
-
<Button className={styles.button} kind="primary" type="submit" disabled={form.formState.isSubmitting}>
|
|
176
|
-
{t('submit', 'Submit')}
|
|
177
|
-
</Button>
|
|
178
|
-
</ButtonSet>
|
|
179
|
-
</Form>
|
|
180
|
-
);
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
export default RelationshipUpdateForm;
|
|
File without changes
|
|
File without changes
|