Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include full dataset of Bio data : email,addresses, #39

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion __mocks__/inpatient-request.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { mockPatientAlice } from './patient.mock';
import { mockLocationInpatientWard } from './locations.mock';
import { type InpatientRequest } from '@openmrs/esm-ward-app/src/types';
import { type InpatientRequest } from '@kenyaemr/esm-ward-app/src/types';
import { mockPastVisit } from './visits.mock';
import { mockAddress } from './address.mock';

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openmrs/esm-patient-management",
"version": "7.1.0",
"version": "8.0.0",
"private": true,
"description": "Patient management microfrontend for the OpenMRS 3.x frontend",
"workspaces": [
Expand All @@ -11,7 +11,7 @@
"ci:publish": "yarn workspaces foreach --all --topological --exclude @openmrs/esm-patient-management npm publish --access public --tag latest",
"ci:prepublish": "yarn workspaces foreach --all --topological --exclude @openmrs/esm-patient-management npm publish --access public --tag next",
"release": "yarn workspaces foreach --all --topological version",
"verify": "turbo run lint typescript test --concurrency=1",
"verify": "turbo run lint typescript --concurrency=1",
"test-e2e": "playwright test",
"postinstall": "husky install"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/esm-active-visits-app/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@openmrs/esm-active-visits-app",
"version": "7.1.0",
"description": "Active visits widget microfrontend for O3",
"browser": "dist/openmrs-esm-active-visits-app.js",
"name": "@kenyaemr/esm-active-visits-app",
"version": "8.0.0",
"description": "Active visits widget microfrontend for the OpenMRS SPA",
"browser": "dist/kenyaemr-esm-active-visits-app.js",
"main": "src/index.ts",
"source": true,
"license": "MPL-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-active-visits-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { configSchema } from './config-schema';
import activeVisitsComponent from './active-visits-widget/active-visits.component';
import visitDetailComponent from './visits-summary/visit-detail.component';

const moduleName = '@openmrs/esm-active-visits-app';
const moduleName = '@kenyaemr/esm-active-visits-app';

const options = {
featureName: 'active-visits',
Expand Down
8 changes: 4 additions & 4 deletions packages/esm-appointments-app/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@openmrs/esm-appointments-app",
"version": "7.1.0",
"description": "Appointments front-end module for O3",
"browser": "dist/openmrs-esm-appointments-app.js",
"name": "@kenyaemr/esm-appointments-app",
"version": "8.0.0",
"description": "Appointments front-end module for the OpenMRS SPA",
"browser": "dist/kenyaemr-esm-appointments-app.js",
"main": "src/index.ts",
"source": true,
"license": "MPL-2.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import userEvent from '@testing-library/user-event';
import { render, screen } from '@testing-library/react';
import { getDefaultsFromConfigSchema, useConfig } from '@openmrs/esm-framework';
import { getDefaultsFromConfigSchema, useConfig, defineConfigSchema } from '@openmrs/esm-framework';
import { type ConfigObject, configSchema } from '../../config-schema';
import type { Appointment, AppointmentKind, AppointmentStatus } from '../../types';
import { downloadAppointmentsAsExcel } from '../../helpers/excel';
Expand All @@ -15,6 +15,7 @@ const defaultProps = {
tableHeading: 'scheduled',
visits: [],
};
defineConfigSchema('@kenyaemr/esm-appointments-app', configSchema);

const mockAppointments = [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-appointments-app/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const spaHomePage = ` ${window.getOpenmrsSpaBase()}home`;
export const omrsDateFormat = 'YYYY-MM-DDTHH:mm:ss.SSSZZ';
export const appointmentLocationTagName = 'Appointment Location';

export const moduleName = '@openmrs/esm-appointments-app';
export const moduleName = '@kenyaemr/esm-appointments-app';

export const datePickerPlaceHolder = 'dd/mm/yyyy';
export const dateFormat = 'DD/MM/YYYY';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,27 +289,22 @@ const AppointmentsForm: React.FC<AppointmentsFormProps> = ({
const appointmentPayload = constructAppointmentPayload(data);

// check if Duplicate Response Occurs
const response: FetchResponse = await checkAppointmentConflict(appointmentPayload);
let errorMessage = t('appointmentConflict', 'Appointment conflict');
if (response?.data?.hasOwnProperty('SERVICE_UNAVAILABLE')) {
errorMessage = t('serviceUnavailable', 'Appointment time is outside of service hours');
} else if (response?.data?.hasOwnProperty('PATIENT_DOUBLE_BOOKING')) {
if (context !== 'editing') {
errorMessage = t('patientDoubleBooking', 'Patient already booked for an appointment at this time');
} else {
errorMessage = null;
}
}

if (response.status === 200 && errorMessage) {
setIsSubmitting(false);
showSnackbar({
isLowContrast: true,
kind: 'error',
title: errorMessage,
});
return;
}
// const response: FetchResponse = await checkAppointmentConflict(appointmentPayload);
// let errorMessage = t('appointmentConflict', 'Appointment conflict');
// if (response?.data?.hasOwnProperty('SERVICE_UNAVAILABLE')) {
// errorMessage = t('serviceUnavailable', 'Appointment time is outside of service hours');
// } else if (response?.data?.hasOwnProperty('PATIENT_DOUBLE_BOOKING')) {
// errorMessage = t('patientDoubleBooking', 'Patient already booked for an appointment at this time');
// }
// if (response.status === 200) {
// setIsSubmitting(false);
// showSnackbar({
// isLowContrast: true,
// kind: 'error',
// title: errorMessage,
// });
// return;
// }

// Construct recurring pattern payload
const recurringAppointmentPayload = {
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-appointments-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import appointementsForm from './form/appointments-form.component';
import patientSearch from './patient-search/patient-search.component';
export const importTranslation = require.context('../translations', false, /.json$/, 'lazy');

const moduleName = '@openmrs/esm-appointments-app';
const moduleName = '@kenyaemr/esm-appointments-app';

const options = {
featureName: 'appointments',
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-bed-management-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openmrs/esm-bed-management-app",
"version": "7.0.0",
"version": "8.0.0",
"description": "Bed management app for OpenMRS 3",
"browser": "dist/openmrs-esm-bed-management-app.js",
"main": "src/index.ts",
Expand Down
6 changes: 3 additions & 3 deletions packages/esm-patient-list-management-app/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@openmrs/esm-patient-list-management-app",
"version": "7.1.0",
"name": "@kenyaemr/esm-patient-list-management-app",
"version": "8.0.0",
"description": "Microfrontend for managing patient lists in O3",
"browser": "dist/openmrs-esm-patient-list-management-app.js",
"browser": "dist/kenyaemr-esm-patient-list-management-app.js",
"main": "src/index.ts",
"source": true,
"license": "MPL-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-patient-list-management-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import rootComponent from './root.component';
import listDetailsTableComponent from './list-details-table/list-details-table.component';
import addPatientToPatientListMenuItemComponent from './add-patient-to-patient-list-menu-item.component';

const moduleName = '@openmrs/esm-patient-list-management-app';
const moduleName = '@kenyaemr/esm-patient-list-management-app';

const options = {
featureName: 'patient list',
Expand Down
8 changes: 4 additions & 4 deletions packages/esm-patient-registration-app/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@openmrs/esm-patient-registration-app",
"version": "7.1.0",
"description": "Patient registration microfrontend for O3",
"browser": "dist/openmrs-esm-patient-registration-app.js",
"name": "@kenyaemr/esm-patient-registration-app",
"version": "8.0.0",
"description": "Patient registration microfrontend for the OpenMRS SPA",
"browser": "dist/kenyaemr-esm-patient-registration-app.js",
"main": "src/index.ts",
"source": true,
"license": "MPL-2.0",
Expand Down
5 changes: 5 additions & 0 deletions packages/esm-patient-registration-app/src/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export interface FieldDefinition {
};
answerConceptSetUuid?: string;
customConceptAnswers?: Array<CustomConceptAnswer>;
showWhenExpression?: {
field: string;
value: string;
};
renderType?: string;
}

export interface CustomConceptAnswer {
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-patient-registration-app/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const personRelationshipRepresentation =
'personB:(age,display,birthdate,uuid),' +
'relationshipType:(uuid,display,description,aIsToB,bIsToA))';

export const moduleName = '@openmrs/esm-patient-registration-app';
export const moduleName = '@kenyaemr/esm-patient-registration-app';
export const patientRegistration = 'patient-registration';

export const cacheForOfflineHeaders: OmrsOfflineHttpHeaders = {
Expand Down
10 changes: 10 additions & 0 deletions packages/esm-patient-registration-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,13 @@ export const deleteIdentifierConfirmationModal = getAsyncLifecycle(
() => import('./widgets/delete-identifier-confirmation.modal'),
options,
);

export const confirmClientRegistryModal = getAsyncLifecycle(
() => import('./patient-verification/verification-modal/confirm-prompt.component'),
options,
);

export const emptyClientRegistryModal = getAsyncLifecycle(
() => import('./patient-verification/verification-modal/empty-prompt.component'),
options,
);
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,7 @@ async function fetchPatientIdentifierTypes(): Promise<Array<FetchedPatientIdenti

const primaryIdentifierTypeUuid = primaryIdentifierTypeResponse?.data?.results?.[0]?.metadataUuid;

let identifierTypes = primaryIdentifierTypeResponse?.ok
? [
mapPatientIdentifierType(
patientIdentifierTypes?.find((type) => type.uuid === primaryIdentifierTypeUuid),
true,
),
]
: [];
let identifierTypes = [];

patientIdentifierTypes.forEach((type) => {
if (type.uuid !== primaryIdentifierTypeUuid) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { type RegistrationConfig } from '../../config-schema';
import { AddressField } from './address/custom-address-field.component';
import { ObsField } from './obs/obs-field.component';
import { PersonAttributeField } from './person-attributes/person-attribute-field.component';
import { useField } from 'formik';

export interface CustomFieldProps {
name: string;
Expand All @@ -13,6 +14,11 @@ export function CustomField({ name }: CustomFieldProps) {
const config = useConfig() as RegistrationConfig;
const fieldDefinition = config.fieldDefinitions.filter((def) => def.id == name)[0];

const [{ value }] = useField(`attributes.${fieldDefinition.showWhenExpression?.field}`);
if (fieldDefinition.showWhenExpression && value !== fieldDefinition.showWhenExpression.value) {
return null;
}

if (fieldDefinition.type === 'person attribute') {
return <PersonAttributeField fieldDefinition={fieldDefinition} />;
} else if (fieldDefinition.type === 'obs') {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React from 'react';
import { Field } from 'formik';
import { Layer, Select, SelectItem } from '@carbon/react';
import { type PersonAttributeTypeResponse } from '../../patient-registration.types';
import { useTranslation } from 'react-i18next';
import styles from './../field.scss';
import classNames from 'classnames';

type CustomPersonAttributeFieldProps = {
id: string;
personAttributeType: PersonAttributeTypeResponse;
answerConceptSetUuid: string;
label?: string;
customConceptAnswers: Array<{ uuid: string; label?: string }>;
required: boolean;
};

const CustomPersonAttributeField: React.FC<CustomPersonAttributeFieldProps> = ({
personAttributeType,
required,
id,
label,
customConceptAnswers,
}) => {
const { t } = useTranslation();
const fieldName = `attributes.${personAttributeType.uuid}`;

return (
<div className={classNames(styles.customField, styles.halfWidthInDesktopView)}>
<Layer>
<Field name={fieldName}>
{({ field, form: { touched, errors }, meta }) => {
return (
<>
<Select
id={id}
name={`person-attribute-${personAttributeType.uuid}`}
labelText={label ?? personAttributeType?.display}
invalid={errors[fieldName] && touched[fieldName]}
required={required}
{...field}>
<SelectItem value={''} text={t('selectAnOption', 'Select an option')} />
{customConceptAnswers.map((answer) => (
<SelectItem key={answer.uuid} value={answer.uuid} text={answer.uuid} />
))}
</Select>
</>
);
}}
</Field>
</Layer>
</div>
);
};

export default CustomPersonAttributeField;
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { usePersonAttributeType } from './person-attributes.resource';
import { TextPersonAttributeField } from './text-person-attribute-field.component';
import { useTranslation } from 'react-i18next';
import styles from '../field.scss';
import CustomPersonAttributeField from './custom-person-attribute-field.component';

export interface PersonAttributeFieldProps {
fieldDefinition: FieldDefinition;
Expand All @@ -22,13 +23,26 @@ export function PersonAttributeField({ fieldDefinition }: PersonAttributeFieldPr
switch (personAttributeType.format) {
case 'java.lang.String':
return (
<TextPersonAttributeField
personAttributeType={personAttributeType}
validationRegex={fieldDefinition.validation?.matches ?? ''}
label={fieldDefinition.label}
required={fieldDefinition.validation?.required ?? false}
id={fieldDefinition?.id}
/>
<>
{fieldDefinition.renderType === 'select' ? (
<CustomPersonAttributeField
personAttributeType={personAttributeType}
answerConceptSetUuid={fieldDefinition.answerConceptSetUuid}
label={fieldDefinition.label}
id={fieldDefinition?.id}
customConceptAnswers={fieldDefinition.customConceptAnswers ?? []}
required={fieldDefinition.validation?.required ?? false}
/>
) : (
<TextPersonAttributeField
personAttributeType={personAttributeType}
validationRegex={fieldDefinition.validation?.matches ?? ''}
label={fieldDefinition.label}
required={fieldDefinition.validation?.required ?? false}
id={fieldDefinition?.id}
/>
)}
</>
);
case 'org.openmrs.Concept':
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ export class FormManager {
);
} else {
const encounterToSave: Encounter = {
encounterDatetime: new Date(),
patient: savePatientResponse.data.uuid,
encounterType: config.registrationObs.encounterTypeUuid,
location: currentLocation,
Expand Down
Loading