Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Drawing;
- using System.Linq;
- using System.Net.Http;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using VMS.OIS.ARIAExternal.WebServices.Documents.Contracts;
- namespace AAWebServiceTests
- {
- class Program
- {
- [STAThread]
- static void Main(string[] args)
- {
- string apiKeyDoc = "63578-blahblahblahblah-347-854ef"; //place your API key here
- string printdata = "";
- string patid = "12345"; //type in your patient Id to search here
- //replace these 'Document Types' with ones you want to check from your clinic:
- string doc1 = "Simulation Physician Order";
- string doc2 = "Physician-Clinical Treatment Plan";
- string doc3 = "Therapist -CT Simulation Note";
- string doc4 = "Consent";
- string doc5 = "Treatment Plan";
- string doc6 = "Physics - Patient DQA";
- string doc7 = "Therapist-Verification Simulation";
- string doc8 = "Physics - Weekly Chart Check";
- string request = "{\"__type\":\"GetDocumentsRequest:http://services.varian.com/Patient/Documents\",\"Attributes\":[],\"PatientId\":{ \"ID1\":\"" + patid + "\"}}";
- string response = SendData(request, true, apiKeyDoc);
- var VisitNoteList = new List<string>();
- int visitnoteloc = response.IndexOf("PtVisitNoteId");
- while (visitnoteloc > 0)
- {
- VisitNoteList.Add(response.Substring(visitnoteloc + 15, 2).Replace(",", ""));
- visitnoteloc = response.IndexOf("PtVisitNoteId", visitnoteloc + 1);
- }
- var response_Doc = JsonConvert.DeserializeObject<DocumentsResponse>(response);
- var DocTypeList = new List<string>();
- var DateServiceList = new List<DateTime>();
- var PatNameList = new List<string>();
- int loopnum = 0;
- foreach (var document in response_Doc.Documents)
- {
- string thePtId = document.PtId;
- string thePtVisitId = document.PtVisitId.ToString();
- string theVisitNoteId = VisitNoteList[loopnum];
- loopnum++;
- string request_docdetails = "{\"__type\":\"GetDocumentRequest:http://services.varian.com/Patient/Documents\",\"Attributes\":[],\"PatientId\":{ \"PtId\":\"" + thePtId + "\"},\"PatientVisitId\":" + thePtVisitId + ",\"VisitNoteId\":" + theVisitNoteId + "}";
- string response_docdetails = SendData(request_docdetails, true, apiKeyDoc);
- int typeloc = response_docdetails.IndexOf("DocumentType");
- int enteredloc = response_docdetails.IndexOf("EnteredBy");
- if (typeloc > 0) { DocTypeList.Add(response_docdetails.Substring(typeloc + 15, enteredloc - typeloc - 18)); }
- int nameloc = response_docdetails.IndexOf("PatientLastName");
- int dobloc = response_docdetails.IndexOf("PreviewText");
- if (nameloc > 0) { PatNameList.Add(response_docdetails.Substring(nameloc + 18, dobloc - nameloc - 21)); }
- int dateservloc = response_docdetails.IndexOf("DateOfService");
- int datesignloc = response_docdetails.IndexOf("DateSigned");
- if (dateservloc > 0)
- {
- System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
- dtDateTime = dtDateTime.AddSeconds(Convert.ToDouble(response_docdetails.Substring(dateservloc + 23, datesignloc - dateservloc - 34)) / 1000).ToLocalTime();
- DateServiceList.Add(dtDateTime);
- }
- }
- var SimPhysicianOrderList = new List<DateTime>();
- var ClinicalTreatPlanList = new List<DateTime>();
- var CTSimNoteList = new List<DateTime>();
- var ConsentList = new List<DateTime>();
- var TreatmentPlanList = new List<DateTime>();
- var PhysicsDQAList = new List<DateTime>();
- var TherapistVSim = new List<DateTime>();
- var PhysicsWeeklyList = new List<DateTime>();
- for (int i = 0; i < DocTypeList.Count; i++)
- {
- if (DocTypeList[i] == doc1) { SimPhysicianOrderList.Add(DateServiceList[i]); }
- if (DocTypeList[i] == doc2) { ClinicalTreatPlanList.Add(DateServiceList[i]); }
- if (DocTypeList[i] == doc3) { CTSimNoteList.Add(DateServiceList[i]); }
- if (DocTypeList[i] == doc4) { ConsentList.Add(DateServiceList[i]); }
- if (DocTypeList[i] == doc5) { TreatmentPlanList.Add(DateServiceList[i]); }
- if (DocTypeList[i] == doc6) { PhysicsDQAList.Add(DateServiceList[i]); }
- if (DocTypeList[i] == doc7) { TherapistVSim.Add(DateServiceList[i]); }
- if (DocTypeList[i] == doc8) { PhysicsWeeklyList.Add(DateServiceList[i]); }
- }
- printdata += "Patient: " + PatNameList[0] + " - " + patid+ "\n";
- printdata += "(" + SimPhysicianOrderList.Count + ") " + doc1 + ": " + SimPhysicianOrderList.DefaultIfEmpty().Max().ToString("MM/dd/yy").Replace("01/01/01", "") + "\n";
- printdata += "(" + ClinicalTreatPlanList.Count + ") " + doc2 + ": " + ClinicalTreatPlanList.DefaultIfEmpty().Max().ToString("MM/dd/yy").Replace("01/01/01", "") + "\n";
- printdata += "(" + CTSimNoteList.Count + ") " + doc3 + ": " + CTSimNoteList.DefaultIfEmpty().Max().ToString("MM/dd/yy").Replace("01/01/01", "") + "\n";
- printdata += "(" + ConsentList.Count + ") " + doc4 + ": " + ConsentList.DefaultIfEmpty().Max().ToString("MM/dd/yy").Replace("01/01/01", "") + "\n";
- printdata += "(" + TreatmentPlanList.Count + ") " + doc5 + ": " + TreatmentPlanList.DefaultIfEmpty().Max().ToString("MM/dd/yy").Replace("01/01/01", "") + "\n";
- printdata += "(" + PhysicsDQAList.Count + ") " + doc6 + ": " + PhysicsDQAList.DefaultIfEmpty().Max().ToString("MM/dd/yy").Replace("01/01/01", "") + "\n";
- printdata += "(" + TherapistVSim.Count + ") " + doc7 + ": " + TherapistVSim.DefaultIfEmpty().Max().ToString("MM/dd/yy").Replace("01/01/01", "") + "\n";
- printdata += "(" + PhysicsWeeklyList.Count + ") " + doc8 + ": " + PhysicsWeeklyList.DefaultIfEmpty().Max().ToString("MM/dd/yy").Replace("01/01/01", "") + "\n";
- printdata += "--------------------------------" + "\n";
- MessageBox.Show(printdata);
- }
- }
- }
Add Comment
Please, Sign In to add comment