using System;

using System.ServiceModel;

using System.Collections;

using System.Collections.Specialize;

using System.Linq;

using PatientService.LINQ;

 

namespace PatientService

{

    [ServiceContract]

    public interface IPatientService

    {

        [OperationContract]

        IQueryable<Encounter> Find(int pid);

        [OperationContract]

        IQueryable<Patient> GetPatients(DateTime since);

    }

 

    public class PatientService : IPatientService

    {

        DataClasses1DataContext medbill = new DataClasses1DataContext();

        public IQueryable<Patient> GetPatients(DateTime since)

        {

            var patients = from p in medbill.Patients where p.Created <= DateTime.Today select p;

            return patients;

        }

 

        public IQueryable<Encounter> Find(int pid)

        {

            var ee = from enc in medbill.Encounters where enc.Patient_ID == pid select enc;

            return ee;

 

        }

    }

 

    // Define the Service

 

    public class service

    {

        public static void Main()

        {

            System.ServiceModel.ServiceHost sh = new System.ServiceModel.ServiceHost(typeof(PatientService));

            sh.Open();

            Console.WriteLine("Click <Enter> to terminate");

            Console.ReadLine();

            sh.Close();

        }

    }

}