Guest User

Untitled

a guest
Sep 3rd, 2020
1,006
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.74 KB | None | 0 0
  1. using Newtonsoft.Json;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Configuration;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Net.Http;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. using VMS.OIS.ARIAExternal.WebServices.Documents.Contracts;
  12.  
  13. namespace AAWebServiceTests
  14. {
  15.     class Program
  16.     {
  17.         [STAThread]
  18.         static void Main(string[] args)
  19.         {
  20.  
  21.             string apiKeyDoc = "63578-blahblahblahblah-347-854ef"; //place your API key here
  22.             string printdata = "";
  23.             string patid = "12345"; //type in your patient Id to search here
  24.  
  25.  
  26.                //replace these 'Document Types' with ones you want to check from your clinic:
  27.                string doc1 = "Simulation Physician Order";
  28.                string doc2 = "Physician-Clinical Treatment Plan";
  29.                string doc3 = "Therapist -CT Simulation Note";
  30.                string doc4 = "Consent";
  31.                string doc5 = "Treatment Plan";
  32.                string doc6 = "Physics - Patient DQA";
  33.                string doc7 = "Therapist-Verification Simulation";
  34.                string doc8 = "Physics - Weekly Chart Check";
  35.  
  36.  
  37.  
  38.             string request = "{\"__type\":\"GetDocumentsRequest:http://services.varian.com/Patient/Documents\",\"Attributes\":[],\"PatientId\":{ \"ID1\":\"" + patid + "\"}}";
  39.             string response = SendData(request, true, apiKeyDoc);
  40.  
  41.             var VisitNoteList = new List<string>();
  42.             int visitnoteloc = response.IndexOf("PtVisitNoteId");
  43.             while (visitnoteloc > 0)
  44.             {
  45.                 VisitNoteList.Add(response.Substring(visitnoteloc + 15, 2).Replace(",", ""));
  46.                 visitnoteloc = response.IndexOf("PtVisitNoteId", visitnoteloc + 1);
  47.             }
  48.             var response_Doc = JsonConvert.DeserializeObject<DocumentsResponse>(response);
  49.  
  50.             var DocTypeList = new List<string>();
  51.             var DateServiceList = new List<DateTime>();
  52.             var PatNameList = new List<string>();
  53.  
  54.             int loopnum = 0;
  55.             foreach (var document in response_Doc.Documents)
  56.             {
  57.                 string thePtId = document.PtId;
  58.                 string thePtVisitId = document.PtVisitId.ToString();
  59.                 string theVisitNoteId = VisitNoteList[loopnum];
  60.                 loopnum++;
  61.  
  62.                 string request_docdetails = "{\"__type\":\"GetDocumentRequest:http://services.varian.com/Patient/Documents\",\"Attributes\":[],\"PatientId\":{ \"PtId\":\"" + thePtId + "\"},\"PatientVisitId\":" + thePtVisitId + ",\"VisitNoteId\":" + theVisitNoteId + "}";
  63.                 string response_docdetails = SendData(request_docdetails, true, apiKeyDoc);
  64.  
  65.                 int typeloc = response_docdetails.IndexOf("DocumentType");
  66.                 int enteredloc = response_docdetails.IndexOf("EnteredBy");
  67.                 if (typeloc > 0) { DocTypeList.Add(response_docdetails.Substring(typeloc + 15, enteredloc - typeloc - 18)); }
  68.  
  69.                 int nameloc = response_docdetails.IndexOf("PatientLastName");
  70.                 int dobloc = response_docdetails.IndexOf("PreviewText");
  71.                 if (nameloc > 0) { PatNameList.Add(response_docdetails.Substring(nameloc + 18, dobloc - nameloc - 21)); }
  72.  
  73.                 int dateservloc = response_docdetails.IndexOf("DateOfService");
  74.                 int datesignloc = response_docdetails.IndexOf("DateSigned");
  75.                 if (dateservloc > 0)
  76.                 {
  77.                     System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
  78.                     dtDateTime = dtDateTime.AddSeconds(Convert.ToDouble(response_docdetails.Substring(dateservloc + 23, datesignloc - dateservloc - 34)) / 1000).ToLocalTime();
  79.                     DateServiceList.Add(dtDateTime);
  80.                 }
  81.             }
  82.  
  83.             var SimPhysicianOrderList = new List<DateTime>();
  84.             var ClinicalTreatPlanList = new List<DateTime>();
  85.             var CTSimNoteList = new List<DateTime>();
  86.             var ConsentList = new List<DateTime>();
  87.             var TreatmentPlanList = new List<DateTime>();
  88.             var PhysicsDQAList = new List<DateTime>();
  89.             var TherapistVSim = new List<DateTime>();
  90.             var PhysicsWeeklyList = new List<DateTime>();
  91.  
  92.             for (int i = 0; i < DocTypeList.Count; i++)
  93.             {
  94.                 if (DocTypeList[i] == doc1) { SimPhysicianOrderList.Add(DateServiceList[i]); }
  95.                 if (DocTypeList[i] == doc2) { ClinicalTreatPlanList.Add(DateServiceList[i]); }
  96.                 if (DocTypeList[i] == doc3) { CTSimNoteList.Add(DateServiceList[i]); }
  97.                 if (DocTypeList[i] == doc4) { ConsentList.Add(DateServiceList[i]); }
  98.                 if (DocTypeList[i] == doc5) { TreatmentPlanList.Add(DateServiceList[i]); }
  99.                 if (DocTypeList[i] == doc6) { PhysicsDQAList.Add(DateServiceList[i]); }
  100.                 if (DocTypeList[i] == doc7) { TherapistVSim.Add(DateServiceList[i]); }
  101.                 if (DocTypeList[i] == doc8) { PhysicsWeeklyList.Add(DateServiceList[i]); }
  102.             }
  103.             printdata += "Patient: " + PatNameList[0] + " - " + patid+ "\n";
  104.             printdata += "(" + SimPhysicianOrderList.Count + ") " + doc1 + ":            " + SimPhysicianOrderList.DefaultIfEmpty().Max().ToString("MM/dd/yy").Replace("01/01/01", "") + "\n";
  105.             printdata += "(" + ClinicalTreatPlanList.Count + ") " + doc2 + ":  " + ClinicalTreatPlanList.DefaultIfEmpty().Max().ToString("MM/dd/yy").Replace("01/01/01", "") + "\n";
  106.             printdata += "(" + CTSimNoteList.Count + ") " + doc3 + ":       " + CTSimNoteList.DefaultIfEmpty().Max().ToString("MM/dd/yy").Replace("01/01/01", "") + "\n";
  107.             printdata += "(" + ConsentList.Count + ") " + doc4 + ":                                            " + ConsentList.DefaultIfEmpty().Max().ToString("MM/dd/yy").Replace("01/01/01", "") + "\n";
  108.             printdata += "(" + TreatmentPlanList.Count + ") " + doc5 + ":                                 " + TreatmentPlanList.DefaultIfEmpty().Max().ToString("MM/dd/yy").Replace("01/01/01", "") + "\n";
  109.             printdata += "(" + PhysicsDQAList.Count + ") " + doc6 + ":                      " + PhysicsDQAList.DefaultIfEmpty().Max().ToString("MM/dd/yy").Replace("01/01/01", "") + "\n";
  110.             printdata += "(" + TherapistVSim.Count + ") " + doc7 + ":  " + TherapistVSim.DefaultIfEmpty().Max().ToString("MM/dd/yy").Replace("01/01/01", "") + "\n";
  111.             printdata += "(" + PhysicsWeeklyList.Count + ") " + doc8 + ":         " + PhysicsWeeklyList.DefaultIfEmpty().Max().ToString("MM/dd/yy").Replace("01/01/01", "") + "\n";
  112.             printdata += "--------------------------------" + "\n";
  113.  
  114.             MessageBox.Show(printdata);
  115.  
  116.   }
  117.  }
  118. }
Add Comment
Please, Sign In to add comment