-
Notifications
You must be signed in to change notification settings - Fork 0
/
enums.go
159 lines (134 loc) · 3.82 KB
/
enums.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
package healthcrm
import (
"fmt"
"io"
"strconv"
)
type IdentifierType string
type ContactType string
type GenderType string
const (
// Identifier types
IdentifierTypeNationalID IdentifierType = "NATIONAL_ID"
IdentifierTypePassportNo IdentifierType = "PASSPORT_NO"
IdentifierTypeMilitaryID IdentifierType = "MILITARY_ID"
IdentifierTypeAlienID IdentifierType = "ALIEN_ID"
IdentifierTypeNHIFNo IdentifierType = "NHIF_NO"
IdentifierTypePatientNo IdentifierType = "PATIENT_NO"
IdentifierTypePayerMemberNo IdentifierType = "PAYER_MEMBER_NO"
IdentifierTypeSmartMemberNo IdentifierType = "SMART_MEMBER_NO"
IdentifierTypeFHIRPatientID IdentifierType = "FHIR_PATIENT_ID"
IdentifierTypeERPCustomerID IdentifierType = "ERP_CUSTOMER_ID"
IdentifierTypeCCCNumber IdentifierType = "CCC_NUMBER"
)
const (
ContactTypePhoneNumber ContactType = "PHONE_NUMBER"
ContactTypeEmail ContactType = "EMAIL"
)
const (
GenderTypeMale GenderType = "MALE"
GenderTypeFemale GenderType = "FEMALE"
GenderTypeOther GenderType = "OTHER"
// GenderTypeASKU stands for Asked but Unknown
GenderTypeASKU GenderType = "ASKU"
// GenderTypeUNK stands for Unknown
GenderTypeUNK GenderType = "UNK"
)
// IsValid returns true if a contact type is valid
func (f ContactType) IsValid() bool {
switch f {
case ContactTypePhoneNumber, ContactTypeEmail:
return true
default:
return false
}
}
// String converts the contact type enum to a string
func (f ContactType) String() string {
return string(f)
}
// UnmarshalGQL converts the supplied value to a contact type.
func (f *ContactType) UnmarshalGQL(v interface{}) error {
str, ok := v.(string)
if !ok {
return fmt.Errorf("enums must be strings")
}
*f = ContactType(str)
if !f.IsValid() {
return fmt.Errorf("%s is not a valid ContactType type", str)
}
return nil
}
// MarshalGQL writes the contact type to the supplied writer
func (f ContactType) MarshalGQL(w io.Writer) {
fmt.Fprint(w, strconv.Quote(f.String()))
}
// IsValid returns true if an identifier type is valid
func (f IdentifierType) IsValid() bool {
switch f {
case
IdentifierTypeNationalID,
IdentifierTypePassportNo,
IdentifierTypeMilitaryID,
IdentifierTypeAlienID,
IdentifierTypeNHIFNo,
IdentifierTypePatientNo,
IdentifierTypePayerMemberNo,
IdentifierTypeSmartMemberNo,
IdentifierTypeFHIRPatientID,
IdentifierTypeERPCustomerID,
IdentifierTypeCCCNumber:
return true
default:
return false
}
}
// String converts the identifier type enum to a string
func (f IdentifierType) String() string {
return string(f)
}
// UnmarshalGQL converts the supplied value to an identifier type.
func (f *IdentifierType) UnmarshalGQL(v interface{}) error {
str, ok := v.(string)
if !ok {
return fmt.Errorf("enums must be strings")
}
*f = IdentifierType(str)
if !f.IsValid() {
return fmt.Errorf("%s is not a valid IdentifierType type", str)
}
return nil
}
// MarshalGQL writes the identifier type to the supplied writer
func (f IdentifierType) MarshalGQL(w io.Writer) {
fmt.Fprint(w, strconv.Quote(f.String()))
}
// IsValid returns true if a Gender type is valid
func (f GenderType) IsValid() bool {
switch f {
case GenderTypeMale, GenderTypeFemale, GenderTypeOther, GenderTypeASKU, GenderTypeUNK:
return true
default:
return false
}
}
// String converts the Gender type enum to a string
func (f GenderType) String() string {
return string(f)
}
// UnmarshalGQL converts the supplied value to a Gender type.
func (f *GenderType) UnmarshalGQL(v interface{}) error {
str, ok := v.(string)
if !ok {
return fmt.Errorf("enums must be strings")
}
*f = GenderType(str)
if !f.IsValid() {
return fmt.Errorf("%s is not a valid ContactType type", str)
}
return nil
}
// MarshalGQL writes the gender type to the supplied writer
func (f GenderType) MarshalGQL(w io.Writer) {
fmt.Fprint(w, strconv.Quote(f.String()))
}