Exemplo n.º 1
0
        static void Main(string[] args)
        {
            string commandLine = "";

            Console.WriteLine("Enter C for checkin patient, P for pending patient queue, M for Mongo tests, F for fingerprint identity and Q to quit");
            while (commandLine != "q")
            {
                if (commandLine == "c")
                {
                    // call PatentCheckinUri
                    Console.WriteLine("Sending test patient FHIR message.");
                    Patient testPt = TestPatient();
                    SendJSON(testPt);
                    Console.WriteLine("Sending FHIR message from file.");
                    Patient readPt = ReadPatient(@"C:\JSONTest\sample-new-patient.json");
                    SendJSON(readPt);
                }
                else if (commandLine == "p") //send profiles
                {
                    // call PendingPatientsUri
                    IList <PatientProfile> patientProfiles = GetCheckinList();
                    Console.WriteLine("Patient profiles received.");
                }
                else if (commandLine == "m") // MongoDB tests
                {
                    MongoDBWrapper dbwrapper = new MongoDBWrapper(NoIDMongoDBAddress, SparkMongoDBAddress);
                    SessionQueue   seq       = new SessionQueue();
                    seq._id                 = Guid.NewGuid().ToString();
                    seq.ClinicArea          = "Test Clinic";
                    seq.LocalReference      = "123456";
                    seq.SparkReference      = "spark5";
                    seq.ApprovalStatus      = "pending";
                    seq.PatientStatus       = "new";
                    seq.RemoteHubReference  = "rem440403";
                    seq.SessionComputerName = "Prototype Computer 1";
                    seq.SubmitDate          = DateTime.UtcNow.AddMinutes(-15);
                    seq.PatientBeginDate    = DateTime.UtcNow.AddMinutes(-19);
                    Console.WriteLine(seq.Serialize());
                    dbwrapper.AddPendingPatient(seq);
                    List <SessionQueue> PendingPatients = dbwrapper.GetPendingPatients();
                    dbwrapper.UpdateSessionQueueRecord(seq._id, "approved", "TestUser", "TestComputer");
                }
                else if (commandLine == "f") // test fingerprint identity web service
                {
                    Media readMedia = ReadMedia(@"C:\JSONTest\sample-media-fhir-message.json");
                    SendJSON(readMedia);
                }
                string previousCommand = commandLine;
                commandLine = Console.ReadLine();
                if (commandLine.Length > 0)
                {
                    commandLine = commandLine.ToLower().Substring(0, 1);
                }
                else
                {
                    commandLine = previousCommand;
                }
            }
        }
Exemplo n.º 2
0
        private IList <PatientProfile> GetPendingPatients()
        {
            List <PatientProfile> listPending = new List <PatientProfile>();

            try
            {
                MongoDBWrapper      dbwrapper          = new MongoDBWrapper(NoIDMongoDBAddress, SparkMongoDBAddress);
                List <SessionQueue> pendingSessionList = dbwrapper.GetPendingPatients();
                FhirClient          client             = new FhirClient(sparkEndpointAddress);

                foreach (var pending in pendingSessionList)
                {
                    string         sparkAddress   = sparkEndpointAddress.ToString() + "/Patient/" + pending.SparkReference;
                    Patient        pendingPatient = (Patient)client.Get(sparkAddress);
                    PatientProfile patientProfile = new PatientProfile(pendingPatient, true);
                    patientProfile.SessionID       = pending._id;
                    patientProfile.LocalNoID       = pending.LocalReference;
                    patientProfile.NoIDStatus      = pending.ApprovalStatus;
                    patientProfile.NoIDType        = pending.PatientStatus;
                    patientProfile.CheckinDateTime = FHIRUtilities.DateTimeToFHIRString(pending.SubmitDate);

                    listPending.Add(patientProfile);
                }

                /*
                 * string gtDateFormat = "gt" + FHIRUtilities.DateToFHIRString(DateTime.UtcNow.AddDays(-2));
                 * client.PreferredFormat = ResourceFormat.Json;
                 * Uri uriTwoDays = new Uri(sparkEndpointAddress.ToString() + "/Patient?_lastUpdated=" + gtDateFormat);
                 * Bundle patientBundle = (Bundle)client.Get(uriTwoDays);
                 * foreach (Bundle.EntryComponent entry in patientBundle.Entry)
                 * {
                 *  string ptURL = entry.FullUrl.ToString().Replace("http://localhost:49911/fhir", sparkEndpointAddress.ToString());
                 *  Patient pt = (Patient)client.Get(ptURL);
                 *  if (pt.Meta.Extension.Count > 0)
                 *  {
                 *      Extension ext = pt.Meta.Extension[0];
                 *      if (ext.Value.ToString().ToLower().Contains("pending") == true)
                 *      {
                 *          PatientProfile patientProfile = new PatientProfile(pt, false);
                 *          listPending.Add(patientProfile);
                 *      }
                 *  }
                 * }
                 */
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(listPending);
        }