# Path: gloss/tests/test_messages.py
# COMPLEX_WINPATH_RESULT = r"""
# MSH|^~\&|Corepoint|TDL|UCLH|UCLH|201411261546||ORU^R01|1126154698U000057|P|2.3
# PID||^^NHS|50031772^^HOSP|C2130015640^^OASIS|TEST^TEST||19870912|M
# PV1|||HAEM^HAEMATOLOGY OUTPATIENTS^^^^^^^OP||||||HC1^COHEN DR H
# ORC|RE|98U000057|98U000057||CM||||201411261546
# OBR|1|98U000057|98U000057|FBCY^FULL BLOOD COUNT^WinPath||201411121606|201411121600|||||||||HC1^COHEN DR H||||||201411121608||H1|F
# OBX|1|NM|WCC^White cell count^Winpath||8.00|x10\S\9/L|3.0-10.0||||F
# OBX|2|NM|RCC^Red cell count^Winpath||3.20|x10\S\12/L|4.4-5.8|L|||F
# OBX|3|NM|HBGL^Haemoglobin (g/L)^Winpath||87|g/L|||||F
# OBX|4|NM|HCTU^HCT^Winpath||0.350|L/L|0.37-0.50|L|||F
# OBX|5|NM|MCVU^MCV^Winpath||78.0|fL|80-99|L|||F
# OBX|6|NM|MCHU^MCH^Winpath||28.0|pg|27.0-33.5||||F
# OBX|7|NM|MCGL^MCHC (g/L)^Winpath||300|g/L|||||F
# OBX|8|NM|RDWU^RDW^Winpath||17.0|%|11.5-15.0|H|||F
# OBX|9|NM|PLT^Platelet count^Winpath||250|x10\S\9/L|150-400||||F
# OBX|10|NM|MPVU^MPV^Winpath||10.0|fL|7-13||||F
# OBR|2|98U000057|98U000057|FBCZ^DIFFERENTIAL^WinPath||201411121606|201411121600|||||||||HC1^COHEN DR H||||||201411121609||H1|F
# OBX|1|NM|NE^Neutrophils^Winpath||55.0%  4.40|x10\S\9/L|2.0-7.5||||F
# OBX|2|NM|LY^Lymphocytes^Winpath||25.0%  2.00|x10\S\9/L|1.2-3.65||||F
# OBX|3|NM|MO^Monocytes^Winpath||15.0%  1.20|x10\S\9/L|0.2-1.0|H|||F
# OBX|4|NM|EO^Eosinophils^Winpath||3.0%  0.24|x10\S\9/L|0.0-0.4||||F
# OBX|5|NM|BA^Basophils^Winpath||2.0%  0.16|x10\S\9/L|0.0-0.1|H|||F
# """
# 
# def read_message(some_msg):
#     return hl7.parse(some_msg.replace("\n", "\r"))
# 
# Path: gloss/importers/hl7_importer.py
# class HL7Importer(SafelImporter):
#     def import_message(self, msg, gloss_service):
#         hl7 = hl7_translator.HL7Translator.translate(msg)
#         importer = HL7TranslationToMessage.get_for_hl7(hl7)
#         if importer:
#             processed_messages = importer.import_hl7()
#             hospital_number = importer.get_hospital_number()
#             return messages.MessageContainer(
#                 messages=processed_messages,
#                 hospital_number=hospital_number,
#                 issuing_source=gloss_service.issuing_source
#             )
# 
# 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):


import datetime
import mock
from unittest import TestCase
from gloss.tests.test_messages import (
    COMPLEX_WINPATH_RESULT, read_message
)
from gloss.importers.hl7_importer import HL7Importer
from gloss import message_type
                                 'reference_range': u'0.0-0.4',
                                 'result_status': None,
                                 'test_code': u'EO',
                                 'test_name': u'Eosinophils',
                                 'units': u'x10^9/L',
                                 'value_type': u'NM'},
                                {'comments': None,
                                 'observation_value': u'2.0%  0.16',
                                 'reference_range': u'0.0-0.1',
                                 'result_status': None,
                                 'test_code': u'BA',
                                 'test_name': u'Basophils',
                                 'units': u'x10^9/L',
                                 'value_type': u'NM'}],
               'profile_code': u'FBCZ',
               'profile_description': u'DIFFERENTIAL',
               'request_datetime': datetime.datetime(2014, 11, 12, 16, 6),
               'result_status': 'FINAL'}]}}


class TestToDict(TestCase):
    def test_pathology_to_dict(self):
        msg = read_message(COMPLEX_WINPATH_RESULT)
        service = mock.MagicMock()
        service.issuing_source = "uclh"
        message_container = HL7Importer().import_message(msg, service)
        result = message_container.to_dict()
        self.assertEqual(result, expected)

    def test_to_dict_function(self):

