Class: Mirah::Client
- Inherits:
-
Object
- Object
- Mirah::Client
- Defined in:
- lib/mirah/client.rb
Overview
A client designed to communicate with the Mirah system in a constrained set of well defined ways. This is a front to the more general Graphql backend which is available.
Patient Methods
Organization Methods
Practitioner Methods
Appointment Methods
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Access to the underlying graphql client.
Instance Method Summary collapse
-
#find_appointment(id) ⇒ Data::Appointment?
Find an appointment by the given Mirah internal UUID.
-
#find_appointment_by_external_id(external_id) ⇒ Data::Appointment?
Find an appointment by your external id.
-
#find_diagnostic_code(id) ⇒ Data::DiagnosticCode?
Find an diagnostic code by the given Mirah internal UUID.
-
#find_diagnostic_code_by_external_id(external_id) ⇒ Data::DiagnosticCode?
Find a diagnostic code by your external id.
-
#find_organization(id) ⇒ Data::Organization?
Find an organization by the given Mirah internal UUID.
-
#find_organization_by_external_id(external_id) ⇒ Data::Organization?
Find an organization by your external id.
-
#find_patient(id) ⇒ Data::Patient?
Find a patient by the given Mirah internal UUID.
-
#find_patient_by_external_id(external_id) ⇒ Data::Patient?
Find a patient by your external id.
-
#find_patient_condition(id) ⇒ Data::PatientCondition?
Find an condition by the given Mirah internal UUID.
-
#find_patient_condition_by_external_id(external_id) ⇒ Data::PatientCondition?
Find a condition by your external id.
-
#find_practitioner(id) ⇒ Data::Practitioner?
Find an practitioner by the given Mirah internal UUID.
-
#find_practitioner_by_external_id(external_id) ⇒ Data::Practitioner?
Find an practitioner by your external id.
-
#initialize(host:, user_id:, access_token:) ⇒ Client
constructor
Construct a new Client with the given host and credentials.
-
#push_appointment(external_id:, status:, **input_values) ⇒ PushResult<Data::Appointment>
Create or update an appointment.
-
#push_diagnostic_code(external_id:, **input_values) ⇒ PushResult<Data::DiagnosticCode>
Create or update a diagnosis code.
-
#push_organization(external_id:, **input_values) ⇒ PushResult<Data::Organization>
Create or update an organization.
-
#push_patient(external_id:, **input_values) ⇒ PushResult<Data::Patient>
Create or update a patient.
-
#push_patient_condition(external_id:, **input_values) ⇒ PushResult<Data::PatientCondition>
Create or update a condition.
-
#push_practitioner(external_id:, **input_values) ⇒ PushResult<Data::Practitioner>
Create or update an practitioner.
-
#query_appointments(external_id: nil, status: nil) ⇒ Collection<Data::Appointment>
A collection of pageable appointments.
-
#query_diagnostic_codes(external_id: nil, search: nil) ⇒ Collection<Data::Appointment>
Query for diagnostic codes.
-
#query_organizations(external_id: nil, search: nil) ⇒ Collection<Data::Organization>
A collection of pageable organizations.
-
#query_patient_conditions(external_id: nil) ⇒ Collection<Data::Appointment>
Query for conditions.
-
#query_patients(external_id: nil, search: nil) ⇒ Collection<Data::Patient>
Query for patients.
-
#query_practitioners(external_id: nil, search: nil) ⇒ Collection<Data::Practitioner>
Query for practitioners.
Constructor Details
#initialize(host:, user_id:, access_token:) ⇒ Client
Construct a new Client with the given host and credentials.
42 43 44 45 |
# File 'lib/mirah/client.rb', line 42 def initialize(host:, user_id:, access_token:) @client = Graphql.create_client(host: host) @client_context = { user_id: user_id, access_token: access_token } end |
Instance Attribute Details
#client ⇒ Object (readonly)
Access to the underlying graphql client. You may use this for advanced queries that are not provided as part of the standard library.
49 50 51 |
# File 'lib/mirah/client.rb', line 49 def client @client end |
Instance Method Details
#find_appointment(id) ⇒ Data::Appointment?
Find an appointment by the given Mirah internal UUID. This method should be used if you already know the Mirah identifier. If you wish to query by your own system identifier, you should use #find_appointment_by_external_id
249 250 251 |
# File 'lib/mirah/client.rb', line 249 def find_appointment(id) query_record(Graphql::Queries::AppointmentIdQuery, id, Data::Appointment, 'appointment') end |
#find_appointment_by_external_id(external_id) ⇒ Data::Appointment?
Find an appointment by your external id. This is a convenience method. If you wish to query a list of appointments by external id, please use #query_appointments.
259 260 261 262 263 264 |
# File 'lib/mirah/client.rb', line 259 def find_appointment_by_external_id(external_id) query_record_by_external_id(Graphql::Queries::AppointmentExternalIdQuery, external_id, Data::Appointment, 'appointmentExternal') end |
#find_diagnostic_code(id) ⇒ Data::DiagnosticCode?
Find an diagnostic code by the given Mirah internal UUID. This method should be used if you already know the Mirah identifier. If you wish to query by your own system identifier, you should use #find_diagnostic_code_by_external_id
316 317 318 |
# File 'lib/mirah/client.rb', line 316 def find_diagnostic_code(id) query_record(Graphql::Queries::DiagnosticCodeIdQuery, id, Data::DiagnosticCode, 'diagnosticCode') end |
#find_diagnostic_code_by_external_id(external_id) ⇒ Data::DiagnosticCode?
Find a diagnostic code by your external id. This is a convenience method. If you wish to query a list of codes by external id, please use #query_diagnostic_codes.
326 327 328 329 330 331 |
# File 'lib/mirah/client.rb', line 326 def find_diagnostic_code_by_external_id(external_id) query_record_by_external_id(Graphql::Queries::DiagnosticCodeExternalIdQuery, external_id, Data::DiagnosticCode, 'diagnosticCodeExternal') end |
#find_organization(id) ⇒ Data::Organization?
Find an organization by the given Mirah internal UUID. This method should be used if you already know the Mirah identifier. If you wish to query by your own system identifier, you should use #find_organization_by_external_id
126 127 128 |
# File 'lib/mirah/client.rb', line 126 def find_organization(id) query_record(Graphql::Queries::OrganizationIdQuery, id, Data::Organization, 'organization') end |
#find_organization_by_external_id(external_id) ⇒ Data::Organization?
Find an organization by your external id. This is a convenience method. If you wish to query a list of organizations by external id, please use #query_organizations.
136 137 138 139 140 141 |
# File 'lib/mirah/client.rb', line 136 def find_organization_by_external_id(external_id) query_record_by_external_id(Graphql::Queries::OrganizationExternalIdQuery, external_id, Data::Organization, 'organizationExternal') end |
#find_patient(id) ⇒ Data::Patient?
Find a patient by the given Mirah internal UUID. This method should be used if you already know the Mirah identifier. If you wish to query by your own system identifier, you should use #find_patient_by_external_id
61 62 63 |
# File 'lib/mirah/client.rb', line 61 def find_patient(id) query_record(Graphql::Queries::PatientIdQuery, id, Data::Patient, 'patient') end |
#find_patient_by_external_id(external_id) ⇒ Data::Patient?
Find a patient by your external id. This is a convenience method. If you wish to query a list of patients by external id, please use #query_patients.
71 72 73 74 75 76 |
# File 'lib/mirah/client.rb', line 71 def find_patient_by_external_id(external_id) query_record_by_external_id(Graphql::Queries::PatientExternalIdQuery, external_id, Data::Patient, 'patientExternal') end |
#find_patient_condition(id) ⇒ Data::PatientCondition?
Find an condition by the given Mirah internal UUID. This method should be used if you already know the Mirah identifier. If you wish to query by your own system identifier, you should use #find_patient_condition_by_external_id
375 376 377 |
# File 'lib/mirah/client.rb', line 375 def find_patient_condition(id) query_record(Graphql::Queries::PatientConditionIdQuery, id, Data::PatientCondition, 'patientCondition') end |
#find_patient_condition_by_external_id(external_id) ⇒ Data::PatientCondition?
Find a condition by your external id. This is a convenience method. If you wish to query a list of codes by external id, please use #query_patient_conditions.
385 386 387 388 389 390 |
# File 'lib/mirah/client.rb', line 385 def find_patient_condition_by_external_id(external_id) query_record_by_external_id(Graphql::Queries::PatientConditionExternalIdQuery, external_id, Data::PatientCondition, 'patientConditionExternal') end |
#find_practitioner(id) ⇒ Data::Practitioner?
Find an practitioner by the given Mirah internal UUID. This method should be used if you already know the Mirah identifier. If you wish to query by your own system identifier, you should use #find_practitioner_by_external_id
184 185 186 |
# File 'lib/mirah/client.rb', line 184 def find_practitioner(id) query_record(Graphql::Queries::PractitionerIdQuery, id, Data::Practitioner, 'practitioner') end |
#find_practitioner_by_external_id(external_id) ⇒ Data::Practitioner?
Find an practitioner by your external id. This is a convenience method. If you wish to query a list of practitioners by external id, please use #query_practitioners.
194 195 196 197 198 199 |
# File 'lib/mirah/client.rb', line 194 def find_practitioner_by_external_id(external_id) query_record_by_external_id(Graphql::Queries::PractitionerExternalIdQuery, external_id, Data::Practitioner, 'practitionerExternal') end |
#push_appointment(external_id:, status:, **input_values) ⇒ PushResult<Data::Appointment>
Create or update an appointment. You must specify an external identifier, all other parameters are optional, but you may receive errors if you attempt to specify too few parameters for an appointment that does not exist.
299 300 301 302 303 |
# File 'lib/mirah/client.rb', line 299 def push_appointment(external_id:, status:, **input_values) mutate(Graphql::Mutations::CreateOrUpdateAppointmentMutation, Inputs::AppointmentInput.new(input_values.merge(external_id: external_id, status: status)), Data::Appointment, 'createOrUpdateAppointment') end |
#push_diagnostic_code(external_id:, **input_values) ⇒ PushResult<Data::DiagnosticCode>
Create or update a diagnosis code. You must specify an external identifier, all other parameters are optional, but you may receive errors if you attempt to specify too few parameters for an appointment that does not exist.
358 359 360 361 362 |
# File 'lib/mirah/client.rb', line 358 def push_diagnostic_code(external_id:, **input_values) mutate(Graphql::Mutations::CreateOrUpdateDiagnosticCodeMutation, Inputs::DiagnosticCodeInput.new(input_values.merge(external_id: external_id)), Data::DiagnosticCode, 'createOrUpdateDiagnosticCode') end |
#push_organization(external_id:, **input_values) ⇒ PushResult<Data::Organization>
Create or update an organization. You must specify an external identifier, all other parameters are optional, but you may receive errors if you attempt to specify too few parameters for an organization that does not exist.
168 169 170 171 172 |
# File 'lib/mirah/client.rb', line 168 def push_organization(external_id:, **input_values) mutate(Graphql::Mutations::CreateOrUpdateOrganizationMutation, Inputs::OrganizationInput.new(input_values.merge(external_id: external_id)), Data::Organization, 'createOrUpdateOrganization') end |
#push_patient(external_id:, **input_values) ⇒ PushResult<Data::Patient>
Create or update a patient. You must specify an external identifier, all other parameters are optional, but you may receive errors if you attempt to specify too few parameters for a patient that does not exist.
110 111 112 113 114 |
# File 'lib/mirah/client.rb', line 110 def push_patient(external_id:, **input_values) mutate(Graphql::Mutations::CreateOrUpdatePatientMutation, Inputs::PatientInput.new(input_values.merge(external_id: external_id)), Data::Patient, 'createOrUpdatePatient') end |
#push_patient_condition(external_id:, **input_values) ⇒ PushResult<Data::PatientCondition>
Create or update a condition. You must specify an external identifier, all other parameters are optional, but you may receive errors if you attempt to specify too few parameters for an appointment that does not exist.
416 417 418 419 420 |
# File 'lib/mirah/client.rb', line 416 def push_patient_condition(external_id:, **input_values) mutate(Graphql::Mutations::CreateOrUpdatePatientConditionMutation, Inputs::PatientConditionInput.new(input_values.merge(external_id: external_id)), Data::PatientCondition, 'createOrUpdatePatientCondition') end |
#push_practitioner(external_id:, **input_values) ⇒ PushResult<Data::Practitioner>
Create or update an practitioner. You must specify an external identifier, all other parameters are optional, but you may receive errors if you attempt to specify too few parameters for an practitioner that does not exist.
233 234 235 236 237 |
# File 'lib/mirah/client.rb', line 233 def push_practitioner(external_id:, **input_values) mutate(Graphql::Mutations::CreateOrUpdatePractitionerMutation, Inputs::PractitionerInput.new(input_values.merge(external_id: external_id)), Data::Practitioner, 'createOrUpdatePractitioner') end |
#query_appointments(external_id: nil, status: nil) ⇒ Collection<Data::Appointment>
Returns a collection of pageable appointments.
273 274 275 276 277 278 279 280 281 |
# File 'lib/mirah/client.rb', line 273 def query_appointments(external_id: nil, status: nil) query_connection( Graphql::Queries::AppointmentQuery, Filters::AppointmentFilters.new(external_id: external_id, status: status), Filters::Paging.default, Data::Appointment, 'appointments' ) end |
#query_diagnostic_codes(external_id: nil, search: nil) ⇒ Collection<Data::Appointment>
Query for diagnostic codes. You may specify a set of parameters as defined in Filters::DiagnosticCodeFilters. Results are returned in a paginated format. See Mirah::Collection for how to page results.
340 341 342 343 344 345 346 347 348 |
# File 'lib/mirah/client.rb', line 340 def query_diagnostic_codes(external_id: nil, search: nil) query_connection( Graphql::Queries::DiagnosticCodeQuery, Filters::DiagnosticCodeFilters.new(external_id: external_id, search: search), Filters::Paging.default, Data::DiagnosticCode, 'diagnosticCodes' ) end |
#query_organizations(external_id: nil, search: nil) ⇒ Collection<Data::Organization>
Returns a collection of pageable organizations.
150 151 152 153 154 155 156 157 158 |
# File 'lib/mirah/client.rb', line 150 def query_organizations(external_id: nil, search: nil) query_connection( Graphql::Queries::OrganizationQuery, Filters::OrganizationFilters.new(external_id: external_id, search: search), Filters::Paging.default, Data::Organization, 'organizations' ) end |
#query_patient_conditions(external_id: nil) ⇒ Collection<Data::Appointment>
Query for conditions. You may specify a set of parameters as defined in Filters::PatientConditionFilters. Results are returned in a paginated format. See Mirah::Collection for how to page results.
398 399 400 401 402 403 404 405 406 |
# File 'lib/mirah/client.rb', line 398 def query_patient_conditions(external_id: nil) query_connection( Graphql::Queries::PatientConditionQuery, Filters::PatientConditionFilters.new(external_id: external_id), Filters::Paging.default, Data::PatientCondition, 'patientConditions' ) end |
#query_patients(external_id: nil, search: nil) ⇒ Collection<Data::Patient>
Query for patients. You may specify a set of parameters as defined in Filters::PatientFilters. Results are returned in a paginated format. See Mirah::Collection for how to page results.
85 86 87 88 89 90 91 92 93 |
# File 'lib/mirah/client.rb', line 85 def query_patients(external_id: nil, search: nil) query_connection( Graphql::Queries::PatientQuery, Filters::PatientFilters.new(external_id: external_id, search: search), Filters::Paging.default, Data::Patient, 'patients' ) end |
#query_practitioners(external_id: nil, search: nil) ⇒ Collection<Data::Practitioner>
Query for practitioners. You may specify a set of parameters as defined in Filters::PractitionerFilters. Results are returned in a paginated format. See Mirah::Collection for how to page results.
208 209 210 211 212 213 214 215 216 |
# File 'lib/mirah/client.rb', line 208 def query_practitioners(external_id: nil, search: nil) query_connection( Graphql::Queries::PractitionerQuery, Filters::PractitionerFilters.new(external_id: external_id, search: search), Filters::Paging.default, Data::Practitioner, 'practitioners' ) end |