[ADE-66] Enhance medical document processing by adding trusted medical sources for analysis and other improvements #110
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Change
This pull request introduces significant enhancements to the medical document processing pipeline by incorporating verification against trusted medical sources and improving error handling. Key changes include adding a verification step using Perplexity AI, updating the analysis logic to handle missing reference ranges, and expanding the Perplexity service with a new method for reviewing medical analyses.
Enhancements to Medical Document Analysis:
aws-bedrock.service.tsto include a list of trusted medical sources (e.g., Mayo Clinic, CDC, WHO) for analysis and to handle cases where reference ranges are missing by using standard ranges from these sources. ([[1]](https://github.com/ModusCreateOrg/app-med-ai-gen/pull/110/files#diff-5c85186b48ca73f6f71ee9bca3b21941f8a85b0f18c47f20c0bb94dfddcbb0adR59-R70),[[2]](https://github.com/ModusCreateOrg/app-med-ai-gen/pull/110/files#diff-5c85186b48ca73f6f71ee9bca3b21941f8a85b0f18c47f20c0bb94dfddcbb0adR103))Integration of Perplexity AI for Verification:
document-processor.service.tsto introduce a new step where Perplexity AI reviews and verifies the medical analysis. If the review fails, the system falls back to the initial analysis. ([backend/src/document-processor/services/document-processor.service.tsL58-R82](https://github.com/ModusCreateOrg/app-med-ai-gen/pull/110/files#diff-5e997b182ce449d133c60c45abf8b6a3951b5730d733d3cc56869f4d5624df89L58-R82))reviewMedicalAnalysismethod inperplexity.service.tsto validate medical document analyses against trusted sources, ensuring accuracy in lab values, interpretations, and recommendations. ([backend/src/services/perplexity.service.tsR165-R229](https://github.com/ModusCreateOrg/app-med-ai-gen/pull/110/files#diff-43cc86a138bda7d361d75e44ee9b0ff5c3128c44e30d9f7bc4cbc01a8ac6b45dR165-R229))Improvements to Perplexity API Interaction:
createChatCompletionmethod's description inperplexity.service.tsto clarify its purpose. ([backend/src/services/perplexity.service.tsL99-R99](https://github.com/ModusCreateOrg/app-med-ai-gen/pull/110/files#diff-43cc86a138bda7d361d75e44ee9b0ff5c3128c44e30d9f7bc4cbc01a8ac6b45dL99-R99))Does this PR introduce a breaking change?
{...}
What needs to be documented once your changes are merged?
{...}
Additional Comments
{...}