first commit
This commit is contained in:
66
services/person/person.services.go
Normal file
66
services/person/person.services.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package person
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"sismedika.com/sas/westone/types"
|
||||
"sismedika.com/sas/westone/utils"
|
||||
)
|
||||
|
||||
func (h *Handler) getDisplayTerminology(person types.Person) (*types.PersonJSON, error) {
|
||||
ret := new(types.PersonJSON)
|
||||
err := utils.MatchStruct(person, ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if person.PersonBloodTypeCode != "" {
|
||||
blood, err := h.terminology.GetTerminologyDisplay(person.PersonBloodTypeCode, person.PersonBloodTypeSystem)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("blood")
|
||||
}
|
||||
ret.PersonBlood = *blood
|
||||
}
|
||||
|
||||
if person.PersonEducationCode != "" {
|
||||
education, err := h.terminology.GetTerminologyDisplay(person.PersonEducationCode, person.PersonEducationSystem)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("edu")
|
||||
}
|
||||
ret.PersonEducation = *education
|
||||
}
|
||||
|
||||
if person.PersonEtnicityCode != "" {
|
||||
etnicity, err := h.terminology.GetTerminologyDisplay(person.PersonEtnicityCode, person.PersonEtnicitySystem)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("etni")
|
||||
}
|
||||
ret.PersonEtnicity = *etnicity
|
||||
}
|
||||
|
||||
if person.PersonJobClassCode != "" {
|
||||
job, err := h.terminology.GetTerminologyDisplay(person.PersonJobClassCode, person.PersonJobClassSystem)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("job")
|
||||
}
|
||||
ret.PersonJobClass = *job
|
||||
}
|
||||
|
||||
if person.PersonReligionCode != "" {
|
||||
religion, err := h.terminology.GetTerminologyDisplay(person.PersonReligionCode, person.PersonReligionSystem)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("reli")
|
||||
}
|
||||
ret.PersonReligion = *religion
|
||||
}
|
||||
|
||||
if person.PersonRhesusCode != "" {
|
||||
rhesus, err := h.terminology.GetTerminologyDisplay(person.PersonRhesusCode, person.PersonRhesusSystem)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("rhes")
|
||||
}
|
||||
ret.PersonRhesus = *rhesus
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
Reference in New Issue
Block a user