```go
package service
import (
"fmt"
"github.com/hyperledger/fabric-sdk-go/pkg/client/channel"
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/fab"
"time"
)
type Health struct {
ObjectType string `json:"docType"`
EntityID string `json:"EntityID"`
Name string `json:"Name"`
Sex string `json:"Sex"`
Stunumber string `json:"Stunumber"`
EnrollDate string `json:"EnrollDate"`
GraduationDate string `json:"GraduationDate"`
SchoolName string `json:"SchoolName"`
College string `json:"College"`
Major string `json:"Major"`
QuaType string `json:"QuaType"`
Length string `json:"Length"`
Photo string `json:"Photo"`
Height float64 `json:"Height"`
Weight float64 `json:"Weight"`
Vol float64 `json:"Vol"`
Vor float64 `json:"Vor"`
Colorblindness string `json:"Colorblindness"`
Earsick string `json:"Earsick"`
Nose string `json:"Nose"`
Stutter bool `json:"Stutter"`
Teeth string `json:"Teeth"`
Waistline float64 `json:"Waistline"`
Skin string `json:"Skin"`
Thyroid string `json:"Thyroid"`
Spine string `json:"Spine"`
Joints string `json:"Joints"`
Flatfoot bool `json:"Flatfoot"`
Pulse float64 `json:"Pulse"`
Mental string `json:"Mental"`
Lungsrespiratory string `json:"Lungsrespiratory"`
Heartbloodvessel string `json:"Heartbloodvessel"`
Liver string `json:"Liver"`
Spleen string `json:"Spleen"`
Other string `json:"Other"`
Persion string `json:"Persion"`
Date time.Time `json:"Date"`
Historys []HistoryItem
}
type HistoryItem struct {
Txid string
Health Health
}
type ServiceSetup struct {
ChaincodeID string
Client *channel.Client
}
func regitserEvent(client *channel.Client, chaincodeID, eventID string) (fab.Registration, <-chan *fab.CCEvent) {
reg, notifier, err := client.RegisterChaincodeEvent(chaincodeID, eventID)
if err != nil {
fmt.Println("注册链码事件失败: %s", err)
}
return reg, notifier
}
func eventResult(notifier <-chan *fab.CCEvent, eventID string) error {
select {
case ccEvent := <-notifier:
fmt.Printf("接收到链码事件: %v\n", ccEvent)
case <-time.After(time.Second * 20):
return fmt.Errorf("不能根据指定的事件ID接收到相应的链码事件(%s)", eventID)
}
return nil
}