mirah-ruby 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d6112c2bab9f017614f4ff32fec8d1a79bd53d3099f68a86679563dc6aae644
4
- data.tar.gz: 49592ec2080f7af06bdb559f4f9d10cb3ee0acbbc12f9184a4a53544ac3fa429
3
+ metadata.gz: 41451cd5cce251f00e1436c8a7aae2140fe8fbc0c34b8a559531684cbc415c10
4
+ data.tar.gz: 51b5c3d5095058f4da1b2e0ac5fd36f9fcfdf00ac43dba25b499a0254b87b05b
5
5
  SHA512:
6
- metadata.gz: a913e4a74bea01d36cdd9b9a1045ba0af9872afd2caf75cbbaad6b251cc6d2f1466d134af9c1e97424dbbdb1a5f92bb9b7176a3d98a5fc9b41323cdb8a9c2119
7
- data.tar.gz: 8d3743ef319ccdd90200993c78a201fa3003d07a28319c0666a5276a5cae0f4f2716dc4e691f985f4c8030edba1c87033f47fb639537501dfc5c17e53a0b4f3a
6
+ metadata.gz: 8a0f1ccd84d3b52be85a2639127815ee2614f1a629c72f88d2b0e2629989b69112343f49990f732bc346016b79ffbc19c0fc26e208e06a065f2e9fc72321dc05
7
+ data.tar.gz: a2e0cb5cfb08bb316255ab708c1167d555e29b67cd753ac97a5aca447a640c20f67c497d9a8aa92a1b124045c1957d9420d501ae43a524c425d635ab623baec0
data/lib/mirah/client.rb CHANGED
@@ -104,7 +104,8 @@ module Mirah
104
104
  # @option input_values [String, nil] :primary_language see {Data::Patient#primary_language}
105
105
  # @option input_values [String, nil] :email see {Data::Patient#email}
106
106
  # @option input_values [String, nil] :phone_number see {Data::Patient#phone_number}
107
- # @option input_values [String, nil] :external_managing_organization_id see {Data::Patient#external_managing_organization_id}
107
+ # @option input_values [String, nil] :external_managing_organization_id
108
+ # see {Data::Patient#external_managing_organization_id}
108
109
  # @return [PushResult<Data::Patient>] the operation result with a patient on success
109
110
  def push_patient(external_id:, **input_values)
110
111
  mutate(Graphql::Mutations::CreateOrUpdatePatientMutation,
@@ -301,6 +302,123 @@ module Mirah
301
302
  Data::Appointment, 'createOrUpdateAppointment')
302
303
  end
303
304
 
