Skip to content

Commit

Permalink
fix: remove service code and add fields to identifiers and contacts (#38
Browse files Browse the repository at this point in the history
)
  • Loading branch information
robinmuhia committed May 8, 2024
1 parent 9327b95 commit 809ea85
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
6 changes: 2 additions & 4 deletions healthcrm.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ var (

const (
facilitiesPath = "/v1/facilities/facilities/"
// TODO: use an environment variable
crmServiceCode = "05"
)

// HealthCRMLib interacts with the healthcrm APIs
Expand Down Expand Up @@ -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{}
Expand Down Expand Up @@ -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 {
Expand Down
16 changes: 11 additions & 5 deletions healthcrm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ func TestHealthCRMLib_GetFacilities(t *testing.T) {
serviceIDs []string
pagination *Pagination
searchParameter string
crmServiceCode string
}
tests := []struct {
name string
Expand All @@ -200,6 +201,7 @@ func TestHealthCRMLib_GetFacilities(t *testing.T) {
Page: "1",
PageSize: "10",
},
crmServiceCode: "05",
},
wantErr: false,
},
Expand All @@ -216,6 +218,7 @@ func TestHealthCRMLib_GetFacilities(t *testing.T) {
Page: "1",
PageSize: "10",
},
crmServiceCode: "05",
},
wantErr: false,
},
Expand All @@ -232,6 +235,7 @@ func TestHealthCRMLib_GetFacilities(t *testing.T) {
Page: "1",
PageSize: "10",
},
crmServiceCode: "05",
},
wantErr: false,
},
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -658,6 +663,7 @@ func TestHealthCRMLib_GetServices(t *testing.T) {
Page: "2",
PageSize: "5",
},
crmServiceCode: "05",
},
wantErr: false,
},
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions input.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package healthcrm

import (
"fmt"
"time"
)

// Facility is the hospitals data class
Expand Down Expand Up @@ -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"`
}

0 comments on commit 809ea85

Please sign in to comment.