}
@code
{
[Parameter]
public List PdhQuestions { get; set; } = new();
[Parameter]
public List PshQuestions { get; set; } = new();
private string _pdhQuestionTitle = string.Empty;
private MedicalHistoryQuestionType _pdhQuestionType;
private string _pshQuestionTitle = string.Empty;
private MedicalHistoryQuestionType _pshQuestionType;
[Parameter]
public string ChiefComplaint { get; set; } = string.Empty;
private void RemovePiQuestion(MedicalHistoryQuestionSDto question)
{
PdhQuestions.Remove(question);
}
private void AddPiQuestion()
{
PdhQuestions.Add(new MedicalHistoryQuestionSDto
{
QuestionType = _pdhQuestionType,
Part = MedicalHistoryPart.PastDiseasesHistory,
Question = _pdhQuestionTitle
});
_pdhQuestionTitle = string.Empty;
}
private void RemovePshQuestion(MedicalHistoryQuestionSDto question)
{
PshQuestions.Remove(question);
}
private void AddPshQuestion()
{
PshQuestions.Add(new MedicalHistoryQuestionSDto
{
Part = MedicalHistoryPart.PastSurgeryHistory,
QuestionType = _pshQuestionType,
Question = _pshQuestionTitle
});
_pshQuestionTitle = string.Empty;
}
private bool IsProcessing { get; set; }
private MarkupString AiPMHResponse { get; set; }
private async Task AskPMHWithAi()
{
try
{
IsProcessing = true;
var request = new
{
content = $"شکایت اصلی بیمار (CC) {ChiefComplaint} است. لطفاً سوالات بخش تاریخچه بیماری قبلی ( Past Medical History ) را در سه دسته زیر تولید کنید: سوالات توضیحی (Open-ended): سوالاتی که بیمار باید توضیح دهد. سوالات بله/خیر (Yes/No): سوالاتی که پاسخ مشخص بله یا خیر دارند. سوالات زمانی (Time-based): سوالاتی مرتبط با زمان شروع، مدت و تغییرات مشکل. لطفاً سوالات مرتبط با سردرد شامل شدت، محل، عوامل تشدیدکننده یا تسکیندهنده و علائم همراه (مثل تهوع یا تاری دید) باشد. use html concept for response and just send html and remove , head , html and body tag"
};
var response = await RestWrapper.AiRestApi.ChatAsync(request);
response = response.Replace("```html", null);
response = response.Replace("```", null);
response = response.Replace("\\n", null);
response = response.Replace(@"""", null);
AiPMHResponse = (MarkupString)response;
}
catch (ApiException ex)
{
var exe = await ex.GetContentAsAsync();
Snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error);
}
catch (Exception e)
{
Snackbar.Add(e.Message, Severity.Error);
}
finally
{
IsProcessing = false;
}
}
private MarkupString AiPSHResponse { get; set; }
private async Task AskPSHWithAi()
{
try
{
IsProcessing = true;
var request = new
{
content = $"شکایت اصلی بیمار (CC) {ChiefComplaint} است. لطفاً سوالات بخش تاریخچه جراحی های قبلی ( Past Surgery History ) را در سه دسته زیر تولید کنید: سوالات توضیحی (Open-ended): سوالاتی که بیمار باید توضیح دهد. سوالات بله/خیر (Yes/No): سوالاتی که پاسخ مشخص بله یا خیر دارند. سوالات زمانی (Time-based): سوالاتی مرتبط با زمان شروع، مدت و تغییرات مشکل. لطفاً سوالات مرتبط با سردرد شامل شدت، محل، عوامل تشدیدکننده یا تسکیندهنده و علائم همراه (مثل تهوع یا تاری دید) باشد. use html concept for response and just send html and remove , head , html and body tag"
};
var response = await RestWrapper.AiRestApi.ChatAsync(request);
response = response.Replace("```html", null);
response = response.Replace("```", null);
response = response.Replace("\\n", null);
response = response.Replace(@"""", null);
AiPSHResponse = (MarkupString)response;
}
catch (ApiException ex)
{
var exe = await ex.GetContentAsAsync();
Snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error);
}
catch (Exception e)
{
Snackbar.Add(e.Message, Severity.Error);
}
finally
{
IsProcessing = false;
}
}
}