305
+ #################################################################################################################
306
+ # DIAGNOSTIC CODE METHODS
307
+ #################################################################################################################
308
+
309
+ # Find an diagnostic code by the given Mirah internal UUID. This method should be used if you already know the Mirah
310
+ # identifier. If you wish to query by your own system identifier, you should use
311
+ # {#find_diagnostic_code_by_external_id}
312
+ #
313
+ # @since 0.4.0
314
+ # @param id [String] Mirah UUID for the diagnostic code
315
+ # @return [Data::DiagnosticCode, nil] the code, or nil if the record does not exist.
316
+ def find_diagnostic_code(id)
317
+ query_record(Graphql::Queries::DiagnosticCodeIdQuery, id, Data::DiagnosticCode, 'diagnosticCode')
318
+ end
319
+
320
+ # Find a diagnostic code by your external id. This is a convenience method. If you wish to query a list of
321
+ # codes by external id, please use {Client#query_diagnostic_codes}.
322
+ #
323
+ # @since 0.4.0
324
+ # @param external_id [String] The identifier of the system of record
325
+ # @return [Data::DiagnosticCode, nil] the code, or nil if the record does not exist.
326
+ def find_diagnostic_code_by_external_id(external_id)
327
+ query_record_by_external_id(Graphql::Queries::DiagnosticCodeExternalIdQuery,
328
+ external_id,
329
+ Data::DiagnosticCode,
330
+ 'diagnosticCodeExternal')
331
+ end
332
+
333
+ # Query for diagnostic codes. You may specify a set of parameters as defined in
334
+ # {Mirah::Filters::DiagnosticCodeFilters}.
335
+ # Results are returned in a paginated format. See {Collection} for how to page results.
336
+ # @since 0.4.0
337
+ # @param external_id [Array<String>] See {Mirah::Filters::DiagnosticCodeFilters#external_id}
338
+ # @param search [Array<String>] See {Mirah::Filters::DiagnosticCodeFilters#search}
339
+ # @return [Collection<Data::Appointment>] a collection of pageable codes.
340
+ def query_diagnostic_codes(external_id: nil, search: nil)
341
+ query_connection(
342
+ Graphql::Queries::DiagnosticCodeQuery,
343
+ Filters::DiagnosticCodeFilters.new(external_id: external_id, search: search),
344
+ Filters::Paging.default,
345
+ Data::DiagnosticCode,
346
+ 'diagnosticCodes'
347
+ )
348
+ end
349
+
350
+ # Create or update a diagnosis code. You must specify an external identifier, all other parameters are optional,
351
+ # but you may receive errors if you attempt to specify too few parameters for an appointment that does not exist.
352
+ #
353
+ # @since 0.1.0
354
+ # @param external_id [String] the external identifier for this code
355
+ # @option input_values [String, nil] :name see {Data::DiagnosticCode#name}
356
+ # @option input_values [String, nil] :code see {Data::DiagnosticCode#code}
357
+ # @return [PushResult<Data::DiagnosticCode>] the operation result with the code on success
358
+ def push_diagnostic_code(external_id:, **input_values)
359
+ mutate(Graphql::Mutations::CreateOrUpdateDiagnosticCodeMutation,
360
+ Inputs::DiagnosticCodeInput.new(input_values.merge(external_id: external_id)),
361
+ Data::DiagnosticCode, 'createOrUpdateDiagnosticCode')
362
+ end
363
+
364
+ #################################################################################################################
365
+ # PATIENT CONDITION METHODS
366
+ #################################################################################################################
367
+
368
+ # Find an condition by the given Mirah internal UUID. This method should be used if you already know the Mirah
369
+ # identifier. If you wish to query by your own system identifier, you should use
370
+ # {#find_patient_condition_by_external_id}
371
+ #
372
+ # @since 0.4.0
373
+ # @param id [String] Mirah UUID for the condition
374
+ # @return [Data::PatientCondition, nil] the code, or nil if the record does not exist.
375
+ def find_patient_condition(id)
376
+ query_record(Graphql::Queries::PatientConditionIdQuery, id, Data::PatientCondition, 'patientCondition')
377
+ end
378
+
379
+ # Find a condition by your external id. This is a convenience method. If you wish to query a list of
380
+ # codes by external id, please use {Client#query_patient_conditions}.
381
+ #
382
+ # @since 0.4.0
383
+ # @param external_id [String] The identifier of the system of record
384
+ # @return [Data::PatientCondition, nil] the code, or nil if the record does not exist.
385
+ def find_patient_condition_by_external_id(external_id)
386
+ query_record_by_external_id(Graphql::Queries::PatientConditionExternalIdQuery,
387
+ external_id,
388
+ Data::PatientCondition,
389
+ 'patientConditionExternal')
390
+ end
391
+
392
+ # Query for conditions. You may specify a set of parameters as defined in
393
+ # {Mirah::Filters::PatientConditionFilters}.
394
+ # Results are returned in a paginated format. See {Collection} for how to page results.
395
+ # @since 0.4.0
396
+ # @param external_id [Array<String>] See {Mirah::Filters::PatientConditionFilters#external_id}
397
+ # @return [Collection<Data::Appointment>] a collection of pageable codes.
398
+ def query_patient_conditions(external_id: nil)
399
+ query_connection(
400
+ Graphql::Queries::PatientConditionQuery,
401
+ Filters::PatientConditionFilters.new(external_id: external_id),
402
+ Filters::Paging.default,
403
+ Data::PatientCondition,
404
+ 'patientConditions'
405
+ )
406
+ end
407
+
408
+ # Create or update a condition. You must specify an external identifier, all other parameters are optional,
409
+ # but you may receive errors if you attempt to specify too few parameters for an appointment that does not exist.
410
+ #
411
+ # @since 0.1.0
412
+ # @param external_id [String] the external identifier for this code
413
+ # @option input_values [String, nil] :name see {Data::PatientCondition#name}
414
+ # @option input_values [String, nil] :code see {Data::PatientCondition#code}
415
+ # @return [PushResult<Data::PatientCondition>] the operation result with the code on success
416
+ def push_patient_condition(external_id:, **input_values)
417
+ mutate(Graphql::Mutations::CreateOrUpdatePatientConditionMutation,
418
+ Inputs::PatientConditionInput.new(input_values.merge(external_id: external_id)),
419
+ Data::PatientCondition, 'createOrUpdatePatientCondition')
420
+ end
421
+
304
422
  ##################################################################################################################
