Skip to content

Commit

Permalink
Merge pull request #6339 from msupply-foundation/6306-add-next-of-kin…
Browse files Browse the repository at this point in the history
…-to-patient-edit

6306 add next of kin to patient edit
  • Loading branch information
lache-melvin authored Jan 30, 2025
2 parents cae05f6 + 10e4d3c commit 94029a7
Show file tree
Hide file tree
Showing 15 changed files with 148 additions and 21 deletions.
45 changes: 45 additions & 0 deletions client/packages/common/src/types/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,26 @@ export type CentralPatientSearchInput = {

export type CentralPatientSearchResponse = CentralPatientSearchConnector | CentralPatientSearchError;

export type CentralPluginMutations = {
__typename: 'CentralPluginMutations';
installUploadedPlugin: PluginInfoNode;
};


export type CentralPluginMutationsInstallUploadedPluginArgs = {
fileId: Scalars['String']['input'];
};

export type CentralPluginQueries = {
__typename: 'CentralPluginQueries';
uploadedPluginInfo: UploadedPluginInfoResponse;
};


export type CentralPluginQueriesUploadedPluginInfoArgs = {
fileId: Scalars['String']['input'];
};

export type CentralServerMutationNode = {
__typename: 'CentralServerMutationNode';
assetCatalogue: AssetCatalogueMutations;
Expand All @@ -936,9 +956,15 @@ export type CentralServerMutationNode = {
general: CentralGeneralMutations;
itemVariant: ItemVariantMutations;
logReason: AssetLogReasonMutations;
plugins: CentralPluginMutations;
vaccineCourse: VaccineCourseMutations;
};

export type CentralServerQueryNode = {
__typename: 'CentralServerQueryNode';
plugin: CentralPluginQueries;
};

export type CentralSyncRequired = AuthTokenErrorInterface & {
__typename: 'CentralSyncRequired';
description: Scalars['String']['output'];
Expand Down Expand Up @@ -2885,6 +2911,7 @@ export type InsertPatientInput = {
id: Scalars['String']['input'];
isDeceased?: InputMaybe<Scalars['Boolean']['input']>;
lastName?: InputMaybe<Scalars['String']['input']>;
nextOfKinId?: InputMaybe<Scalars['String']['input']>;
phone?: InputMaybe<Scalars['String']['input']>;
};

Expand Down Expand Up @@ -5360,6 +5387,11 @@ export type PluginDataSortInput = {
key: PluginDataSortFieldInput;
};

export type PluginInfoNode = {
__typename: 'PluginInfoNode';
backendPluginCodes: Array<Scalars['String']['output']>;
};

export type PluginNode = {
__typename: 'PluginNode';
config: Scalars['String']['output'];
Expand Down Expand Up @@ -5677,6 +5709,7 @@ export type Queries = {
authToken: AuthTokenResponse;
barcodeByGtin: BarcodeResponse;
centralPatientSearch: CentralPatientSearchResponse;
centralServer: CentralServerQueryNode;
clinicians: CliniciansResponse;
/** Query omSupply "cold_storage_type" entries */
coldStorageTypes: ColdStorageTypesResponse;
Expand Down Expand Up @@ -8328,6 +8361,7 @@ export type UpdatePatientInput = {
id: Scalars['String']['input'];
isDeceased?: InputMaybe<Scalars['Boolean']['input']>;
lastName?: InputMaybe<Scalars['String']['input']>;
nextOfKinId?: InputMaybe<Scalars['String']['input']>;
phone?: InputMaybe<Scalars['String']['input']>;
};

Expand Down Expand Up @@ -8784,6 +8818,17 @@ export type UpdateVaccineCourseInput = {

export type UpdateVaccineCourseResponse = UpdateVaccineCourseError | VaccineCourseNode;

export type UploadedPluginError = {
__typename: 'UploadedPluginError';
error: UploadedPluginErrorVariant;
};

export enum UploadedPluginErrorVariant {
CannotParseFile = 'CANNOT_PARSE_FILE'
}

export type UploadedPluginInfoResponse = PluginInfoNode | UploadedPluginError;

export type UpsertBundledItemError = {
__typename: 'UpsertBundledItemError';
error: UpsertBundledItemErrorInterface;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React, { useEffect } from 'react';
import { rankWith, ControlProps, uiTypeIs } from '@jsonforms/core';
import { withJsonFormsControlProps } from '@jsonforms/react';
import { Box, DetailInputWithLabelRow } from '@openmsupply-client/common';
import { DefaultFormRowSx, FORM_GAP, FORM_LABEL_WIDTH } from '../common';
import {
PatientSearchInput,
SearchInputPatient,
usePatient,
} from '@openmsupply-client/system';

export const patientSearchTester = rankWith(10, uiTypeIs('PatientSearch'));

const UIComponent = (props: ControlProps) => {
const { data, handleChange, label, path } = props;

const [patient, setPatient] = React.useState<SearchInputPatient | null>(null);

const onChangePatient = async (patient: SearchInputPatient) => {
setPatient(patient);
handleChange(path, patient.id);
};

const { data: patientData } = usePatient.document.get(data);

useEffect(() => {
if (!patientData) return;
setPatient(patientData);
}, [patientData]);

return (
<DetailInputWithLabelRow
sx={DefaultFormRowSx}
label={label}
labelWidthPercentage={FORM_LABEL_WIDTH}
inputAlignment={'start'}
Input={
<Box display="flex" alignItems="center" gap={FORM_GAP} width="100%">
<PatientSearchInput value={patient} onChange={onChangePatient} />
</Box>
}
/>
);
};

const UIComponentWrapper = (props: ControlProps) => {
if (!props.visible) {
return null;
}
return <UIComponent {...props} />;
};

export const PatientSearch = withJsonFormsControlProps(UIComponentWrapper);
1 change: 1 addition & 0 deletions client/packages/programs/src/JsonForms/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export * from './Search/Search';
export * from './ProgramEvent';
export * from './HistoricEncounterData';
export * from './BloodPressure';
export * from './PatientSearch';
export * from './Prescription/Prescription';
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import {
BloodPressure,
Prescription,
prescriptionTester,
patientSearchTester,
PatientSearch,
} from './components';
import { EnrolmentId, enrolmentIdTester } from './components/EnrolmentId';
import {
Expand Down Expand Up @@ -83,6 +85,7 @@ const additionalRenderers: JsonFormsRendererRegistryEntry[] = [
{ tester: enrolmentIdTester, renderer: EnrolmentId },
{ tester: bloodPressureTester, renderer: BloodPressure },
{ tester: prescriptionTester, renderer: Prescription },
{ tester: patientSearchTester, renderer: PatientSearch },
];

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
"phone": {
"description": "Phone number",
"type": "string"
},
"nextOfKinId": {
"description": "ID of the mSupply name record for the patient's next of kin",
"type": "string"
}
},
"required": ["id", "code", "firstName", "lastName"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
"type": "Control",
"scope": "#/properties/phone",
"label": "Phone"
},
{
"type": "PatientSearch",
"scope": "#/properties/nextOfKinId",
"label": "Next of Kin"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ const PatientDetailView = ({
isDeceased: currentPatient.isDeceased ?? undefined,
phone: currentPatient.phone ?? undefined,
address1: currentPatient.address1 ?? undefined,
nextOfKinId: currentPatient.nextOfKinId ?? undefined,
},
isCreating: false,
};
Expand Down
Loading

0 comments on commit 94029a7

Please sign in to comment.