From 809ea85dd591ba4f7c1cef46e513c5f8cb8473f1 Mon Sep 17 00:00:00 2001 From: Robin Muhia <109961694+robinmuhia@users.noreply.github.com> Date: Wed, 8 May 2024 12:53:55 +0300 Subject: [PATCH] fix: remove service code and add fields to identifiers and contacts (#38) --- healthcrm.go | 6 ++---- healthcrm_test.go | 16 +++++++++++----- input.go | 7 +++++++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/healthcrm.go b/healthcrm.go index 202bae9..f890f63 100644 --- a/healthcrm.go +++ b/healthcrm.go @@ -19,8 +19,6 @@ var ( const ( facilitiesPath = "/v1/facilities/facilities/" - // TODO: use an environment variable - crmServiceCode = "05" ) // HealthCRMLib interacts with the healthcrm APIs @@ -129,7 +127,7 @@ func (h *HealthCRMLib) UpdateFacility(ctx context.Context, id string, updatePayl // GetServices retrieves a list of healthcare services provided by facilities // that are owned by a specific SIL service, such as Mycarehub or Advantage. -func (h *HealthCRMLib) GetServices(ctx context.Context, pagination *Pagination) (*FacilityServicePage, error) { +func (h *HealthCRMLib) GetServices(ctx context.Context, pagination *Pagination, crmServiceCode string) (*FacilityServicePage, error) { path := "/v1/facilities/services/" queryParams := url.Values{} @@ -289,7 +287,7 @@ func (h *HealthCRMLib) LinkServiceToFacility(ctx context.Context, facilityID str // This will return a list of all facilities ordered by the proximity // // Example 3: Retrieve all facilities without specifying location or services: -func (h *HealthCRMLib) GetFacilities(ctx context.Context, location *Coordinates, serviceIDs []string, searchParameter string, pagination *Pagination) (*FacilityPage, error) { +func (h *HealthCRMLib) GetFacilities(ctx context.Context, location *Coordinates, serviceIDs []string, searchParameter string, pagination *Pagination, crmServiceCode string) (*FacilityPage, error) { queryParams := url.Values{} if pagination != nil { diff --git a/healthcrm_test.go b/healthcrm_test.go index 3e5e51f..bf35396 100644 --- a/healthcrm_test.go +++ b/healthcrm_test.go @@ -181,6 +181,7 @@ func TestHealthCRMLib_GetFacilities(t *testing.T) { serviceIDs []string pagination *Pagination searchParameter string + crmServiceCode string } tests := []struct { name string @@ -200,6 +201,7 @@ func TestHealthCRMLib_GetFacilities(t *testing.T) { Page: "1", PageSize: "10", }, + crmServiceCode: "05", }, wantErr: false, }, @@ -216,6 +218,7 @@ func TestHealthCRMLib_GetFacilities(t *testing.T) { Page: "1", PageSize: "10", }, + crmServiceCode: "05", }, wantErr: false, }, @@ -232,6 +235,7 @@ func TestHealthCRMLib_GetFacilities(t *testing.T) { Page: "1", PageSize: "10", }, + crmServiceCode: "05", }, wantErr: false, }, @@ -411,7 +415,7 @@ func TestHealthCRMLib_GetFacilities(t *testing.T) { t.Errorf("unable to initialize sdk: %v", err) } - _, err = h.GetFacilities(tt.args.ctx, tt.args.location, tt.args.serviceIDs, tt.args.searchParameter, tt.args.pagination) + _, err = h.GetFacilities(tt.args.ctx, tt.args.location, tt.args.serviceIDs, tt.args.searchParameter, tt.args.pagination, tt.args.crmServiceCode) if (err != nil) != tt.wantErr { t.Errorf("HealthCRMLib.GetFacilities() error = %v, wantErr %v", err, tt.wantErr) return @@ -641,9 +645,10 @@ func TestHealthCRMLib_UpdateFacility(t *testing.T) { func TestHealthCRMLib_GetServices(t *testing.T) { type args struct { - ctx context.Context - facilityID string - pagination *Pagination + ctx context.Context + facilityID string + pagination *Pagination + crmServiceCode string } tests := []struct { name string @@ -658,6 +663,7 @@ func TestHealthCRMLib_GetServices(t *testing.T) { Page: "2", PageSize: "5", }, + crmServiceCode: "05", }, wantErr: false, }, @@ -737,7 +743,7 @@ func TestHealthCRMLib_GetServices(t *testing.T) { t.Errorf("unable to initialize sdk: %v", err) } - _, err = h.GetServices(tt.args.ctx, tt.args.pagination) + _, err = h.GetServices(tt.args.ctx, tt.args.pagination, tt.args.crmServiceCode) if (err != nil) != tt.wantErr { t.Errorf("HealthCRMLib.GetServices() error = %v, wantErr %v", err, tt.wantErr) return diff --git a/input.go b/input.go index 1a41276..4ac2ab2 100644 --- a/input.go +++ b/input.go @@ -2,6 +2,7 @@ package healthcrm import ( "fmt" + "time" ) // Facility is the hospitals data class @@ -100,10 +101,16 @@ type ProfileInput struct { type ProfileIdentifierInput struct { IdentifierType IdentifierType `json:"identifier_type"` IdentifierValue string `json:"identifier_value"` + Verified bool `json:"verified"` + ValidFrom time.Time `json:"valid_from,omitempty"` + ValidTo time.Time `json:"valid_to,omitempty"` } // ProfileContanctInput is used to create profile(s) contact(s) type ProfileContactInput struct { ContactType ContactType `json:"contact_type"` ContactValue string `json:"contact_value"` + Verified bool `json:"verified"` + ValidFrom time.Time `json:"valid_from,omitempty"` + ValidTo time.Time `json:"valid_to,omitempty"` }