305
423
  # Internal methods
306
424
  ##################################################################################################################
@@ -411,7 +529,7 @@ module Mirah
411
529
  if response.errors[:data] == ['401 Unauthorized'] # rubocop:disable Style/GuardClause
412
530
  raise Errors::InvalidCredentials, 'The credentials you have supplied are invalid'
413
531
  else
414
- raise Errors::ServerError, 'Unknown error from Mirah server: ' + response.errors.values.flatten.join(',')
532
+ raise Errors::ServerError, "Unknown error from Mirah server: #{response.errors.values.flatten.join(',')}"
415
533
  end
416
534
  end
417
535
 
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mirah
4
+ module Data
5
+ # Diagnostic codes represent ICD10 or other codes that contain information on diagnosis. The Mirah system models
6
+ # this simply as a code and a name, effectively operating like a tag.
7
+ # For example, Major Depressive Disorder could be represented with the code F320.
8
+ class DiagnosticCode < BaseObject
9
+ # @!attribute [r] id
10
+ # @return [string] The internal Mirah identifier
11
+ attribute :id
12
+
13
+ # @!attribute [r] external_id
14
+ # @return [string] The identifier provided by your system
15
+ attribute :external_id
16
+
17
+ # @!attribute [r] name
18
+ # @return [string] A description of the code, e.g. "Major Depressive Disorder"
19
+ attribute :name
20
+
21
+ # @!attribute [r] code
22
+ # @return [string] A string representing the code, e.g. "F320"
23
+ attribute :code
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mirah
4
+ module Data
5
+ class PatientCondition < BaseObject
6
+ # @!attribute [r] id
7
+ # @return [string] The internal Mirah identifier
8
+ attribute :id
9
+
10
+ # @!attribute [r] external_id
11
+ # @return [string] The identifier provided by your system
12
+ attribute :external_id
13
+
14
+ # @!attribute [r] status
15
+ # @return [string] The status of this condition
16
+ attribute :status
17
+
18
+ # @!attribute [r] onset_date
19
+ # @return [string] The date of onset
20
+ attribute :onset_date, serializer: Serializers::DateTimeSerializer.new
21
+
22
+ # @!attribute [r] abatement_date
23
+ # @return [string] The date of abatement
24
+ attribute :abatement_date, serializer: Serializers::DateTimeSerializer.new
25
+
26
+ # @!attribute [r] patient_id
27
+ # @return [string] The internal mirah id of the patient the condition applies to
28
+ attribute :patient_id, path: %w[patient], target: 'id'
29
+
30
+ # @!attribute [r] external_patient_id
31
+ # @return [string] Your system identifier for the patient the condition applies to
32
+ attribute :external_patient_id, path: %w[patient], target: 'externalId'
33
+
34
+ # @!attribute [r] diagnostic_code_id
35
+ # @return [string] The internal mirah id of the code the patient has been diagnosed with
36
+ attribute :diagnostic_code_id, path: %w[diagnosticCode], target: 'id'
37
+
38
+ # @!attribute [r] external_diagnostic_code_id
39
+ # @return [string] Your system identifier for the code the patient has been diagnosed with
40
+ attribute :external_diagnostic_code_id, path: %w[diagnosticCode], target: 'externalId'
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mirah
4
+ module Filters
5
+ # Input parameters and filters for queries returning {Data::DiagnosticCode} objects.
6
+ class DiagnosticCodeFilters < BaseObject
7
+ # @!attribute [r] external_id
8
+ # @return [Array<string>] An array of external identifiers to match.
9
+ attribute :external_id
10
+
11
+ # @!attribute [r] search
12
+ # @return [string] Smart search by name and other fields where appropriate
13
+ attribute :search
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mirah
4
+ module Filters
5
+ # Input parameters and filters for queries returning {Data::PatientCondition} objects.
6
+ class PatientConditionFilters < BaseObject
7
+ # @!attribute [r] external_id
8
+ # @return [Array<string>] An array of external identifiers to match.
9
+ attribute :external_id
10
+ end
11
+ end
12
+ end
@@ -107,6 +107,39 @@ module Mirah
107
107
  }
