This repository has been archived by the owner on Nov 16, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
encounter.go
61 lines (57 loc) · 2.54 KB
/
encounter.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
package golem
import "github.com/mitchellh/mapstructure"
// GetEncounterMethod returns a EncounterMethod object
// Acceptable search queries:
// ID, String
func GetEncounterMethod(query string) EncounterMethod {
searchType := idOrString(query)
encounterMethod := EncounterMethod{}
if checkCache("encounter-method", query, searchType) {
mapstructure.Decode(getDataCache("encounter-method", query, searchType, encounterMethod), &encounterMethod)
} else {
dataInterface = getDataAPI("encounter-method", query, encounterMethod)
if dataInterface != nil {
mapstructure.Decode(dataInterface, &encounterMethod)
storeData(false, encounterMethod, "encounter-method", encounterMethod.ID, encounterMethod.Name)
}
}
return encounterMethod
}
// GetEncounterCondition returns a EncounterCondition object
// Acceptable search queries:
// ID, String
func GetEncounterCondition(query string) EncounterCondition {
searchType := idOrString(query)
encounterCondition := EncounterCondition{}
if checkCache("encounter-condition", query, searchType) {
mapstructure.Decode(getDataCache("encounter-condition", query, searchType, encounterCondition), &encounterCondition)
} else {
dataInterface = getDataAPI("encounter-condition", query, encounterCondition)
if dataInterface != nil {
mapstructure.Decode(dataInterface, &encounterCondition)
storeData(false, encounterCondition, "encounter-condition", encounterCondition.ID, encounterCondition.Name)
}
}
for _, ecf := range encounterCondition.Values {
encounterCondition.GetValues = append(encounterCondition.GetValues, getEncounterConditionValue(ecf.Name))
}
return encounterCondition
}
// GetEncounterConditionValue returns a EncounterConditionValue object
// Acceptable search queries:
// ID, String
func GetEncounterConditionValue(query string) EncounterConditionValue {
searchType := idOrString(query)
encounterConditionValue := EncounterConditionValue{}
if checkCache("encounter-condition-value", query, searchType) {
mapstructure.Decode(getDataCache("encounter-condition-value", query, searchType, encounterConditionValue), &encounterConditionValue)
} else {
dataInterface = getDataAPI("encounter-condition-value", query, encounterConditionValue)
if dataInterface != nil {
mapstructure.Decode(dataInterface, &encounterConditionValue)
storeData(false, encounterConditionValue, "encounter-condition-value", encounterConditionValue.ID, encounterConditionValue.Name)
}
}
encounterConditionValue.GetCondition = getEncounterCondition(encounterConditionValue.Condition.Name)
return encounterConditionValue
}