// GetDiseasesFromIDs - Interface to the'getDisease' view of the DB
// Return the diseases informations from their IDs
Interface to the'getDisease' view of the DB
Return the diseases informations from their IDs
// GetDiseasesFromIDs - Interface to the ' getDisease ' view of the DB // Return the diseases informations from their IDs
func GetDiseasesFromIDs(diseasesIDs []float64) ([]*Models.Disease, error) {
	IDList, err := json.Marshal(diseasesIDs)
	if err != nil {
		return nil, fmt.Errorf("Error while converting IDs array to json :\n	==>  %v", err)
	}
	params := url.Values{"keys": []string{strings.Replace(fmt.Sprint(IDList), " ", ", ", -1)}}
	queryResults := viewResponse{}
	err = db.GetView("diseases", "GetDiseases", &queryResults, &params)
	if err != nil {
		return nil, fmt.Errorf("Error while Querying Orpha:\n	==>  %v", err)
	}
	var diseasesArray []*Models.Disease
	for _, row := range queryResults.Rows {
		tmpDisease := new(Models.Disease)
		tmpDisease.Name = row.Value["Name"].(map[string]interface{})["text"].(string)
		tmpDisease.OrphaID = row.Value["OrphaNumber"].(float64)
		tmpDisease.Sources = append(tmpDisease.Sources, "Orpha")
		diseasesArray = append(diseasesArray, tmpDisease)
	}
	return diseasesArray, err
}
func GetDiseasesFromIDs ( diseasesIDs [ ] float64 ) ( [ ] * Models . Disease , error ) { IDList , err := json . Marshal ( diseasesIDs ) if err != nil { return nil , fmt . Errorf ( " \n " , err ) } params := url . Values { " " : [ ] string { strings . Replace ( fmt . Sprint ( IDList ) , " " , " " , - 1 ) } } queryResults := viewResponse { } err = db . GetView ( " " , " " , & queryResults , & params ) if err != nil { return nil , fmt . Errorf ( " \n " , err ) } var diseasesArray [ ] * Models . Disease for _ , row := range queryResults . Rows { tmpDisease := new ( Models . Disease ) tmpDisease . Name = row . Value [ " " ] . ( map [ string ] interface { } ) [ " " ] . ( string ) tmpDisease . OrphaID = row . Value [ " " ] . ( float64 ) tmpDisease . Sources = append ( tmpDisease . Sources , " " ) diseasesArray = append ( diseasesArray , tmpDisease ) } return diseasesArray , err }
Interface to the'getDisease' view of the DB
Return the diseases informations from their IDs
Interface to the ' getDisease ' view of the DB Return the diseases informations from their IDs
// Build ID json array // Make the request to couchDB // Put diseases from queryResults in diseasesArray // Get all the diseases from queryResults, format them and put them in diseasesArray