108
108
  }
109
109
  GRAPHQL
110
+
111
+ DiagnosticCodeFragment = Graphql::ValidationClient.parse <<-'GRAPHQL'
112
+ fragment on DiagnosticCode {
113
+ id
114
+ externalId
115
+ name
116
+ code
117
+ identifier {
118
+ value
119
+ }
120
+ }
121
+ GRAPHQL
122
+
123
+ PatientConditionFragment = Graphql::ValidationClient.parse <<-'GRAPHQL'
124
+ fragment on PatientCondition {
125
+ id
126
+ externalId
127
+ patient {
128
+ id
129
+ externalId
130
+ }
131
+ diagnosticCode {
132
+ id
133
+ externalId
134
+ }
135
+ identifier {
136
+ value
137
+ }
138
+ onsetDate
139
+ abatementDate
140
+ status
141
+ }
142
+ GRAPHQL
110
143
  end
111
144
  end
112
145
  end
@@ -67,6 +67,38 @@ module Mirah
67
67
  }
68
68
  }
69
69
  GRAPHQL
70
+
71
+ # Create or update a diagnostic code
72
+ CreateOrUpdateDiagnosticCodeMutation = Graphql::ValidationClient.parse <<-'GRAPHQL'
73
+ mutation($input: CreateOrUpdateDiagnosticCodeInput!) {
74
+ createOrUpdateDiagnosticCode(input: $input) {
75
+ status
76
+ errors {
77
+ path
78
+ message
79
+ }
80
+ result {
81
+ ...Mirah::Graphql::Fragments::DiagnosticCodeFragment
82
+ }
83
+ }
84
+ }
85
+ GRAPHQL
86
+
87
+ # Create or update a patient condition
88
+ CreateOrUpdatePatientConditionMutation = Graphql::ValidationClient.parse <<-'GRAPHQL'
89
+ mutation($input: CreateOrUpdatePatientConditionInput!) {
90
+ createOrUpdatePatientCondition(input: $input) {
91
+ status
92
+ errors {
93
+ path
94
+ message
95
+ }
96
+ result {
97
+ ...Mirah::Graphql::Fragments::PatientConditionFragment
98
+ }
99
+ }
100
+ }
101
+ GRAPHQL
70
102
  end
71
103
  end
72
104
  end
@@ -191,6 +191,98 @@ module Mirah
191
191
  }
192
192
  }
193
193
  GRAPHQL
