public LocalPatientRecords Deserialize(TextReader reader) { LocalPatientRecords lpr = (LocalPatientRecords)_s.Deserialize(reader); reader.Close(); return(lpr); }
private string StringSerialize(LocalPatientRecords lpr) { TextWriter w = WriterSerialize(lpr); string xml = w.ToString(); w.Close(); return(xml.Trim()); }
private TextWriter WriterSerialize(LocalPatientRecords lpr) { TextWriter w = new StringWriter(); _s = new XmlSerializer(_type); _s.Serialize(w, lpr); w.Flush(); return(w); }
public XmlDocument Serialize(LocalPatientRecords lpr) { string xml = StringSerialize(lpr); XmlDocument doc = new XmlDocument(); doc.PreserveWhitespace = true; doc.LoadXml(xml); return(doc); }
private static void TestGetValidatedConnections(string token, ref LocalPatientRecords localPatientRecords) { try { HVConnect.HVConnectClient client = new HVConnect.HVConnectClient(); HVConnect.ValidatedConnectionsRequest request = new HVConnect.ValidatedConnectionsRequest(); request.Token = token; request.SinceDate = DateTime.Parse("1/1/1900"); HVConnect.ValidatedConnectionsResponse response = client.GetValidatedConnections(request); if (response.Success) { Console.WriteLine("\nValidated HealthVault Account Connections:\n"); foreach (HVConnect.ValidatedConnection vc in response.Connections) { if (localPatientRecords.ValidateRecord(vc) == false) { // This record is NOT known to us locally, add the connection to our list. Console.WriteLine("\t**ORPHAN-RECORD: ApplicationID={0}\n\tPatientID={1}\n\tApplicationRecordID={2}\n\tPersonID={3}\n\tRecordID={4}\n", vc.ApplicationId.ToString(), vc.ApplicationPatientId, vc.ApplicationSpecificRecordId, vc.PersonId.ToString(), vc.RecordId.ToString()); // Add the orphaned record to our list of records. PatientRecord patientRecord = new PatientRecord(vc.ApplicationPatientId, "ORPHAN", "UNKOWN", "UNKNOWN", "UNKNOWN", "UNKOWN", "UNKNOWN", vc.PersonId.ToString(), vc.RecordId.ToString(), vc.ApplicationSpecificRecordId, "validated"); localPatientRecords.PatientRecords.Add(patientRecord); } else { // This record is known to us locally, no action needed. Console.WriteLine("\tApplicationID={0}\n\tPatientID={1}\n\tApplicationRecordID={2}\n\tPersonID={3}\n\tRecordID={4}\n", vc.ApplicationId.ToString(), vc.ApplicationPatientId, vc.ApplicationSpecificRecordId, vc.PersonId.ToString(), vc.RecordId.ToString()); } } } else { Console.WriteLine("Error = {0}\n", response.Message); } } catch (Exception ex) { Console.WriteLine("Exception : GetValidatedConnections : {0}", ex.Message); return; } }
public static bool WriteFile(string file, LocalPatientRecords lpr) { bool ok = false; PatientRecordsSerializer serializer = new PatientRecordsSerializer(); try { string xml = serializer.Serialize(lpr).OuterXml; using (StreamWriter writer = new StreamWriter(file, false)) { writer.Write(xml.Trim()); writer.Flush(); writer.Close(); } ok = true; } catch { } return(ok); }
private static void Main(string[] args) { HVProxyTest myHVProxyTest = new HVProxyTest(); LocalPatientRecords myLocalPatientRecords = new LocalPatientRecords(); string filePath = null; try { if (args.Count() == 0) { Console.WriteLine("{0}", myUsage); return; } Arguments CommandLine = new Arguments(args); if (CommandLine["deserialize"] != null) // **** DE-SERIALIZE LOCAL PATIENT RECORDS FROM FILE { Console.WriteLine("\nImport patient records. File name? "); filePath = Console.ReadLine(); myLocalPatientRecords = PatientRecordsSerializer.ReadFile(filePath); foreach (PatientRecord pr in myLocalPatientRecords.PatientRecords) { Console.WriteLine("PatientId={0}\tLocalRecordId={1}\tPersonId={2}\tRecordId={3}", pr.PatientId, pr.ApplicationRecordId, pr.PersonId, pr.RecordId); } } if (CommandLine["createconnection"] != null) // **** TEST CREATE CONNECTION { Console.WriteLine("\nTest CreateConnectionRequest API\n"); Console.WriteLine("Local patient name? "); string patientName = Console.ReadLine(); Console.WriteLine("Local patient identifier? "); string patientId = Console.ReadLine(); Console.WriteLine("Local patient eMail? "); string patientEmail = Console.ReadLine(); Console.WriteLine("Secret question? "); string secretQuestion = Console.ReadLine(); Console.WriteLine("Secret answer? "); string secretAnswer = Console.ReadLine(); // PatientRecord patientRecord = new PatientRecord(patientId, patientName, patientEmail, secretQuestion, secretAnswer, null, null, null, null, null, "requested"); TestCreateConnection(myHVApplicationToken, ref patientRecord); myLocalPatientRecords.PatientRecords.Add(patientRecord); // Console.WriteLine("Go validate the connection request using the provided URL and key, then return to this session. \nPress any key to continue; 'q' to quit...\n"); if (Console.ReadKey().KeyChar == 'q') { return; } } if (CommandLine["getconnections"] != null) // **** TEST GET VALIDATED CONNECTIONS { Console.WriteLine("\nTest GetValidatedConnections API\n"); // TestGetValidatedConnections(myHVApplicationToken, ref myLocalPatientRecords); // Console.WriteLine("\nUse the connections info listed above for subsequent API tests. \nPress any key to continue; 'q' to quit...\n"); if (Console.ReadKey().KeyChar == 'q') { return; } } if (CommandLine["getthings"] != null) // **** TEST GET-THINGS { Console.WriteLine("\nTest GetThings API\n"); Console.WriteLine("HV PersonId? "); string personId = Console.ReadLine(); Console.WriteLine("HV RecordId? "); string recordId = Console.ReadLine(); // TestGetThings(myHVApplicationToken, personId, recordId, ref myHVProxyTest.myTypeIds); // Console.WriteLine("\nPress any key to continue; 'q' to quit...\n"); if (Console.ReadKey().KeyChar == 'q') { return; } } if (CommandLine["putthing"] != null) // **** TEST PUT-THING { Console.WriteLine("\nTest PutThing API\n"); Console.WriteLine("HV PersonId? "); string personId = Console.ReadLine(); Console.WriteLine("HV RecordId? "); string recordId = Console.ReadLine(); // TestPutThing(myHVApplicationToken, personId, recordId); // Console.WriteLine("\nPress any key to continue; 'q' to quit...\n"); if (Console.ReadKey().KeyChar == 'q') { return; } } if (CommandLine["putthings"] != null) // **** TEST PUT-THINGS { Console.WriteLine("\nTest PutThings API\n"); Console.WriteLine("HV PersonId? "); string personId = Console.ReadLine(); Console.WriteLine("HV RecordId? "); string recordId = Console.ReadLine(); // TestPutThings(myHVApplicationToken, personId, recordId); // Console.WriteLine("\nPress any key to continue; 'q' to quit...\n"); if (Console.ReadKey().KeyChar == 'q') { return; } } if (CommandLine["getupdatedrecords"] != null) // **** TEST GET UPDATED RECORDS { Console.WriteLine("\nTest GetUpdatedRecords API\n"); // TestGetUpdatedRecords(myHVApplicationToken); // Console.WriteLine("\nPress any key to continue; 'q' to quit...\n"); if (Console.ReadKey().KeyChar == 'q') { return; } } if (CommandLine["deleteconnection"] != null) // **** TEST DELETE PENDING CONNECTION { Console.WriteLine("\nTest DeletePendingConnection API\n"); Console.WriteLine("Local patient identifier? "); string patientId = Console.ReadLine(); // TestDeletePendingConnection(myHVApplicationToken, patientId); // Console.WriteLine("\nPress any key to continue; 'q' to quit...\n"); if (Console.ReadKey().KeyChar == 'q') { return; } } if (CommandLine["revokeapplication"] != null) // **** TEST REVOKE APPLICATION CONNECTION { Console.WriteLine("\nTest RevokeApplicationConnection API\n"); Console.WriteLine("HV PersonId? "); string personId = Console.ReadLine(); Console.WriteLine("HV RecordId? "); string recordId = Console.ReadLine(); // TestRevokeApplicationConnection(myHVApplicationToken, personId, recordId); // Console.WriteLine("\nPress any key to continue; 'q' to quit...\n"); if (Console.ReadKey().KeyChar == 'q') { return; } } if (CommandLine["DOPU"] != null) // **** TEST THE DROP-OFF PICK-UP API { Console.WriteLine("\nTest Drop-Off and Pick-Up API\n"); Console.WriteLine("Local patient identifier? "); string patientId = Console.ReadLine(); Console.WriteLine("Local patient eMail? "); string patientEmail = Console.ReadLine(); Console.WriteLine("Secret question? "); string secretQuestion = Console.ReadLine(); Console.WriteLine("Secret answer? "); string secretAnswer = Console.ReadLine(); // TestDropOffPickUp(myHVApplicationToken, patientId, patientEmail, secretQuestion, secretAnswer); // Console.WriteLine("\nPress any key to continue; 'q' to quit...\n"); if (Console.ReadKey().KeyChar == 'q') { return; } } if (CommandLine["serialize"] != null) // **** Serialize local patient records to file { Console.WriteLine("\nExport patient records. File name? "); filePath = Console.ReadLine(); PatientRecordsSerializer.WriteFile(filePath, myLocalPatientRecords); } // TO-DO : ADD OTHER API TESTS HERE. } catch (Exception ex) { Console.WriteLine("\nException : {0}\n{1}\n{2}", ex.Message, ex.InnerException.Message, ex.InnerException.StackTrace); } Console.WriteLine("\nPress any key to exit...\n"); Console.ReadKey(); return; } // Main
public LocalPatientRecords(LocalPatientRecords copy) { myLocalPatientRecords = copy.PatientRecords; }