feat(mapping): 完成 PHIS 健康档案转换(T-212)
This commit is contained in:
Vendored
+23
@@ -12,6 +12,8 @@ type DictionarySnapshot struct {
|
||||
regionByName map[string]string
|
||||
doctorByName map[string]string
|
||||
orgByName map[string]string
|
||||
doctorIDs map[string]struct{}
|
||||
orgIDs map[string]struct{}
|
||||
}
|
||||
|
||||
type PublicClient interface {
|
||||
@@ -42,15 +44,19 @@ func NewDictionarySnapshot(grids []osi.GridAddress, doctors []osi.Doctor, orgs [
|
||||
regionByName: make(map[string]string, len(grids)),
|
||||
doctorByName: make(map[string]string, len(doctors)),
|
||||
orgByName: make(map[string]string, len(orgs)),
|
||||
doctorIDs: make(map[string]struct{}, len(doctors)),
|
||||
orgIDs: make(map[string]struct{}, len(orgs)),
|
||||
}
|
||||
for _, row := range grids {
|
||||
put(snapshot.regionByName, row.RegionName, row.RegionCode)
|
||||
}
|
||||
for _, row := range doctors {
|
||||
put(snapshot.doctorByName, row.PersonName, row.PersonID)
|
||||
putID(snapshot.doctorIDs, row.PersonID)
|
||||
}
|
||||
for _, row := range orgs {
|
||||
put(snapshot.orgByName, row.OrganizName, row.OrganizCode)
|
||||
putID(snapshot.orgIDs, row.OrganizCode)
|
||||
}
|
||||
return snapshot
|
||||
}
|
||||
@@ -102,6 +108,16 @@ func (s DictionarySnapshot) ManaUnitIDByName(name string) (string, bool) {
|
||||
return lookup(s.orgByName, name)
|
||||
}
|
||||
|
||||
func (s DictionarySnapshot) DoctorIDExists(id string) bool {
|
||||
_, ok := s.doctorIDs[strings.TrimSpace(id)]
|
||||
return ok
|
||||
}
|
||||
|
||||
func (s DictionarySnapshot) ManaUnitIDExists(id string) bool {
|
||||
_, ok := s.orgIDs[strings.TrimSpace(id)]
|
||||
return ok
|
||||
}
|
||||
|
||||
func put(index map[string]string, name string, code string) {
|
||||
name = strings.TrimSpace(name)
|
||||
code = strings.TrimSpace(code)
|
||||
@@ -113,6 +129,13 @@ func put(index map[string]string, name string, code string) {
|
||||
}
|
||||
}
|
||||
|
||||
func putID(index map[string]struct{}, id string) {
|
||||
id = strings.TrimSpace(id)
|
||||
if id != "" {
|
||||
index[id] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
func lookup(index map[string]string, name string) (string, bool) {
|
||||
code, ok := index[strings.TrimSpace(name)]
|
||||
return code, ok
|
||||
|
||||
Reference in New Issue
Block a user