# Path: sites/rfh/coded_values/drugs.py

# 
# Path: gloss/message_type.py
# class Field(object):
# class GlossMessageMeta(type):
# class MessageContainer(object):
# class MessageType(six.with_metaclass(GlossMessageMeta)):
# class PatientMessage(MessageType):
# class PatientMergeMessage(MessageType):
# class AllergyMessage(MessageType):
# class ObservationMessage(MessageType):
# class ResultMessage(MessageType):
# class OrderMessage(MessageType):
# class InpatientAdmissionMessage(MessageType):
# class InpatientAdmissionTransferMessage(InpatientAdmissionMessage):
# class InpatientAdmissionDeleteMessage(MessageType):
#     def __init__(self, required=False):
#     def __new__(cls, name, bases, attrs):
#     def __init__(self, messages, hospital_number, issuing_source):
#     def to_dict(self):
# def construct_message_container(
#     someMessages, hospital_number, issuing_source="uclh"
# ):
#     def __init__(self, **kwargs):
#     def to_dict(self):
#         def to_dict_or_not_to_dict(some_value):
#     def __init__(
#         self, **kwargs
#     ):
#     def to_dict(self):
#     def __init__(self, **kw):
# 
# Path: gloss/importers/file_importer.py
# class FileType(SafelImporter):
#     """
#     Base class for Files that we'll be processing
#     with Gloss
#     """
#     def __init__(self, path):
#         self.path = path


import datetime
from sites.rfh.coded_values import drugs
from gloss import message_type
from gloss.importers.file_importer import FileType


class RFHBloodCulturesFileType(FileType):

    def _to_date(self, datestr):
        return datetime.datetime.strptime(datestr, '%d/%m/%Y')

    def res(self, row):
        return [
            u"{0} {1}".format(drugs.abbreviations[a], getattr(row, a))
            for a in drugs.abbreviations if getattr(row, a) in ('R', 'r')
        ]

    def sens(self, row):
        return [
            u"{0} {1}".format(drugs.abbreviations[a], getattr(row, a))
            for a in drugs.abbreviations if getattr(row, a) in ('S', 's')
        ]

    def row_to_result_message(self, row):

# Path: sites/rfh/coded_values/drugs.py

# 
# Path: gloss/message_type.py
# class Field(object):
# class GlossMessageMeta(type):
# class MessageContainer(object):
# class MessageType(six.with_metaclass(GlossMessageMeta)):
# class PatientMessage(MessageType):
# class PatientMergeMessage(MessageType):
# class AllergyMessage(MessageType):
# class ObservationMessage(MessageType):
# class ResultMessage(MessageType):
# class OrderMessage(MessageType):
# class InpatientAdmissionMessage(MessageType):
# class InpatientAdmissionTransferMessage(InpatientAdmissionMessage):
# class InpatientAdmissionDeleteMessage(MessageType):
#     def __init__(self, required=False):
#     def __new__(cls, name, bases, attrs):
#     def __init__(self, messages, hospital_number, issuing_source):
#     def to_dict(self):
# def construct_message_container(
#     someMessages, hospital_number, issuing_source="uclh"
# ):
#     def __init__(self, **kwargs):
#     def to_dict(self):
#         def to_dict_or_not_to_dict(some_value):
#     def __init__(
#         self, **kwargs
#     ):
#     def to_dict(self):
#     def __init__(self, **kw):
# 
# Path: gloss/importers/file_importer.py
# class FileType(SafelImporter):
#     """
#     Base class for Files that we'll be processing
#     with Gloss
#     """
#     def __init__(self, path):
#         self.path = path


# Path: sites/rfh/importers/file_importer.py
import datetime
from sites.rfh.coded_values import drugs
from gloss import message_type
from gloss.importers.file_importer import FileType



class RFHBloodCulturesFileType(FileType):

    def _to_date(self, datestr):
        return datetime.datetime.strptime(datestr, '%d/%m/%Y')

    def res(self, row):
        return [
            u"{0} {1}".format(drugs.abbreviations[a], getattr(row, a))
            for a in drugs.abbreviations if getattr(row, a) in ('R', 'r')
        ]

    def sens(self, row):
        return [
            u"{0} {1}".format(drugs.abbreviations[a], getattr(row, a))
            for a in drugs.abbreviations if getattr(row, a) in ('S', 's')
        ]

    def row_to_result_message(self, row):

        return message_type.ResultMessage(