Skip to content

Commit

Permalink
fix: change time unmasharlling to date (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
robinmuhia authored Nov 22, 2024
1 parent 51e9ca3 commit 4027439
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 24 deletions.
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/jarcoal/httpmock v1.3.1
github.com/savannahghi/authutils v0.0.10
github.com/savannahghi/enumutils v0.0.6
github.com/savannahghi/scalarutils v0.0.4
github.com/savannahghi/serverutils v0.0.7
github.com/sirupsen/logrus v1.8.1
)
Expand All @@ -28,6 +29,7 @@ require (
firebase.google.com/go v3.13.0+incompatible // indirect
github.com/99designs/gqlgen v0.13.0 // indirect
github.com/agnivade/levenshtein v1.0.3 // indirect
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/aws/aws-sdk-go v1.37.0 // indirect
github.com/census-instrumentation/opencensus-proto v0.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand All @@ -54,6 +56,7 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/savannahghi/errorcodeutil v0.0.5 // indirect
github.com/savannahghi/firebasetools v0.0.19 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/stretchr/testify v1.7.0 // indirect
github.com/ugorji/go/codec v1.1.7 // indirect
github.com/vektah/gqlparser/v2 v2.1.0 // indirect
Expand Down
7 changes: 7 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kd
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q=
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ=
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
github.com/aws/aws-sdk-go v1.37.0 h1:GzFnhOIsrGyQ69s7VgqtrG2BG8v7X7vwB3Xpbd/DBBk=
github.com/aws/aws-sdk-go v1.37.0/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
Expand Down Expand Up @@ -255,6 +257,7 @@ github.com/google/pprof v0.0.0-20220113144219-d25a53d42d00 h1:hQb7P4XOakoaN+LET7
github.com/google/pprof v0.0.0-20220113144219-d25a53d42d00/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
Expand Down Expand Up @@ -379,13 +382,17 @@ github.com/savannahghi/errorcodeutil v0.0.5 h1:LrOLsEW1ZgA8PhJIXFCVOofm0hJFVOdd0
github.com/savannahghi/errorcodeutil v0.0.5/go.mod h1:l2OVW1VE45rmEOLKQHnGnJ0gsSo60VCyErfm2Vfl4v0=
github.com/savannahghi/firebasetools v0.0.19 h1:NIsC2NRdk8DhgQ4J7dGd5jeV9fiHoYiBYw7DTVjwskQ=
github.com/savannahghi/firebasetools v0.0.19/go.mod h1:QZfM+Ts0Ub2UhCS5L9IszvtGIyKQTstWpzBvCwMihAo=
github.com/savannahghi/scalarutils v0.0.4 h1:UT0a5zl1ByzV4+W7hYjGlIyLmILmpJV/Wgc39sGVc6U=
github.com/savannahghi/scalarutils v0.0.4/go.mod h1:Z+Dl3wc3vy5zKvthctHAtYzol1p8w27zEVRfOYueoks=
github.com/savannahghi/serverutils v0.0.4/go.mod h1:3VCEJ8BTHf/DW3WFjLqV4SznzrXaul/As2RJ5eNOO7U=
github.com/savannahghi/serverutils v0.0.7 h1:+7ZDVG1jASPqfjlyPXb8zlL221epw78ZXw/66JS208s=
github.com/savannahghi/serverutils v0.0.7/go.mod h1:QTqJJaNk3Rmtl2RV9ltxERjvv7WPkMJyieX18TKYDG8=
github.com/schollz/closestmatch v2.1.0+incompatible/go.mod h1:RtP1ddjLong6gTkbtmuhtR2uUrrJOpYzYRvbcPAid+g=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw=
Expand Down
63 changes: 52 additions & 11 deletions healthcrm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/jarcoal/httpmock"
"github.com/savannahghi/authutils"
"github.com/savannahghi/enumutils"
"github.com/savannahghi/scalarutils"
"github.com/savannahghi/serverutils"
)

