@kenyaemr/esm-patient-registration-app 8.0.2 → 8.0.3-pre.136

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.0.2"}
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.0.3-pre.136"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kenyaemr/esm-patient-registration-app",
3
- "version": "8.0.2",
3
+ "version": "8.0.3-pre.136",
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",
@@ -53,5 +53,6 @@
53
53
  },
54
54
  "devDependencies": {
55
55
  "webpack": "^5.74.0"
56
- }
56
+ },
57
+ "stableVersion": "8.0.2"
57
58
  }
@@ -35,7 +35,7 @@ class Mapper<T, U> {
35
35
  */
36
36
  class PatientMapper extends Mapper<HIEPatient, FormValues> {
37
37
  mapHIEPatientToFormValues(hiePatient: HIEPatient, currentFormValues: FormValues): FormValues {
38
- const name = hiePatient.name?.[0] || {};
38
+ const { familyName, givenName, middleName } = getPatientName(hiePatient);
39
39
  const telecom = hiePatient.telecom || [];
40
40
 
41
41
  const telecomAttributes = this.mapTelecomToAttributes(telecom);
@@ -46,10 +46,10 @@ class PatientMapper extends Mapper<HIEPatient, FormValues> {
46
46
  isDead: hiePatient.deceasedBoolean || false,
47
47
  gender: hiePatient.gender || '',
48
48
  birthdate: hiePatient.birthDate || '',
49
- givenName: name.given?.[0] || '',
50
- familyName: name.family || '',
49
+ givenName,
50
+ familyName,
51
51
  telephoneNumber: telecom.find((t) => t.system === 'phone')?.value || '',
52
- middleName: name.given?.[1],
52
+ middleName,
53
53
  address: extensionAddressEntries,
54
54
  identifiers: updatedIdentifiers,
55
55
  attributes: telecomAttributes,
@@ -160,3 +160,25 @@ export const fetchPatientFromHIE = async (
160
160
  export const mapHIEPatientToFormValues = (hiePatient: HIEPatient, currentFormValues: FormValues): FormValues => {
161
161
  return patientMapper.mapHIEPatientToFormValues(hiePatient, currentFormValues);
162
162
  };
163
+
164
+ /**
165
+ * Mask sensitive data by replacing end digits starting from the 2nd to last with '*'
166
+ * @param data {string} - The data to mask
167
+ * @returns {string} - The masked data
168
+ */
169
+ export const maskData = (data: string): string => {
170
+ const maskedData = data.slice(0, 2) + '*'.repeat(data.length - 2);
171
+ return maskedData;
172
+ };
173
+
174
+ /**
175
+ * Get patient name from FHIR Patient resource
176
+ * @param patient {fhir.Patient} - The FHIR Patient resource
177
+ * @returns {object} - The patient name
178
+ */
179
+ export const getPatientName = (patient: fhir.Patient) => {
180
+ const familyName = patient?.name[0]?.['family'] ?? '';
181
+ const givenName = patient.name[0]?.['given']?.[0]?.split(' ')?.[0] ?? '';
182
+ const middleName = patient.name[0]?.['given']?.[0]?.replace(givenName, '')?.trim() ?? '';
183
+ return { familyName, givenName, middleName };
184
+ };
@@ -5,12 +5,13 @@ import styles from './confirm-hie.scss';
5
5
  import { age, ExtensionSlot, formatDate } from '@openmrs/esm-framework';
6
6
  import { type HIEPatient } from '../hie-types';
7
7
  import capitalize from 'lodash-es/capitalize';
8
+ import { getPatientName, maskData } from '../hie-resource';
8
9
 
9
- const PatientInfo: React.FC<{ label: string; value: string }> = ({ label, value }) => {
10
+ const PatientInfo: React.FC<{ label: string; value: string | (() => React.ReactNode) }> = ({ label, value }) => {
10
11
  return (
11
12
  <div style={{ display: 'grid', gridTemplateColumns: '0.25fr 0.75fr', margin: '0.25rem' }}>
12
13
  <span style={{ minWidth: '5rem', fontWeight: 'bold' }}>{label}</span>
13
- <span>{value}</span>
14
+ <span>{typeof value === 'function' ? value() : value}</span>
14
15
  </div>
15
16
  );
16
17
  };
@@ -23,8 +24,7 @@ interface HIEConfirmationModalProps {
23
24
 
24
25
  const HIEConfirmationModal: React.FC<HIEConfirmationModalProps> = ({ closeModal, patient, onUseValues }) => {
25
26
  const { t } = useTranslation();
26
- const firstName = patient?.name[0]['given']?.[0];
27
- const lastName = patient?.name[0]['family'];
27
+ const { familyName, givenName, middleName } = getPatientName(patient);
28
28
 
29
29
  const handleUseValues = () => {
30
30
  onUseValues();
@@ -41,11 +41,22 @@ const HIEConfirmationModal: React.FC<HIEConfirmationModalProps> = ({ closeModal,
41
41
  <ExtensionSlot
42
42
  style={{ display: 'flex', alignItems: 'center' }}
43
43
  name="patient-photo-slot"
44
- state={{ patientName: `${firstName} ${lastName}` }}
44
+ state={{ patientName: `${maskData(givenName)} . ${maskData(middleName)} . ${maskData(familyName)}` }}
45
45
  />
46
46
  <div style={{ width: '100%', marginLeft: '0.625rem' }}>
47
47
  <PatientInfo label={t('healthID', 'HealthID')} value={patient?.id} />
48
- <PatientInfo label={t('patientName', 'Patient name')} value={`${firstName} ${lastName}`} />
48
+ <PatientInfo
49
+ label={t('patientName', 'Patient name')}
50
+ value={() => (
51
+ <span className={styles.patientNameValue}>
52
+ <p>{maskData(givenName)}</p>
53
+ <span>&bull;</span>
54
+ <p>{maskData(middleName)}</p>
55
+ <span>&bull;</span>
56
+ <p>{maskData(familyName)}</p>
57
+ </span>
58
+ )}
59
+ />
49
60
  <PatientInfo label={t('age', 'Age')} value={age(patient?.birthDate)} />
50
61
  <PatientInfo label={t('dateOfBirth', 'Date of birth')} value={formatDate(new Date(patient?.birthDate))} />
51
62
  <PatientInfo label={t('gender', 'Gender')} value={capitalize(patient?.gender)} />
@@ -1,5 +1,6 @@
1
1
  @use '@carbon/type';
2
- @use '@openmrs/esm-styleguide/src/vars' as *;
2
+ @use '@carbon/layout';
3
+ @use '@carbon/colors';
3
4
 
4
5
  .header {
5
6
  @include type.type-style('heading-03');
@@ -8,3 +9,13 @@
8
9
  .body {
9
10
  @include type.type-style('body-01');
10
11
  }
12
+
13
+ .patientNameValue {
14
+ display: flex;
15
+ gap: layout.$spacing-03;
16
+ align-items: center;
17
+
18
+ & > span {
19
+ color: colors.$gray-40;
20
+ }
21
+ }