git clone https://github.com/xwjahahahaha/woodpecker.git
starport serve -v
实现链上的电子医疗病历的CRUD, 解决电子病历链上共享与隐私保护。
(仓库仅cosmos模块代码,但提供了接口可自行实现前端)
链上登陆
病历被分为三部分存储Attribute、MedicalHistory、BodyIndex
hashkey字段为病历唯一key,Attribute、BodyIndex没有创建create直接set即可,所以没有ID(没有创建就是创建,创建过了就是修改)
MedicalHistory创建需要使用create,其有ID字段,即表示一个病人的病历会有多个
$ woodpeckercli tx woodpecker set-attribute [name] [idNumber] [address] [job] [nation] [hashKey] [flags] --from user
$ woodpeckercli tx woodpecker set-attribute xwj 123 cq it china 1902 --from user1 -y
all:
$ woodpeckercli query woodpecker list-attribute
one:
$ woodpeckercli query woodpecker list-attribute [hashKey]
$ woodpeckercli tx woodpecker set-attribute [name] [idNumber] [address] [job] [nation] [hashKey] [flags] --from user
同创建
$ woodpeckercli tx woodpecker delete-attribute [hashKey]
# 查
# one
your IP:1317/woodpecker/attribute/[hashKey]
# all
your IP:1317/woodpecker/attribute
交易通过接口无法签名,可以通过前端js实现cosmosJs
$ woodpeckercli tx woodpecker create-medicalHistory 协和医院 2021/03/14 精神科 脑子 小阳 深井冰 放弃治疗 1902 --from user1 -y
$ woodpeckercli query woodpecker list-all-medicalHistory
$ woodpeckercli query woodpecker list-medicalHistory 1902
1902:
xwj:
$ woodpeckercli query woodpecker get-medicalHistory [hashKey] [id]
$ woodpeckercli query woodpecker get-medicalHistory 1902 0
$ woodpeckercli tx woodpecker set-medicalHistory [id] [medicalInstitutionName] [diagnosisTime] [diagnosisDepartment] [diagnosisType] [diagnosisDoctor] [diagnosisResult] [treatmentOptions] [hashKey] [flags]
$ woodpeckercli tx woodpecker set-medicalHistory 0 北京医院 2021/4/10 骨科 骨质疏松 小阳 骨头坏死 截肢 1902 --from user1 -y
再次查询:
$ woodpeckercli tx woodpecker delete-medicalHistory [id] [hashKey]
$ woodpeckercli tx woodpecker delete-medicalHistory 4 xwj --from user1 -y
再次查询;
注意:需要交易的方法(创建、修改、删除)都需要本地签名才会生效, 建议前端使用cosmosjs
# Then sign this transaction
# NOTE: In a real environment the raw transaction should be signed on the client side. Also the sequence needs to be adjusted, depending on what the query of user2's account has shown.
woodpeckercli tx sign unsignedTx.json --from user1 --offline --chain-id namechain --sequence 1 --account-number 0 > signedTx.json
# And finally broadcast the signed transaction
woodpeckercli tx broadcast signedTx.json
URL : IP Address:1317/woodpecker/medicalHistory
POST
Data Simple:
{
"base_req": {
"from": "cosmos15qfsrthwsfu378m5epe2fzggsu5m7r7d0yexep",
"chain_id": "woodpacker"
},
"creator": "cosmos15qfsrthwsfu378m5epe2fzggsu5m7r7d0yexep",
"medicalInstitutionName": "南京和谐",
"diagnosisTime": "2021/08/24",
"diagnosisDepartment": "dkaskd",
"diagnosisType": "脑壳",
"diagnosisDoctor": "小样",
"diagnosisResult": "deal",
"treatmentOptions": "ldsl",
"hash_key": "xwj"
}
URL: IP Address:1317/woodpecker/medicalHistory
GET
result simple:
{
"height": "0",
"result": [
{
"creator": "cosmos1r304rwx7z4vh6yz4wkp4utwchg03ymc6rw45je",
"id": "0",
"medicalInstitutionName": "协和医院",
"diagnosisTime": "2021/03/14",
"diagnosisDepartment": "精神科",
"diagnosisType": "脑子",
"diagnosisDoctor": "小阳",
"diagnosisResult": "深井冰",
"treatmentOptions": "放弃治疗"
},
{
"creator": "cosmos1r304rwx7z4vh6yz4wkp4utwchg03ymc6rw45je",
"id": "1",
"medicalInstitutionName": "协和医院",
"diagnosisTime": "2021/03/14",
"diagnosisDepartment": "精神科",
"diagnosisType": "脑子",
"diagnosisDoctor": "小阳",
"diagnosisResult": "深井冰",
"treatmentOptions": "放弃治疗"
}
]
}
URL: IP Address:1317/woodpecker/medicalHistory/[hashKey]
GET
URL: IP Address:1317/woodpecker/medicalHistory/[hashKey]/[id]
GET
URL: IP Address:1317/woodpecker/medicalHistory
PUT
Data Sample:
{
"base_req": {
"from": "cosmos1x7acsyd53mmjc3znwt8xw2ju3vpwm6gku7muu0",
"chain_id": "woodpacker"
},
"creator": "cosmos1x7acsyd53mmjc3znwt8xw2ju3vpwm6gku7muu0",
"medicalInstitutionName": "xxxx",
"diagnosisTime": "xxxxxs",
"diagnosisDepartment": "dkaskd",
"diagnosisType": "xxxxx",
"diagnosisDoctor": "小样",
"diagnosisResult": "deal",
"treatmentOptions": "ldsl",
"hash_key": "xwj",
"id": "3"
}
URL: IP Address:1317/woodpecker/medicalHistory
DELET
Data Sample:
{
"base_req": {
"from": "cosmos1x7acsyd53mmjc3znwt8xw2ju3vpwm6gku7muu0",
"chain_id": "woodpacker"
},
"creator": "cosmos1x7acsyd53mmjc3znwt8xw2ju3vpwm6gku7muu0",
"hash_key": "xwj",
"id": "3"
}
参数较长建议使用文件
$ woodpeckercli tx woodpecker set-bodyIndex [age] [sex] [nation] [weight] [height] [weightIndex] [obesityWaistline] [waistline] [maxBloodPressure] [minBloodPressure] [goodCholesterol] [batCholesterol] [totalCholesterol] [Dyslipidemia] [pvd] [sportActivities] [education] [marry] [income] [sourceCase] [visionBad] [drink] [highBloodPressure] [familialHighBloodPressure] [diabetes] [familialDiabetes] [hepatitis] [familialHepatitis] [chronicFatigue] [alf] [hashKey]
$ woodpeckercli tx woodepecker set-bodyIndex $(<data.txt)
# all
$ woodpeckercli query woodpecker list-bodyIndex
# one
$ woodpeckercli query woodpecker list-bodyIndex [hashKey]
$ woodpeckercli tx woodpecker delete-bodyIndex [hashKey]
# all
IP:1317/woodpecker/attribute
# one
IP:1317/woodpecker/attribute/[hashKey]