Skip to content
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

Support for Reproductive Health #102

Open
Johan-dutoit opened this issue May 17, 2021 · 12 comments · May be fixed by #103
Open

Support for Reproductive Health #102

Johan-dutoit opened this issue May 17, 2021 · 12 comments · May be fixed by #103
Assignees
Labels
enhancement New feature or request

Comments

@Johan-dutoit
Copy link

It seems Reproductive Health has completely been missed

I'm specifically interested in HKCategoryTypeIdentifierMenstrualFlow but the others missing are

  • HKQuantityTypeIdentifierBasalBodyTemperature
    A quantity sample type that records the user’s basal body temperature.
  • HKCategoryTypeIdentifierCervicalMucusQuality
    A category sample type that records the quality of the user’s cervical mucus.
  • HKCategoryTypeIdentifierContraceptive
    A category sample type that records the use of contraceptives.
  • HKCategoryTypeIdentifierIntermenstrualBleeding
    A category sample type that records spotting outside the normal menstruation period.
  • HKCategoryTypeIdentifierLactation
    A category type that records lactation.
  • HKCategoryTypeIdentifierOvulationTestResult
    A category sample type that records the result of an ovulation home test.
  • HKCategoryTypeIdentifierPregnancy
    A category type that records pregnancy.
  • HKCategoryTypeIdentifierSexualActivity
    A category sample type that records sexual activity.

I don't have much experience with Health Kit, but if someone can guide me on one, I can use that as a template for the rest.

@Johan-dutoit Johan-dutoit added the enhancement New feature or request label May 17, 2021
@fakeheal fakeheal linked a pull request May 17, 2021 that will close this issue
1 task
@fakeheal
Copy link
Contributor

Hello,

I started adding these data types to the package, however I cannot find any information as of why Apple allows only writing to Health for those data types.

What is your use case? Have you came across information as to why you can't read these data types from Health?

@Johan-dutoit
Copy link
Author

Hey @fakeheal, I completely skipped checking PR's to see if someone has implemented this yet (my apologies).

My use case, is that I'm working on a fitness app that takes a users cycle into consideration. My guess was I had to query HKCategoryTypeIdentifierMenstrualFlow.

Based on https://github.com/skooal/HealthKitUsageDemo, it seems that it is readable?

@Johan-dutoit
Copy link
Author

If it helps, here's the code

https://github.com/skooal/HealthKitUsageDemo/blob/91d77101d508774b9220a6b3f1fb51d5c5429105/skoal/skoal.m#L824-L841

@fakeheal
Copy link
Contributor

fakeheal commented May 18, 2021

Thank you so much for the clarification, @Johan-dutoit! Silly me, I have added the permissions in the getWritePermFromText, but not in getReadPermFromText in RCTAppleHealthKit+TypesAndPermissions.m.

I have fixed that mistake in my fork @ support-for-reproductive-health and I have added two methods:

You can test my changes by adding, my repo+branch as dependency in your project:

yarn add https://github.com/fakeheal/react-native-health#support-for-reproductive-health

I am fairly new in this as well, but if you follow my commits and the changed files in them, you can see the "steps":


For testing, while developing features/debugging/etc, I have this repository checked out twice:

  • ./react-native-health
  • ./react-native-health-example

In the example repository, go to example/ folder and do yarn add ../../react-native-health, this will add your local folder as dependency. Then you can edit files in react-native-health (and use git to keep track of your changes) and then do yarn add again, to update your example repository and build the app in xcode.


Also, this is my code that you can use to test the methods I added: App.tsx

@Johan-dutoit
Copy link
Author

I'm going to give this a go right now, thanks for your efforts!

@Johan-dutoit
Copy link
Author

Johan-dutoit commented May 19, 2021

Here is what I managed to do

  • Successfully requested read permissions for the reproductive health data,
  • Successfully queried data (got the data I set via the health app),
  • Successfully requested write permission (although couldn't find the write function, I was only going to use it to insert test data, used the health app to add test data instead)

After some testing, I got the following feedback

Missing types

  • Reproductive Permissions types,
  • Reproductive Function types,
  • Return values (i.e. the value seems to be a string, based on your example and HealthValue has a number)

Other

  • No write functions for reproductive health, although I'm not sure this is actually supported. It might be, as that is what you had setup initially?

@fakeheal
Copy link
Contributor

Hey, @Johan-dutoit,

Successfully queried data (well, I got an empty array),
Successfully requested write permission (although couldn't find the write function, I was only going to use it to insert test data, used the health app to add test data instead)

You can add data manually using the Health app, to see if its fetched properly. Write functions are yet to be implemented, so this is the only way to add data right now (or use another app that writes those data types).

Missing types, Reproductive Function types, etc...

I think those are missing, because package's js/ts is yet to be bundled.

@Johan-dutoit
Copy link
Author

I can confirm nothing but success for what I've tried. Thanks.

@fakeheal
Copy link
Contributor

I am glad it works! Thank you for testing!

What other data types are you using in your project? Maybe we can split the work on adding the other functionality related to Reproductive Health? I can add methods for adding data for HKCategoryTypeIdentifierMenstrualFlow, so you can see it and use as template?

Or you can help with testing the methods I add?

@Johan-dutoit
Copy link
Author

At the moment it's purely HKCategoryTypeIdentifierMenstrualFlow, however I'm more than happy to split it up once you have a template in place?

@abarisic86
Copy link

@Johan-dutoit @fakeheal is there an update on this topic? is there a plan for it to be integrated at some point?

@NTag
Copy link

NTag commented Jun 9, 2022

Hello 👋

For an app I did (My PrEP) I would also be very interested in being able to write sexual activity to Apple HealthKit 🙏 .

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants