package com.agilex.healthcare.schedulingmanager.mdws.translator;

import com.agilex.healthcare.schedulingmanager.mdws.MdwsResponseException;
import com.agilex.healthcare.schedulingmanager.mdws.generatedwsdl.emrservice.TaggedText;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by scottchun on 8/27/14.
 */
public class SpecialtiesTranslator {
    public Map<String, String> translate(TaggedText arr) {
        Map<String, String> retValue = new HashMap<String, String>();
        if (arr == null)
            throw new MdwsResponseException(MdwsResponseException.UserMessages.INVALID_DATA_RETURNED, "Specialties was null");
        if (arr.getFault() != null)
            throw new MdwsResponseException(arr.getFault());

        List<TaggedText> taggedTextList = arr.getTaggedResults() == null ? null : arr.getTaggedResults().getTaggedText();
        if (taggedTextList == null || taggedTextList.size() == 0) {
            return retValue;
        }

        for (TaggedText taggedText: taggedTextList) {
            retValue.put(taggedText.getTag(), taggedText.getText());
        }

        return retValue;
    }
}
