A method and system for generating real-time structured medical records that supports local regulation
By pre-building a machine-readable inference skeleton plan, parsing the template structure and slot guidance information offline, loading the plan in online stages and applying regional constraints, the problems of long generation time and non-closed format in the prior art are solved, and real-time streaming submission at the slot level is realized.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING HUIMEI CLOUD TECHNOLOGY CO LTD
- Filing Date
- 2026-05-11
- Publication Date
- 2026-07-31
AI Technical Summary
Existing technologies have problems such as long processing time for generating drafts, extracting fields, and making corrections when generating structured medical records, as well as ambiguous field boundaries and non-closed formats, making it difficult to achieve stable real-time submission at the slot level.
By pre-constructing a machine-readable inference skeleton plan, parsing the template structure and slot guidance information offline, loading the plan in the online stage and applying regional constraints, the generation behavior of the language model is controlled to ensure that the slot values are output immediately after generation.
It significantly shortens the time from request to output structured data, solves the problems of format drift and field misalignment, and realizes real-time streaming submission at the slot level.
Smart Images

Figure CN122177336B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of medical information technology, and in particular to a method and system for generating real-time structured medical records that supports local control. Background Technology
[0002] In the field of medical informatics, due to historical reasons in the design of traditional EMR (Electronic Medical Record) systems, many hospitals typically use medical record writing templates consisting of "fixed text paragraphs" and "slot placeholders" (such as...). This is a hybrid structure. The slots also carry fill attributes (required, empty, data type) and candidate values (such as standardized terms, enumerated options). This semi-structured template aims to balance the narrative standardization of documents with the structured collection of data.
[0003] With the widespread application of large language models in medical settings, automatically generating structured medical records using these models has become an important direction for improving clinical work efficiency. However, existing solutions for generating structured medical records using large models typically suffer from the following problems when handling complex templates: Chinese patent "CN120544764A" discloses a method, apparatus, computer equipment, and medium for generating scripts for extracting medical record data. This patent first allows a model to generate a full-text draft (free text) through a single inference, then extracts structured fields from the draft using information extraction technology, and finally performs consistency correction or completion. The problem is: Structured results often become available only after multiple steps, such as "generating drafts, extracting fields, and consistency correction / completeness," are completed sequentially, and the first field takes a relatively long time to become available.
[0004] The free expression in the first stage will result in various ways of writing the "same field", which will easily lead to ambiguity, misalignment or omission of field boundaries in the subsequent extraction stage, thus limiting the accuracy.
[0005] Chinese patent CN119694472B discloses a method, system, device, and storage medium for generating structured Chinese electronic medical records. This patent requires the model to "output in JSON or a fixed format" in its prompts, and then parses and performs error correction on the output. The problem lies in: The model needs to perform the dual tasks of "content reasoning" and "maintaining strict formatting". Common problems include missing fields, duplicate fields, unclosed structures, or the inclusion of explanatory text, which can lead to parsing failures or require complex fault tolerance.
[0006] When information is missing, the model tends to perform inferential completion in order to meet format requirements, and the consistency between fields (e.g., chief complaint-present illness-diagnosis) deteriorates due to format pressure.
[0007] During streaming output, because the JSON or fixed structure is not closed, in engineering, it is usually necessary to wait for the complete structure to be generated before it can be safely parsed and stored in the database, making it difficult to achieve stable real-time submission at the slot level. Summary of the Invention
[0008] Based on this, it is necessary to provide a real-time structured medical record generation method and system that supports local control to address the above-mentioned technical problems. By pre-constructing a machine-readable inference skeleton plan, the preliminary work such as template structure parsing and slot guidance information organization can be completed offline. In the online stage, only the plan needs to be loaded and a single inference is executed, which avoids the multi-stage serial time consumption of "generation, extraction and correction" in the existing technology and significantly shortens the time from request to output of structured data.
[0009] This invention provides a method for generating real-time structured medical records that supports local control, the method comprising: Obtain a semi-structured template from a medical institution, wherein the semi-structured template contains fixed text paragraphs and slot placeholders; Obtain the slot information associated with the semi-structured template, wherein the slot information includes the identifier, content description and data type of each slot; A machine-readable inference skeleton plan is generated based on a semi-structured template and slot information. The inference skeleton plan defines the internal guidance information and output format requirements of each fixed text paragraph and each slot in sequence. In response to the online medical record generation request, load the corresponding inference skeleton plan and obtain patient information and generation target; Using the inference skeleton plan as the control structure, constraints are imposed on the language model decoding process, and the generation behavior is controlled differently in different regions. After each slot value is generated and closed, structured update data containing the slot identifier and corresponding value is output in real time.
[0010] In one embodiment, obtaining the slot information associated with the semi-structured template includes: Perform an integrity check on the slot information to determine whether it covers all slot placeholders in the semi-structured template; If the coverage is incomplete, the large model will automatically generate the missing slot information and merge it with the acquired slot information to obtain a complete set of slot information.
[0011] In one embodiment, the step of automatically generating missing slot information using a large model includes: Input semi-structured templates and writing examples into the large model; The instruction big model outputs structured data, which includes the identifier of the missing slot, content description, data type, and candidate value set; The slot information output by the large model is merged with the acquired slot information to form complete slot information.
[0012] In one embodiment, the generation of a machine-readable inference skeleton plan based on a semi-structured template and slot information includes: Based on the paragraph order of the semi-structured template, create static nodes for each fixed text paragraph, with the node content being the original text. Create a slot node for each slot, which contains the slot identifier, internal guidance information, and output format requirements; The plan is to assemble all nodes into a structured data format inference skeleton according to the semi-structured template sequence.
[0013] In one embodiment, the constraint imposed on the language model decoding process using the inference skeleton plan as the control structure, and the differentiated control of generation behavior by region, includes: In the fixed region of the skeleton, by restricting the set of candidate lexical units, the currently allowed lexical units are limited to the fixed text or tags specified in the inference skeleton plan, forcing the model to output static content and slot guide tags in sequence; In the slot value region, remove the word restrictions to allow the model to freely generate slot value content; Once the end-of-value marker is detected, immediately switch back to the fixed skeleton region and continue generating subsequent nodes.
[0014] In one embodiment, the forced model to output static content and slot guide markers in sequence includes: The boot start marker, internal guidance information, and boot end marker are output sequentially. Output value start marker to enable slot value generation; The content subsequently generated by the model becomes the slot value, until the end-of-value marker is detected.
[0015] In one embodiment, the method further includes: Obtain multiple different semi-structured templates maintained by medical institutions; For each half of the structured template, the steps of obtaining slot information and generating inference skeleton plan are executed to obtain multiple corresponding inference skeleton plans. Each inference skeleton plan is associated with and stored with a corresponding template identifier, and can be loaded and used as needed during online generation.
[0016] This invention also provides a real-time structured medical record generation system supporting local control, applied to the real-time structured medical record generation method supporting local control described in any of the above embodiments, the system comprising: The template acquisition module is used to acquire semi-structured templates from medical institutions, wherein the semi-structured templates contain fixed text paragraphs and slot placeholders. The slot acquisition module is used to acquire slot information associated with the semi-structured template. The slot information includes the identifier, content description and data type of each slot. The plan generation module is used to generate a machine-readable inference skeleton plan based on a semi-structured template and slot information. The inference skeleton plan defines the internal guidance information and output format requirements of each fixed text paragraph and each slot in sequence. The request and response module is used to respond to online medical record generation requests, load the corresponding inference skeleton plan, and obtain patient information and generation objectives. The constraint control module is used to impose constraints on the language model decoding process using the inference skeleton plan as the control structure, and to control the generation behavior in a differentiated manner according to different regions. The update output module is used to output structured update data containing the slot identifier and corresponding value in real time after each slot value is generated and closed.
[0017] The present invention also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the real-time structured medical record generation method supporting local control as described above.
[0018] The present invention also provides a computer storage medium storing a computer program, which, when executed by a processor, implements the real-time structured medical record generation method supporting local control as described above.
[0019] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the real-time structured medical record generation method supporting local control as described above.
[0020] The aforementioned real-time structured medical record generation method and system that supports local control completes preliminary work such as template structure parsing and slot guidance information organization offline by pre-constructing a machine-readable inference skeleton plan; in the online stage, only the plan needs to be loaded and a single inference is executed, avoiding the multi-stage serial time consumption of "generation, extraction, and correction" in the prior art, and significantly shortening the time from request to output structured data.
[0021] By using the inference skeleton plan as the control structure for the decoding process, regional constraints are imposed on the language model (i.e., the skeleton fixed region is forced to output, and the slot value region is freely generated), which ensures the strict and stable output of skeleton parts such as fixed text paragraphs and slot guide marks. Compared with existing technologies that rely on prompt words or post-processing extraction, this fundamentally solves the problems of format drift, unclosed structure, or field misalignment caused by the free output of the model.
[0022] By adopting a "regional differentiated control" decoding strategy, structured data with clear slot identifiers can be output immediately after each slot value is generated and closed, without waiting for the full text to be generated. This achieves real-time streaming submission at the slot level, solving the problem of unstable real-time output in existing technologies due to the need to wait for the complete structure to be generated, and enabling downstream systems to obtain structured medical record fragments with lower latency. Attached Figure Description
[0023] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0024] Figure 1 A flowchart illustrating the steps of the real-time structured medical record generation method supporting local control provided by this invention; Figure 2 A block diagram of a real-time structured medical record generation system supporting local control provided by the present invention; Figure 3 The online stage-structured streaming reasoning state transition diagram provided by this invention; Figure 4 An internal structural diagram of the computer device provided by the present invention. Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0026] The following is combined Figures 1 to 4 This invention describes a method and system for generating real-time structured medical records that supports local control.
[0027] In one embodiment, a method for generating real-time structured medical records that supports localized regulation includes the following steps: Step S100: Obtain a semi-structured template of the medical institution, wherein the semi-structured template contains fixed text paragraphs and slot placeholders.
[0028] Specifically, the semi-structured template typically consists of fixed document paragraph text and slot placeholders (e.g., ...). Medical institutions maintain various types of medical record templates, such as admission records, discharge summaries, and progress notes, and these templates are iterated upon according to departmental standards.
[0029] Taking the simplified "admission record template" as an example, the specific form of the semi-structured template is as follows: [Basic Information] Name:
[0030] gender:
[0031] age:
[0032] Chief Complaint
[0033] [Preliminary Diagnosis]
[0034] The obtained template is a slotted semi-structured template actually used by medical institutions, which serves as the basic input for the subsequent generation of the reasoning skeleton plan.
[0035] Step S200: Obtain slot information associated with the semi-structured template. The slot information includes the identifier, content description and data type of each slot.
[0036] Specifically, the slot information set M obtained synchronously includes not only slot identifier, content description, and data type, but also slot filling attributes (required / empty, length) and optional candidate values / enumeration sets (such as diagnostic candidates, gender enumeration, etc.).
[0037] Taking the admission record template as an example, some slot information is as follows: 1. sex: Patient gender, enumeration, candidate values = [male, female, unknown]; 2. age: Patient's age, integer, candidate value = none; 3. primary_diagnosis: The patient's initial diagnosis upon admission, either an enumeration or a string. If there are too many candidate values, they will not be listed.
[0038] Step S300: Generate a machine-readable inference skeleton plan based on the semi-structured template and slot information. The inference skeleton plan defines the internal guidance information and output format requirements of each fixed text paragraph and each slot in sequence.
[0039] Specifically, the inference skeleton plan is a GSP (Guided Skeleton Plan) JSON, which is a standardized machine-readable representation of the template structure and slot information. It can be bound to the template identifier template_id for version management. The version update is triggered when any of the following occurs: template text modification, slot addition / deletion, or slot attribute change. The inference skeleton plan must be regenerated and the version information updated. This plan solidifies the logic of "how the template structure should be executed and how each slot should be filled", realizing the forward shift of template understanding cost and reuse. It is the core control structure for online stage constraint large model decoding.
[0040] Step S400: Respond to the online medical record generation request, load the corresponding inference skeleton plan, and obtain patient information and generation target.
[0041] Specifically, the online input consists of three core types of information: Patient Information B (structured or semi-structured text is acceptable); Generate target P (the medical record content to be generated, such as: "discharge summary", "treatment process in the discharge summary"); Load the GSP JSON that was generated offline beforehand using template_id.
[0042] After receiving the online request, perform loading and initialization operations: Initialize slot index i=1, value buffer buf, and enter the WAIT_ASSIST state. This state is used to distinguish between system prompts and model responses, avoiding the mistaken use of user input or system messages as the starting point for forced skeleton output; the specific judgment method is as follows: Skeleton forcing and value extraction are not performed until the model outputs the assistant role tag or generates the first valid token. Once the model is detected to have entered the assistant output area (i.e., the model outputs the assistant role tag or starts generating the first valid token), the process transitions to the SKELETON skeleton field forcing output phase.
[0043] Online input is encapsulated through the standard chat template interface of the target model, or it can be directly appended with the static template content of the first paragraph (if the first item in the parts list has the type "static"). Taking Qwen3 as an example, the appended format is: <|im_start|>system You are a medical record assistant.
[0044] <|im_end|> <|im_start|>user Patient information: ... <|im_end|> <|im_start|>assistant (Template starting static fragment) <def> (Requirements for generating VALUE)< / def> <value> Step S500: Using the inference skeleton plan as the control structure, constraints are imposed on the language model decoding process, and the generation behavior is controlled differently by region.
[0045] Specifically, unlike existing technologies that use cue word constraints or post-processing extraction, this embodiment generates and constrains the skeleton while allowing free reasoning within the value range: In the "skeleton fixed fragment" stage, the inference service restricts the set of candidate lexical units allowed for the next step to the lexical units expected by the skeleton, forcing the model to output according to the skeleton; The skeleton words that are forced to be output will enter the model context. The model is aware of the skeleton and DEF guidance and will affect the inference content of subsequent VALUE. During the "value range" stage, the model generates the slot values. Once the value range closure flag is detected, the system immediately switches back to the skeleton fixed segment stage.
[0046] The process is executed linearly along with the token stream, meeting the requirements for high performance and real-time output. The structured generation can be completed in a single inference call, without the need for multi-stage serial processing.
[0047] Step S600: After each slot value is generated and closed, the structured update data containing the slot identifier and corresponding value is output in real time.
[0048] Specifically, after the slot value is generated and closed, the EMT_UPDATE slot update phase begins: First, the contents of the value buffer buf are subjected to necessary normalization processing, including removing quotes, trimming redundant characters (the criteria for judging redundant characters are invalid spaces at the beginning and end of the slot value, meaningless punctuation marks, and explanatory text not related to the slot value that is mistakenly generated by the model), and verifying the mapping between the data type of the slot information and the candidate value. After processing, the final slot value v_i of the slot is obtained; then, a slot-level structured update event is immediately output.
[0049] The update event format is: update (slot_id_i, value=v_i [, path_i (path_i is the hierarchical path of the current slot in the parts node of the GSP JSON)][, step (step is the total number of steps in generating the current medical record)][, value_step (value_step is the number of steps in generating the current slot value)]).
[0050] If there is still a next slot, then set the slot index i = i + 1, clear the value buffer buf, and return to the SKELETON skeleton field stage; if there are no subsequent slots, then enter the SUFFIX stage, and the generation process ends.
[0051] The following is an example of online execution: Load the inference skeleton plan with template_id=admission_note_simple. The online input is "Patient name Zhang San, male, 34 years old, chief complaint of fever and cough for 3 days." In a single inference, slot-level streaming updates will be generated in slot order. First, update(slot_id="patient_name", value="Zhang San") will be output, followed by update(slot_id="sex", value="male"), and so on, updating all slots in sequence. The final complete output medical record text is only a concatenation of "static template fragments and values of each slot". DEF and VALUE markers are not included in the visible text, for example, "[Basic Information]". Name: Zhang San Gender: Male...
[0052] This process enables stable streaming submission at the slot level, without waiting for the full text to be generated or relying on fault-tolerant parsing of semi-finished JSON. Downstream systems can obtain structured medical record fragments in real time, significantly reducing data acquisition latency.
[0053] It should be noted that the online phase structured streaming reasoning state transition diagram is as follows: Figure 3 As shown.
[0054] The aforementioned real-time structured medical record generation method supporting local control first obtains a semi-structured template containing fixed text paragraphs and slot placeholders, along with their associated slot information, to generate a machine-readable inference skeleton plan. This plan sequentially defines the internal guidance information and output format requirements for each fixed text paragraph and slot. Based on this, when responding to an online medical record generation request, the corresponding inference skeleton plan is loaded, and this plan serves as the control structure to constrain the decoding process of the language model, achieving differentiated control of generation behavior by region. Finally, after each slot value is generated and closed, structured update data containing the slot identifier and corresponding value is output in real time.
[0055] By pre-constructing a machine-readable inference skeleton plan, preliminary work such as template structure parsing and slot guidance information organization is completed offline; in the online stage, only the plan needs to be loaded and a single inference is executed, avoiding the multi-stage serial time consumption of "generation, extraction, and correction" in existing technologies, and significantly shortening the time from request to output structured data.
[0056] By using the inference skeleton plan as the control structure for the decoding process, regional constraints are imposed on the language model (i.e., the skeleton fixed region is forced to output, and the slot value region is freely generated), which ensures the strict and stable output of skeleton parts such as fixed text paragraphs and slot guide marks. Compared with existing technologies that rely on prompt words or post-processing extraction, this fundamentally solves the problems of format drift, unclosed structure, or field misalignment caused by the free output of the model.
[0057] By adopting a "regional differentiated control" decoding strategy, structured data with clear slot identifiers can be output immediately after each slot value is generated and closed, without waiting for the full text to be generated. This achieves real-time streaming submission at the slot level, solving the problem of unstable real-time output in existing technologies due to the need to wait for the complete structure to be generated, and enabling downstream systems to obtain structured medical record fragments with lower latency.
[0058] In one embodiment, obtaining the slot information associated with the semi-structured template includes the following steps: Step S210: Perform an integrity check on the slot information to determine whether it covers all slot placeholders in the semi-structured template.
[0059] Specifically, the completeness judgment follows these criteria: each slot placeholder in template T must have a corresponding entry in the slot information set M, and each entry must have at least a slot meaning description and data type. If the slot information explicitly requires the existence of candidate values (such as enumerable fields like gender or diagnostic classification), then the corresponding candidate value set in M must also be provided completely. If the candidate value set is missing but should have an enumerable range according to the slot content description, it is also considered incomplete. Among these, the candidate values for enumerable type slots must be provided in a list or equivalent structured form.
[0060] If the above conditions are met, the slot information is complete; otherwise, it is missing.
[0061] Taking the admission record template as an example, it is necessary to determine Each slot has a corresponding entry in M, and each entry must contain at least a content description and a data type. If these conditions are met, the slot information is complete; otherwise, it is missing.
[0062] In step S220, if the coverage is incomplete, the large model is called to automatically generate the missing slot information and merge it with the acquired slot information to obtain a complete set of slot information.
[0063] Specifically, missing slot information includes three situations: medical institutions do not provide slot information, only provide partial slot information, or the provided slot information lacks necessary fields (such as no data type or incomplete content description). In all these cases, the process of automatically generating missing slot information by the large model needs to be triggered. The generated slot information needs to be merged with the partial metadata already provided by the medical institution to form the final usable set of slot information.
[0064] In one embodiment, the step of automatically generating missing slot information using a large model includes the following steps: Step S221: Input semi-structured templates and writing examples into the large model.
[0065] Specifically, the input to the large model consists of the full content of the semi-structured template T provided by the medical institution, as well as several real medical record writing examples corresponding to the template. The writing examples must be medical record texts that are actually used in clinical practice by the medical institution, conform to the template specifications, and have no formatting errors. The number of reference examples should be at least 1-3 valid examples to provide a reference basis for the large model to generate accurate slot information. The input content has no extra redundant information to ensure that the large model focuses on the generation of slot information.
[0066] Step S222: The instruction large model outputs structured data, which includes the identifier of the missing slot, content description, data type, and candidate value set.
[0067] Specifically, strict format requirements are imposed on the output of large models, requiring them to output only structured data in strict JSON format and not to output any explanatory text; the JSON data must clearly provide the core information of each missing slot, including the slot identifier (which can be obtained by mapping from placeholders in the template or field names generated by the model), content description (clearly defining the meaning of the information that needs to be filled in the slot), data type (such as string / enumeration / date / number / multi-value list, etc.), and candidate value set.
[0068] The conditions for generating the candidate value set are that the value range of the slot is enumerable and the number is moderate (moderate number means that the model automatically judges based on domain knowledge, or the system presets a threshold of ≤20 items; if the threshold is exceeded or cannot be enumerated, it is marked as "no candidate value" or left blank). If the value range cannot be enumerated or the number is too large, it is marked as "no candidate value" or left blank.
[0069] Step S223: Merge the slot information output by the large model with the acquired slot information to form complete slot information.
[0070] Specifically, the merging process performs precise matching based on slot identifiers. The slot information already provided by medical institutions remains unchanged. The missing slot information generated by the large model is supplemented into the slot information set M according to the slot order of the template, forming a complete M that covers all slot placeholders of the template. The merged slot information is still stored in a structured form, which is convenient for subsequent splicing with the template to generate the inference skeleton plan.
[0071] In one embodiment, generating a machine-readable inference skeleton plan based on a semi-structured template and slot information includes the following steps: Step S310: Based on the paragraph order of the semi-structured template, create static nodes for each fixed text segment, with the node content being the original text.
[0072] Specifically, following the natural paragraph and text order of the semi-structured template, fixed text content is extracted segment by segment, and a static node is created for each segment of fixed text. The node contains only the original template text and has no additional redundant information.
[0073] Taking the admission record template as an example, it consists of "[Basic Information]". Name: "Create a static node with the original text content as '" Gender: "Create a separate static node, maintaining the same order as the template."
[0074] Step S320: Create a slot node for each slot. The node contains a slot identifier, internal guidance information, and output format requirements.
[0075] Specifically, create a slot node of type `slot` for each slot in the template. The node must contain core information: The slot identifier, slot_id, is consistent with the identifier in the template placeholder and the slot information set; The internal guidance information, guidance_text, is generated by combining the content description, data type, and candidate value set (if any) from the slot information.
[0076] This combination can use the standardized sentence structure of "Generate + Slot content description + (If there are candidate values, add 'limited to + candidate value set')", or it can use other equivalent natural language expressions, as long as the generation requirements of the slot are clear (such as "Generate gender, limited to male / female / unknown"). The output format requirement is `value_format`, which defines the output format of the slot value (e.g., `quoted_string`). The creation order of the slot nodes is exactly the same as the order in which the slot placeholders appear in the template.
[0077] Step S330: Assemble all nodes into a structured data format inference skeleton plan according to the semi-structured template sequence.
[0078] Specifically, all created static nodes and slot nodes are arranged sequentially according to the text and slot order of the semi-structured template, and then concatenated into a predefined format of standardized JSON, namely the inference skeleton plan GSP JSON. Taking the simplified admission record template as an example, the assembled inference skeleton plan contains the following content: { "template_id": "admission_note_simple", "parts": [ {"type": "static", "text": "
Basic Information
[0079] In one embodiment, the method of using the inference skeleton plan as the control structure to impose constraints on the language model decoding process and to differentiate the generation behavior by region includes the following steps: Step S510: In the fixed skeleton region, by restricting the candidate lexical set, the currently allowed lexicals are limited to the fixed text or tags specified in the inference skeleton plan, and the model is forced to output static content and slot guide tags in sequence.
[0080] Specifically, during the SKELETON skeleton field forced output phase, the parts nodes of the inference skeleton plan are executed in strict order. First, the static fragment content of the current type is output, and then the internal guidance and value range opening mark of the current slot are output. The skeleton forced output supports multiple implementation granularities such as word-by-word meta-constraint, segmentation constraint, or finite state constraint syntax, all of which are equivalent implementation methods.
[0081] Forced output is achieved by restricting the candidate lexical set to the expected skeleton lexical set. The specific logic for constructing the lexical set is to extract the static node text from the GSP. <def> / < / def> < / value> Effective lexical units are extracted word by word from the core tags, and after deduplication, a skeleton expectation lexical unit library without redundancy is formed. The model can only select output from the limited lexical unit set to ensure that the skeleton content is output in order and stably, without format drift or misalignment issues. The lexical units that are forced to be output are synchronously entered into the model context. The context update time of the skeleton lexical units is to update the model inference context in real time after each lexical unit is output, so that the model can perceive the slot generation requirements.
[0082] Step S520: In the slot value region, remove the word restriction to allow the model to freely generate slot value content.
[0083] Specifically, after entering the VALUE stage, the inference service completely removes the restrictions on the candidate word set, allowing the model to fully utilize its content inference capabilities and freely generate slot value content that conforms to the internal guidance information of the slot. The content generated by the model in real time is continuously written into the pre-initialized value buffer buf. The buffer is updated in real time with the model generation process, with no content length limit, adapting to the generation needs of different slots.
[0084] In step S530, after detecting the end-of-value marker, immediately switch back to the skeleton fixed region and continue generating subsequent nodes.
[0085] Specifically, the inference service monitors the output content in real time during model generation. When a value domain closure flag is detected, it determines that the current slot value has been generated. First, it performs necessary normalization processing on the content in the value buffer buf, including removing quotes, pruning redundant characters, and verifying the mapping between the data type of the slot information and the candidate value. After processing, the final slot value v_i of the slot is obtained, and a slot-level structured update event is immediately output (i.e., the EMT_UPDATE stage of step S600). After the update output is completed, the VALUE value domain stage is immediately terminated, and the process switches back to the SKELETON skeleton domain forced output stage. If there are still subsequent static nodes and slot nodes in the template, the forced output of subsequent nodes continues to be executed in the order of the inference skeleton plan until all nodes are processed.
[0086] In one embodiment, the forced model to output static content and slot guide markers in sequence includes the following steps: Step S511: Output the boot start marker, internal guidance information, and boot end marker in sequence.
[0087] Specifically, the bootstrap start marker is <def> The guide ends with the marker.< / def> During the skeleton domain phase, output in sequence. <def> +guidance_text, the internal guidance information for slot nodes in the inference skeleton plan+< / def>This section only serves as contextual signals during the decoding process and is not included in the final output medical record text. This balances "model-aware guidance" with "clean user-visible output." For example, for the sex slot, the output... <def> Generate gender, limited to male / female / unknown.< / def> .
[0088] Step S512: Output value start marker to enable slot value generation.
[0089] Specifically, the starting value is marked as <value>After outputting the internal guidance marks and information of the slot, immediately output <value>As a sign that the value domain is open, the model detects this mark and enters the VALUE value domain stage of slot value generation. This mark is the key dividing marker between the skeleton domain and the value domain. It can be replaced with an equivalent private mark or an equivalent boundary symbol. The replacement mark must be a private symbol that the model cannot recognize. After replacement, the accuracy of state detection and the logical consistency of domain switching must be guaranteed, without affecting the core generation process or core functions.
[0090] In step S513, the content subsequently generated by the model is the slot value, until the end-of-value marker is detected.
[0091] Specifically, the model is in <value> All content generated after marking will be the slot value for that slot, and marking will end when a value is detected.< / value> The end marker is the back-cut identifier between the value domain and the skeleton domain. It can also be replaced with an equivalent private marker or an equivalent boundary symbol. The replacement marker must be a private symbol that the model cannot recognize. After replacement, the accuracy of state detection and the logical consistency of domain switching must be guaranteed, and the core generation process must not be affected. Between the value start marker and the end marker, the model only focuses on the content reasoning of the slot value and has no format-related output pressure.
[0092] In one embodiment, the method further includes the following steps: Step S710: Obtain multiple different semi-structured templates maintained by the medical institution.
[0093] Specifically, the system acquires all semi-structured medical record templates maintained by various departments and treatment processes within medical institutions in batches, including but not limited to admission records, discharge summaries, progress notes, surgical records, and consultation records. All templates are slotted semi-structured templates actually used in clinical practice by medical institutions and are categorized and organized by department and template type to prepare for subsequent batch generation of inference skeletons.
[0094] Step S720: For each half of the structured template, perform the steps of obtaining slot information and generating inference skeleton plan to obtain multiple corresponding inference skeleton plans.
[0095] Specifically, for each semi-structured template after processing, the entire process from step S200 (obtaining slot information, including integrity judgment, missing information generation, and merging) to step S330 (generating the inference skeleton plan) is executed independently. That is, the slot information is obtained and completed separately for each template, and then the corresponding GSP JSON inference skeleton plan is generated separately. Each template is assigned an independent processing task and dataset, and the processing flow is executed in a process isolation manner to ensure that the processing data of different templates does not overlap and the process does not interfere with each other, and to ensure that each inference skeleton plan corresponds one-to-one with the template.
[0096] Step S730: Each inference skeleton plan is associated with and stored with the corresponding template identifier for on-demand loading during online generation.
[0097] Specifically, a unique template identifier, template_id, is assigned to each semi-structured template. The GSP JSON of the inference skeleton plan corresponding to each template is precisely bound to the template_id and stored using a version-based management method. The version update is triggered when any of the following occurs: template text modification, slot addition / deletion, or slot attribute change. In this case, the corresponding process must be re-executed to generate a new inference skeleton plan and update the version information corresponding to template_id. During the online generation phase, the inference service only needs to use the template_id in the online request to quickly and accurately load the corresponding inference skeleton plan, enabling on-demand invocation.
[0098] The real-time structured medical record generation system supporting local control provided by the present invention will be described below. The real-time structured medical record generation system supporting local control described below and the real-time structured medical record generation method supporting local control described above can be referred to in correspondence.
[0099] In one embodiment, a real-time structured medical record generation system supporting local control is applied to the real-time structured medical record generation method supporting local control described in any of the above embodiments. The system includes a template acquisition module, a slot acquisition module, a plan generation module, a request response module, a constraint control module, and an update output module.
[0100] The template acquisition module is used to acquire semi-structured templates from medical institutions. The semi-structured templates contain fixed text paragraphs and slot placeholders.
[0101] The slot acquisition module is used to acquire slot information associated with the semi-structured template. The slot information includes the identifier, content description and data type of each slot.
[0102] The plan generation module is used to generate a machine-readable inference skeleton plan based on a semi-structured template and slot information. The inference skeleton plan defines the internal guidance information and output format requirements of each fixed text paragraph and each slot in sequence.
[0103] The request-response module is used to respond to online medical record generation requests, load the corresponding inference skeleton plan, and obtain patient information and generation objectives.
[0104] The constraint control module is used to impose constraints on the language model decoding process using the inference skeleton plan as the control structure, and to control the generation behavior in a differentiated manner according to different regions.
[0105] The update output module is used to output structured update data containing the slot identifier and corresponding value in real time after each slot value is generated and closed.
[0106] Figure 4 This example illustrates a schematic diagram of the physical structure of an electronic device, which can be a smart terminal. Its internal structure diagram can be as follows: Figure 4 As shown, the electronic device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface is used to communicate with external terminals via a network connection. When the computer program is executed by the processor, it implements a real-time structured medical record generation method that supports localized control.
[0107] Those skilled in the art will understand that Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present invention and does not constitute a limitation on the electronic device to which the present invention is applied. A specific electronic device may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0108] On the other hand, the present invention also provides a computer storage medium storing a computer program, which, when executed by a processor, implements a real-time structured medical record generation method that supports local control.
[0109] On another front, a computer program product or computer program is provided, comprising computer instructions stored in a computer storage medium. A processor of an electronic device reads the computer instructions from the computer storage medium, and when the processor executes the computer instructions, it implements a real-time structured medical record generation method supporting localized control.
[0110] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided by this invention can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory.
[0111] By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0112] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0113] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the appended claims.< / value> < / value>
Claims
1. A method for generating real-time structured medical records that supports local control, characterized in that, The method includes: Obtain a semi-structured template from a medical institution, wherein the semi-structured template contains fixed text paragraphs and slot placeholders; Obtain the slot information associated with the semi-structured template, wherein the slot information includes the identifier, content description and data type of each slot; A machine-readable inference skeleton plan is generated based on a semi-structured template and slot information. The inference skeleton plan defines the internal guidance information and output format requirements of each fixed text paragraph and each slot in sequence. The inference skeleton plan includes: creating static nodes for each fixed text segment according to the paragraph order of the semi-structured template, with the node content being the original text; creating slot nodes for each slot, with each node containing a slot identifier, internal guidance information, and output format requirements; and assembling all nodes into an inference skeleton plan in a structured data format according to the semi-structured template order. In response to the online medical record generation request, load the corresponding inference skeleton plan and obtain patient information and generation target; Using the inference skeleton plan as the control structure, constraints are imposed on the language model decoding process, and the generation behavior is controlled differently in different regions. This includes: in the fixed skeleton region, by restricting the candidate word set, the currently allowed words to be generated are limited to fixed text or tags specified in the inference skeleton plan, forcing the model to output static content and slot guide tags in sequence; in the slot value region, the word restrictions are lifted, allowing the model to freely generate slot value content; after detecting the end of the value tag, the model immediately switches back to the fixed skeleton region and continues the generation of subsequent nodes. After each slot value is generated and closed, structured update data containing the slot identifier and corresponding value is output in real time.
2. The real-time structured medical record generation method supporting local regulation according to claim 1, characterized in that, The step of obtaining the slot information associated with the semi-structured template includes: Perform an integrity check on the slot information to determine whether it covers all slot placeholders in the semi-structured template; If the coverage is incomplete, the large model will automatically generate the missing slot information and merge it with the acquired slot information to obtain a complete set of slot information.
3. The real-time structured medical record generation method supporting local regulation according to claim 2, characterized in that, The process of automatically generating missing slot information using a large model includes: Input semi-structured templates and writing examples into the large model; The instruction big model outputs structured data, which includes the identifier of the missing slot, content description, data type, and candidate value set; The slot information output by the large model is merged with the acquired slot information to form complete slot information.
4. The real-time structured medical record generation method supporting local control according to claim 3, characterized in that, The forced model outputs static content and slot guide markers in sequence, including: The boot start marker, internal guidance information, and boot end marker are output sequentially. Output value start marker to enable slot value generation; The content subsequently generated by the model becomes the slot value, until the end-of-value marker is detected.
5. The real-time structured medical record generation method supporting local control according to claim 4, characterized in that, The method further includes: Obtain multiple different semi-structured templates maintained by medical institutions; For each half of the structured template, the steps of obtaining slot information and generating inference skeleton plan are executed to obtain multiple corresponding inference skeleton plans. Each inference skeleton plan is associated with and stored with a corresponding template identifier, and can be loaded and used as needed during online generation.
6. A real-time structured medical record generation system supporting local control, applied to the real-time structured medical record generation method supporting local control as described in any one of claims 1 to 5, characterized in that, The system includes: The template acquisition module is used to acquire semi-structured templates from medical institutions, wherein the semi-structured templates contain fixed text paragraphs and slot placeholders. The slot acquisition module is used to acquire slot information associated with the semi-structured template. The slot information includes the identifier, content description and data type of each slot. The plan generation module is used to generate a machine-readable inference skeleton plan based on a semi-structured template and slot information. The inference skeleton plan defines the internal guidance information and output format requirements of each fixed text paragraph and each slot in sequence. The request and response module is used to respond to online medical record generation requests, load the corresponding inference skeleton plan, and obtain patient information and generation objectives. The constraint control module is used to impose constraints on the language model decoding process using the inference skeleton plan as the control structure, and to control the generation behavior in a differentiated manner according to different regions. The update output module is used to output structured update data containing the slot identifier and corresponding value in real time after each slot value is generated and closed.
7. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.
8. A computer storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.