Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
kajambiya committed Apr 25, 2024
1 parent 49ebef7 commit b9cd626
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
23 changes: 22 additions & 1 deletion src/components/encounter/encounter-form.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ export const EncounterForm: React.FC<EncounterFormProps> = ({
};
}

let formPatientIdentifiers = '';
const patientIdentifierFields = fields.filter((field) => field.type === 'patientIdentifier');
const patientIdentifierPromises = patientIdentifierFields.map((field) => {
const identfier: PatientIdentifier = {
Expand All @@ -572,8 +573,28 @@ export const EncounterForm: React.FC<EncounterFormProps> = ({
});

return Promise.all(patientIdentifierPromises)
.then(() => saveEncounterWithAttachments(encounterForSubmission))
.then(() => {
for (let i = 0; i < patientIdentifierFields.length; i++) {
formPatientIdentifiers += patientIdentifierFields[i].value;
if (i < patientIdentifierFields.length - 1) {
formPatientIdentifiers += ', ';
}
}
if (patientIdentifierFields.length) {
showSnackbar({
title: t('identifierCreated', 'Identifier Created'),
subtitle: t(
'identifierCreatedDescription',
`Patient Identifier(s) ${formPatientIdentifiers} successfully created!`,
),
kind: 'success',
isLowContrast: true,
});
}
saveEncounterWithAttachments(encounterForSubmission);
})
.catch((error) => {
setIsSubmitting(false);
showSnackbar({
title: t('errorDescriptionTitle', 'Error on saving form'),
subtitle: t('errorDescription', error.message),
Expand Down
14 changes: 6 additions & 8 deletions src/submission-handlers/patientIdentifierHandler.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import { SubmissionHandler } from '..';
import { OpenmrsEncounter, OHRIFormField } from '../api/types';
import { EncounterContext } from '../ohri-form-context';
import { EncounterContext, FormField, OpenmrsEncounter, SubmissionHandler } from '..';
import { getPatientLatestIdentifier } from '../utils/patient-identifier-helper';

export const PatientIdentifierHandler: SubmissionHandler = {
handleFieldSubmission: (field: OHRIFormField, value: any, context: EncounterContext) => {
handleFieldSubmission: (field: FormField, value: any, context: EncounterContext) => {
return value;
},
getInitialValue: (
encounter: OpenmrsEncounter,
field: OHRIFormField,
allFormFields: Array<OHRIFormField>,
field: FormField,
allFormFields: Array<FormField>,
context: EncounterContext,
) => {
const patientIdentifier = getPatientLatestIdentifier(context.patient, field.questionOptions.identifierType);
return patientIdentifier?.value;
},

getDisplayValue: (field: OHRIFormField, value: any) => {
getDisplayValue: (field: FormField, value: any) => {
return value;
},
getPreviousValue: (field: OHRIFormField, encounter: OpenmrsEncounter, allFormFields: Array<OHRIFormField>) => {
getPreviousValue: (field: FormField, encounter: OpenmrsEncounter, allFormFields: Array<FormField>) => {
return null;
},

Expand Down
2 changes: 1 addition & 1 deletion src/utils/patient-identifier-helper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PatientIdentifier } from "../api/types";
import { savePatientIdentifier} from "../api/api";
import { PatientIdentifier } from "../types";

export const saveIdentifier = (patient: fhir.Patient, patientIdentifier:PatientIdentifier) =>{
const identifier = getPatientLatestIdentifier(patient, patientIdentifier.identifierType);
Expand Down

0 comments on commit b9cd626

Please sign in to comment.