@kenyaemr/esm-patient-registration-app 8.1.2-pre.238 → 8.1.2-pre.240

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/dist/routes.json CHANGED
@@ -1 +1 @@
1
- {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":"^2.24.0"},"pages":[{"component":"root","route":"patient-registration","online":true,"offline":true},{"component":"editPatient","routeRegex":"patient\\/([a-zA-Z0-9\\-]+)\\/edit","online":true,"offline":true}],"extensions":[{"component":"addPatientLink","name":"add-patient-action","slot":"top-nav-actions-slot","online":true,"offline":true},{"component":"patientPhotoExtension","name":"patient-photo-widget","slot":"patient-photo-slot","online":true,"offline":true},{"component":"editPatientDetailsButton","name":"edit-patient-details-button","slot":"patient-actions-slot","online":true,"offline":true},{"component":"editPatientDetailsButton","name":"edit-patient-details-button","slot":"patient-search-actions-slot","online":true,"offline":true}],"modals":[{"name":"cancel-patient-edit-modal","component":"cancelPatientEditModal"},{"name":"delete-identifier-confirmation-modal","component":"deleteIdentifierConfirmationModal"},{"component":"emptyClientRegistryModal","name":"empty-client-registry-modal"},{"component":"confirmClientRegistryModal","name":"confirm-client-registry-modal"},{"component":"hieConfirmationModal","name":"hie-confirmation-modal"}],"version":"8.1.2-pre.238"}
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":"^2.24.0"},"pages":[{"component":"root","route":"patient-registration","online":true,"offline":true},{"component":"editPatient","routeRegex":"patient\\/([a-zA-Z0-9\\-]+)\\/edit","online":true,"offline":true}],"extensions":[{"component":"addPatientLink","name":"add-patient-action","slot":"top-nav-actions-slot","online":true,"offline":true},{"component":"patientPhotoExtension","name":"patient-photo-widget","slot":"patient-photo-slot","online":true,"offline":true},{"component":"editPatientDetailsButton","name":"edit-patient-details-button","slot":"patient-actions-slot","online":true,"offline":true},{"component":"editPatientDetailsButton","name":"edit-patient-details-button","slot":"patient-search-actions-slot","online":true,"offline":true}],"modals":[{"name":"cancel-patient-edit-modal","component":"cancelPatientEditModal"},{"name":"delete-identifier-confirmation-modal","component":"deleteIdentifierConfirmationModal"},{"component":"emptyClientRegistryModal","name":"empty-client-registry-modal"},{"component":"confirmClientRegistryModal","name":"confirm-client-registry-modal"},{"component":"hieConfirmationModal","name":"hie-confirmation-modal"}],"version":"8.1.2-pre.240"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kenyaemr/esm-patient-registration-app",
3
- "version": "8.1.2-pre.238",
3
+ "version": "8.1.2-pre.240",
4
4
  "description": "Patient registration microfrontend for the OpenMRS SPA",
5
5
  "browser": "dist/kenyaemr-esm-patient-registration-app.js",
6
6
  "main": "src/index.ts",
@@ -14,8 +14,31 @@ export function CustomField({ name }: CustomFieldProps) {
14
14
  const config = useConfig() as RegistrationConfig;
15
15
  const fieldDefinition = config.fieldDefinitions.filter((def) => def.id == name)[0];
16
16
 
17
- const [{ value }] = useField(`attributes.${fieldDefinition.showWhenExpression?.field}`);
18
- if (fieldDefinition.showWhenExpression && value !== fieldDefinition.showWhenExpression.value) {
17
+ let watchFieldPath: string | null = null;
18
+
19
+ if (fieldDefinition.showWhenExpression) {
20
+ const { field: watchedFieldUuid } = fieldDefinition.showWhenExpression;
21
+ const watchedFieldDefinition = config.fieldDefinitions.find((def) => def.uuid === watchedFieldUuid);
22
+
23
+ if (watchedFieldDefinition?.type === 'obs') {
24
+ watchFieldPath = `obs.${watchedFieldUuid}`;
25
+ } else if (watchedFieldDefinition?.type === 'person attribute') {
26
+ watchFieldPath = `attributes.${watchedFieldUuid}`;
27
+ } else {
28
+ watchFieldPath = `attributes.${watchedFieldUuid}`;
29
+ }
30
+ }
31
+
32
+ const [{ value: currentValue }] = useField(watchFieldPath || 'dummy');
33
+
34
+ let shouldShow = true;
35
+
36
+ if (fieldDefinition.showWhenExpression && watchFieldPath) {
37
+ const { value: expectedValue } = fieldDefinition.showWhenExpression;
38
+ shouldShow = currentValue === expectedValue;
39
+ }
40
+
41
+ if (!shouldShow) {
19
42
  return null;
20
43
  }
21
44