-
Notifications
You must be signed in to change notification settings - Fork 248
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
(feat) O3-3365: Add the ability to record non-coded cause-of-death #1876
Conversation
Hey @ibacher and @denniskigen, I kindly request for your guidance please! I'm a bit stuck on how to properly utilize |
const OTHER_CONCEPT_UUID = 'UUID of other'; | ||
const OTHER_CONCEPT_DISPLAY = t('other', 'Other'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const OTHER_CONCEPT_UUID = 'UUID of other'; | |
const OTHER_CONCEPT_DISPLAY = t('other', 'Other'); | |
```suggestion | |
const freetextCauseOfDeathUuid = 5622AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'; |
@@ -34,25 +35,34 @@ const MarkPatientDeceasedForm: React.FC<DefaultPatientWorkspaceProps> = ({ close | |||
const { deathDate, isDead } = usePatientDeceasedStatus(patientUuid); | |||
const [isSubmitting, setIsSubmitting] = useState(false); | |||
const [searchTerm, setSearchTerm] = useState(''); | |||
const [showOtherInputField, setShowOtherInputField] = useState(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const [showOtherInputField, setShowOtherInputField] = useState(false); |
const filteredCausesOfDeath = useMemo(() => { | ||
if (!searchTerm) { | ||
return causesOfDeath; | ||
if (!causesOfDeath) return []; | ||
|
||
let filtered = causesOfDeath.filter((concept) => concept.uuid !== OTHER_CONCEPT_UUID); | ||
|
||
if (searchTerm) { | ||
filtered = fuzzy | ||
.filter(searchTerm, filtered, { | ||
extract: (causeOfDeathConcept) => causeOfDeathConcept.display, | ||
}) | ||
.sort((r1, r2) => r1.score - r2.score) | ||
.map((result) => result.original); | ||
} | ||
|
||
return searchTerm | ||
? fuzzy | ||
.filter(searchTerm, causesOfDeath, { | ||
extract: (causeOfDeathConcept) => causeOfDeathConcept.display, | ||
}) | ||
.sort((r1, r2) => r1.score - r2.score) | ||
.map((result) => result.original) | ||
: causesOfDeath; | ||
}, [searchTerm, causesOfDeath]); | ||
filtered.push({ uuid: OTHER_CONCEPT_UUID, display: OTHER_CONCEPT_DISPLAY, name: OTHER_CONCEPT_DISPLAY }); | ||
|
||
return filtered; | ||
}, [searchTerm, causesOfDeath, OTHER_CONCEPT_DISPLAY]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need any of these changes.
useEffect(() => { | ||
setShowOtherInputField(causeOfDeathValue === OTHER_CONCEPT_UUID); | ||
}, [causeOfDeathValue]); | ||
|
||
useEffect(() => { | ||
if (causesOfDeath && causesOfDeath.length > 0) { | ||
setShowOtherInputField(causeOfDeathValue === OTHER_CONCEPT_UUID); | ||
} | ||
}, [causesOfDeath, causeOfDeathValue]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this.
const causeOfDeathToSubmit = causeOfDeath === OTHER_CONCEPT_UUID ? freeTextCauseOfDeath : causeOfDeath; | ||
|
||
markPatientDeceased(deathDate, patientUuid, causeOfDeathToSubmit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const causeOfDeathToSubmit = causeOfDeath === OTHER_CONCEPT_UUID ? freeTextCauseOfDeath : causeOfDeath; | |
markPatientDeceased(deathDate, patientUuid, causeOfDeathToSubmit) | |
markPatientDeceased(deathDate, patientUuid, causeOfDeath === freetextCauseOfDeathUuid ? freeTextCauseOfDeath : causeOfDeath) |
{filteredCausesOfDeath.map(({ uuid, display, name }) => ( | ||
<RadioButton | ||
key={uuid} | ||
className={styles.radioButton} | ||
id={name} | ||
labelText={display} | ||
value={uuid} | ||
/> | ||
))} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can undo this change as well
)} | ||
/> | ||
</div> | ||
)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this below the <section>
tag.
@@ -216,6 +240,24 @@ const MarkPatientDeceasedForm: React.FC<DefaultPatientWorkspaceProps> = ({ close | |||
) : null} | |||
</div> | |||
{errors?.causeOfDeath && <p className={styles.errorMessage}>{errors?.causeOfDeath?.message}</p>} | |||
{showOtherInputField && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{showOtherInputField && ( | |
{causeOfDeathValue === freetextCauseOfDeathUuid && ( |
@denniskigen Thanks |
@ibacher what property should be used to record the freetext value to the backend? https://rest.openmrs.org/#create-a-person |
|
@denniskigen this is funny. We walking on the same issue at ago. Thanks am looking at some of the changes you have pushed and I can consent I wasn't thinking in that direction and I will be glad learning something from the coffee break session. |
@denniskigen I was concentrating on validating this form since it can be submitted successfully with or without a date. Should I continue with the task or terminate it the task? |
06fdc0e
to
1e189d8
Compare
c1f44c2
to
1e189d8
Compare
@denniskigen am so sorry for the late response I had issues with internet. Kindly I have tested and attached the current snapshot everything seems to be working as expected. |
1e189d8
to
838ef1f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -34,12 +35,12 @@ const MarkPatientDeceasedForm: React.FC<DefaultPatientWorkspaceProps> = ({ close | |||
const { deathDate, isDead } = usePatientDeceasedStatus(patientUuid); | |||
const [isSubmitting, setIsSubmitting] = useState(false); | |||
const [searchTerm, setSearchTerm] = useState(''); | |||
const freetextCauseOfDeathUuid = '5622AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ibacher should this value be configurable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Just about anywhere we use a concept, the concept should be configurable. Technically, the platform only enforces that there is a True / False concept.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me work that in. Thanks
Requirements
Summary
I included a feature to allow users to enter a free-text cause of death. If someone selects 'Other', the text input field will be available for entering this free-text concept
Screenshots
screencast.2024-06-25.11.PM-55-08.mp4
Related Issue
https://openmrs.atlassian.net/browse/O3-3365
Other