194
+
195
+ #========================================================================
196
+ # DIAGNOSTIC CODE QUERIES
197
+ #========================================================================
198
+
199
+ DiagnosticCodeQuery = Graphql::ValidationClient.parse <<-'GRAPHQL'
200
+ query(
201
+ $first: Int
202
+ $last: Int
203
+ $after: String
204
+ $before: String,
205
+ $externalId: [String!],
206
+ $search: String
207
+ ) {
208
+ diagnosticCodes(
209
+ first: $first
210
+ after: $after
211
+ before: $before
212
+ last: $last,
213
+ externalId: $externalId,
214
+ search: $search
215
+ ) {
216
+ nodes {
217
+ ...Mirah::Graphql::Fragments::DiagnosticCodeFragment
218
+ }
219
+ pageInfo {
220
+ ...Mirah::Graphql::Fragments::PageInfoFragment
221
+ }
222
+ }
223
+ }
224
+ GRAPHQL
225
+
226
+ DiagnosticCodeIdQuery = Graphql::ValidationClient.parse <<-'GRAPHQL'
227
+ query($id: ID!) {
228
+ diagnosticCode(id: $id) {
229
+ ...Mirah::Graphql::Fragments::DiagnosticCodeFragment
230
+ }
231
+ }
232
+ GRAPHQL
233
+
234
+ DiagnosticCodeExternalIdQuery = Graphql::ValidationClient.parse <<-'GRAPHQL'
235
+ query($externalId: String!) {
236
+ diagnosticCodeExternal(externalId: $externalId) {
237
+ ...Mirah::Graphql::Fragments::DiagnosticCodeFragment
238
+ }
239
+ }
240
+ GRAPHQL
241
+
242
+ #========================================================================
243
+ # PATIENT CONDITION QUERIES
244
+ #========================================================================
245
+
246
+ PatientConditionQuery = Graphql::ValidationClient.parse <<-'GRAPHQL'
247
+ query(
248
+ $first: Int
249
+ $last: Int
250
+ $after: String
251
+ $before: String,
252
+ $externalId: [String!]
253
+ ) {
254
+ patientConditions(
255
+ first: $first
256
+ after: $after
257
+ before: $before
258
+ last: $last,
259
+ externalId: $externalId
260
+ ) {
261
+ nodes {
262
+ ...Mirah::Graphql::Fragments::PatientConditionFragment
263
+ }
264
+ pageInfo {
265
+ ...Mirah::Graphql::Fragments::PageInfoFragment
266
+ }
267
+ }
268
+ }
269
+ GRAPHQL
270
+
271
+ PatientConditionIdQuery = Graphql::ValidationClient.parse <<-'GRAPHQL'
272
+ query($id: ID!) {
273
+ patientCondition(id: $id) {
274
+ ...Mirah::Graphql::Fragments::PatientConditionFragment
275
+ }
276
+ }
277
+ GRAPHQL
278
+
279
+ PatientConditionExternalIdQuery = Graphql::ValidationClient.parse <<-'GRAPHQL'
280
+ query($externalId: String!) {
281
+ patientConditionExternal(externalId: $externalId) {
282
+ ...Mirah::Graphql::Fragments::PatientConditionFragment
283
+ }
284
+ }
285
+ GRAPHQL
194
286
  end
195
287
  end
196
288
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mirah
4
+ module Inputs
5
+ # A set of parameters for updating a {Data::DiagnosticCocde}
6
+ class DiagnosticCodeInput < BaseInputObject
7
+ # @!attribute [r] external_id
8
+ # @return (see Mirah::Data::DiagnosticCode#external_id)
9
+ input :external_id, required: true
10
+
11
+ # @!attribute [r] name
12
+ # @return (see Mirah::Data::DiagnosticCode#name)
13
+ input :name, required: false
14
+
15
+ # @!attribute [r] name
16
+ # @return (see Mirah::Data::DiagnosticCode#code)
17
+ input :code, required: false
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mirah
4
+ module Inputs
5
+ # A set of parameters for updating a {Data::Appointment}
6
+ class PatientConditionInput < BaseInputObject
7
+ # @!attribute [r] external_id
8
+ # @return (see Mirah::Data::PatientCondition#external_id)
9
+ input :external_id, required: true
10
+
11
+ # @!attribute [r] onset_date
12
+ # @return (see Mirah::Data::PatientCondition#onset_date)
13
+ input :onset_date, required: false, serializer: Serializers::DateTimeSerializer.new
14
+
15
+ # @!attribute [r] abatement_date
16
+ # @return (see Mirah::Data::PatientCondition#abatement_date)
17
+ input :abatement_date, required: false, serializer: Serializers::DateTimeSerializer.new
18
+
19
+ # @!attribute [r] status
20
+ # @return (see Mirah::Data::PatientCondition#status)
21
+ input :status, required: true
22
+
23
+ # @!attribute [r] external_patient_id
24
+ # @return (see Mirah::Data::PatientCondition#external_patient_id)
25
+ input :external_patient_id, required: false
26
+
27
+ # @!attribute [r] external_diagnostic_code_id
28
+ # @return (see Mirah::Data::PatientCondition#external_diagnostic_code_id)
29
+ input :external_diagnostic_code_id, required: false
30
+ end
31
+ end
32
+ end
data/lib/mirah/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mirah
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.0'
5
5
  end