Skip to content

Commit cd45ee9

Browse files
BN-173|Fix.State For PatientUUID and Rename NewVisitData to VisitData to Models
1 parent 0e9f342 commit cd45ee9

File tree

5 files changed

+8
-19
lines changed

5 files changed

+8
-19
lines changed

apps/registration/src/pages/createPatientPage/visitTypeSelector.tsx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
dispatchAuditEvent,
1111
AUDIT_LOG_EVENT_DETAILS,
1212
getRegistrationConfig,
13-
type NewVisitData,
13+
type VisitData,
1414
type AuditEventType,
1515
} from '@bahmni-frontend/bahmni-services';
1616
import { useQuery } from '@tanstack/react-query';
@@ -27,14 +27,8 @@ export const VisitTypeSelector = ({
2727
patientUuid,
2828
}: VisitTypeSelectorProps) => {
2929
const { t } = useTranslation();
30-
const [visitPayload, setVisitPayload] = useState<NewVisitData>();
31-
const [patientUUID, setPatientUUID] = useState<string | null>(null);
30+
const [visitPayload, setVisitPayload] = useState<VisitData>();
3231

33-
useEffect(() => {
34-
if (patientUuid && !patientUUID) {
35-
setPatientUUID(patientUuid);
36-
}
37-
}, [patientUuid, patientUUID]);
3832
const {
3933
data: visitTypes,
4034
isLoading: isLoadingVisitTypes,
@@ -129,12 +123,7 @@ export const VisitTypeSelector = ({
129123
) => {
130124
if (!selectedItem) return;
131125

132-
let currentPatientUUID = patientUUID;
133-
134-
if (!currentPatientUUID) {
135-
currentPatientUUID = await onVisitSave();
136-
setPatientUUID(currentPatientUUID);
137-
}
126+
const currentPatientUUID = patientUuid ?? (await onVisitSave());
138127

139128
if (currentPatientUUID && visitLocationUUID) {
140129
setVisitPayload({

packages/bahmni-services/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export {
2222
type IdentifierTypesResponse,
2323
type CreatePatientRequest,
2424
type CreatePatientResponse,
25-
type NewVisitData,
25+
type VisitData,
2626
type PatientName,
2727
type PatientAddress,
2828
type PatientIdentifier,

packages/bahmni-services/src/patientService/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export {
2222
type IdentifierTypesResponse,
2323
type CreatePatientRequest,
2424
type CreatePatientResponse,
25-
type NewVisitData,
25+
type VisitData,
2626
type PatientName,
2727
type PatientAddress,
2828
type PatientIdentifier,

packages/bahmni-services/src/patientService/models.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export interface VisitType {
148148
visitTypes: Record<string, string>;
149149
}
150150

151-
export interface NewVisitData {
151+
export interface VisitData {
152152
patient: string;
153153
visitType: string;
154154
location: string;

packages/bahmni-services/src/patientService/patientService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import {
3030
CreatePatientResponse,
3131
AddressHierarchyEntry,
3232
VisitType,
33-
NewVisitData,
33+
VisitData,
3434
VisitLocationResponse,
3535
ActiveVisit,
3636
} from './models';
@@ -359,7 +359,7 @@ export const getVisitTypes = async (): Promise<VisitType> => {
359359
* @param visitData - The visit data including patient UUID, visit type, and location
360360
* @returns Promise<unknown> - The created visit object
361361
*/
362-
export const createVisit = async (visitData: NewVisitData): Promise<string> => {
362+
export const createVisit = async (visitData: VisitData): Promise<string> => {
363363
return post<string>(CREATE_VISIT_URL, visitData);
364364
};
365365

0 commit comments

Comments
 (0)