Skip to content

Conversation

@apoorvapendse
Copy link

Addresses: medic/cht-core#10221.

Description

WIP documentation updates to add POST /api/v1/person and PUT /api/v1/person endpoints
[description]

POST /api/v1/person
image
image
image

PUT /api/v1/person
image
image
image

License

The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.

@apoorvapendse apoorvapendse marked this pull request as draft August 18, 2025 12:38
@apoorvapendse apoorvapendse force-pushed the create-update-person-docs branch from de913a3 to 77fca3c Compare August 18, 2025 12:39
@sugat009 sugat009 self-requested a review August 19, 2025 06:33
@sugat009 sugat009 added the Type: Feature Add something new label Aug 19, 2025
@sugat009 sugat009 marked this pull request as ready for review August 19, 2025 06:34
Copy link
Member

@sugat009 sugat009 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Can you add all the endpoints in this PR?

```

### POST /api/v1/person

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: add a "added in X.X.X" version note for all the endpoints

```

### POST /api/v1/person

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: add the description of the endpoint

Comment on lines 1269 to 1271
Either of the two:
1. `can_edit`
2. `can_view_contacts` and `can_create_people`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Either of the two:
1. `can_edit`
2. `can_view_contacts` and `can_create_people`
Should have `can_edit` or both `can_view_contacts` and `can_create_people`

The wording seemed a bit confusing to me.

Comment on lines 1274 to 1288
| Key | Description |
| ---- | ----------------------------------- |
| name | String used to describe the person. |
| type | ID of the `contact_type` for the new person. Pass in `person` for older versions. |
| parent | ID of the parent document, which is a place, for the new person. The type of the parent must belong to one of the allowed `parents` for the `contact_type` id in the settings config. |

#### Optional

| Key | Description |
| ------------- | ---------------------------------------------------------------------- |
| reported_date | Timestamp of when the record was reported or created. Defaults to now. |
| _id | ID of the new person document to be created. |
| short_name | String to denote short name of the person. |
| phone | Phone number of the person in string format. |
| role | Role of the person in string format. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: let's use fields instead of key here

#### Required
| Key | Description |
| ---- | ----------------------------------- |
| name | String used to describe the person. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| name | String used to describe the person. |
| name | Name of the person. |

| Key | Description |
| ------------- | ---------------------------------------------------------------------- |
| reported_date | Timestamp of when the record was reported or created. Defaults to now. |
| _id | ID of the new person document to be created. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| _id | ID of the new person document to be created. |
| _id | ID of the new person document to be created in UUID format. |

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: how about adding another column that contains the type of the field instead of doing a "... string format" in the description?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm makes sense.

"contact_type": "person"
}
```
### PUT /api/v1/person
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### PUT /api/v1/person
### PUT /api/v1/person

| reported_date | Timestamp of when the record was reported or created. |
| contact_type| Required if the type of the person is `contact`. |
| type | The type of the person. |
| parent | The parent lineage of the person to be updated, can be hydrated or dehydrated. |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: parent cannot be updated

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be helpful to document why parent cannot be updated

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant "person to be updated"'s parent

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohhh, my bad. I misread this.

@apoorvapendse apoorvapendse force-pushed the create-update-person-docs branch from 77fca3c to 01752bd Compare August 19, 2025 13:51
Signed-off-by: Apoorva Pendse <[email protected]>
@apoorvapendse apoorvapendse force-pushed the create-update-person-docs branch 2 times, most recently from 3bdce51 to f5429a0 Compare August 19, 2025 14:56
Signed-off-by: apoorvapendse <[email protected]>
@apoorvapendse apoorvapendse force-pushed the create-update-person-docs branch from f5429a0 to ab7235b Compare August 19, 2025 14:56
@sugat009 sugat009 self-requested a review August 25, 2025 04:19

### POST /api/v1/person

*Added in x.x.x*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: not literally x.x.x. It indicates the CHT version in which the API was released.

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now you can add the version as 5.0.0. If something changes, it can be changed.

Comment on lines 1338 to 1341
#### Permissions
Either of the two:
1. `can_edit`
2. `can_view_contacts` and `can_update_people`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: make the same changes as above in this section as well

| parent | The parent lineage of the place to be updated. Not required if the place is at the top of the hierarchy. | Minified or hydrated parent lineage |
| contact | The contact lineage linked with the place. This can be inserted as a part of update if not already present. | Minified or hydrated lineage |

### Required mutable fields
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Required mutable fields
#### Required mutable fields

Comment on lines 1276 to 1280
| Field | Description | Format |
| ---- | ----------------------------------- | -------- |
| name | Name of the person. | string |
| type | ID of the `contact_type` for the new person. Pass in `person` for older versions. | string |
| parent | ID of the parent document, which is a place, for the new person. The type of the parent must belong to one of the allowed `parents` for the `contact_type` id in the settings config. | UUID string |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: if there is an option to format these tables in your editor, then please do so. For reference check the GET API's table.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

apoorvapendse and others added 2 commits August 25, 2025 11:59
@apoorvapendse apoorvapendse requested a review from sugat009 August 25, 2025 06:53
Copy link
Member

@sugat009 sugat009 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
I'll merge this once the release version for medic/cht-core#9835 is finalized.

@sugat009 sugat009 changed the title feat(#10221): add documentation to create/update a person feat(#10221): add documentation to create and update person, place and report Aug 28, 2025
@andrablaj andrablaj removed the Type: Feature Add something new label Sep 23, 2025
@apoorvapendse
Copy link
Author

Updates: (similar for person and report endpoints)
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants