@kenyaemr/esm-patient-clinical-view-app 5.4.2-pre.2230 → 5.4.2-pre.2234

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.
@@ -4,32 +4,17 @@ import { z } from 'zod';
4
4
  import { Patient } from '../types';
5
5
  import { ConfigObject } from '../config-schema';
6
6
  import omit from 'lodash/omit';
7
+ import pick from 'lodash/pick';
7
8
 
8
9
  export const BOOLEAN_YES = '1065';
9
10
  export const BOOLEAN_NO = '1066';
10
11
  export const HIV_EXPOSED_INFANT = 'HIV exposed infant';
11
12
  export const INFANT_AGE_THRESHOLD_IN_MONTHS = 24;
12
13
 
13
- export const relationshipUpdateFormSchema = z
14
- .object({
15
- startDate: z.date({ coerce: true }).max(new Date(), 'Can not be a furture date'),
16
- endDate: z.date({ coerce: true }).optional(),
17
- relationshipType: z.string().uuid(),
18
- })
19
- .refine(
20
- (data) => {
21
- if (data.endDate && data.startDate && data.endDate < data.startDate) {
22
- return false;
23
- }
24
- return true;
25
- },
26
- { message: 'End date must be after start date', path: ['endDate'] },
27
- );
28
-
29
14
  export const updateRelationship = (relationshipUuid: string, payload: z.infer<typeof relationshipUpdateFormSchema>) => {
30
15
  const url = `${restBaseUrl}/relationship/${relationshipUuid}`;
31
16
  return openmrsFetch(url, {
32
- body: JSON.stringify(payload),
17
+ body: JSON.stringify(pick(payload, ['relationshipType', 'startDate', 'endDate'])),
33
18
  method: 'POST',
34
19
  headers: {
35
20
  'Content-Type': 'application/json',
@@ -100,6 +85,18 @@ export const relationshipFormSchema = z.object({
100
85
  .optional(),
101
86
  });
102
87
 
88
+ export const relationshipUpdateFormSchema = relationshipFormSchema
89
+ .omit({ personBInfo: true, mode: true, personA: true, personB: true })
90
+ .refine(
91
+ (data) => {
92
+ if (data.endDate && data.startDate && data.endDate < data.startDate) {
93
+ return false;
94
+ }
95
+ return true;
96
+ },
97
+ { message: 'End date must be after start date', path: ['endDate'] },
98
+ );
99
+
103
100
  export function generateOpenmrsIdentifier(source: string) {
104
101
  const abortController = new AbortController();
105
102
  return openmrsFetch(`${restBaseUrl}/idgen/identifiersource/${source}/identifier`, {
File without changes