@imranq2/fhirpatientsummary 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +81 -0
- package/lib/src/generators/fhir_summary_generator.d.ts +46 -0
- package/lib/src/generators/fhir_summary_generator.js +228 -0
- package/lib/src/generators/narrative_generator.d.ts +40 -0
- package/lib/src/generators/narrative_generator.js +80 -0
- package/lib/src/narratives/templates/typescript/AdvanceDirectivesTemplate.d.ts +22 -0
- package/lib/src/narratives/templates/typescript/AdvanceDirectivesTemplate.js +70 -0
- package/lib/src/narratives/templates/typescript/AllergyIntoleranceTemplate.d.ts +31 -0
- package/lib/src/narratives/templates/typescript/AllergyIntoleranceTemplate.js +155 -0
- package/lib/src/narratives/templates/typescript/ClinicalImpressionTemplate.d.ts +15 -0
- package/lib/src/narratives/templates/typescript/ClinicalImpressionTemplate.js +111 -0
- package/lib/src/narratives/templates/typescript/DiagnosticResultsTemplate.d.ts +50 -0
- package/lib/src/narratives/templates/typescript/DiagnosticResultsTemplate.js +153 -0
- package/lib/src/narratives/templates/typescript/FamilyHistoryTemplate.d.ts +15 -0
- package/lib/src/narratives/templates/typescript/FamilyHistoryTemplate.js +103 -0
- package/lib/src/narratives/templates/typescript/FunctionalStatusTemplate.d.ts +22 -0
- package/lib/src/narratives/templates/typescript/FunctionalStatusTemplate.js +70 -0
- package/lib/src/narratives/templates/typescript/HistoryOfProceduresTemplate.d.ts +22 -0
- package/lib/src/narratives/templates/typescript/HistoryOfProceduresTemplate.js +66 -0
- package/lib/src/narratives/templates/typescript/ImmunizationsTemplate.d.ts +22 -0
- package/lib/src/narratives/templates/typescript/ImmunizationsTemplate.js +73 -0
- package/lib/src/narratives/templates/typescript/MedicalDevicesTemplate.d.ts +22 -0
- package/lib/src/narratives/templates/typescript/MedicalDevicesTemplate.js +67 -0
- package/lib/src/narratives/templates/typescript/MedicationSummaryTemplate.d.ts +50 -0
- package/lib/src/narratives/templates/typescript/MedicationSummaryTemplate.js +206 -0
- package/lib/src/narratives/templates/typescript/PastHistoryOfIllnessTemplate.d.ts +15 -0
- package/lib/src/narratives/templates/typescript/PastHistoryOfIllnessTemplate.js +59 -0
- package/lib/src/narratives/templates/typescript/PatientTemplate.d.ts +65 -0
- package/lib/src/narratives/templates/typescript/PatientTemplate.js +158 -0
- package/lib/src/narratives/templates/typescript/PlanOfCareTemplate.d.ts +15 -0
- package/lib/src/narratives/templates/typescript/PlanOfCareTemplate.js +63 -0
- package/lib/src/narratives/templates/typescript/PregnancyTemplate.d.ts +22 -0
- package/lib/src/narratives/templates/typescript/PregnancyTemplate.js +68 -0
- package/lib/src/narratives/templates/typescript/ProblemListTemplate.d.ts +22 -0
- package/lib/src/narratives/templates/typescript/ProblemListTemplate.js +119 -0
- package/lib/src/narratives/templates/typescript/SocialHistoryTemplate.d.ts +22 -0
- package/lib/src/narratives/templates/typescript/SocialHistoryTemplate.js +70 -0
- package/lib/src/narratives/templates/typescript/TemplateUtilities.d.ts +251 -0
- package/lib/src/narratives/templates/typescript/TemplateUtilities.js +696 -0
- package/lib/src/narratives/templates/typescript/TypeScriptTemplateMapper.d.ts +17 -0
- package/lib/src/narratives/templates/typescript/TypeScriptTemplateMapper.js +64 -0
- package/lib/src/narratives/templates/typescript/VitalSignsTemplate.d.ts +22 -0
- package/lib/src/narratives/templates/typescript/VitalSignsTemplate.js +74 -0
- package/lib/src/narratives/templates/typescript/interfaces/ITemplate.d.ts +13 -0
- package/lib/src/narratives/templates/typescript/interfaces/ITemplate.js +2 -0
- package/lib/src/profiles/ips_resource_profile_registry.d.ts +7 -0
- package/lib/src/profiles/ips_resource_profile_registry.js +143 -0
- package/lib/src/structures/ips_mandatory_sections.d.ts +7 -0
- package/lib/src/structures/ips_mandatory_sections.js +11 -0
- package/lib/src/structures/ips_recommended_sections.d.ts +8 -0
- package/lib/src/structures/ips_recommended_sections.js +12 -0
- package/lib/src/structures/ips_resource_profile.d.ts +7 -0
- package/lib/src/structures/ips_resource_profile.js +2 -0
- package/lib/src/structures/ips_section_loinc_codes.d.ts +4 -0
- package/lib/src/structures/ips_section_loinc_codes.js +48 -0
- package/lib/src/structures/ips_section_resource_map.d.ts +8 -0
- package/lib/src/structures/ips_section_resource_map.js +69 -0
- package/lib/src/structures/ips_sections.d.ts +19 -0
- package/lib/src/structures/ips_sections.js +27 -0
- package/lib/src/types/partials/Address.d.ts +16 -0
- package/lib/src/types/partials/Address.js +3 -0
- package/lib/src/types/partials/AllergyIntoleranceReaction.d.ts +16 -0
- package/lib/src/types/partials/AllergyIntoleranceReaction.js +3 -0
- package/lib/src/types/partials/Annotation.d.ts +12 -0
- package/lib/src/types/partials/Annotation.js +3 -0
- package/lib/src/types/partials/Attachment.d.ts +17 -0
- package/lib/src/types/partials/Attachment.js +3 -0
- package/lib/src/types/partials/BundleEntry.d.ts +18 -0
- package/lib/src/types/partials/BundleEntry.js +3 -0
- package/lib/src/types/partials/BundleLink.d.ts +9 -0
- package/lib/src/types/partials/BundleLink.js +3 -0
- package/lib/src/types/partials/BundleRequest.d.ts +14 -0
- package/lib/src/types/partials/BundleRequest.js +3 -0
- package/lib/src/types/partials/BundleResponse.d.ts +14 -0
- package/lib/src/types/partials/BundleResponse.js +3 -0
- package/lib/src/types/partials/BundleSearch.d.ts +9 -0
- package/lib/src/types/partials/BundleSearch.js +3 -0
- package/lib/src/types/partials/CarePlanActivity.d.ts +15 -0
- package/lib/src/types/partials/CarePlanActivity.js +3 -0
- package/lib/src/types/partials/CarePlanDetail.d.ts +33 -0
- package/lib/src/types/partials/CarePlanDetail.js +3 -0
- package/lib/src/types/partials/ClinicalImpressionFinding.d.ts +11 -0
- package/lib/src/types/partials/ClinicalImpressionFinding.js +3 -0
- package/lib/src/types/partials/ClinicalImpressionInvestigation.d.ts +10 -0
- package/lib/src/types/partials/ClinicalImpressionInvestigation.js +3 -0
- package/lib/src/types/partials/CodeableConcept.d.ts +8 -0
- package/lib/src/types/partials/CodeableConcept.js +3 -0
- package/lib/src/types/partials/CodeableReference.d.ts +9 -0
- package/lib/src/types/partials/CodeableReference.js +3 -0
- package/lib/src/types/partials/Coding.d.ts +11 -0
- package/lib/src/types/partials/Coding.js +3 -0
- package/lib/src/types/partials/CompositionAttester.d.ts +11 -0
- package/lib/src/types/partials/CompositionAttester.js +3 -0
- package/lib/src/types/partials/CompositionEvent.d.ts +12 -0
- package/lib/src/types/partials/CompositionEvent.js +3 -0
- package/lib/src/types/partials/CompositionRelatesTo.d.ts +11 -0
- package/lib/src/types/partials/CompositionRelatesTo.js +3 -0
- package/lib/src/types/partials/CompositionSection.d.ts +19 -0
- package/lib/src/types/partials/CompositionSection.js +3 -0
- package/lib/src/types/partials/ConditionEvidence.d.ts +10 -0
- package/lib/src/types/partials/ConditionEvidence.js +3 -0
- package/lib/src/types/partials/ConditionStage.d.ts +11 -0
- package/lib/src/types/partials/ConditionStage.js +3 -0
- package/lib/src/types/partials/ConsentActor.d.ts +10 -0
- package/lib/src/types/partials/ConsentActor.js +3 -0
- package/lib/src/types/partials/ConsentData.d.ts +9 -0
- package/lib/src/types/partials/ConsentData.js +3 -0
- package/lib/src/types/partials/ConsentPolicy.d.ts +9 -0
- package/lib/src/types/partials/ConsentPolicy.js +3 -0
- package/lib/src/types/partials/ConsentProvision.d.ts +22 -0
- package/lib/src/types/partials/ConsentProvision.js +3 -0
- package/lib/src/types/partials/ConsentVerification.d.ts +11 -0
- package/lib/src/types/partials/ConsentVerification.js +3 -0
- package/lib/src/types/partials/ContactDetail.d.ts +8 -0
- package/lib/src/types/partials/ContactDetail.js +3 -0
- package/lib/src/types/partials/ContactPoint.d.ts +12 -0
- package/lib/src/types/partials/ContactPoint.js +3 -0
- package/lib/src/types/partials/Contributor.d.ts +9 -0
- package/lib/src/types/partials/Contributor.js +3 -0
- package/lib/src/types/partials/DataRequirement.d.ts +21 -0
- package/lib/src/types/partials/DataRequirement.js +3 -0
- package/lib/src/types/partials/DataRequirementCodeFilter.d.ts +11 -0
- package/lib/src/types/partials/DataRequirementCodeFilter.js +3 -0
- package/lib/src/types/partials/DataRequirementDateFilter.d.ts +13 -0
- package/lib/src/types/partials/DataRequirementDateFilter.js +3 -0
- package/lib/src/types/partials/DataRequirementSort.d.ts +7 -0
- package/lib/src/types/partials/DataRequirementSort.js +3 -0
- package/lib/src/types/partials/DeviceDeviceName.d.ts +8 -0
- package/lib/src/types/partials/DeviceDeviceName.js +3 -0
- package/lib/src/types/partials/DeviceProperty.d.ts +11 -0
- package/lib/src/types/partials/DeviceProperty.js +3 -0
- package/lib/src/types/partials/DeviceSpecialization.d.ts +9 -0
- package/lib/src/types/partials/DeviceSpecialization.js +3 -0
- package/lib/src/types/partials/DeviceUdiCarrier.d.ts +14 -0
- package/lib/src/types/partials/DeviceUdiCarrier.js +3 -0
- package/lib/src/types/partials/DeviceVersion.d.ts +11 -0
- package/lib/src/types/partials/DeviceVersion.js +3 -0
- package/lib/src/types/partials/DiagnosticReportMedia.d.ts +9 -0
- package/lib/src/types/partials/DiagnosticReportMedia.js +3 -0
- package/lib/src/types/partials/Dosage.d.ts +26 -0
- package/lib/src/types/partials/Dosage.js +3 -0
- package/lib/src/types/partials/DosageDoseAndRate.d.ts +16 -0
- package/lib/src/types/partials/DosageDoseAndRate.js +3 -0
- package/lib/src/types/partials/Expression.d.ts +12 -0
- package/lib/src/types/partials/Expression.js +3 -0
- package/lib/src/types/partials/Extension.d.ts +99 -0
- package/lib/src/types/partials/Extension.js +3 -0
- package/lib/src/types/partials/FamilyMemberHistoryCondition.d.ts +19 -0
- package/lib/src/types/partials/FamilyMemberHistoryCondition.js +3 -0
- package/lib/src/types/partials/HumanName.d.ts +13 -0
- package/lib/src/types/partials/HumanName.js +3 -0
- package/lib/src/types/partials/Identifier.d.ts +15 -0
- package/lib/src/types/partials/Identifier.js +3 -0
- package/lib/src/types/partials/ImmunizationEducation.d.ts +12 -0
- package/lib/src/types/partials/ImmunizationEducation.js +3 -0
- package/lib/src/types/partials/ImmunizationPerformer.d.ts +10 -0
- package/lib/src/types/partials/ImmunizationPerformer.js +3 -0
- package/lib/src/types/partials/ImmunizationProtocolApplied.d.ts +16 -0
- package/lib/src/types/partials/ImmunizationProtocolApplied.js +3 -0
- package/lib/src/types/partials/ImmunizationReaction.d.ts +11 -0
- package/lib/src/types/partials/ImmunizationReaction.js +3 -0
- package/lib/src/types/partials/MedicationBatch.d.ts +9 -0
- package/lib/src/types/partials/MedicationBatch.js +3 -0
- package/lib/src/types/partials/MedicationIngredient.d.ts +13 -0
- package/lib/src/types/partials/MedicationIngredient.js +3 -0
- package/lib/src/types/partials/MedicationRequestDispenseRequest.d.ts +18 -0
- package/lib/src/types/partials/MedicationRequestDispenseRequest.js +3 -0
- package/lib/src/types/partials/MedicationRequestInitialFill.d.ts +9 -0
- package/lib/src/types/partials/MedicationRequestInitialFill.js +3 -0
- package/lib/src/types/partials/MedicationRequestSubstitution.d.ts +10 -0
- package/lib/src/types/partials/MedicationRequestSubstitution.js +3 -0
- package/lib/src/types/partials/Meta.d.ts +16 -0
- package/lib/src/types/partials/Meta.js +3 -0
- package/lib/src/types/partials/Money.d.ts +8 -0
- package/lib/src/types/partials/Money.js +3 -0
- package/lib/src/types/partials/Narrative.d.ts +8 -0
- package/lib/src/types/partials/Narrative.js +3 -0
- package/lib/src/types/partials/ObservationComponent.d.ts +31 -0
- package/lib/src/types/partials/ObservationComponent.js +3 -0
- package/lib/src/types/partials/ObservationReferenceRange.d.ts +15 -0
- package/lib/src/types/partials/ObservationReferenceRange.js +3 -0
- package/lib/src/types/partials/OrganizationContact.d.ts +14 -0
- package/lib/src/types/partials/OrganizationContact.js +3 -0
- package/lib/src/types/partials/ParameterDefinition.d.ts +14 -0
- package/lib/src/types/partials/ParameterDefinition.js +3 -0
- package/lib/src/types/partials/PatientCommunication.d.ts +9 -0
- package/lib/src/types/partials/PatientCommunication.js +3 -0
- package/lib/src/types/partials/PatientContact.d.ts +19 -0
- package/lib/src/types/partials/PatientContact.js +3 -0
- package/lib/src/types/partials/PatientLink.d.ts +9 -0
- package/lib/src/types/partials/PatientLink.js +3 -0
- package/lib/src/types/partials/Period.d.ts +8 -0
- package/lib/src/types/partials/Period.js +3 -0
- package/lib/src/types/partials/ProcedureFocalDevice.d.ts +10 -0
- package/lib/src/types/partials/ProcedureFocalDevice.js +3 -0
- package/lib/src/types/partials/ProcedurePerformer.d.ts +11 -0
- package/lib/src/types/partials/ProcedurePerformer.js +3 -0
- package/lib/src/types/partials/Quantity.d.ts +12 -0
- package/lib/src/types/partials/Quantity.js +3 -0
- package/lib/src/types/partials/Range.d.ts +8 -0
- package/lib/src/types/partials/Range.js +3 -0
- package/lib/src/types/partials/Ratio.d.ts +8 -0
- package/lib/src/types/partials/Ratio.js +3 -0
- package/lib/src/types/partials/RatioRange.d.ts +9 -0
- package/lib/src/types/partials/RatioRange.js +3 -0
- package/lib/src/types/partials/Reference.d.ts +14 -0
- package/lib/src/types/partials/Reference.js +3 -0
- package/lib/src/types/partials/RelatedArtifact.d.ts +16 -0
- package/lib/src/types/partials/RelatedArtifact.js +3 -0
- package/lib/src/types/partials/SampledData.d.ts +15 -0
- package/lib/src/types/partials/SampledData.js +3 -0
- package/lib/src/types/partials/Signature.d.ts +16 -0
- package/lib/src/types/partials/Signature.js +3 -0
- package/lib/src/types/partials/Timing.d.ts +12 -0
- package/lib/src/types/partials/Timing.js +3 -0
- package/lib/src/types/partials/TimingRepeat.d.ts +30 -0
- package/lib/src/types/partials/TimingRepeat.js +3 -0
- package/lib/src/types/partials/TriggerDefinition.d.ts +19 -0
- package/lib/src/types/partials/TriggerDefinition.js +3 -0
- package/lib/src/types/partials/UsageContext.d.ts +15 -0
- package/lib/src/types/partials/UsageContext.js +3 -0
- package/lib/src/types/resources/AllergyIntolerance.d.ts +45 -0
- package/lib/src/types/resources/AllergyIntolerance.js +3 -0
- package/lib/src/types/resources/Bundle.d.ts +22 -0
- package/lib/src/types/resources/Bundle.js +3 -0
- package/lib/src/types/resources/CarePlan.d.ts +47 -0
- package/lib/src/types/resources/CarePlan.js +3 -0
- package/lib/src/types/resources/ClinicalImpression.d.ts +45 -0
- package/lib/src/types/resources/ClinicalImpression.js +3 -0
- package/lib/src/types/resources/Composition.d.ts +39 -0
- package/lib/src/types/resources/Composition.js +3 -0
- package/lib/src/types/resources/Condition.d.ts +51 -0
- package/lib/src/types/resources/Condition.js +3 -0
- package/lib/src/types/resources/Consent.d.ts +38 -0
- package/lib/src/types/resources/Consent.js +3 -0
- package/lib/src/types/resources/Device.d.ts +53 -0
- package/lib/src/types/resources/Device.js +3 -0
- package/lib/src/types/resources/DeviceUseStatement.d.ts +38 -0
- package/lib/src/types/resources/DeviceUseStatement.js +3 -0
- package/lib/src/types/resources/DiagnosticReport.d.ts +43 -0
- package/lib/src/types/resources/DiagnosticReport.js +3 -0
- package/lib/src/types/resources/DomainResource.d.ts +16 -0
- package/lib/src/types/resources/DomainResource.js +3 -0
- package/lib/src/types/resources/FamilyMemberHistory.d.ts +53 -0
- package/lib/src/types/resources/FamilyMemberHistory.js +3 -0
- package/lib/src/types/resources/Immunization.d.ts +56 -0
- package/lib/src/types/resources/Immunization.js +3 -0
- package/lib/src/types/resources/Medication.d.ts +30 -0
- package/lib/src/types/resources/Medication.js +3 -0
- package/lib/src/types/resources/MedicationRequest.d.ts +59 -0
- package/lib/src/types/resources/MedicationRequest.js +3 -0
- package/lib/src/types/resources/MedicationStatement.d.ts +42 -0
- package/lib/src/types/resources/MedicationStatement.js +3 -0
- package/lib/src/types/resources/Observation.d.ts +69 -0
- package/lib/src/types/resources/Observation.js +3 -0
- package/lib/src/types/resources/Organization.d.ts +32 -0
- package/lib/src/types/resources/Organization.js +3 -0
- package/lib/src/types/resources/Patient.d.ts +47 -0
- package/lib/src/types/resources/Patient.js +3 -0
- package/lib/src/types/resources/Procedure.d.ts +59 -0
- package/lib/src/types/resources/Procedure.js +3 -0
- package/lib/src/types/simpleTypes/Base64Binary.d.ts +1 -0
- package/lib/src/types/simpleTypes/Base64Binary.js +2 -0
- package/lib/src/types/simpleTypes/Canonical.d.ts +1 -0
- package/lib/src/types/simpleTypes/Canonical.js +2 -0
- package/lib/src/types/simpleTypes/Date.d.ts +1 -0
- package/lib/src/types/simpleTypes/Date.js +2 -0
- package/lib/src/types/simpleTypes/DateTime.d.ts +1 -0
- package/lib/src/types/simpleTypes/DateTime.js +2 -0
- package/lib/src/types/simpleTypes/Decimal.d.ts +1 -0
- package/lib/src/types/simpleTypes/Decimal.js +2 -0
- package/lib/src/types/simpleTypes/Id.d.ts +1 -0
- package/lib/src/types/simpleTypes/Id.js +2 -0
- package/lib/src/types/simpleTypes/Instant.d.ts +1 -0
- package/lib/src/types/simpleTypes/Instant.js +2 -0
- package/lib/src/types/simpleTypes/Int.d.ts +1 -0
- package/lib/src/types/simpleTypes/Int.js +2 -0
- package/lib/src/types/simpleTypes/Markdown.d.ts +1 -0
- package/lib/src/types/simpleTypes/Markdown.js +2 -0
- package/lib/src/types/simpleTypes/Oid.d.ts +1 -0
- package/lib/src/types/simpleTypes/Oid.js +2 -0
- package/lib/src/types/simpleTypes/ResourceContainer.d.ts +1 -0
- package/lib/src/types/simpleTypes/ResourceContainer.js +2 -0
- package/lib/src/types/simpleTypes/Time.d.ts +1 -0
- package/lib/src/types/simpleTypes/Time.js +2 -0
- package/lib/src/types/simpleTypes/UnsignedInt.d.ts +1 -0
- package/lib/src/types/simpleTypes/UnsignedInt.js +2 -0
- package/lib/src/types/simpleTypes/Uri.d.ts +1 -0
- package/lib/src/types/simpleTypes/Uri.js +2 -0
- package/lib/src/types/simpleTypes/Url.d.ts +1 -0
- package/lib/src/types/simpleTypes/Url.js +2 -0
- package/lib/src/types/simpleTypes/Uuid.d.ts +1 -0
- package/lib/src/types/simpleTypes/Uuid.js +2 -0
- package/lib/src/types/simpleTypes/Xhtml.d.ts +1 -0
- package/lib/src/types/simpleTypes/Xhtml.js +2 -0
- package/lib/test/fhir-summary-bundle/fhir-summary-bundle.test.d.ts +1 -0
- package/lib/test/fhir-summary-bundle/fhir-summary-bundle.test.js +72 -0
- package/lib/test/ips-test/ips.test.d.ts +1 -0
- package/lib/test/ips-test/ips.test.js +389 -0
- package/lib/test/narrativeGenerator/narrativeGenerator.test.d.ts +1 -0
- package/lib/test/narrativeGenerator/narrativeGenerator.test.js +676 -0
- package/lib/test/summary.test.d.ts +1 -0
- package/lib/test/summary.test.js +452 -0
- package/lib/test/utilities/testHelpers.d.ts +21 -0
- package/lib/test/utilities/testHelpers.js +137 -0
- package/package.json +126 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// TypeScriptNarrativeGenerator.ts - TypeScript replacement for narrative_generator.ts using TypeScript templates
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.NarrativeGenerator = void 0;
|
|
5
|
+
const TypeScriptTemplateMapper_1 = require("../narratives/templates/typescript/TypeScriptTemplateMapper");
|
|
6
|
+
/**
|
|
7
|
+
* Generates narrative content for FHIR resources using TypeScript templates
|
|
8
|
+
* Replaces the Nunjucks-based narrative generator
|
|
9
|
+
*/
|
|
10
|
+
class NarrativeGenerator {
|
|
11
|
+
/**
|
|
12
|
+
* Generates narrative HTML content for a section
|
|
13
|
+
* @param section - IPS section type
|
|
14
|
+
* @param resources - Array of domain resources
|
|
15
|
+
* @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
|
|
16
|
+
* @returns Generated HTML content or undefined if no resources
|
|
17
|
+
*/
|
|
18
|
+
static generateNarrativeContent(section, resources, timezone) {
|
|
19
|
+
if (!resources || resources.length === 0) {
|
|
20
|
+
return undefined; // No resources to generate narrative
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
// Create a bundle-like structure for the template
|
|
24
|
+
const bundle = {
|
|
25
|
+
resourceType: 'Bundle',
|
|
26
|
+
type: 'collection',
|
|
27
|
+
entry: resources.map(resource => ({
|
|
28
|
+
resource
|
|
29
|
+
}))
|
|
30
|
+
};
|
|
31
|
+
// Use the TypeScript template mapper to generate HTML
|
|
32
|
+
return TypeScriptTemplateMapper_1.TypeScriptTemplateMapper.generateNarrative(section, bundle, timezone);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
console.error(`Error generating narrative for section ${section}:`, error);
|
|
36
|
+
return `<div class="error">Error generating narrative: ${error instanceof Error ? error.message : String(error)}</div>`;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates a complete FHIR Narrative object
|
|
41
|
+
* @param content - HTML content
|
|
42
|
+
* @returns FHIR Narrative object
|
|
43
|
+
*/
|
|
44
|
+
static createNarrative(content) {
|
|
45
|
+
// remove extra whitespace and newlines
|
|
46
|
+
content = content.replace(/\s+/g, ' ').trim();
|
|
47
|
+
// Strip outer <div> wrappers if present
|
|
48
|
+
const divMatch = content.match(/^<div[^>]*>(.*?)<\/div>$/);
|
|
49
|
+
if (divMatch) {
|
|
50
|
+
content = divMatch[1]; // Extract inner content
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
status: 'generated',
|
|
54
|
+
div: `<div xmlns="http://www.w3.org/1999/xhtml">${content}</div>`
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Generates a complete FHIR Narrative object for a section
|
|
59
|
+
* @param section - IPS section type
|
|
60
|
+
* @param resources - Array of domain resources
|
|
61
|
+
* @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
|
|
62
|
+
* @returns FHIR Narrative object or undefined if no resources
|
|
63
|
+
*/
|
|
64
|
+
static generateNarrative(section, resources, timezone) {
|
|
65
|
+
const content = this.generateNarrativeContent(section, resources, timezone);
|
|
66
|
+
if (!content) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
return this.createNarrative(content);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Wrap content in XHTML div with FHIR namespace
|
|
73
|
+
* @param content - HTML content to wrap
|
|
74
|
+
* @returns XHTML div string
|
|
75
|
+
*/
|
|
76
|
+
static wrapInXhtml(content) {
|
|
77
|
+
return `<div xmlns="http://www.w3.org/1999/xhtml">${content}</div>`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.NarrativeGenerator = NarrativeGenerator;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { TBundle } from '../../../types/resources/Bundle';
|
|
2
|
+
import { ITemplate } from './interfaces/ITemplate';
|
|
3
|
+
/**
|
|
4
|
+
* Class to generate HTML narrative for Advance Directives (Consent resources)
|
|
5
|
+
* This replaces the Jinja2 advancedirectives.j2 template
|
|
6
|
+
*/
|
|
7
|
+
export declare class AdvanceDirectivesTemplate implements ITemplate {
|
|
8
|
+
/**
|
|
9
|
+
* Generate HTML narrative for Advance Directives
|
|
10
|
+
* @param resource - FHIR Bundle containing Advance Directive resources
|
|
11
|
+
* @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
|
|
12
|
+
* @returns HTML string for rendering
|
|
13
|
+
*/
|
|
14
|
+
generateNarrative(resource: TBundle, timezone: string | undefined): string;
|
|
15
|
+
/**
|
|
16
|
+
* Internal static implementation that actually generates the narrative
|
|
17
|
+
* @param resource - FHIR Bundle containing Advance Directive resources
|
|
18
|
+
* @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
|
|
19
|
+
* @returns HTML string for rendering
|
|
20
|
+
*/
|
|
21
|
+
private static generateStaticNarrative;
|
|
22
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AdvanceDirectivesTemplate = void 0;
|
|
4
|
+
// AdvanceDirectivesTemplate.ts - TypeScript replacement for Jinja2 advancedirectives.j2
|
|
5
|
+
const TemplateUtilities_1 = require("./TemplateUtilities");
|
|
6
|
+
/**
|
|
7
|
+
* Class to generate HTML narrative for Advance Directives (Consent resources)
|
|
8
|
+
* This replaces the Jinja2 advancedirectives.j2 template
|
|
9
|
+
*/
|
|
10
|
+
class AdvanceDirectivesTemplate {
|
|
11
|
+
/**
|
|
12
|
+
* Generate HTML narrative for Advance Directives
|
|
13
|
+
* @param resource - FHIR Bundle containing Advance Directive resources
|
|
14
|
+
* @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
|
|
15
|
+
* @returns HTML string for rendering
|
|
16
|
+
*/
|
|
17
|
+
generateNarrative(resource, timezone) {
|
|
18
|
+
return AdvanceDirectivesTemplate.generateStaticNarrative(resource, timezone);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Internal static implementation that actually generates the narrative
|
|
22
|
+
* @param resource - FHIR Bundle containing Advance Directive resources
|
|
23
|
+
* @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
|
|
24
|
+
* @returns HTML string for rendering
|
|
25
|
+
*/
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
27
|
+
static generateStaticNarrative(resource, timezone) {
|
|
28
|
+
var _a;
|
|
29
|
+
const templateUtilities = new TemplateUtilities_1.TemplateUtilities(resource);
|
|
30
|
+
// Start building the HTML table
|
|
31
|
+
let html = `
|
|
32
|
+
<h5>Advance Directives</h5>
|
|
33
|
+
<table class="hapiPropertyTable">
|
|
34
|
+
<thead>
|
|
35
|
+
<tr>
|
|
36
|
+
<th>Scope</th>
|
|
37
|
+
<th>Status</th>
|
|
38
|
+
<th>Action Controlled</th>
|
|
39
|
+
<th>Date</th>
|
|
40
|
+
</tr>
|
|
41
|
+
</thead>
|
|
42
|
+
<tbody>`;
|
|
43
|
+
// Check if we have entries in the bundle
|
|
44
|
+
if (resource.entry && Array.isArray(resource.entry)) {
|
|
45
|
+
// Loop through entries in the bundle
|
|
46
|
+
for (const entry of resource.entry) {
|
|
47
|
+
const consent = entry.resource;
|
|
48
|
+
// Skip Composition resources
|
|
49
|
+
if (consent.resourceType === 'Composition') {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
// Use the enhanced narrativeLinkId utility function to extract the ID
|
|
53
|
+
// Add a table row for this consent
|
|
54
|
+
html += `
|
|
55
|
+
<tr id="${(templateUtilities.narrativeLinkId(consent))}">
|
|
56
|
+
<td>${templateUtilities.codeableConcept(consent.scope, 'display')}</td>
|
|
57
|
+
<td>${consent.status || ''}</td>
|
|
58
|
+
<td>${((_a = consent.provision) === null || _a === void 0 ? void 0 : _a.action) ? templateUtilities.concatCodeableConcept(consent.provision.action) : ''}</td>
|
|
59
|
+
<td>${consent.dateTime || ''}</td>
|
|
60
|
+
</tr>`;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Close the HTML table
|
|
64
|
+
html += `
|
|
65
|
+
</tbody>
|
|
66
|
+
</table>`;
|
|
67
|
+
return html;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.AdvanceDirectivesTemplate = AdvanceDirectivesTemplate;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TBundle } from '../../../types/resources/Bundle';
|
|
2
|
+
import { ITemplate } from './interfaces/ITemplate';
|
|
3
|
+
/**
|
|
4
|
+
* Class to generate HTML narrative for AllergyIntolerance resources
|
|
5
|
+
* This replaces the Jinja2 allergyintolerance.j2 template
|
|
6
|
+
*/
|
|
7
|
+
export declare class AllergyIntoleranceTemplate implements ITemplate {
|
|
8
|
+
/**
|
|
9
|
+
* Generate HTML narrative for AllergyIntolerance resources
|
|
10
|
+
* @param resource - FHIR Bundle containing AllergyIntolerance resources
|
|
11
|
+
* @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
|
|
12
|
+
* @returns HTML string for rendering
|
|
13
|
+
*/
|
|
14
|
+
generateNarrative(resource: TBundle, timezone: string | undefined): string;
|
|
15
|
+
/**
|
|
16
|
+
* Internal static implementation that actually generates the narrative
|
|
17
|
+
* @param resource - FHIR Bundle containing AllergyIntolerance resources
|
|
18
|
+
* @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
|
|
19
|
+
* @returns HTML string for rendering
|
|
20
|
+
*/
|
|
21
|
+
private static generateStaticNarrative;
|
|
22
|
+
/**
|
|
23
|
+
* Helper method to generate HTML table rows for allergies
|
|
24
|
+
* @param allergies - Array of allergy resources to process
|
|
25
|
+
* @param templateUtilities - Utilities for formatting
|
|
26
|
+
* @param includeResolved - Whether to include resolved date column
|
|
27
|
+
* @param timezone - Optional timezone to use for date formatting
|
|
28
|
+
* @returns HTML string with table rows
|
|
29
|
+
*/
|
|
30
|
+
private static generateAllergyRows;
|
|
31
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AllergyIntoleranceTemplate = void 0;
|
|
4
|
+
// AllergyIntoleranceTemplate.ts - TypeScript replacement for Jinja2 allergyintolerance.j2
|
|
5
|
+
const TemplateUtilities_1 = require("./TemplateUtilities");
|
|
6
|
+
/**
|
|
7
|
+
* Class to generate HTML narrative for AllergyIntolerance resources
|
|
8
|
+
* This replaces the Jinja2 allergyintolerance.j2 template
|
|
9
|
+
*/
|
|
10
|
+
class AllergyIntoleranceTemplate {
|
|
11
|
+
/**
|
|
12
|
+
* Generate HTML narrative for AllergyIntolerance resources
|
|
13
|
+
* @param resource - FHIR Bundle containing AllergyIntolerance resources
|
|
14
|
+
* @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
|
|
15
|
+
* @returns HTML string for rendering
|
|
16
|
+
*/
|
|
17
|
+
generateNarrative(resource, timezone) {
|
|
18
|
+
return AllergyIntoleranceTemplate.generateStaticNarrative(resource, timezone);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Internal static implementation that actually generates the narrative
|
|
22
|
+
* @param resource - FHIR Bundle containing AllergyIntolerance resources
|
|
23
|
+
* @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
|
|
24
|
+
* @returns HTML string for rendering
|
|
25
|
+
*/
|
|
26
|
+
static generateStaticNarrative(resource, timezone) {
|
|
27
|
+
var _a, _b, _c;
|
|
28
|
+
const templateUtilities = new TemplateUtilities_1.TemplateUtilities(resource);
|
|
29
|
+
// Group allergies by status (active vs resolved/inactive)
|
|
30
|
+
const activeAllergies = [];
|
|
31
|
+
const resolvedAllergies = [];
|
|
32
|
+
if (resource.entry && Array.isArray(resource.entry)) {
|
|
33
|
+
for (const entry of resource.entry) {
|
|
34
|
+
const allergy = entry.resource;
|
|
35
|
+
// Check clinical status to determine if active or resolved
|
|
36
|
+
const status = ((_c = (_b = (_a = allergy.clinicalStatus) === null || _a === void 0 ? void 0 : _a.coding) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.code) || '';
|
|
37
|
+
if (status === 'inactive' || status === 'resolved') {
|
|
38
|
+
resolvedAllergies.push(allergy);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
activeAllergies.push(allergy);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// Start building the HTML with proper XHTML namespace
|
|
46
|
+
let html = `<div xmlns="http://www.w3.org/1999/xhtml">`;
|
|
47
|
+
// Active Allergies section
|
|
48
|
+
html += `
|
|
49
|
+
<div class="ActiveAllergies">
|
|
50
|
+
<h3>Active Allergies and Intolerances</h3>
|
|
51
|
+
<table class="ActiveAllergyTable">
|
|
52
|
+
<thead>
|
|
53
|
+
<tr>
|
|
54
|
+
<th>Allergen</th>
|
|
55
|
+
<th>Status</th>
|
|
56
|
+
<th>Category</th>
|
|
57
|
+
<th>Reaction</th>
|
|
58
|
+
<th>Severity</th>
|
|
59
|
+
<th>Onset Date</th>
|
|
60
|
+
<th>Comments</th>
|
|
61
|
+
</tr>
|
|
62
|
+
</thead>
|
|
63
|
+
<tbody>`;
|
|
64
|
+
// Process active allergies
|
|
65
|
+
if (activeAllergies.length > 0) {
|
|
66
|
+
html += this.generateAllergyRows(activeAllergies, templateUtilities, timezone);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
html += `
|
|
70
|
+
<tr>
|
|
71
|
+
<td colspan="7">No active allergies recorded</td>
|
|
72
|
+
</tr>`;
|
|
73
|
+
}
|
|
74
|
+
// Close the active allergies table
|
|
75
|
+
html += `
|
|
76
|
+
</tbody>
|
|
77
|
+
</table>
|
|
78
|
+
</div>`;
|
|
79
|
+
// Resolved Allergies section
|
|
80
|
+
html += `
|
|
81
|
+
<div class="ResolvedAllergies">
|
|
82
|
+
<h3>Resolved Allergies and Intolerances</h3>
|
|
83
|
+
<table class="ResolvedAllergyTable">
|
|
84
|
+
<thead>
|
|
85
|
+
<tr>
|
|
86
|
+
<th>Allergen</th>
|
|
87
|
+
<th>Status</th>
|
|
88
|
+
<th>Category</th>
|
|
89
|
+
<th>Reaction</th>
|
|
90
|
+
<th>Severity</th>
|
|
91
|
+
<th>Onset Date</th>
|
|
92
|
+
<th>Comments</th>
|
|
93
|
+
<th>Resolved Date</th>
|
|
94
|
+
</tr>
|
|
95
|
+
</thead>
|
|
96
|
+
<tbody>`;
|
|
97
|
+
// Process resolved allergies
|
|
98
|
+
if (resolvedAllergies.length > 0) {
|
|
99
|
+
html += this.generateAllergyRows(resolvedAllergies, templateUtilities, timezone, true);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
html += `
|
|
103
|
+
<tr>
|
|
104
|
+
<td colspan="8">No resolved allergies recorded</td>
|
|
105
|
+
</tr>`;
|
|
106
|
+
}
|
|
107
|
+
// Close the resolved allergies table
|
|
108
|
+
html += `
|
|
109
|
+
</tbody>
|
|
110
|
+
</table>
|
|
111
|
+
</div>
|
|
112
|
+
</div>`;
|
|
113
|
+
return html;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Helper method to generate HTML table rows for allergies
|
|
117
|
+
* @param allergies - Array of allergy resources to process
|
|
118
|
+
* @param templateUtilities - Utilities for formatting
|
|
119
|
+
* @param includeResolved - Whether to include resolved date column
|
|
120
|
+
* @param timezone - Optional timezone to use for date formatting
|
|
121
|
+
* @returns HTML string with table rows
|
|
122
|
+
*/
|
|
123
|
+
static generateAllergyRows(allergies, templateUtilities, timezone, includeResolved = false) {
|
|
124
|
+
let html = '';
|
|
125
|
+
for (const allergy of allergies) {
|
|
126
|
+
// Find the narrative link extension if it exists
|
|
127
|
+
// Add a table row for this allergy with appropriate classes
|
|
128
|
+
html += `
|
|
129
|
+
<tr id="${(templateUtilities.narrativeLinkId(allergy.extension))}">
|
|
130
|
+
<td class="Name"><span class="AllergenName">${templateUtilities.codeableConcept(allergy.code)}</span></td>
|
|
131
|
+
<td class="Status">${templateUtilities.codeableConcept(allergy.clinicalStatus) || '-'}</td>
|
|
132
|
+
<td class="Category">${templateUtilities.safeConcat(allergy.category, 'value') || '-'}</td>
|
|
133
|
+
<td class="Reaction">${templateUtilities.concatReactionManifestation(allergy.reaction) || '-'}</td>
|
|
134
|
+
<td class="Severity">${templateUtilities.safeConcat(allergy.reaction, 'severity') || '-'}</td>
|
|
135
|
+
<td class="OnsetDate">${templateUtilities.renderTime(allergy.onsetDateTime, timezone) || '-'}</td>
|
|
136
|
+
<td class="Comments">${templateUtilities.renderNotes(allergy.note, timezone, { styled: true, warning: true })}</td>`;
|
|
137
|
+
// Add resolved date column for resolved allergies
|
|
138
|
+
if (includeResolved) {
|
|
139
|
+
// Try to find end date from extension or use '-' if not found
|
|
140
|
+
let endDate = '-';
|
|
141
|
+
if (allergy.extension && Array.isArray(allergy.extension)) {
|
|
142
|
+
const endDateExt = allergy.extension.find(ext => ext.url === 'http://hl7.org/fhir/StructureDefinition/allergyintolerance-resolutionDate');
|
|
143
|
+
if (endDateExt && endDateExt.valueDateTime) {
|
|
144
|
+
endDate = templateUtilities.renderDate(endDateExt.valueDateTime);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
html += `
|
|
148
|
+
<td class="ResolvedDate">${endDate}</td>`;
|
|
149
|
+
}
|
|
150
|
+
html += `</tr>`;
|
|
151
|
+
}
|
|
152
|
+
return html;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.AllergyIntoleranceTemplate = AllergyIntoleranceTemplate;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TBundle } from '../../../types/resources/Bundle';
|
|
2
|
+
import { ITemplate } from './interfaces/ITemplate';
|
|
3
|
+
/**
|
|
4
|
+
* Class to generate HTML narrative for Clinical Impression resources
|
|
5
|
+
* This generates narrative for the Clinical Impression section of the IPS
|
|
6
|
+
*/
|
|
7
|
+
export declare class ClinicalImpressionTemplate implements ITemplate {
|
|
8
|
+
/**
|
|
9
|
+
* Generate HTML narrative for Clinical Impressions
|
|
10
|
+
* @param resource - FHIR Bundle containing ClinicalImpression resources
|
|
11
|
+
* @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
|
|
12
|
+
* @returns HTML string for rendering
|
|
13
|
+
*/
|
|
14
|
+
generateNarrative(resource: TBundle, timezone: string | undefined): string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClinicalImpressionTemplate = void 0;
|
|
4
|
+
// ClinicalImpressionTemplate.ts - TypeScript template for Clinical Impression section
|
|
5
|
+
const TemplateUtilities_1 = require("./TemplateUtilities");
|
|
6
|
+
/**
|
|
7
|
+
* Class to generate HTML narrative for Clinical Impression resources
|
|
8
|
+
* This generates narrative for the Clinical Impression section of the IPS
|
|
9
|
+
*/
|
|
10
|
+
class ClinicalImpressionTemplate {
|
|
11
|
+
/**
|
|
12
|
+
* Generate HTML narrative for Clinical Impressions
|
|
13
|
+
* @param resource - FHIR Bundle containing ClinicalImpression resources
|
|
14
|
+
* @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
|
|
15
|
+
* @returns HTML string for rendering
|
|
16
|
+
*/
|
|
17
|
+
generateNarrative(resource, timezone) {
|
|
18
|
+
const templateUtilities = new TemplateUtilities_1.TemplateUtilities(resource);
|
|
19
|
+
// Start building the HTML table
|
|
20
|
+
let html = `
|
|
21
|
+
<h5>Clinical Impressions</h5>
|
|
22
|
+
<table class="hapiPropertyTable">
|
|
23
|
+
<thead>
|
|
24
|
+
<tr>
|
|
25
|
+
<th>Date</th>
|
|
26
|
+
<th>Status</th>
|
|
27
|
+
<th>Description</th>
|
|
28
|
+
<th>Summary</th>
|
|
29
|
+
<th>Findings</th>
|
|
30
|
+
<th>Notes</th>
|
|
31
|
+
</tr>
|
|
32
|
+
</thead>
|
|
33
|
+
<tbody>`;
|
|
34
|
+
// Check if we have entries in the bundle
|
|
35
|
+
if (resource.entry && Array.isArray(resource.entry)) {
|
|
36
|
+
let hasClinicalImpressions = false;
|
|
37
|
+
// Loop through entries in the bundle
|
|
38
|
+
for (const entry of resource.entry) {
|
|
39
|
+
const res = entry.resource;
|
|
40
|
+
// Skip non-ClinicalImpression resources
|
|
41
|
+
if (!res || res.resourceType !== 'ClinicalImpression') {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
hasClinicalImpressions = true;
|
|
45
|
+
const impression = res;
|
|
46
|
+
// Format date (could be effectiveDateTime, effectivePeriod, or date)
|
|
47
|
+
let formattedDate = '';
|
|
48
|
+
if (impression.effectiveDateTime) {
|
|
49
|
+
formattedDate = templateUtilities.renderTime(impression.effectiveDateTime, timezone);
|
|
50
|
+
}
|
|
51
|
+
else if (impression.effectivePeriod) {
|
|
52
|
+
formattedDate = templateUtilities.renderPeriod(impression.effectivePeriod, timezone);
|
|
53
|
+
}
|
|
54
|
+
else if (impression.date) {
|
|
55
|
+
formattedDate = templateUtilities.renderDate(impression.date);
|
|
56
|
+
}
|
|
57
|
+
// Format status
|
|
58
|
+
const status = impression.status || '';
|
|
59
|
+
// Description and summary
|
|
60
|
+
const description = impression.description || '';
|
|
61
|
+
const summary = impression.summary || '';
|
|
62
|
+
// Format findings
|
|
63
|
+
let findingsHtml = '';
|
|
64
|
+
if (impression.finding && impression.finding.length > 0) {
|
|
65
|
+
findingsHtml = '<ul>';
|
|
66
|
+
for (const finding of impression.finding) {
|
|
67
|
+
// Each finding has an itemCodeableConcept and/or itemReference
|
|
68
|
+
const findingText = finding.itemCodeableConcept
|
|
69
|
+
? templateUtilities.codeableConcept(finding.itemCodeableConcept, 'display')
|
|
70
|
+
: (finding.itemReference
|
|
71
|
+
? templateUtilities.renderReference(finding.itemReference)
|
|
72
|
+
: '');
|
|
73
|
+
// Add cause if present
|
|
74
|
+
const cause = finding.basis || '';
|
|
75
|
+
findingsHtml += `<li>${findingText}${cause ? ` - ${cause}` : ''}</li>`;
|
|
76
|
+
}
|
|
77
|
+
findingsHtml += '</ul>';
|
|
78
|
+
}
|
|
79
|
+
// Format notes
|
|
80
|
+
const notes = templateUtilities.renderNotes(impression.note, timezone);
|
|
81
|
+
html += `
|
|
82
|
+
<tr id="${templateUtilities.narrativeLinkId(impression)}">
|
|
83
|
+
<td>${formattedDate}</td>
|
|
84
|
+
<td>${status}</td>
|
|
85
|
+
<td>${description}</td>
|
|
86
|
+
<td>${summary}</td>
|
|
87
|
+
<td>${findingsHtml}</td>
|
|
88
|
+
<td>${notes}</td>
|
|
89
|
+
</tr>`;
|
|
90
|
+
}
|
|
91
|
+
// If no clinical impression entries were found
|
|
92
|
+
if (!hasClinicalImpressions) {
|
|
93
|
+
html += `
|
|
94
|
+
<tr>
|
|
95
|
+
<td colspan="6">No clinical impressions recorded</td>
|
|
96
|
+
</tr>`;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
html += `
|
|
101
|
+
<tr>
|
|
102
|
+
<td colspan="6">No clinical impressions recorded</td>
|
|
103
|
+
</tr>`;
|
|
104
|
+
}
|
|
105
|
+
html += `
|
|
106
|
+
</tbody>
|
|
107
|
+
</table>`;
|
|
108
|
+
return html;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.ClinicalImpressionTemplate = ClinicalImpressionTemplate;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { TBundle } from '../../../types/resources/Bundle';
|
|
2
|
+
import { ITemplate } from './interfaces/ITemplate';
|
|
3
|
+
/**
|
|
4
|
+
* Class to generate HTML narrative for Diagnostic Results (Observation resources)
|
|
5
|
+
* This replaces the Jinja2 diagnosticresults.j2 template
|
|
6
|
+
*/
|
|
7
|
+
export declare class DiagnosticResultsTemplate implements ITemplate {
|
|
8
|
+
/**
|
|
9
|
+
* Generate HTML narrative for Diagnostic Results
|
|
10
|
+
* @param resource - FHIR Bundle containing Observation and DiagnosticReport resources
|
|
11
|
+
* @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
|
|
12
|
+
* @returns HTML string for rendering
|
|
13
|
+
*/
|
|
14
|
+
generateNarrative(resource: TBundle, timezone: string | undefined): string;
|
|
15
|
+
/**
|
|
16
|
+
* Internal static implementation that actually generates the narrative
|
|
17
|
+
* @param resource - FHIR Bundle containing Observation and DiagnosticReport resources
|
|
18
|
+
* @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
|
|
19
|
+
* @returns HTML string for rendering
|
|
20
|
+
*/
|
|
21
|
+
private static generateStaticNarrative;
|
|
22
|
+
/**
|
|
23
|
+
* Extract Observation resources from the bundle
|
|
24
|
+
* @param resource - FHIR Bundle
|
|
25
|
+
* @returns Array of Observation resources
|
|
26
|
+
*/
|
|
27
|
+
private static getObservations;
|
|
28
|
+
/**
|
|
29
|
+
* Extract DiagnosticReport resources from the bundle
|
|
30
|
+
* @param resource - FHIR Bundle
|
|
31
|
+
* @returns Array of DiagnosticReport resources
|
|
32
|
+
*/
|
|
33
|
+
private static getDiagnosticReports;
|
|
34
|
+
/**
|
|
35
|
+
* Render HTML table for Observation resources
|
|
36
|
+
* @param templateUtilities - Instance of TemplateUtilities for utility functions
|
|
37
|
+
* @param observations - Array of Observation resources
|
|
38
|
+
* @param timezone - Optional timezone to use for date formatting
|
|
39
|
+
* @returns HTML string for rendering
|
|
40
|
+
*/
|
|
41
|
+
private static renderObservations;
|
|
42
|
+
/**
|
|
43
|
+
* Render HTML table for DiagnosticReport resources
|
|
44
|
+
* @param templateUtilities - Instance of TemplateUtilities for utility functions
|
|
45
|
+
* @param reports - Array of DiagnosticReport resources
|
|
46
|
+
* @param timezone - Optional timezone to use for date formatting
|
|
47
|
+
* @returns HTML string for rendering
|
|
48
|
+
*/
|
|
49
|
+
private static renderDiagnosticReports;
|
|
50
|
+
}
|