# Path: gloss/tests/test_messages.py
# COMPLEX_WINPATH_RESULT = r"""
# MSH|^~\&|Corepoint|TDL|UCLH|UCLH|201411261546||ORU^R01|1126154698U000057|P|2.3
# PID||^^NHS|50031772^^HOSP|C2130015640^^OASIS|TEST^TEST||19870912|M
# PV1|||HAEM^HAEMATOLOGY OUTPATIENTS^^^^^^^OP||||||HC1^COHEN DR H
# ORC|RE|98U000057|98U000057||CM||||201411261546
# OBR|1|98U000057|98U000057|FBCY^FULL BLOOD COUNT^WinPath||201411121606|201411121600|||||||||HC1^COHEN DR H||||||201411121608||H1|F
# OBX|1|NM|WCC^White cell count^Winpath||8.00|x10\S\9/L|3.0-10.0||||F
# OBX|2|NM|RCC^Red cell count^Winpath||3.20|x10\S\12/L|4.4-5.8|L|||F
# OBX|3|NM|HBGL^Haemoglobin (g/L)^Winpath||87|g/L|||||F
# OBX|4|NM|HCTU^HCT^Winpath||0.350|L/L|0.37-0.50|L|||F
# OBX|5|NM|MCVU^MCV^Winpath||78.0|fL|80-99|L|||F
# OBX|6|NM|MCHU^MCH^Winpath||28.0|pg|27.0-33.5||||F
# OBX|7|NM|MCGL^MCHC (g/L)^Winpath||300|g/L|||||F
# OBX|8|NM|RDWU^RDW^Winpath||17.0|%|11.5-15.0|H|||F
# OBX|9|NM|PLT^Platelet count^Winpath||250|x10\S\9/L|150-400||||F
# OBX|10|NM|MPVU^MPV^Winpath||10.0|fL|7-13||||F
# OBR|2|98U000057|98U000057|FBCZ^DIFFERENTIAL^WinPath||201411121606|201411121600|||||||||HC1^COHEN DR H||||||201411121609||H1|F
# OBX|1|NM|NE^Neutrophils^Winpath||55.0%  4.40|x10\S\9/L|2.0-7.5||||F
# OBX|2|NM|LY^Lymphocytes^Winpath||25.0%  2.00|x10\S\9/L|1.2-3.65||||F
# OBX|3|NM|MO^Monocytes^Winpath||15.0%  1.20|x10\S\9/L|0.2-1.0|H|||F
# OBX|4|NM|EO^Eosinophils^Winpath||3.0%  0.24|x10\S\9/L|0.0-0.4||||F
# OBX|5|NM|BA^Basophils^Winpath||2.0%  0.16|x10\S\9/L|0.0-0.1|H|||F
# """
# 
# def read_message(some_msg):
#     return hl7.parse(some_msg.replace("\n", "\r"))
# 
# Path: gloss/importers/hl7_importer.py
# class HL7Importer(SafelImporter):
#     def import_message(self, msg, gloss_service):
#         hl7 = hl7_translator.HL7Translator.translate(msg)
#         importer = HL7TranslationToMessage.get_for_hl7(hl7)
#         if importer:
#             processed_messages = importer.import_hl7()
#             hospital_number = importer.get_hospital_number()
#             return messages.MessageContainer(
#                 messages=processed_messages,
#                 hospital_number=hospital_number,
#                 issuing_source=gloss_service.issuing_source
#             )
# 
# 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/tests/test_message_type.py
import datetime
import mock
from unittest import TestCase
from gloss.tests.test_messages import (
    COMPLEX_WINPATH_RESULT, read_message
)
from gloss.importers.hl7_importer import HL7Importer
from gloss import message_type

                                 'reference_range': u'0.0-0.4',
                                 'result_status': None,
                                 'test_code': u'EO',
                                 'test_name': u'Eosinophils',
                                 'units': u'x10^9/L',
                                 'value_type': u'NM'},
                                {'comments': None,
                                 'observation_value': u'2.0%  0.16',
                                 'reference_range': u'0.0-0.1',
                                 'result_status': None,
                                 'test_code': u'BA',
                                 'test_name': u'Basophils',
                                 'units': u'x10^9/L',
                                 'value_type': u'NM'}],
               'profile_code': u'FBCZ',
               'profile_description': u'DIFFERENTIAL',
               'request_datetime': datetime.datetime(2014, 11, 12, 16, 6),
               'result_status': 'FINAL'}]}}


class TestToDict(TestCase):
    def test_pathology_to_dict(self):
        msg = read_message(COMPLEX_WINPATH_RESULT)
        service = mock.MagicMock()
        service.issuing_source = "uclh"
        message_container = HL7Importer().import_message(msg, service)
        result = message_container.to_dict()
        self.assertEqual(result, expected)

    def test_to_dict_function(self):

        class A(message_type.MessageType):