Adjusting code for API call to ChatGPT for medical scribe

Hello, I am creating a medical scribe AI that will listen in on patient visits and create documentation. I have nearly created the web app for this but my output is not as desirable as I would like it to be. My app allows any note type to be made, in my example I will use SOAP note which is a common type of note. I have uploaded a screenshot below (I can only upload one because I am new, the others are here:
ibb. co/6mPM7JK and ibb. co/j60QBcs):

So in this case I created a SOAP note template, the first section being subjective. You can see there is something called sample note there, which is a section for a user to insert their own note they did in the past, that the ChatGPT can learn from. So I’ve done all this but as you can see the output on the image, it’s not a nice looking output, and me and my developer are having trouble fixing that issue. For one, I don’t know why it’s separating it into CONTENT and ASSISTANTSUGGESTEDUSERRESPONSES. That is not taking on the formatting of the sample note at all. Here is the main code relating to the application below:

 if (sectionsList.isEmpty && !fullNote && !patientInstructions) {
    return null;
  } else {
    String keys = '';

    String sectionKeys = '"Provider Recommendation", ';
    if (patientInstructions) {
      sectionKeys += '"Patient Instruction", ';
    if (additionalInstruction.trim().isNotEmpty) {
      sectionKeys += '"Additional Information", ';
    sectionKeys += => '"${e.title}",').toList().join(" ");

    sectionKeys = sectionKeys.replaceRange(sectionKeys.length - 1, null, '');

    final basicIst =
        "Your role as a healthcare provider, assume your patient has presented for a visit with you. And using the transcript available in the user prompt Please provide a detailed and informative response for the sections :- [  $sectionKeys ] AND DO NOT SEND SAMPLE EXAMPLE IN RESPONSE IF YOU DIDN'T FIND THE REQUIRE INFORMATION WROTE \"UNABLE TO FIND THIS DETAILS\" INSTEAD.";

    sectionsList.sort((a, b) => a.index.compareTo(b.index));

    if (additionalInstruction.trim().isNotEmpty) {
      keys +=
          '\n\nSection name:- \"Additional Information\" \n - Definition: ${additionalInstruction.trim()}\n - Structure: { Additional Note }';
    for (int i = 0; i < sectionsList.length; i++) {
      keys +=
          '\n\nSection name:- "${sectionsList[i].title}" \n - Definition: "${sectionsList[i].bodyText}"\n - Structure: {${sectionsList[i].sampleNote}}';

    final linesInst =
        "\n\nFor your convenience, comprehensive explanations have been provided for the designated section. It is important to note that the Sample Note serves merely as a reference, aiding your understanding of the type of response needed for the particular section. Your task is to create a note using a similar formatting and writing style as outlined in the structure.";
    final appInst =
        "\n\nIt is important to note that this application is intended for the purpose of creating health-related notes. Your responses should strictly adhere to the text provided in the user prompt, without the inclusion of any supplementary instructions or recommendations from your end. Please formulate your responses accordingly. Please structure your responses as a Map<String, dynamic> object with the following keys (Section name) and values. If possible, please keep your response limited to a maximum of 1500 tokens. If you believe you cannot generate a response based on the user prompt, then please send this message as a response: \"***-System text - Your audio is not clear-***.\"";

    final systemPrompt = basicIst + '\n' + keys + '\n\n' + linesInst + appInst;

    debugPrint('------> $systemPrompt');
    return systemPrompt;

So are there any obvious changes that could be made to this? The app as a whole is working somewhat well but it’s not still close to how we want in terms of output.

1 Like