Expand Down Expand Up @@ -1622,7 +1623,7 @@ func TestHealthCRMLib_GetPersonIdentifiers(t *testing.T) {
name: "Happy case: get list of identifiers",
args: args{
ctx: context.Background(),
healthID: "5113010000018400",
healthID: "0000010000000041",
identifierType: nil,
},
wantErr: false,
Expand All @@ -1640,7 +1641,7 @@ func TestHealthCRMLib_GetPersonIdentifiers(t *testing.T) {
name: "Sad case: invalid identifier",
args: args{
ctx: context.Background(),
healthID: "5113010000018400",
healthID: "0000010000000041",
identifierType: []*IdentifierType{
&invalid,
},
Expand All @@ -1651,7 +1652,7 @@ func TestHealthCRMLib_GetPersonIdentifiers(t *testing.T) {
name: "Sad case: invalid identifier",
args: args{
ctx: context.Background(),
healthID: "5113010000018400",
healthID: "0000010000000041",
identifierType: []*IdentifierType{
&payer,
&invalid,
Expand All @@ -1663,7 +1664,7 @@ func TestHealthCRMLib_GetPersonIdentifiers(t *testing.T) {
name: "Sad case: unable to make request",
args: args{
ctx: context.Background(),
healthID: "5113010000018400",
healthID: "0000010000000041",
identifierType: []*IdentifierType{
&payer,
&nhif,
Expand All @@ -1675,15 +1676,15 @@ func TestHealthCRMLib_GetPersonIdentifiers(t *testing.T) {
name: "Sad case: invalid status code",
args: args{
ctx: context.Background(),
healthID: "5113010000018400",
healthID: "0000010000000041",
identifierType: nil,
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
path := fmt.Sprintf("%s/v1/identities/persons/5113010000018400/identifiers/", BaseURL)
path := fmt.Sprintf("%s/v1/identities/persons/0000010000000041/identifiers/", BaseURL)

if tt.name == "Happy case: get list of identifiers" {
httpmock.RegisterResponder(http.MethodGet, path, func(r *http.Request) (*http.Response, error) {
Expand All @@ -1701,6 +1702,16 @@ func TestHealthCRMLib_GetPersonIdentifiers(t *testing.T) {
ExternalID: uuid.New().String(),
SladeCode: "1234",
},
ValidFrom: &scalarutils.Date{
Month: 1,
Day: 1,
Year: 2020,
},
ValidTo: &scalarutils.Date{
Month: 1,
Day: 1,
Year: 2020,
},
},
{
IdentifierType: IdentifierTypeNationalID,
Expand All @@ -1714,6 +1725,16 @@ func TestHealthCRMLib_GetPersonIdentifiers(t *testing.T) {
ExternalID: uuid.New().String(),
SladeCode: "1234",
},
ValidFrom: &scalarutils.Date{
Month: 1,
Day: 1,
Year: 2020,
},
ValidTo: &scalarutils.Date{
Month: 1,
Day: 1,
Year: 2020,
},
},
},
}
Expand Down Expand Up @@ -1773,7 +1794,7 @@ func TestHealthCRMLib_GetPersonContacts(t *testing.T) {
name: "Happy case: get list of contacts",
args: args{
ctx: context.Background(),
healthID: "5113010000018400",
healthID: "0000010000000041",
},
wantErr: false,
},
Expand All @@ -1789,30 +1810,30 @@ func TestHealthCRMLib_GetPersonContacts(t *testing.T) {
name: "Sad case: invalid identifier",
args: args{
ctx: context.Background(),
healthID: "5113010000018400",
healthID: "0000010000000041",
},
wantErr: true,
},
{
name: "Sad case: unable to make request",
args: args{
ctx: context.Background(),
healthID: "5113010000018400",
healthID: "0000010000000041",
},
wantErr: true,
},
{
name: "Sad case: invalid status code",
args: args{
ctx: context.Background(),
healthID: "5113010000018400",
healthID: "0000010000000041",
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
path := fmt.Sprintf("%s/v1/identities/persons/5113010000018400/contacts/", BaseURL)
path := fmt.Sprintf("%s/v1/identities/persons/0000010000000041/contacts/", BaseURL)

if tt.name == "Happy case: get list of contacts" {
httpmock.RegisterResponder(http.MethodGet, path, func(r *http.Request) (*http.Response, error) {
Expand All @@ -1830,6 +1851,16 @@ func TestHealthCRMLib_GetPersonContacts(t *testing.T) {
ExternalID: uuid.New().String(),
SladeCode: "1234",
},
ValidFrom: &scalarutils.Date{
Month: 1,
Day: 1,
Year: 2020,
},
ValidTo: &scalarutils.Date{
Month: 1,
Day: 1,
Year: 2020,
},
},
{
ContactType: ContactTypeEmail,
Expand All @@ -1843,6 +1874,16 @@ func TestHealthCRMLib_GetPersonContacts(t *testing.T) {
ExternalID: uuid.New().String(),
SladeCode: "1234",
},
ValidFrom: &scalarutils.Date{
Month: 1,
Day: 1,
Year: 2020,
},
ValidTo: &scalarutils.Date{
Month: 1,
Day: 1,
Year: 2020,
},
},
},
}
Expand Down
30 changes: 17 additions & 13 deletions output.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package healthcrm

import "time"
import (
"time"

"github.com/savannahghi/scalarutils"
)

// FacilityPage is the hospitals model used to show facility details
type FacilityPage struct {
Expand Down Expand Up @@ -133,12 +137,12 @@ type Profile struct {

// ProfileIdentifierOutput is used to display profile(s) identifier(s)
type ProfileIdentifierOutput 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"`
Profile Profile `json:"profile"`
IdentifierType IdentifierType `json:"identifier_type"`
IdentifierValue string `json:"identifier_value"`
Verified bool `json:"verified"`
ValidFrom *scalarutils.Date `json:"valid_from,omitempty"`
ValidTo *scalarutils.Date `json:"valid_to,omitempty"`
Profile Profile `json:"profile"`
}

// ProfileIdentifierOutputs is used to get a list of identifiers
Expand All @@ -148,12 +152,12 @@ type ProfileIdentifierOutputs struct {

// ProfileContactOutput is used to display profile(s) contact(s)
type ProfileContactOutput 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"`
Profile Profile `json:"profile"`
ContactType ContactType `json:"contact_type"`
ContactValue string `json:"contact_value"`
Verified bool `json:"verified"`
ValidFrom *scalarutils.Date `json:"valid_from,omitempty"`
ValidTo *scalarutils.Date `json:"valid_to,omitempty"`
Profile Profile `json:"profile"`
}

// ProfileContactOutputs is used to get a list of contacts
Expand Down

0 comments on commit 4027439

Please sign in to comment.