SlideShare a Scribd company logo


2
3
4
5
6
7
8
9
11
12
13
14
15
16
17
18
20
21
import UIKit
import HealthStore
class ViewController: UIViewController {
private let healthStore = HealthStore()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
}
22
guard let healthStore = healthStore else { return }
guard let type = HKQuantityType.quantityType(forIdentifier: .stepCount) else { return }
let builder = DailyQueryBuilder(quantityType: type)
healthStore.requestSources(from: Date.startOfToday(), to: Date(), builder: builder) { (sources: [StepSource]?) in
if let sources = sources {
print("sources: (sources)”)
} else {
print("step sources are not found.”)
}
}
23
guard let healthStore = healthStore else { return }
guard let type = HKQuantityType.quantityType(forIdentifier: .stepCount) else { return }
let builder = DailyQueryBuilder(quantityType: type)
healthStore.requestSources(from: Date.startOfToday(), to: Date(), builder: builder) { (sources: [StepSource]?) in
if let sources = sources {
print("sources: (sources)”)
} else {
print("step sources are not found.”)
}
}
24
guard let healthStore = healthStore else { return }
guard let type = HKQuantityType.quantityType(forIdentifier: .stepCount) else { return }
let builder = DailyQueryBuilder(quantityType: type)
healthStore.requestSources(to: Date(), builder: builder) { (sources: [StepSource]?) in
if let sources = sources {
print("sources: (sources)”)
} else {
print("step sources are not found.”)
}
}
25
guard let healthStore = healthStore else { return }
guard let type = HKQuantityType.quantityType(forIdentifier: .stepCount) else { return }
let builder = DailyQueryBuilder(quantityType: type)
healthStore.observeSourceUpdates(from: Date(), builder: builder, handler: { (sources: [StepSource]?) in
if let sources = sources {
print("sources: (sources)")
} else {
print("step sources are not found.")
}
})
26
guard let healthStore = healthStore else { return }
guard let type = HKQuantityType.quantityType(forIdentifier: .stepCount) else { return }
let builder = RestrictedSourceQueryBuilder(quantityType: type)
healthStore.requestSources(from: Date.startOfToday(), to: Date(), builder: builder) { (sources: [StepSource]?) in
if let sources = sources {
print("sources: (sources)”)
} else {
print("step sources are not found.”)
}
}
27
28
import HealthKit
public protocol HealthStoreQueryBuildable {
var quantityType: HKQuantityType { get }
var typesToWrite: Set<HKSampleType>? { get }
var typesToRead: Set<HKObjectType>? { get }
var options: HKStatisticsOptions { get }
var anchorDate: Date { get }
var intervalComponents: DateComponents { get }
var predicates: [NSPredicate] { get }
func build() -> HKStatisticsCollectionQuery?
func build(completion: @escaping (HKStatisticsCollectionQuery?) -> Void)
}
29
public extension HealthStoreQueryBuildable {
var typesToWrite: Set<HKSampleType>? {
return nil
}
var typesToRead: Set<HKObjectType>? {
return nil
}
func build() -> HKStatisticsCollectionQuery? {
let predicate = NSCompoundPredicate(andPredicateWithSubpredicates: predicates)
return HKStatisticsCollectionQuery(
quantityType: quantityType,
quantitySamplePredicate: predicate,
options: options,
anchorDate: anchorDate,
intervalComponents: intervalComponents)
}
func build(completion: @escaping (HKStatisticsCollectionQuery?) -> Void) {
completion(build())
}
}
30
public struct DailyQueryBuilder: HealthStoreQueryBuildable {
public let quantityType: HKQuantityType
public var typesToRead: Set<HKObjectType>? {
return [quantityType]
}
public let options: HKStatisticsOptions = .cumulativeSum
public let anchorDate: Date
public let intervalComponents: DateComponents = DateComponents(day: 1)
public let predicates: [NSPredicate] = []
public init(quantityType: HKQuantityType, anchorDate: Date = Date.startOfToday()) {
self.quantityType = quantityType
self.anchorDate = anchorDate
}
}
31
public class RestrictedSourceQueryBuilder: HealthStoreQueryBuildable {
public func build(completion: @escaping (HKStatisticsCollectionQuery?) -> Void) {
guard let provider = HealthSourceProvider() else {
completion(nil)
return
}
provider.appleSources(sampleType: quantityType) { (sources, error) in
if let error = error {
print(error)
}
guard let sources = sources else {
completion(nil)
return
}
// update predicates
let metadataPredicate = HKQuery.predicateForObjects(withMetadataKey: HKMetadataKeyWasUserEntered,
operatorType: .notEqualTo,
value: true)
let sourcePredicate = HKQuery.predicateForObjects(from: sources)
self.predicates = [metadataPredicate, sourcePredicate]
// build query
completion(self.build())
}
}
}
32
33
34
35
36
38
39
🤖
🚀
40
💗
👀
41
42
43
44
45
46
47
var (
ErrNoSuchUser = errors.New("...")
)
type Repository interface {
Get(id string) (*User, error)
}
var NewRepository func(context.Context) Repository
domain/user/repository.go
48
49
type userRepository struct {
Ctx context.Context
}
func NewUserRepository(ctx context.Context) user.Repository {
return &userRepository{
Ctx: ctx,
}
}
func (r *userRepository) Get(id string) (*user.User, error) {
// ...
}
infrastructure/persistence/datastore/user_repository.go
50
func init() {
user.NewRepository = datastore.NewUserRepository
}
func main() {
repo := user.NewRepository(ctx) // datastore.userRepository
}
51
type userRepository struct {
Ctx context.Context
}
func NewUserRepository(ctx context.Context) user.Repository {
return &userRepository{
Ctx: ctx,
}
}
func (r *userRepository) Get(id string) (*user.User, error) {
// ...
}
infrastructure/persistence/mock/user_repository.go
52
func TestMain(m *testing.M) {
user.NewRepository = mock.NewUserRepository
m.Run()
}
53
👍
👍
👍
58
59
func Namespacer(h http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// treat an error!
ctx, _ := appengine.Namespace(r.Context(), "Namespace-a")
h(w, r.WithContext(ctx))
}
}
Middleware
63
64
👍
👍
👍
BigQuery
App Engine
Datastore
Data Studio
BigQuery
App Engine
Datastore
Data Studio
App Engine
Task Queue
BigQuery
Access
Enqueue
BigQuery
App Engine
Datastore
Data Studio
Cron Export Backup
Load
71
Cron Export Backup
72
Create Load Job
Backup
Trigger
Load
Cron Export Backup
Load
BigQuery
App Engine
Datastore
Data Studio
BigQuery
Data Studio
76
77
👍
👍
👍
ヘルスケアサービスを実現する最新技術
〜HealthKit・GCP+Go〜

More Related Content

What's hot

Do something in 5 with gas 9-copy between databases with oauth2
Do something in 5 with gas 9-copy between databases with oauth2Do something in 5 with gas 9-copy between databases with oauth2
Do something in 5 with gas 9-copy between databases with oauth2
Bruce McPherson
 
Ken 20150306 心得分享
Ken 20150306 心得分享Ken 20150306 心得分享
Ken 20150306 心得分享
LearningTech
 
Webinar: Applikationsentwicklung mit MongoDB : Teil 5: Reporting & Aggregation
Webinar: Applikationsentwicklung mit MongoDB: Teil 5: Reporting & AggregationWebinar: Applikationsentwicklung mit MongoDB: Teil 5: Reporting & Aggregation
Webinar: Applikationsentwicklung mit MongoDB : Teil 5: Reporting & Aggregation
MongoDB
 
Query for json databases
Query for json databasesQuery for json databases
Query for json databases
Binh Le
 
CodiLime Tech Talk - Katarzyna Ziomek-Zdanowicz: RxJS main concepts and real ...
CodiLime Tech Talk - Katarzyna Ziomek-Zdanowicz: RxJS main concepts and real ...CodiLime Tech Talk - Katarzyna Ziomek-Zdanowicz: RxJS main concepts and real ...
CodiLime Tech Talk - Katarzyna Ziomek-Zdanowicz: RxJS main concepts and real ...
CodiLime
 
Testowanie JavaScript
Testowanie JavaScriptTestowanie JavaScript
Testowanie JavaScript
Tomasz Bak
 
The Ring programming language version 1.5.1 book - Part 59 of 180
The Ring programming language version 1.5.1 book - Part 59 of 180The Ring programming language version 1.5.1 book - Part 59 of 180
The Ring programming language version 1.5.1 book - Part 59 of 180
Mahmoud Samir Fayed
 
ApplicationCoordinator для навигации между экранами / Павел Гуров (Avito)
ApplicationCoordinator для навигации между экранами / Павел Гуров (Avito)ApplicationCoordinator для навигации между экранами / Павел Гуров (Avito)
ApplicationCoordinator для навигации между экранами / Павел Гуров (Avito)
Ontico
 
Compose Async with RxJS
Compose Async with RxJSCompose Async with RxJS
Compose Async with RxJS
Kyung Yeol Kim
 
The Ring programming language version 1.5.2 book - Part 64 of 181
The Ring programming language version 1.5.2 book - Part 64 of 181The Ring programming language version 1.5.2 book - Part 64 of 181
The Ring programming language version 1.5.2 book - Part 64 of 181
Mahmoud Samir Fayed
 
Architecture components, Константин Марс, TeamLead, Senior Developer, DataArt
Architecture components, Константин Марс, TeamLead, Senior Developer, DataArtArchitecture components, Константин Марс, TeamLead, Senior Developer, DataArt
Architecture components, Константин Марс, TeamLead, Senior Developer, DataArt
Alina Vilk
 
Do something in 5 with apps scripts number 6 - fusion crossfilter
Do something in 5 with apps scripts number 6 - fusion crossfilterDo something in 5 with apps scripts number 6 - fusion crossfilter
Do something in 5 with apps scripts number 6 - fusion crossfilter
Bruce McPherson
 
Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...
Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...
Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...
Bruce McPherson
 
Do something in 5 with gas 8-copy between databases
Do something in 5 with gas 8-copy between databasesDo something in 5 with gas 8-copy between databases
Do something in 5 with gas 8-copy between databases
Bruce McPherson
 
The Ring programming language version 1.5.4 book - Part 62 of 185
The Ring programming language version 1.5.4 book - Part 62 of 185The Ring programming language version 1.5.4 book - Part 62 of 185
The Ring programming language version 1.5.4 book - Part 62 of 185
Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 74 of 210
The Ring programming language version 1.9 book - Part 74 of 210The Ring programming language version 1.9 book - Part 74 of 210
The Ring programming language version 1.9 book - Part 74 of 210
Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 47 of 88
The Ring programming language version 1.3 book - Part 47 of 88The Ring programming language version 1.3 book - Part 47 of 88
The Ring programming language version 1.3 book - Part 47 of 88
Mahmoud Samir Fayed
 
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheetDo something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Bruce McPherson
 
Меняем javascript с помощью javascript
Меняем javascript с помощью javascriptМеняем javascript с помощью javascript
Меняем javascript с помощью javascript
Pavel Volokitin
 
JS Fest 2019. Anjana Vakil. Serverless Bebop
JS Fest 2019. Anjana Vakil. Serverless BebopJS Fest 2019. Anjana Vakil. Serverless Bebop
JS Fest 2019. Anjana Vakil. Serverless Bebop
JSFestUA
 

What's hot (20)

Do something in 5 with gas 9-copy between databases with oauth2
Do something in 5 with gas 9-copy between databases with oauth2Do something in 5 with gas 9-copy between databases with oauth2
Do something in 5 with gas 9-copy between databases with oauth2
 
Ken 20150306 心得分享
Ken 20150306 心得分享Ken 20150306 心得分享
Ken 20150306 心得分享
 
Webinar: Applikationsentwicklung mit MongoDB : Teil 5: Reporting & Aggregation
Webinar: Applikationsentwicklung mit MongoDB: Teil 5: Reporting & AggregationWebinar: Applikationsentwicklung mit MongoDB: Teil 5: Reporting & Aggregation
Webinar: Applikationsentwicklung mit MongoDB : Teil 5: Reporting & Aggregation
 
Query for json databases
Query for json databasesQuery for json databases
Query for json databases
 
CodiLime Tech Talk - Katarzyna Ziomek-Zdanowicz: RxJS main concepts and real ...
CodiLime Tech Talk - Katarzyna Ziomek-Zdanowicz: RxJS main concepts and real ...CodiLime Tech Talk - Katarzyna Ziomek-Zdanowicz: RxJS main concepts and real ...
CodiLime Tech Talk - Katarzyna Ziomek-Zdanowicz: RxJS main concepts and real ...
 
Testowanie JavaScript
Testowanie JavaScriptTestowanie JavaScript
Testowanie JavaScript
 
The Ring programming language version 1.5.1 book - Part 59 of 180
The Ring programming language version 1.5.1 book - Part 59 of 180The Ring programming language version 1.5.1 book - Part 59 of 180
The Ring programming language version 1.5.1 book - Part 59 of 180
 
ApplicationCoordinator для навигации между экранами / Павел Гуров (Avito)
ApplicationCoordinator для навигации между экранами / Павел Гуров (Avito)ApplicationCoordinator для навигации между экранами / Павел Гуров (Avito)
ApplicationCoordinator для навигации между экранами / Павел Гуров (Avito)
 
Compose Async with RxJS
Compose Async with RxJSCompose Async with RxJS
Compose Async with RxJS
 
The Ring programming language version 1.5.2 book - Part 64 of 181
The Ring programming language version 1.5.2 book - Part 64 of 181The Ring programming language version 1.5.2 book - Part 64 of 181
The Ring programming language version 1.5.2 book - Part 64 of 181
 
Architecture components, Константин Марс, TeamLead, Senior Developer, DataArt
Architecture components, Константин Марс, TeamLead, Senior Developer, DataArtArchitecture components, Константин Марс, TeamLead, Senior Developer, DataArt
Architecture components, Константин Марс, TeamLead, Senior Developer, DataArt
 
Do something in 5 with apps scripts number 6 - fusion crossfilter
Do something in 5 with apps scripts number 6 - fusion crossfilterDo something in 5 with apps scripts number 6 - fusion crossfilter
Do something in 5 with apps scripts number 6 - fusion crossfilter
 
Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...
Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...
Do something useful in Apps Script 5. Get your analytics pageviews to a sprea...
 
Do something in 5 with gas 8-copy between databases
Do something in 5 with gas 8-copy between databasesDo something in 5 with gas 8-copy between databases
Do something in 5 with gas 8-copy between databases
 
The Ring programming language version 1.5.4 book - Part 62 of 185
The Ring programming language version 1.5.4 book - Part 62 of 185The Ring programming language version 1.5.4 book - Part 62 of 185
The Ring programming language version 1.5.4 book - Part 62 of 185
 
The Ring programming language version 1.9 book - Part 74 of 210
The Ring programming language version 1.9 book - Part 74 of 210The Ring programming language version 1.9 book - Part 74 of 210
The Ring programming language version 1.9 book - Part 74 of 210
 
The Ring programming language version 1.3 book - Part 47 of 88
The Ring programming language version 1.3 book - Part 47 of 88The Ring programming language version 1.3 book - Part 47 of 88
The Ring programming language version 1.3 book - Part 47 of 88
 
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheetDo something in 5 with gas 4- Get your analytics profiles to a spreadsheet
Do something in 5 with gas 4- Get your analytics profiles to a spreadsheet
 
Меняем javascript с помощью javascript
Меняем javascript с помощью javascriptМеняем javascript с помощью javascript
Меняем javascript с помощью javascript
 
JS Fest 2019. Anjana Vakil. Serverless Bebop
JS Fest 2019. Anjana Vakil. Serverless BebopJS Fest 2019. Anjana Vakil. Serverless Bebop
JS Fest 2019. Anjana Vakil. Serverless Bebop
 

Similar to ヘルスケアサービスを実現する最新技術
〜HealthKit・GCP+Go〜

Android Design Patterns
Android Design PatternsAndroid Design Patterns
Android Design Patterns
Godfrey Nolan
 
TechDays 2016 - Developing websites using asp.net core mvc6 and entity framew...
TechDays 2016 - Developing websites using asp.net core mvc6 and entity framew...TechDays 2016 - Developing websites using asp.net core mvc6 and entity framew...
TechDays 2016 - Developing websites using asp.net core mvc6 and entity framew...
Fons Sonnemans
 
Beautiful java script
Beautiful java scriptBeautiful java script
Beautiful java script
Ürgo Ringo
 
Reduxing like a pro
Reduxing like a proReduxing like a pro
Reduxing like a pro
Boris Dinkevich
 
Spca2014 hillier build your_own_rest_service
Spca2014 hillier build your_own_rest_serviceSpca2014 hillier build your_own_rest_service
Spca2014 hillier build your_own_rest_serviceNCCOMMS
 
Http Communication in Angular 2.0
Http Communication in Angular 2.0Http Communication in Angular 2.0
Http Communication in Angular 2.0
Eyal Vardi
 
“iOS 11 в App in the Air”, Пронин Сергей, App in the Air
“iOS 11 в App in the Air”, Пронин Сергей, App in the Air“iOS 11 в App in the Air”, Пронин Сергей, App in the Air
“iOS 11 в App in the Air”, Пронин Сергей, App in the Air
AvitoTech
 
API 통신, Retrofit 대신 Ktor 어떠신가요.pdf
API 통신, Retrofit 대신 Ktor 어떠신가요.pdfAPI 통신, Retrofit 대신 Ktor 어떠신가요.pdf
API 통신, Retrofit 대신 Ktor 어떠신가요.pdf
ssuserb6c2641
 
Create methods to_insert
Create methods to_insertCreate methods to_insert
Create methods to_insert
NayanBakhadyo
 
Blending Culture in Twitter Client
Blending Culture in Twitter ClientBlending Culture in Twitter Client
Blending Culture in Twitter Client
Kenji Tanaka
 
«Управление логикой переходов между экранами приложения с помощью координатор...
«Управление логикой переходов между экранами приложения с помощью координатор...«Управление логикой переходов между экранами приложения с помощью координатор...
«Управление логикой переходов между экранами приложения с помощью координатор...
Mail.ru Group
 
【Unity】Scriptable object 入門と活用例
【Unity】Scriptable object 入門と活用例【Unity】Scriptable object 入門と活用例
【Unity】Scriptable object 入門と活用例
Unity Technologies Japan K.K.
 
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
Ali Parmaksiz
 
A test framework out of the box - Geb for Web and mobile
A test framework out of the box - Geb for Web and mobileA test framework out of the box - Geb for Web and mobile
A test framework out of the box - Geb for Web and mobile
GlobalLogic Ukraine
 
React, Redux and es6/7
React, Redux and es6/7React, Redux and es6/7
React, Redux and es6/7
Dongho Cho
 
Vuex to Pinia, how to migrate an existing app
Vuex to Pinia, how to migrate an existing appVuex to Pinia, how to migrate an existing app
Vuex to Pinia, how to migrate an existing app
Denny Biasiolli
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
Nick Lee
 
Durable functions 2.0 (2019-10-10)
Durable functions 2.0 (2019-10-10)Durable functions 2.0 (2019-10-10)
Durable functions 2.0 (2019-10-10)
Paco de la Cruz
 
Cocoaheads Meetup / Alex Zimin / Swift magic
Cocoaheads Meetup / Alex Zimin / Swift magicCocoaheads Meetup / Alex Zimin / Swift magic
Cocoaheads Meetup / Alex Zimin / Swift magic
Badoo Development
 

Similar to ヘルスケアサービスを実現する最新技術
〜HealthKit・GCP+Go〜 (20)

Android Design Patterns
Android Design PatternsAndroid Design Patterns
Android Design Patterns
 
TechDays 2016 - Developing websites using asp.net core mvc6 and entity framew...
TechDays 2016 - Developing websites using asp.net core mvc6 and entity framew...TechDays 2016 - Developing websites using asp.net core mvc6 and entity framew...
TechDays 2016 - Developing websites using asp.net core mvc6 and entity framew...
 
Beautiful java script
Beautiful java scriptBeautiful java script
Beautiful java script
 
Reduxing like a pro
Reduxing like a proReduxing like a pro
Reduxing like a pro
 
Spca2014 hillier build your_own_rest_service
Spca2014 hillier build your_own_rest_serviceSpca2014 hillier build your_own_rest_service
Spca2014 hillier build your_own_rest_service
 
Http Communication in Angular 2.0
Http Communication in Angular 2.0Http Communication in Angular 2.0
Http Communication in Angular 2.0
 
“iOS 11 в App in the Air”, Пронин Сергей, App in the Air
“iOS 11 в App in the Air”, Пронин Сергей, App in the Air“iOS 11 в App in the Air”, Пронин Сергей, App in the Air
“iOS 11 в App in the Air”, Пронин Сергей, App in the Air
 
API 통신, Retrofit 대신 Ktor 어떠신가요.pdf
API 통신, Retrofit 대신 Ktor 어떠신가요.pdfAPI 통신, Retrofit 대신 Ktor 어떠신가요.pdf
API 통신, Retrofit 대신 Ktor 어떠신가요.pdf
 
Create methods to_insert
Create methods to_insertCreate methods to_insert
Create methods to_insert
 
Blending Culture in Twitter Client
Blending Culture in Twitter ClientBlending Culture in Twitter Client
Blending Culture in Twitter Client
 
«Управление логикой переходов между экранами приложения с помощью координатор...
«Управление логикой переходов между экранами приложения с помощью координатор...«Управление логикой переходов между экранами приложения с помощью координатор...
«Управление логикой переходов между экранами приложения с помощью координатор...
 
【Unity】Scriptable object 入門と活用例
【Unity】Scriptable object 入門と活用例【Unity】Scriptable object 入門と活用例
【Unity】Scriptable object 入門と活用例
 
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
 
A test framework out of the box - Geb for Web and mobile
A test framework out of the box - Geb for Web and mobileA test framework out of the box - Geb for Web and mobile
A test framework out of the box - Geb for Web and mobile
 
React, Redux and es6/7
React, Redux and es6/7React, Redux and es6/7
React, Redux and es6/7
 
Vuex to Pinia, how to migrate an existing app
Vuex to Pinia, how to migrate an existing appVuex to Pinia, how to migrate an existing app
Vuex to Pinia, how to migrate an existing app
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
 
F3
F3F3
F3
 
Durable functions 2.0 (2019-10-10)
Durable functions 2.0 (2019-10-10)Durable functions 2.0 (2019-10-10)
Durable functions 2.0 (2019-10-10)
 
Cocoaheads Meetup / Alex Zimin / Swift magic
Cocoaheads Meetup / Alex Zimin / Swift magicCocoaheads Meetup / Alex Zimin / Swift magic
Cocoaheads Meetup / Alex Zimin / Swift magic
 

Recently uploaded

Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 

Recently uploaded (20)

Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 

ヘルスケアサービスを実現する最新技術
〜HealthKit・GCP+Go〜

  • 1.
  • 2. 2
  • 3. 3
  • 4. 4
  • 5. 5
  • 6. 6
  • 7. 7
  • 8. 8
  • 9. 9
  • 10.
  • 11. 11
  • 12. 12
  • 13. 13
  • 14. 14
  • 15. 15
  • 16. 16
  • 17. 17
  • 18. 18
  • 19.
  • 20. 20
  • 21. 21
  • 22. import UIKit import HealthStore class ViewController: UIViewController { private let healthStore = HealthStore() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } } 22
  • 23. guard let healthStore = healthStore else { return } guard let type = HKQuantityType.quantityType(forIdentifier: .stepCount) else { return } let builder = DailyQueryBuilder(quantityType: type) healthStore.requestSources(from: Date.startOfToday(), to: Date(), builder: builder) { (sources: [StepSource]?) in if let sources = sources { print("sources: (sources)”) } else { print("step sources are not found.”) } } 23
  • 24. guard let healthStore = healthStore else { return } guard let type = HKQuantityType.quantityType(forIdentifier: .stepCount) else { return } let builder = DailyQueryBuilder(quantityType: type) healthStore.requestSources(from: Date.startOfToday(), to: Date(), builder: builder) { (sources: [StepSource]?) in if let sources = sources { print("sources: (sources)”) } else { print("step sources are not found.”) } } 24
  • 25. guard let healthStore = healthStore else { return } guard let type = HKQuantityType.quantityType(forIdentifier: .stepCount) else { return } let builder = DailyQueryBuilder(quantityType: type) healthStore.requestSources(to: Date(), builder: builder) { (sources: [StepSource]?) in if let sources = sources { print("sources: (sources)”) } else { print("step sources are not found.”) } } 25
  • 26. guard let healthStore = healthStore else { return } guard let type = HKQuantityType.quantityType(forIdentifier: .stepCount) else { return } let builder = DailyQueryBuilder(quantityType: type) healthStore.observeSourceUpdates(from: Date(), builder: builder, handler: { (sources: [StepSource]?) in if let sources = sources { print("sources: (sources)") } else { print("step sources are not found.") } }) 26
  • 27. guard let healthStore = healthStore else { return } guard let type = HKQuantityType.quantityType(forIdentifier: .stepCount) else { return } let builder = RestrictedSourceQueryBuilder(quantityType: type) healthStore.requestSources(from: Date.startOfToday(), to: Date(), builder: builder) { (sources: [StepSource]?) in if let sources = sources { print("sources: (sources)”) } else { print("step sources are not found.”) } } 27
  • 28. 28
  • 29. import HealthKit public protocol HealthStoreQueryBuildable { var quantityType: HKQuantityType { get } var typesToWrite: Set<HKSampleType>? { get } var typesToRead: Set<HKObjectType>? { get } var options: HKStatisticsOptions { get } var anchorDate: Date { get } var intervalComponents: DateComponents { get } var predicates: [NSPredicate] { get } func build() -> HKStatisticsCollectionQuery? func build(completion: @escaping (HKStatisticsCollectionQuery?) -> Void) } 29
  • 30. public extension HealthStoreQueryBuildable { var typesToWrite: Set<HKSampleType>? { return nil } var typesToRead: Set<HKObjectType>? { return nil } func build() -> HKStatisticsCollectionQuery? { let predicate = NSCompoundPredicate(andPredicateWithSubpredicates: predicates) return HKStatisticsCollectionQuery( quantityType: quantityType, quantitySamplePredicate: predicate, options: options, anchorDate: anchorDate, intervalComponents: intervalComponents) } func build(completion: @escaping (HKStatisticsCollectionQuery?) -> Void) { completion(build()) } } 30
  • 31. public struct DailyQueryBuilder: HealthStoreQueryBuildable { public let quantityType: HKQuantityType public var typesToRead: Set<HKObjectType>? { return [quantityType] } public let options: HKStatisticsOptions = .cumulativeSum public let anchorDate: Date public let intervalComponents: DateComponents = DateComponents(day: 1) public let predicates: [NSPredicate] = [] public init(quantityType: HKQuantityType, anchorDate: Date = Date.startOfToday()) { self.quantityType = quantityType self.anchorDate = anchorDate } } 31
  • 32. public class RestrictedSourceQueryBuilder: HealthStoreQueryBuildable { public func build(completion: @escaping (HKStatisticsCollectionQuery?) -> Void) { guard let provider = HealthSourceProvider() else { completion(nil) return } provider.appleSources(sampleType: quantityType) { (sources, error) in if let error = error { print(error) } guard let sources = sources else { completion(nil) return } // update predicates let metadataPredicate = HKQuery.predicateForObjects(withMetadataKey: HKMetadataKeyWasUserEntered, operatorType: .notEqualTo, value: true) let sourcePredicate = HKQuery.predicateForObjects(from: sources) self.predicates = [metadataPredicate, sourcePredicate] // build query completion(self.build()) } } } 32
  • 33. 33
  • 34. 34
  • 35. 35
  • 36. 36
  • 37.
  • 38. 38
  • 41. 41
  • 42. 42
  • 43. 43
  • 44. 44
  • 45. 45
  • 46. 46
  • 47. 47 var ( ErrNoSuchUser = errors.New("...") ) type Repository interface { Get(id string) (*User, error) } var NewRepository func(context.Context) Repository domain/user/repository.go
  • 48. 48
  • 49. 49 type userRepository struct { Ctx context.Context } func NewUserRepository(ctx context.Context) user.Repository { return &userRepository{ Ctx: ctx, } } func (r *userRepository) Get(id string) (*user.User, error) { // ... } infrastructure/persistence/datastore/user_repository.go
  • 50. 50 func init() { user.NewRepository = datastore.NewUserRepository } func main() { repo := user.NewRepository(ctx) // datastore.userRepository }
  • 51. 51 type userRepository struct { Ctx context.Context } func NewUserRepository(ctx context.Context) user.Repository { return &userRepository{ Ctx: ctx, } } func (r *userRepository) Get(id string) (*user.User, error) { // ... } infrastructure/persistence/mock/user_repository.go
  • 52. 52 func TestMain(m *testing.M) { user.NewRepository = mock.NewUserRepository m.Run() }
  • 54.
  • 55.
  • 56.
  • 57.
  • 58. 58
  • 59. 59 func Namespacer(h http.HandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { // treat an error! ctx, _ := appengine.Namespace(r.Context(), "Namespace-a") h(w, r.WithContext(ctx)) } } Middleware
  • 60.
  • 61.
  • 62.
  • 63. 63
  • 65.
  • 76. 76