Hi all,
I have a C# application which integrates to the DrChrono API, but I've hit a snag when it comes to Patient Flags. I just can't seem to get anything to add a flag to a patient. I can successfully create a flag via api/patient_flag_types and when I try to use that ID and create a payload to send I get the following:
IsSuccessStatusCode: true
ReasonPhrase: "No Content"
{
Authorization: Bearer rZcIoejN2YPgFjRETgzCJawDMUV6rT
Content-Type: application/x-www-form-urlencoded
Content-Length: 219
}
I understand C# support is limited, and as much as I would love a c# sample code that dealt with the additions of patient flags, I'll access code in any language, so I can figure out what content I need to send.
My biggest questions in trying to resolve this are:
1) whats the difference between Patient_Flags and Patient_Flags_Attached. I see that the ID of Patient_Flag corresponds to the Flag_type of Patient_Flags_Attached which corresponds to the ID of a created Patient_Flag_Type.
2) Do I need to submit two different serialized json objects, one for Patient_flags and another for Patient_Flags_Attached?
If it helps, here's my current code:
try
{
AddFlagTypes.flag_type = EHRFlagTypeID;
AddFlagTypes.flag_text = "Patient Flag Test";
var obj = new JavaScriptSerializer().Serialize(AddFlagTypes);
AddFlags.id = EHRFlagTypeID;
AddFlags.doctor = Convert.ToInt32(MRNProviderRefID);
AddFlags.priority = 1;
AddFlags.color = "#71E785";
var obj2 = new JavaScriptSerializer().Serialize(AddFlags);
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", access_token);
MultipartFormDataContent content = new MultipartFormDataContent();
content.Add(new StringContent(MRN), "patient");
content.Add(new StringContent(obj), "patient_flags_attached");
content.Add(new StringContent(obj2), "patient_flags");
var response = await client.PatchAsync(url, content); // Blocking call!
if (response.IsSuccessStatusCode)
{
var dataObject = response.Content.ReadAsStringAsync().Result;
}
}
catch (Exception)
{
throw;
}
Any help would be much appreciated. As an aside, I've used similar code to create appointments, upload documents, and create the flag types, so I can't quite figure out where I've gone wrong other than the actual content.
Thanks!
-Jose