Method and system for generating hospitalization first-time disease course record based on large model
Through large language models and prompt engineering technology, we automatically construct and optimize prompt words, solving the problems of low efficiency and poor quality of traditional first medical records, and achieving efficient and accurate first medical records to meet the personalized needs of different departments and diseases.
Patent Information
- Application Number
- CN202510697512.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-28
- Publication Date
- 2025-09-05
AI Technical Summary
Traditional manual writing of the first medical record is inefficient and of poor quality, and is unable to dynamically adapt to individual patient characteristics and departmental differences, resulting in problems with the completeness, accuracy, and readability of the output results.
Through a large model-based method for generating the first inpatient medical record, using a large language model and prompt engineering technology, combined with a semantic transcription network, a similar case extraction module and prompt word optimization, optimized prompt words with department and disease characteristics are automatically constructed to generate high-quality first medical records.
It realizes the efficient, accurate and readable automatic generation of the first inpatient medical record, improves the efficiency and quality of medical document writing, and adapts to the personalized needs of different departments and diseases.
Smart Images

Figure CN120600205A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of medical documents, and in particular to a method and system for generating an initial inpatient medical record based on a large model. Background Art
[0002] According to the requirements of the "Basic Standards for Medical Record Writing", the first medical record refers to the first medical record written by the attending physician or the physician on duty after the patient is admitted to the hospital. It is one of the most important medical records during the patient's admission stage.
[0003] The initial medical history record includes three parts: case characteristics, proposed diagnosis discussion (diagnostic basis and differential diagnosis), and treatment plan. Among them: 1) Case characteristics refers to the physician's summary of the patient's disease characteristics after a comprehensive analysis of the medical history and examination results, including positive findings and negative symptoms and signs with differential diagnostic significance; 2) Proposed diagnosis discussion (diagnostic basis and differential diagnosis) refers to the physician's proposal of a preliminary diagnosis and diagnostic basis based on the case characteristics, the need to write a differential diagnosis method for unclear diagnoses, and an analysis of the next steps in diagnosis and treatment; 3) Treatment plan refers to the physician's proposed specific examination and treatment measures, as well as issues that should be noted during the diagnosis and treatment process.
[0004] Traditional manual preparation of initial medical records is plagued by inefficiencies and poor quality. According to the 2023 China Healthcare Quality Report, initial medical records take an average of 45 minutes to complete, with a data error rate as high as 32%. In clinical practice, disease templates are often used to improve efficiency and quality. However, this can lead to a lack of dynamic adaptation to individual patient characteristics, resulting in a high rate of duplicate medical histories and a failure to meet the needs of personalized diagnosis and treatment.
[0005] The emergence of large language model technology has provided a new solution for the automated recording of medical records. However, in practical applications, there are still a lot of practical problems to be solved. Specifically, they include: 1) Large amount of input information: The writing of the first-instance record relies on multi-source data such as admission records and examination and test reports, which are usually larger than the text input window size of the large language model. Direct input will lead to information loss; 2) Different departments and diseases have different focuses: When writing the first-instance record, it is necessary to combine the individual situation of the patient, the department and the type of disease, refine the individual situation of the patient, conduct personalized analysis, and propose targeted diagnosis and treatment plans; 3) Different management agencies have different requirements for writing styles: Different provinces, different hospitals, and different departments have different requirements for the writing content of the first-instance record, which need to be dynamically adapted.
[0006] The existence of the above problems will lead to problems in the completeness, accuracy, readability and other aspects of the output results. Summary of the Invention
[0007] The purpose of the technical solution of the present invention is to solve the problem of low accuracy of the first-pass recording content in the prior art.
[0008] In order to achieve the purpose of the above technical solution, the technical solution of the present invention provides a method for generating the first inpatient medical record based on a large model, comprising the following steps:
[0009] Retrieve the patient's medical records stored in the electronic medical record system, including admission records, auxiliary examination reports, laboratory test reports, etc., as well as the patient's previous outpatient and hospitalization medical records before the current visit;
[0010] According to the mapping relationship between admission records, auxiliary examination reports, laboratory test reports and semantic transcription data, the patient's existing medical records for this hospitalization are processed to obtain semantic transcription data;
[0011] Based on the patient's existing medical records and semantic transcription data for this hospitalization, a keyword and semantic hybrid search is used to match case medical records stored in the electronic medical record system that meet the threshold of similarity.
[0012] Based on the semantic transcription data and the initial prompt words recorded in the first session, the prompt words are optimized to construct optimized prompt words with department and disease characteristics;
[0013] The large language model was trained using historical prompt words, historical semantic transcription data and historical case medical records to obtain a model for generating the first inpatient medical record. The optimized prompt words, semantic transcription data and case medical records were input into the model for generating the first inpatient medical record to obtain the first inpatient medical record corresponding to the patient's existing medical record documents for this hospitalization.
[0014] Preferably, the steps of establishing the mapping relationship are as follows:
[0015] Collect historical hospitalization records, including admission records, auxiliary examination reports, laboratory test reports, and initial medical records;
[0016] The historical hospitalization documents were pre-processed using Jieba word segmentation, and then synonyms were matched based on the term dictionary. The matching results were mapped to the standard coding system and the term structured data was output.
[0017] For unmatched candidate terms, UMLS is used for manual review and supplementation, and term structured data is output;
[0018] Based on terminology-structured data, we extract events by matching event patterns with regular expressions. We then use Gensim's LDA model to cluster the extracted events and generate topics, thereby obtaining historical hospitalization records with topics.
[0019] Historical hospitalization records with themes were divided according to whether they were the first medical records. Non-first medical records were regarded as the first event set, and first medical records were regarded as the second event set.
[0020] The first event set and the second event set are respectively converted into a first high-dimensional semantic vector set and a second high-dimensional semantic vector set, the similarity between each event in the first high-dimensional semantic vector set and each event in the second high-dimensional semantic vector set is calculated and sorted according to the topic, the events in the first event set whose similarity meets the preset threshold are used as semantic transcription data, and a mapping relationship is established based on the first event set and the semantic transcription data.
[0021] Preferably, the prompt words are constructed based on case labels such as different departments, types of diseases, number of patient visits, and different structural elements of the first-line record such as medical history characteristics, diagnosis and diagnostic basis, differential diagnosis, diagnosis and treatment principles, and issues that should be paid attention to during diagnosis and treatment.
[0022] Preferably, the first hospitalization medical record includes medical history characteristics, diagnosis and diagnostic basis, differential diagnosis, diagnosis and treatment principles, and issues that should be paid attention to during diagnosis and treatment.
[0023] The technical solution of the present invention further provides a system for generating the first inpatient medical record based on a large model, which adopts the method for generating the first inpatient medical record based on a large model as described above. The system for generating the first inpatient medical record based on a large model includes:
[0024] The medical record retrieval module is used to retrieve the patient's existing medical records for this hospitalization, including admission records, auxiliary examination reports, laboratory test reports, etc., as well as the patient's previous outpatient and hospitalization medical records before this visit;
[0025] The semantic transcription network module is used to process the patient's existing medical records for this hospitalization based on the mapping relationship between admission records, auxiliary examination reports, laboratory test reports and semantic transcription data to obtain semantic transcription data;
[0026] The similar case extraction module is used to retrieve medical records stored in the electronic medical record system based on the patient's existing medical records and semantic transcription data for this hospitalization. The similar case extraction module uses a mixed search of keywords and semantics to match case records from the medical records that meet the similarity threshold;
[0027] The prompt engineering network module is used to optimize prompt words based on semantic transcription data and initial prompt words recorded in the first process, and construct optimized prompt words with department and disease characteristics;
[0028] The large language model module is used to train the large language model using historical prompt words, historical semantic transcription data and historical case medical records to obtain a model for generating the first inpatient medical record. The optimized prompt words, semantic transcription data and case medical records are input into the model for generating the first inpatient medical record to obtain the first inpatient medical record corresponding to the patient's existing medical record documents for this hospitalization.
[0029] The technical solution of the present invention proposes a method and system for generating the first medical record of inpatients based on a large model. The method performs text segmentation, format conversion, terminology standardization, and subject identification on historical inpatient document records, and uses similarity to obtain semantic transcription data, thereby establishing a mapping relationship. According to the mapping relationship, the medical records stored in the electronic medical record system are processed to obtain the semantic transcription data corresponding to the medical record documents. According to the medical record documents and the semantic transcription data, the case medical records stored in the electronic medical record system that meet the similarity threshold are matched through keyword and semantic mixed retrieval. According to the semantic transcription data and the initial prompt words of the first medical record, optimized prompt words with department and disease characteristics are constructed. According to the optimized prompt words, semantic transcription data and case medical records, they are input into the first medical record generation model of inpatients trained with historical data, and finally the first medical record of inpatients is obtained, which solves the problem of low accuracy of the first medical record content in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 A flow chart of a method for generating the first inpatient medical record based on a large model provided by an embodiment of the present invention;
[0031] Figure 2 A schematic diagram of an engineering network is provided in a method for generating an initial inpatient medical record based on a large model according to an embodiment of the present invention. DETAILED DESCRIPTION
[0032] Below in conjunction with specific embodiment, further set forth the present invention.Should be understood that these embodiments are only used to illustrate the present invention and are not used in limiting the scope of the present invention.In addition, should be understood that after reading the content taught by the present invention, those skilled in the art can make various changes or modifications to the present invention, and these equivalent forms fall equally within the scope limited by the appended claims of the application.
[0033] like Figure 1 As shown, an embodiment of the present invention provides a method for generating the first medical record of hospitalization based on a large model. By using technologies such as a large language model (LLM) and prompt engineering, it helps resident physicians write the first medical record in the hospitalization scenario, realizes the fully automatic structured generation of the first medical record of hospitalization, and improves the writing efficiency and quality of medical documents. The method for generating the first medical record of hospitalization includes the following steps:
[0034] The medical record retrieval module automatically retrieves the patient's existing medical records for this hospitalization, including admission records, auxiliary examination reports, laboratory test reports, etc., as well as the patient's medical records for all previous outpatient and hospitalization visits before this visit.
[0035] The semantic transcription network module performs operations such as topic identification, text segmentation, format conversion, and terminology standardization on the data from the medical record retrieval module, reducing the context length while retaining valid information and expressing it in an appropriate form.
[0036] The core of the semantic transcription network module is a semantic transcription neural network model, which is trained as follows:
[0037] 1) Constructing a dataset: Collect historical hospitalization records, including but not limited to admission records, initial medical records, examination reports, imaging reports, etc.
[0038] The historical hospitalization documents were preprocessed using Jieba word segmentation, and then synonyms were matched based on the term dictionary. The matching results were mapped to the standard coding system and the term structured data was output.
[0039] Manual review and supplementation of unmatched candidate terms: Use UMLS (Unified Medical Language System) to implement terminology standardization and terminology mapping functions (terminology standardization) and output terminology structured data.
[0040] Based on terminology-structured data, we extract events by matching event patterns with regular expressions. Gensim's LDA model clusters the extracted events to generate topics (topic identification), thereby obtaining a set of events with topics. Topics include chief complaint, current medical history, and auxiliary examinations.
[0041] Based on the multilingual pre-trained model paraphrase-multilingual-MiniLM-L12-v2, event set A contained in hospitalization documents (excluding the first medical record) and event set B in the first medical record were respectively converted into high-dimensional semantic vectors. The similarity score between each event in event set A and each event in event set B was calculated in the vector space based on the cosine similarity algorithm according to the topic. The event in event set B with the highest similarity score and the similarity value V corresponding to each event in event set A were returned. By setting a redundancy threshold T, events in event set A with a similarity value V lower than the threshold T were judged as redundant events. All events in event set B corresponding to all non-redundant events in dataset A were recorded as semantic transcription data (event set C). Multiple data pairs of admission records, examination reports, imaging reports and semantic transcription data constituted the dataset of the semantic transcription network.
[0042] For example, the dataset for the semantic transcription network is:
[0043] The data of admission records, examination reports, imaging reports and initial medical records are as follows:
[0044]
Main complaint
[0045] [Current medical history] The patient experienced chest tightness and shortness of breath, occasional chest pain, and dry cough for the past month. Five days ago, he returned to China by plane from Japan. During the flight, he lifted heavy objects, which aggravated his chest tightness and caused him to cough and have obvious chest pain.
[0046] [Ancillary Examination] (2023-12-30, outside hospital) Chest CT: 90% compression of the left lung. 2023-01-02 Chest X-ray: A small pneumothorax in the left lung has essentially expanded compared to the previous X-ray (23-01-01). Please refer to clinical follow-up.
[0047] The semantic transcription data is as follows:
[0048] [Chief complaint]: Chest tightness and shortness of breath for 1 month, aggravated by cough and chest pain for 5 days.
[0049] Symptoms: Over the past month, I've experienced chest tightness, shortness of breath, occasional chest pain, and a dry cough, but no fever. Five days ago, I took a flight and lifted something heavy, which worsened my chest tightness. I also had a significant cough and chest pain. Three days ago, I visited an outside hospital. A chest CT scan on December 30, 2023, showed 90% compression of the left lung. A follow-up chest X-ray on January 2, 2024, showed the lung had essentially expanded.
[0050] Training the semantic transcription network: The network uses the Transformer model, and the dataset is divided into training, validation, and test sets in an 8:1:1 ratio. The input and output data of the training set are input into the network. During training, the model predicts the next token based on the currently generated token (as input), and uses masked self-attention to ensure that the decoder only focuses on the generated part to avoid information leakage. Maximum likelihood estimation (MLE) is used to minimize the cross-entropy loss between the predicted token and the true token. Greedy search or beam search is used to generate sequences in the inference stage, and the generation diversity is controlled by temperature parameters or Top-k sampling.
[0051] The similar case extraction module dynamically calls the medical record extraction module to collect and manage all medical records in the electronic medical record system (EMR). It uses the pyserini and sentence_transformers libraries to perform a mixed search using keywords and semantics, and sets a dynamic weight adjustment mechanism to increase the keyword weight for queries with intensive search keywords. It then matches similar cases with the data in the case system and selects the topK cases with high similarity.
[0052] For example, the top K cases with high similarity to the above semantic transcription data are:
[0053] The characteristics of Case A are as follows:
[0054] Mr. Li, male, 21 years old, was admitted to the hospital due to "sudden left chest pain and shortness of breath for 2 days, aggravated for 1 day".
[0055] History of present illness
[0056] Two days prior, the patient experienced sharp left-sided chest pain with shortness of breath, worsening with activity, without apparent cause. One day prior, symptoms worsened, accompanied by a dry cough, without fever or hemoptysis. A chest CT scan performed at an external hospital on November 15, 2023, showed 85% compression of the left lung. A chest X-ray on November 16, 2023, revealed a left-sided pneumothorax (compression >50%), and closed thoracic drainage was performed. A repeat chest X-ray on November 18, 2023, showed good left lung expansion, and the drainage tube was removed.
[0057] [Auxiliary examination] CT scan on November 15, 2023: Left lung compressed 85% (tension pneumothorax). Chest X-ray on November 18, 2023: Left lung fully expanded.
[0058] Physical Examination: Temperature 36.7°C, P 72 bpm, R 18 bpm, BP 118 / 76 mmHg. Clear consciousness, acceptable spirits, steady breathing, adequate nutrition, relaxed expression, normal development, self-positioning, fluent responses, and cooperative examination. Clear breath sounds bilaterally, with no dry or wet rales. No precordial bulge, large heart border, regular rhythm, and no pathological murmurs in any valvular area.
[0059] 2. Diagnosis and diagnostic basis
[0060] [Main diagnosis]: Left spontaneous pneumothorax
[0061] [Diagnostic basis]: The patient was a 21-year-old male who complained of sudden left-sided chest pain and shortness of breath for 2 days, which worsened for 1 day. Chest CT scan at an external hospital showed 85% compression of the left lung. After closed chest drainage, the lung was basically re-expanded, supporting the diagnosis of spontaneous pneumothorax.
[0062]
Secondary diagnosis
[0063] The characteristics of Case B are as follows:
[0064] Wang, a 17-year-old male, was admitted to the hospital due to "right chest pain and dyspnea for 1 week, aggravated for 2 days".
[0065] [Current Medical History] The patient developed sudden right-sided chest pain and dyspnea while playing basketball one week ago, which was slightly relieved after rest. Symptoms worsened two days ago, with shortness of breath occurring with even the slightest activity. A chest X-ray on September 10, 2023, showed a right-sided pneumothorax (70% compression), and thoracentesis was performed. A chest X-ray on September 12, 2023, showed recurrence of the pneumothorax (60% compression), and closed chest drainage was performed. A chest X-ray on September 15, 2023, showed complete right lung re-expansion, and the tube was removed.
[0066] [Assisted examination] Chest X-ray on September 10, 2023: right lung compression 70%. Chest X-ray on September 15, 2023: right lung re-expansion.
[0067] like Figure 2 As shown in the figure, the prompt engineering network module uses the initial prompt words of the first visit record and the output of the semantic transcription network module as input information to optimize the prompt words. For example, the initial prompt words of the first visit record are: Please generate a standardized first visit record based on the patient information {output of the semantic transcription network}. Specifically, it includes five modules: medical history characteristics, diagnosis and diagnostic basis, differential diagnosis, diagnosis and treatment principles, and issues to be noted during diagnosis and treatment.
[0068] Based on patient information, prompt words with department and disease characteristics are automatically constructed and then concatenated with the output of the similar case extraction module as the input required for subsequent large language model generation. The core of the prompt engineering network module is a prompt word optimizer, which is trained using the following method:
[0069] 1) Constructing a prompt-response pair dataset: Using both manual and model generation methods, prompts were constructed based on case labels such as department, disease type, and number of patient visits, as well as different structural elements of the first-line record (such as medical history characteristics, diagnosis and diagnostic basis, differential diagnosis, diagnosis and treatment principles, and issues that should be noted during diagnosis and treatment).
[0070] The model generation method uses a large language model (such as Deepseek-R1 and Qwen2.5-72B) to randomly generate several sets of prompt words. The manual method recruits a team of physicians and engineers to manually design prompt words. Prompt words from different structural element modules applicable to different departments and diseases are spliced together and added to the chain-generated instruction prompt words as input. The complete prompt words are fed into the large language model to obtain the model output, forming prompt word-output pairs, thereby constructing the dataset.
[0071] 2) Labeling Good and Bad Prompts: A team of professional doctors was invited to label prompt word and output pairs, assigning a good or bad label to each data point. If the proportion of good labels for a particular element in a particular case label was low, doctors interacted with the large language model to supplement more prompt word and output pairs with good labels. This ultimately resulted in a dataset of prompt word and output pairs with both good and bad labels.
[0072] 3) Training the prompt word optimizer: Using the dataset of prompt word-output pairs with good and bad labels constructed using the above method, we train the prompt word optimizer using the Black-Box Prompt Optimization (BPO) method. The prompt word optimizer uses the Transformer model (also known as the "Attention Is All You Need" model).
[0073] Based on the traditional supervised training method, contrastive learning loss is added. Prompt pairs with good labels are used as positive samples, prompt pairs with bad labels are also used as positive samples, and mappings of bad and bad or good to bad are used as negative samples. In addition, the concept of integration is introduced. During the testing phase, the top N prompts are selected and input into the model to obtain multiple response results for doctors' reference, thereby being compatible with the diversity of prompts in actual scenarios.
[0074] The output of the engineering network module is as follows:
[0075] You are a respiratory specialist. Please generate a first-pass transcript based on the patient information (output of the semantic transcription network) and key elements according to the following structure: Case Characteristics: Extract the patient's basic information, current medical history (symptoms + examinations + treatment), and physical examination highlights. Diagnosis and Supporting Information: Generate the primary and secondary diagnoses and supporting points. Differential Diagnosis: Sort by likelihood, with exclusion criteria for each. Diagnosis and Treatment Principles: Divide into three sections: monitoring, examination, and treatment. Precautions: Emphasize the risk of recurrence and complications.
[0076] The key points are as follows:
[0077] 1. Case characteristics:
[0078] Name, gender, age, admitted to hospital due to 'chief complaint'.
[0079] [History of current illness] Symptoms (chest tightness, shortness of breath, chest pain, cough), duration, triggers (such as flying, lifting heavy objects), results of external hospital examinations (CT / chest X-ray), and treatment history (such as closed chest drainage).
[0080] [Auxiliary examinations] Imaging (CT / chest X-ray), lung compression ratio, post-drainage recruitment, laboratory tests (such as blood gas analysis, blood routine).
[0081]
Physical examination
[0082] 2. Diagnosis and Evidence Generation
[0083] Primary diagnosis, secondary diagnosis, and diagnostic basis (clinical manifestations + imaging + high-risk factors).
[0084] 3. Differential Diagnosis Logic
[0085] Diseases that need to be excluded (such as pulmonary embolism, myocarditis), the basis for exclusion (such as no electrocardiogram abnormalities), and the probability ranking should be carried out.
[0086] 4. Diagnosis and Treatment Principles Template
[0087] Monitoring (SpO2, vital signs), etiology investigation (high-resolution CT), and treatment measures (oxygen therapy, surgical indications).
[0088] 5. Precautions
[0089] Recurrence risk, complication warning (re-expansion pulmonary edema), and patient education (avoid strenuous exercise).
[0090] The prompt words, semantic transcription data, and similar cases are combined and input into the large language model module to generate the first transcript. The large language model uses Qwen as the base model and optimizes its performance through continued pretraining, using supervised fine-tuning, human feedback reinforcement learning, and other techniques.
[0091] For example, the input of the large language model module is:
[0092] You are a respiratory specialist. Please generate a first-step record based on the patient's information, key points, and similar cases using the following structure: Case Characteristics: Extract the patient's basic information, current medical history (symptoms, examinations, and treatment), and physical examination highlights. Diagnosis and Supporting Information: Generate the primary and secondary diagnoses and supporting evidence. Differential Diagnosis: Sort by likelihood, with exclusion criteria for each. Diagnosis and Treatment Principles: Divide the case into three sections: monitoring, examination, and treatment. Precautions: Emphasize the risk of recurrence and complications.
[0093] {“Patient information”: output of semantic transcription network, “key elements”: output of prompt engineering network, “similar cases”: output of medical record management system.
[0094] The output of the large language model module is:
[0095] 1. Case characteristics:
[0096] xxx, male, 19 years old, was admitted to the hospital due to "chest tightness and shortness of breath for 1 month, aggravated by cough and chest pain for 5 days".
[0097] [Current Medical History] The patient experienced chest tightness, shortness of breath, occasional chest pain, and a dry cough for the past month. Five days ago, he took a flight while carrying heavy objects, which worsened his chest tightness and led to significant cough and chest pain. A chest CT scan on December 30, 2023, showed 90% compression of the left lung. A chest X-ray on December 31, 2023, confirmed a left-sided hydropneumothorax with compression exceeding 40%. He was treated with closed chest drainage on December 31, 2023. A repeat chest X-ray on January 2, 2024, showed that the lung had essentially expanded, and the drainage tube was removed.
[0098] [Assisted Examination] (2023-12-30, outside hospital) Chest CT: 90% compression of the left lung. 2024-01-01 Chest X-ray: A small pneumothorax in the left lung, improved compared to the previous (23-12-31), please refer to clinical follow-up. 2023-01-02 Chest X-ray: A small pneumothorax in the left lung has basically expanded compared to the previous (23-01-01), please refer to clinical follow-up.
[0099] Physical Examination: Temperature: 36.5°C, Phosphorus: 60 breaths / min, Rheumatoid Arthritis: 16 breaths / min, Blood Pressure: 120 / 70 mmHg. Clear consciousness, acceptable spirits, steady breathing, moderate nutrition, relaxed expression, normal development, self-positioning, fluent responses, and cooperative examination. Clear breath sounds bilaterally, with no dry or wet rales. No precordial bulge, no large heart borders, regular rhythm, and no pathological murmurs in the valvular areas.
[0100] 2. Diagnosis and diagnostic basis:
[0101] [Main diagnosis]: Left spontaneous pneumothorax
[0102] Diagnostic Basis: The patient was a 19-year-old male who presented with chest tightness and shortness of breath for one month. He had a history of air travel and heavy lifting before symptoms worsened. A chest CT scan at an external hospital showed 90% compression of the left lung. A chest radiograph further confirmed a left-sided hydropneumothorax. Following closed thoracic drainage, the lung largely expanded, supporting the diagnosis of spontaneous pneumothorax. An SPO2 of 92% (without oxygen) indicated mild hypoxemia, consistent with respiratory impairment caused by pneumothorax. Sudden onset of chest tightness and shortness of breath without a clear cause, especially given recent air travel history, raised concerns about air pressure fluctuations as a possible contributing factor.
[0103] Secondary diagnosis: None
[0104] 3. Differential diagnosis
[0105] 1. Acute myocardial infarction: Although the patient had chest pain symptoms, the electrocardiogram was normal, and the clinical manifestations and auxiliary examinations were more consistent with the characteristics of pneumothorax. Myocardial infarction is usually accompanied by typical electrocardiogram changes and abnormal myocardial enzyme spectrum, which were not mentioned in this case.
[0106] 2. Pneumonia or pulmonary embolism: The patient presents with chest tightness and shortness of breath but no fever, and CT primarily shows pneumothorax rather than typical imaging findings of pulmonary parenchymal inflammation or embolism, such as changes in lung markings or signs of pulmonary artery obstruction. Follow-up chest radiographs show improvement of the pneumothorax with no evidence of progressive inflammation or embolism.
[0107] 3. Rupture of pulmonary bullae: Considering that the patient had no obvious history of trauma but had sudden pneumothorax, especially associated with worsening chest tightness after lifting heavy objects, rupture of pulmonary bullae is a common cause of spontaneous pneumothorax, which is consistent with the patient's young age and no smoking history. However, the diagnosis of pulmonary bullae was not directly mentioned and needs to be further excluded in combination with CT imaging.
[0108] 4. Diagnosis and treatment principles:
[0109] 1. Routine respiratory care should be implemented, the patient's SPO2 and vital signs should be monitored, oxygen therapy should be given when necessary, and attention should be paid to dynamic changes in respiratory status.
[0110] 2. Complete imaging examinations, blood gas analysis, and, if necessary, thoracoscopy to determine the cause of pneumothorax, assess lung re-expansion, and adjust treatment strategies accordingly.
[0111] 3. Closely monitor the reexamination results to ensure recovery after closed chest drainage and promptly evaluate and address possible complications after recruitment.
[0112] V. Important Considerations During Treatment: 1. Regularly monitor oxygen saturation and adjust oxygen therapy promptly, avoiding overoxygenation. Attention should also be paid to changes in chest pain and dyspnea to ensure patient safety. 2. Fully communicate with the patient regarding the risk of recurrence of pneumothorax, the need for treatment, and possible subsequent preventive measures, including lifestyle adjustments and, if necessary, surgical intervention discussions, to ensure patient and family understanding and cooperation with disease management.
[0113] Continue with the pre-training method:
[0114] Based on the Qwen model as the base model, the method of continuing to pretrain the large language model is used for training, and a medical large language model is obtained using supervised fine-tuning and human feedback reinforcement learning technology, thereby assisting doctors in completing the task of assisting in writing electronic medical records.
[0115] The embodiment of the present invention integrates technologies such as large language models and prompt engineering to improve the completeness, accuracy and readability of the results of generating the first inpatient medical record, realize high-quality fully automatic structured generation of the first inpatient medical record, and improve the efficiency and quality of writing medical documents.
[0116] The present invention also provides a system for generating the first inpatient medical record based on a large model, which adopts the method for generating the first inpatient medical record based on a large model as described above, comprising:
[0117] The semantic transcription network module: Medical history writing requires that written content be based on objective facts. Non-standardized input content and excessive redundant information can cause confusion during algorithm model processing, reducing computing performance and output accuracy. The semantic transcription network can eliminate redundant information, standardize terminology, and transcribe language style from multi-source input, thereby reducing the computational complexity of subsequent modules and improving the overall computational efficiency and accuracy of the system.
[0118] The medical record extraction module and the similar case extraction module collect real hospital cases through real-time access to the EMR system. On the one hand, this can ensure the timeliness of external knowledge and timely update knowledge; on the other hand, through similar case matching, while improving the performance of large model generation, it can also provide style guidance on the language used in specific cases.
[0119] The prompt engineering network module can automatically judge and supplement reasonable prompt word information based on the input, including appropriate department templates, disease elements, etc., reducing the amount of manual adaptation engineering, improving the guiding effect of prompt words, and thus improving the accuracy of system output.
[0120] The large language model module concatenates the prompt word and similar cases and inputs them into the data to generate the first-pass transcript. The large language model uses Qwen as the base model and optimizes its performance through continued pretraining, using supervised fine-tuning, human feedback reinforcement learning, and other techniques.
[0121] The embodiment of the present invention provides a system for generating the first inpatient medical record based on a large model. When training a semantic transcription network, it can split and merge multi-source data, and transcribe it into a medical record writing style suitable for human reading, which can improve the authenticity, accuracy and objectivity of the content generated by the model. Using a black box prompt optimization method, combined with technical solutions such as contrastive learning, ensemble learning, and chain generation prompt engineering, it can achieve automatic adaptation of various task scenarios without human intervention. The introduction of a medical record management module automatically retrieves similar cases and guides the generation of documents. It can automatically adapt to the language style that doctors are accustomed to and improve the readability of documents. Through the integration of multiple technologies and the rational planning of data processing workflows, on the one hand, it can automatically adapt to different departments and diseases, realize the rapid and automatic pre-generation of medical records, greatly reduce the time for clinicians to write documents, and on the other hand, it can reduce factual errors in pre-generated content and improve the quality of documents.
[0122] When using the large model-based first-time inpatient medical record generation system of the present invention, the steps are as follows:
[0123] Step 1: The doctor confirms the completeness of the patient's admission record, examination and other input information.
[0124] Step 2: Trigger the need to generate the first trip record.
[0125] Step 3: Check the generated first-pass record content.
[0126] Step 4: Confirm, modify and save the content.
[0127] The system-side usage steps are as follows:
[0128] Prepare the first-journal input data, and the semantic transcription module performs event extraction, entity alignment, and style conversion on the input data (medical history, physical examination, and auxiliary examination) to generate semantic transcription results; then, with the help of the prompt engineering network, combine the initial prompt words of the first-journal and the semantic transcription results to expand the prompt engineering and obtain adaptive prompt words; input the semantic transcription results into the medical record management system, and the system will retrieve the topK similar case contents as samples, and integrate the samples and adaptive prompt words into a few-sample adaptive prompt words, and perform a second expansion of the prompt words. The few-sample adaptive prompt words that have been expanded twice are input into the large language model to generate content for the five modules in the first-journal.
[0129] Specific use cases are as follows:
[0130] Input information: Admission record
[0131] Name: xxx Gender: Male Age: 19
[0132]
Main complaint
[0133] Current Medical History: The patient had experienced chest tightness, shortness of breath, occasional chest pain, and a cough, primarily dry, for the past month, without fever. He had not sought medical attention. Five days ago, he returned to China by plane from Japan. While there, he lifted heavy objects, which worsened his chest tightness and led to significant cough and chest pain. Three days ago, he visited another hospital. A chest CT scan on December 30, 2023, showed 90% compression of the left lung. He subsequently presented to our emergency department. SpO2: 92% (without oxygen), and a normal electrocardiogram. A chest X-ray on December 31, 2023, revealed a left hydropneumothorax with compression greater than 40%. After informed consent, closed chest drainage was initiated. A repeat chest X-ray on January 2, 2024, showed that the lung had essentially expanded, and the chest tube was removed. The patient had no significant discomfort and was admitted today for further evaluation to determine the cause. Since the onset of his illness, he has been in good spirits, with poor appetite, good sleep, and normal urination. His weight has remained stable.
[0134] Past Medical History: The patient had experienced paroxysmal coughing, expectoration, and wheezing since childhood (exact age unknown) after catching a cold. These symptoms were more pronounced at night, without chest tightness or pain, and resolved spontaneously without specific treatment. The symptoms resolved in his teens and have not recurred. He has a history of hypertension for over 10 years, treated with oral losartan potassium. He began experiencing tremors in his hands 8 years ago, which were undiagnosed and untreated. He also has a history of prostatic hyperplasia for over 10 years, treated with finasteride.
[0135] History of infectious diseases: Denied history of "hepatitis, tuberculosis" infectious diseases. History of surgery and trauma: History of cataract surgery on both eyes. History of allergies: No history of drug or food allergies. History of major drug use: Same history. History of vaccination: No history of blood transfusion.
[0136] [System Review] Respiratory system: no cough, sputum, hemoptysis, dyspnea, chills, fever, night sweats Circulatory system: no palpitations, precordial pain; no dyspnea, edema, oliguria, etc. Digestive system: no vomiting, hematemesis; no melena and bloody stools; no abdominal pain, diarrhea; no jaundice of the skin and mucous membranes; no belching or acid reflux Urogenital system: no dysuria; no frequent urination, urgency, or pain when urinating; no edema Hematological system: no fatigue, dizziness, tinnitus, pale skin, petechiae, ecchymosis, hematoma, or enlarged liver, spleen, or lymph nodes Endocrine system: no chills, heat intolerance, sweating, fatigue, visual impairment, abnormal appetite, thirst, or polyuria Neuropsychiatric system: no headache, memory loss, impaired consciousness, syncope, convulsions, or abnormal sensation or movement Motor skeletal system: no numbness, pain, spasm, atrophy, or paralysis of limb muscles; no joint swelling or fractures
[0137] [Personal History] He grew up in his hometown, denied having bad habits such as smoking and drinking, and denied having any history of staying in the epidemic area.
[0138] [Marriage and childbearing history] Unmarried, no children.
[0139]
Family History
[0140] Physical Examination: Temperature: 36.5°C, Phrenia: 60 breaths / min, Rheumatoid Arthritis: 16 breaths / min, Blood Pressure: 120 / 70 mmHg. Clear consciousness, good spirits, stable breathing, moderate nutrition, relaxed expression, normal development, self-positioning, fluent responses, and cooperative examination. No jaundice, palmar erythema, or spider angiomas. No superficial lymphadenopathy, no skull deformities, no icteric sclera, no protruding eyes, pupils of equal size and roundness, sensitive to light, soft neck, neutral trachea, no thyroid enlargement, no chest deformity, clear breath sounds, no dry or wet rales. No precordial bulge, no enlarged heart border, regular heart rhythm, no pathological murmurs in any valve area. A soft, flat abdomen, no tenderness or rebound tenderness. The liver and spleen are not palpable below the ribs, and there is no percussion tenderness over the liver and kidneys. Bowel sounds are 4 beats / min, with a shifting dullness (-). No lower extremity swelling, and normal dorsalis pedis artery pulses. The anus and genitals were not examined, the limbs and spine had no deformity and could move freely, and the neurological system was examined (-).
[0141] [Assisted Examination] (2023-12-30, outside hospital) Chest CT: 90% compression of the left lung. 2024-01-01 Chest X-ray: A small pneumothorax in the left lung, improved compared to the previous (23-12-31), please refer to clinical follow-up. 2023-01-02 Chest X-ray: A small pneumothorax in the left lung has basically expanded compared to the previous (23-01-01), please refer to clinical follow-up.
[0142] The patient was admitted to the hospital with a diagnosis of left spontaneous pneumothorax.
[0143] Output information: First trip record
[0144] 1. Case characteristics:
[0145] xxx, male, 19 years old, was admitted to the hospital due to "chest tightness and shortness of breath for 1 month, aggravated by cough and chest pain for 5 days".
[0146] [Current Medical History] The patient experienced chest tightness and shortness of breath, occasional chest pain, and a dry cough for the past month. Five days ago, he took a flight while carrying heavy objects, which worsened his chest tightness and led to significant cough and chest pain. A chest CT scan on December 30, 2023, showed 90% compression of the left lung. A chest X-ray on December 31, 2023, confirmed a left-sided hydropneumothorax with compression exceeding 40%. He was treated with closed chest drainage on December 31, 2023. A repeat chest X-ray on January 2, 2024, showed that the lung had essentially re-expanded, and the drainage tube was removed.
[0147] [Assisted Examination] (2023-12-30, outside hospital) Chest CT: 90% compression of the left lung. 2024-01-01 Chest X-ray: A small pneumothorax in the left lung, improved compared to the previous (23-12-31), please refer to clinical follow-up. 2023-01-02 Chest X-ray: A small pneumothorax in the left lung has basically expanded compared to the previous (23-01-01), please refer to clinical follow-up.
[0148] Physical Examination: Temperature: 36.5°C, Phosphorus: 60 breaths / min, Rheumatoid Arthritis: 16 breaths / min, Blood Pressure: 120 / 70 mmHg. Clear consciousness, acceptable spirits, steady breathing, moderate nutrition, relaxed expression, normal development, self-positioning, fluent responses, and cooperative examination. Clear breath sounds bilaterally, with no dry or wet rales. No precordial bulge, no large heart borders, regular rhythm, and no pathological murmurs in the valvular areas.
[0149] 2. Diagnosis and diagnostic basis:
[0150] [Main diagnosis]: Left spontaneous pneumothorax
[0151] Diagnostic Basis: The patient was a 19-year-old male who presented with chest tightness and shortness of breath for one month. He had a history of air travel and heavy lifting before symptoms worsened. A chest CT scan at an external hospital showed 90% compression of the left lung. A chest radiograph further confirmed a left-sided hydropneumothorax. Following closed thoracic drainage, the lung largely expanded, supporting the diagnosis of spontaneous pneumothorax. An SPO2 of 92% (without oxygen) indicated mild hypoxemia, consistent with respiratory impairment caused by pneumothorax. Sudden onset of chest tightness and shortness of breath without a clear cause, especially given recent air travel history, raised concerns about air pressure fluctuations as a possible contributing factor.
[0152] Secondary diagnosis: None
[0153] 3. Differential diagnosis
[0154] 1. Acute myocardial infarction: Although the patient had chest pain symptoms, the electrocardiogram was normal, and the clinical manifestations and auxiliary examinations were more consistent with the characteristics of pneumothorax. Myocardial infarction is usually accompanied by typical electrocardiogram changes and abnormal myocardial enzyme spectrum, which were not mentioned in this case.
[0155] 2. Pneumonia or pulmonary embolism: The patient presents with chest tightness and shortness of breath but no fever, and CT primarily shows pneumothorax rather than typical imaging findings of pulmonary parenchymal inflammation or embolism, such as changes in lung markings or signs of pulmonary artery obstruction. Follow-up chest radiographs show improvement of the pneumothorax with no evidence of progressive inflammation or embolism.
[0156] 3. Rupture of pulmonary bullae: Considering that the patient had no obvious history of trauma but had sudden pneumothorax, especially associated with worsening chest tightness after lifting heavy objects, rupture of pulmonary bullae is a common cause of spontaneous pneumothorax, which is consistent with the patient's young age and no smoking history. However, the diagnosis of pulmonary bullae was not directly mentioned and needs to be further excluded in combination with CT imaging.
[0157] 4. Diagnosis and treatment principles:
[0158] 1. Routine respiratory care should be implemented, the patient's SPO2 and vital signs should be monitored, oxygen therapy should be given when necessary, and attention should be paid to dynamic changes in respiratory status.
[0159] 2. Complete imaging examinations, blood gas analysis, and, if necessary, thoracoscopy to determine the cause of pneumothorax, assess lung re-expansion, and adjust treatment strategies accordingly.
[0160] 3. Closely monitor the reexamination results to ensure recovery after closed chest drainage and promptly evaluate and address possible complications after recruitment.
[0161] V. Important Considerations During Treatment: 1. Regularly monitor oxygen saturation and adjust oxygen therapy promptly, avoiding overoxygenation. Attention should also be paid to changes in chest pain and dyspnea to ensure patient safety. 2. Fully communicate with the patient regarding the risk of recurrence of pneumothorax, the need for treatment, and possible subsequent preventive measures, including lifestyle adjustments and, if necessary, surgical intervention discussions, to ensure patient and family understanding and cooperation with disease management.
Claims
1. A method for generating the first inpatient medical record based on a large model, characterized in that: The following steps are involved: Retrieve the patient's medical records stored in the electronic medical record system, including admission records, auxiliary examination reports, laboratory test reports, etc., as well as the patient's previous outpatient and hospitalization medical records before the current visit; According to the mapping relationship between admission records, auxiliary examination reports, laboratory test reports and semantic transcription data, the patient's existing medical records for this hospitalization are processed to obtain semantic transcription data; Based on the patient's existing medical records and semantic transcription data for this hospitalization, a keyword and semantic hybrid search is used to match case medical records stored in the electronic medical record system that meet the threshold of similarity. Based on the semantic transcription data and the initial prompt words recorded during the first recording, the prompt words are optimized to construct optimized prompt words with department and disease characteristics; The large language model was trained using historical prompt words, historical semantic transcription data and historical case medical records to obtain a model for generating the first inpatient medical record. The optimized prompt words, semantic transcription data and case medical records were input into the model for generating the first inpatient medical record to obtain the first inpatient medical record corresponding to the patient's existing medical record documents for this hospitalization.
2. A method for generating the first inpatient medical record based on a large model as claimed in claim 1, characterized in that: The steps for establishing the mapping relationship are as follows: Collect historical hospitalization records, including admission records, auxiliary examination reports, laboratory test reports, and initial medical records; The historical hospitalization documents were pre-processed using Jieba word segmentation, and then synonyms were matched based on the term dictionary. The matching results were mapped to the standard coding system and the term structured data was output. For unmatched candidate terms, UMLS is used for manual review and supplementation, and term structured data is output; Based on terminology-structured data, we extract events by matching event patterns with regular expressions. We then use Gensim's LDA model to cluster the extracted events and generate topics, thereby obtaining historical hospitalization records with topics. Historical hospitalization records with themes were divided according to whether they were the first medical records. Non-first medical records were regarded as the first event set, and first medical records were regarded as the second event set. The first event set and the second event set are respectively converted into a first high-dimensional semantic vector set and a second high-dimensional semantic vector set, the similarity between each event in the first high-dimensional semantic vector set and each event in the second high-dimensional semantic vector set is calculated and sorted according to the topic, the events in the first event set whose similarity meets the preset threshold are used as semantic transcription data, and a mapping relationship is established based on the first event set and the semantic transcription data.
3. The method for generating the first inpatient medical record based on a large model according to claim 1, characterized in that: The prompt words are constructed based on case labels such as different departments, types of diseases, number of patient visits, as well as different structural elements of the first-line record such as medical history characteristics, diagnosis and diagnostic basis, differential diagnosis, diagnosis and treatment principles, and issues that should be paid attention to during diagnosis and treatment.
4. The method for generating the first inpatient medical record based on a large model according to claim 1, characterized in that: The first hospitalization medical record includes medical history characteristics, diagnosis and diagnostic basis, differential diagnosis, diagnosis and treatment principles and issues that should be paid attention to during diagnosis and treatment.
5. A system for generating the first inpatient medical record based on a large model, characterized by: The method for generating the first inpatient medical record based on a large model according to claim 1 is adopted, wherein the system for generating the first inpatient medical record based on a large model comprises: The medical record retrieval module is used to retrieve the patient's existing medical records for this hospitalization, including admission records, auxiliary examination reports, laboratory test reports, etc., as well as the patient's previous outpatient and hospitalization medical records before this visit; The semantic transcription network module is used to process the patient's existing medical records for this hospitalization based on the mapping relationship between admission records, auxiliary examination reports, laboratory test reports and semantic transcription data to obtain semantic transcription data; The similar case extraction module is used to retrieve medical records stored in the electronic medical record system based on the patient's existing medical records and semantic transcription data for this hospitalization. The similar case extraction module uses a mixed search of keywords and semantics to match case records from the medical records that meet the similarity threshold; The prompt engineering network module is used to optimize prompt words based on semantic transcription data and initial prompt words recorded in the first process, and construct optimized prompt words with department and disease characteristics; The large language model module is used to train the large language model using historical prompt words, historical semantic transcription data and historical case medical records to obtain a model for generating the first inpatient medical record. The optimized prompt words, semantic transcription data and case medical records are input into the model for generating the first inpatient medical record to obtain the first inpatient medical record corresponding to the patient's existing medical record documents for this hospitalization.
Citation Information
Cited By
Personalized medical document oriented large language model agent construction method and system
CN121096508A