Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Remove related person #1768

Closed
jackcmeyer opened this issue Jan 20, 2020 · 3 comments · Fixed by #1968
Closed

Remove related person #1768

jackcmeyer opened this issue Jan 20, 2020 · 3 comments · Fixed by #1968
Assignees
Labels
in progress indicates that issue/pull request is currently being worked on patients issue/pull request that interacts with patients module v2.x
Milestone

Comments

@jackcmeyer
Copy link
Member

Scenario

AS

A user who has write access to a patient

I WANT

To be able to remove a related person

SO THAT

My data can be free of any unnecessary entries

Acceptance Criteria

GIVEN

A user with write access to patients

AND

An existing patient with related persons

WHEN

I go to the related persons screen

THEN

I should see a delete button next to each related person

AND

when I click on it the related person should be removed

Related Issues

HospitalRun/hospitalrun-frontend#1689

Technical Notes

@jackcmeyer jackcmeyer transferred this issue from HospitalRun/hospitalrun-frontend Jan 26, 2020
@matteovivona matteovivona transferred this issue from HospitalRun/hospitalrun Jan 29, 2020
@matteovivona matteovivona added good first issue indicates an issue is good for a first time contributor v2.x patients issue/pull request that interacts with patients module labels Jan 29, 2020
@jackcmeyer jackcmeyer added help wanted indicates that an issue is open for contributions and removed good first issue indicates an issue is good for a first time contributor labels Jan 30, 2020
@ocBruno
Copy link
Contributor

ocBruno commented Feb 7, 2020

I was going to give this a shot for pratice.Does anyone have any guidelines on the best design pattern approach?
I see we are storing related persons in an array and considering redux state is immutable should we create something like this code example with a new relatedPersons and just not insert the related person with a certain id?

I'm trying to leave good first issues to attract new contributors but i'm not confident in my patterns enough so I will leave some code snippets and ideas here if anyone has anything to complement or spot any bad design patterns or mistakes please give me a heads up!


  const onRelatedPersonSave = (relatedPerson: RelatedPerson) => {
    const newRelatedPersons: RelatedPerson[] = []

    if (patient.relatedPersons) {
      newRelatedPersons.push(...patient.relatedPersons)
    }

    newRelatedPersons.push(relatedPerson)

    const patientToUpdate = {
      ...patient,
      relatedPersons: newRelatedPersons,
    }

    dispatch(updatePatient(patientToUpdate))
    closeNewRelatedPersonModal()
  }

  const onRelatedPersonDelete = (relatedPersonId: string) => {
    const updatedRelatedPersons: RelatedPerson[] = []

    if (patient.relatedPersons) {
      patient.relatedPersons.forEach((relatedPerson) => {
        relatedPerson.id !== relatedPersonId ? updatedRelatedPersons.push(relatedPerson) : console.log('aes')
      })
    }

    const patientToUpdate = {
      ...patient,
      relatedPersons: updatedRelatedPersons,
    }

    dispatch(updatePatient(patientToUpdate))

  }

If someone knows of a good project with some nice design patterns we can use as reference I can analise it and try to apply some of the patterns to hospitalrun!

@aprameyakatti
Copy link

hi, I wanna contribute to this issue can I know how would I start contributing for this issue?

@jackcmeyer
Copy link
Member Author

Hi @aprameyakatti. I've actually been working on this issue. I apologize for not assigning into myself to make it clear.

@jackcmeyer jackcmeyer self-assigned this Feb 18, 2020
@jackcmeyer jackcmeyer added in progress indicates that issue/pull request is currently being worked on and removed help wanted indicates that an issue is open for contributions labels Feb 18, 2020
@matteovivona matteovivona added this to the v2.0.0 milestone Feb 20, 2020
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
in progress indicates that issue/pull request is currently being worked on patients issue/pull request that interacts with patients module v2.x
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants