-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathInstrumentFactory.swift
172 lines (147 loc) · 6.37 KB
/
InstrumentFactory.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
//
// InstrumentFactory.swift
// SMARTMarkers
//
// Created by Raheel Sayeed on 3/15/19.
// Copyright © 2019 Boston Children's Hospital. All rights reserved.
//
import Foundation
import SMART
let SMARTMarkersSystem = "http://smartmarkers.smarthealthit.org"
let InstrumentSystem = SMARTMarkersSystem + "/vs-instruments"
let TaskAttemptSystem = SMARTMarkersSystem + "/vs-taskAttempt"
/**
Convenience enums to list all available instruments supported natively by SMART Markers.
Can be used to instantiate instruments by `Instruments.<type>.<name>.instance`
Example: `Instruments.ActiveTasks.AmslerGrid.instance`
*/
public enum Instruments {
/// ActiveTasks: FHIR-ized versions of active measurements from ResearchKit
public enum ActiveTasks: String, CaseIterable, CustomStringConvertible {
case AmslerGrid = "amslergrid"
case TowerOfHanoi = "towerofhanoi"
case NineHolePegTest = "mineholepegtest"
case PSAT_2 = "psat-2"
case PSAT_3 = "psat-3"
case RangeOfMotion_shoulder_right = "rangeofmotion.shoulder.right"
case RangeOfMotion_shoulder_left = "rangeofmotion.shoulder.left"
case RangeOfMotion_knee_right = "rangeofmotion.knee.right"
case RangeOfMotion_knee_left = "rangeofmotion.knee.left"
case FingerTappingSpeed = "fingertappingspeed.both"
case FingerTappingSpeed_Left = "fingertappingspeed.left"
case FingerTappingSpeed_Right = "fingertappingspeed.right"
case SpatialSpanMemory = "spatialspanmemory"
case StroopTest = "strooptest"
public var instance: Instrument {
switch self {
case .AmslerGrid:
return SMARTMarkers.AmslerGrid()
case .NineHolePegTest:
return SMARTMarkers.NineHolePegTest()
case .PSAT_2:
return SMARTMarkers.PASAT(interStimulusInterval: 2.0)
case .PSAT_3:
return SMARTMarkers.PASAT(interStimulusInterval: 3.0)
case .TowerOfHanoi:
return SMARTMarkers.TowerOfHanoi()
case .RangeOfMotion_shoulder_left:
return SMARTMarkers.ShoulderRangeOfMotion(limbOption: .left)
case .RangeOfMotion_shoulder_right:
return SMARTMarkers.ShoulderRangeOfMotion(limbOption: .right)
case .RangeOfMotion_knee_left:
return SMARTMarkers.KneeRangeOfMotion(limbOption: .left)
case .RangeOfMotion_knee_right:
return SMARTMarkers.KneeRangeOfMotion(limbOption: .right)
case .FingerTappingSpeed:
return SMARTMarkers.TappingSpeed(hand: .both)
case .FingerTappingSpeed_Left:
return SMARTMarkers.TappingSpeed(hand: .left)
case .FingerTappingSpeed_Right:
return SMARTMarkers.TappingSpeed(hand: .right)
case .SpatialSpanMemory:
return SMARTMarkers.SpatialSpanMemory()
case .StroopTest:
return SMARTMarkers.StroopTest()
}
}
public var description: String {
switch self {
case .AmslerGrid:
return "Amsler Grid"
case .NineHolePegTest:
return "9 Hole Peg Test"
case .PSAT_2:
return "Paced Serial Addition test (2sec)"
case .PSAT_3:
return "Paced Serial Addition test (3sec)"
case .TowerOfHanoi:
return "Tower of Hanoi"
case .RangeOfMotion_shoulder_left:
return "Left Shoulder Range of Motion"
case .RangeOfMotion_shoulder_right:
return "Right Shoulder Range of Motion"
case .RangeOfMotion_knee_left:
return "Left Knee Range of Motion"
case .RangeOfMotion_knee_right:
return "Right Knee Range of Motion"
case .FingerTappingSpeed:
return "Finger Tapping Speed"
case .FingerTappingSpeed_Left:
return "Finger Tapping Speed (Left)"
case .FingerTappingSpeed_Right:
return "Finger Tapping Speed (Right)"
case .SpatialSpanMemory:
return "Spatiel Span Memory"
case .StroopTest:
return "Stroop Test"
}
}
public var coding: Coding {
switch self {
default:
return Coding.sm_ResearchKit(self.rawValue, self.description)
}
}
}
public static func Code(_ code: String) -> Instrument? {
ActiveTasks(rawValue: code)?.instance ??
HealthKit(rawValue: code)?.instance
}
/// HealthKit: Instruments modules that retrieve data from iPhone's HealthKit repository.
public enum HealthKit: String, CaseIterable, CustomStringConvertible {
case StepCount = "stepcount"
case HealthRecords = "healthrecords"
public var description: String {
switch self {
case .HealthRecords:
return "Health Records"
case .StepCount:
return "Step Count"
}
}
public var instance: Instrument {
switch self {
case .StepCount:
return StepReport()
case .HealthRecords:
return SMARTMarkers.HealthRecords()
}
}
}
/// Web repository Instruments. (Omron Blood Pressure)
public enum Web: String, CaseIterable {
case OmronBloodPressure = "omronbloodpressure"
public func instance(authSettings: [String: Any], callbackManager: inout CallbackManager) -> Instrument {
switch self {
case .OmronBloodPressure:
return OMRON(authSettings: authSettings, callbackManager: &callbackManager)
}
}
public var coding: Coding {
switch self {
case .OmronBloodPressure:
return Coding.sm_Coding(self.rawValue, "http://omronhealthcare.com", "Omron Blood Pressure")
}
}
}
}