107 lines
4.1 KiB
Go
107 lines
4.1 KiB
Go
package source
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"encoding/json"
|
||
|
|
"fmt"
|
||
|
|
"strings"
|
||
|
|
)
|
||
|
|
|
||
|
|
type healthRecordEnvelope struct {
|
||
|
|
Code int `json:"code"`
|
||
|
|
Message string `json:"msg"`
|
||
|
|
Compress bool `json:"compress"`
|
||
|
|
Data HealthRecordTask `json:"data"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// HealthRecordTask is one PHIS health-record upload task. Credentials returned
|
||
|
|
// under data.doctor are deliberately absent from this model.
|
||
|
|
type HealthRecordTask struct {
|
||
|
|
Doctor Doctor `json:"doctor"`
|
||
|
|
Record HealthRecord `json:"record"`
|
||
|
|
ArchID string `json:"archId"`
|
||
|
|
BusinessID string `json:"businessId"`
|
||
|
|
EMPIID string `json:"empiId"`
|
||
|
|
PHRID string `json:"phrId"`
|
||
|
|
CardNo string `json:"cardNo"`
|
||
|
|
CardType string `json:"cardType"`
|
||
|
|
}
|
||
|
|
|
||
|
|
type Doctor struct {
|
||
|
|
RealName string `json:"realName"`
|
||
|
|
DoctorID string `json:"doctorId"`
|
||
|
|
}
|
||
|
|
|
||
|
|
type HealthRecord struct {
|
||
|
|
HomePlace string `json:"homePlace"`
|
||
|
|
DeadFlag string `json:"deadFlag"`
|
||
|
|
IDCard string `json:"idCard"`
|
||
|
|
MobileNumber string `json:"mobileNumber"`
|
||
|
|
InputUser string `json:"inputUser"`
|
||
|
|
MaritalStatusCode string `json:"maritalStatusCode"`
|
||
|
|
WorkCode string `json:"workCode"`
|
||
|
|
Contact string `json:"contact"`
|
||
|
|
WaterSourceCode string `json:"shhjCheckYS"`
|
||
|
|
ManaUnitID string `json:"manaUnitId"`
|
||
|
|
PastDiseaseCode string `json:"diseasetext_radio_jb"`
|
||
|
|
FamilyMother string `json:"diseasetextCheckMQ"`
|
||
|
|
FamilySiblings string `json:"diseasetextCheckXDJM"`
|
||
|
|
InputDate string `json:"inputDate"`
|
||
|
|
GeneticDisease string `json:"diseasetextRedioYCBS"`
|
||
|
|
FamilyChildren string `json:"diseasetextCheckZN"`
|
||
|
|
BloodTypeCode string `json:"bloodTypeCode"`
|
||
|
|
CreateUnit string `json:"createUnit"`
|
||
|
|
DrugAllergy string `json:"diseasetext_check_gm"`
|
||
|
|
Birthday string `json:"birthday"`
|
||
|
|
SignFlag string `json:"signFlag"`
|
||
|
|
RhBloodCode string `json:"rhBloodCode"`
|
||
|
|
IsFillSHHJ string `json:"isFillShhj"`
|
||
|
|
EducationCode string `json:"educationCode"`
|
||
|
|
InsuranceCode string `json:"insuranceCode"`
|
||
|
|
InputUnit string `json:"inputUnit"`
|
||
|
|
RegionCode string `json:"regionCode"`
|
||
|
|
FamilyFather string `json:"diseasetext_check_fq"`
|
||
|
|
ExposureHistory string `json:"diseasetext_check_bl"`
|
||
|
|
WorkPlace string `json:"workPlace"`
|
||
|
|
NationCode string `json:"nationCode"`
|
||
|
|
CreateDate string `json:"createDate"`
|
||
|
|
RegisteredPermanent string `json:"registeredPermanent"`
|
||
|
|
Address string `json:"address"`
|
||
|
|
HomePlaceNumber string `json:"homePlaceNumber"`
|
||
|
|
CardType string `json:"cardType"`
|
||
|
|
UpdatedAt string `json:"updateTime"`
|
||
|
|
CookAirTool string `json:"shhjCheckCFPFSS"`
|
||
|
|
Disability string `json:"diseasetextCheckCJ"`
|
||
|
|
PersonName string `json:"personName"`
|
||
|
|
SexCode string `json:"sexCode"`
|
||
|
|
Washroom string `json:"shhjCheckCS"`
|
||
|
|
ManaDoctorID string `json:"manaDoctorId"`
|
||
|
|
AddressNumber string `json:"adressNumber"`
|
||
|
|
PastTransfusionCode string `json:"diseasetext_sx"`
|
||
|
|
CreateTime string `json:"createTime"`
|
||
|
|
PastSurgeryCode string `json:"diseasetext_ss"`
|
||
|
|
CreateUser string `json:"createUser"`
|
||
|
|
ContactPhone string `json:"contactPhone"`
|
||
|
|
PastTraumaCode string `json:"diseasetext_ws"`
|
||
|
|
FuelType string `json:"shhjCheckRLLX"`
|
||
|
|
LivestockColumn string `json:"shhjCheckQCL"`
|
||
|
|
}
|
||
|
|
|
||
|
|
func DecodeHealthRecordTask(raw []byte) (HealthRecordTask, error) {
|
||
|
|
var envelope healthRecordEnvelope
|
||
|
|
if err := json.Unmarshal(raw, &envelope); err != nil {
|
||
|
|
return HealthRecordTask{}, fmt.Errorf("decode PHIS health record: %w", err)
|
||
|
|
}
|
||
|
|
if envelope.Code != 200 {
|
||
|
|
return HealthRecordTask{}, fmt.Errorf("phis response code=%d message=%s", envelope.Code, envelope.Message)
|
||
|
|
}
|
||
|
|
envelope.Data.ArchID = strings.TrimSpace(envelope.Data.ArchID)
|
||
|
|
if envelope.Data.ArchID == "" {
|
||
|
|
return HealthRecordTask{}, fmt.Errorf("archId is required")
|
||
|
|
}
|
||
|
|
return envelope.Data, nil
|
||
|
|
}
|
||
|
|
|
||
|
|
func (t HealthRecordTask) SourceRecordID() string {
|
||
|
|
return t.ArchID
|
||
|
|
}
|