func (p *Parser) ParseSinglePathway(pathwayDefinition []byte) (Pathway, error) {
	pathway := Pathway{}
	pathwayName := UnknownPathwayName
	err := yaml.UnmarshalStrict(pathwayDefinition, &pathway)
	if err != nil {
		var m map[string]Pathway
		err := yaml.UnmarshalStrict(pathwayDefinition, &m)
		if err != nil {
			return Pathway{}, errors.Wrap(err, "cannot unmarshal pathway")
		}
		if len(m) != 1 {
			return Pathway{}, fmt.Errorf("too many pathways: found %d, expected 1", len(m))
		}
		for k, v := range m {  
			pathway = v
			pathwayName = k
		}
	}
	pathway.Init(pathwayName)
	if err := pathway.Valid(p.Clock, p.OrderProfiles, p.Doctors, p.LocationManager, p.Valid); err != nil {
		return Pathway{}, errors.Wrap(err, "invalid pathway")
	}
	pathway, err = pathway.Runnable()
	if err != nil {
		return Pathway{}, errors.Wrap(err, "cannot run Runnable on pathway")
	}
	return pathway, nil
}
ParseSinglePathway parses the given pathway definition as a YAML or JSON format definition for a Pathway,
or as a YAML or JSON format definition for a map with a single Pathway.
In that second case, the returned pathway will have a name.
The returned pathway is initialised and runnable.
package pathway
import (
	"context"
	"fmt"
	"path/filepath"
	"github.com/pkg/errors"
	"gopkg.in/yaml.v2"
	"github.com/google/simhospital/pkg/clock"
	"github.com/google/simhospital/pkg/doctor"
	"github.com/google/simhospital/pkg/files"
	"github.com/google/simhospital/pkg/location"
	"github.com/google/simhospital/pkg/orderprofile"
)
const UnknownPathwayName = "unknown_pathway"
var validExtensions = []string{".json", ".yml", ".yaml"}
type Parser struct {
	Clock clock.Clock
	OrderProfiles *orderprofile.OrderProfiles
	Doctors *doctor.Doctors
	Valid func(*Pathway) error
	LocationManager *location.Manager
}
func (p *Parser) ParsePathways(ctx context.Context, pathwaysDir string) (map[string]Pathway, error) {
	logLocal := log.WithField("pathway_dir", pathwaysDir)
	logLocal.Info("Parsing pathways from directory")
	files, err := files.List(ctx, pathwaysDir)
	if err != nil {
		return nil, errors.Wrapf(err, "Failed to read pathways files from %s", pathwaysDir)
	}
	validPathways := map[string]Pathway{}
	redeclaredPathways := make(map[string]bool, 0)
	for _, file := range files {
		if !fileExtensionIsValid(file.Name()) {
			log.Warnf("File name has invalid extension %s, expected one of %+v. Skipping...", file.Name(), validExtensions)
			continue
		}
		logLocal := logLocal.WithField("pathway_file", file.Name())
		logLocal.Info("Parsing pathways from file")
		p, err := p.parse(ctx, file)
		if err != nil {
			return nil, errors.Wrapf(err, "Failed to parse pathway file %s", file.Name())
		}
		for pathwayName, pathway := range p {
			logLocal := logLocal.WithField("pathway_name", pathwayName)
			if _, ok := validPathways[pathwayName]; ok {
				logLocal.Error("Pathway re-declared")
				redeclaredPathways[pathwayName] = true
				continue
			}
			logLocal.Debug("Adding pathway")
			validPathways[pathwayName] = pathway
		}
	}
	if len(validPathways) == 0 {
		return nil, fmt.Errorf("cannot load pathways from %s: no valid pathways", pathwaysDir)
	}
	if len(redeclaredPathways) > 0 {
		return nil, fmt.Errorf("cannot load pathways from %s: found re-declared pathways: %v", pathwaysDir, redeclaredPathways)
	}
	return validPathways, nil
}