@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.
Files changed (307) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +81 -0
  3. package/lib/src/generators/fhir_summary_generator.d.ts +46 -0
  4. package/lib/src/generators/fhir_summary_generator.js +228 -0
  5. package/lib/src/generators/narrative_generator.d.ts +40 -0
  6. package/lib/src/generators/narrative_generator.js +80 -0
  7. package/lib/src/narratives/templates/typescript/AdvanceDirectivesTemplate.d.ts +22 -0
  8. package/lib/src/narratives/templates/typescript/AdvanceDirectivesTemplate.js +70 -0
  9. package/lib/src/narratives/templates/typescript/AllergyIntoleranceTemplate.d.ts +31 -0
  10. package/lib/src/narratives/templates/typescript/AllergyIntoleranceTemplate.js +155 -0
  11. package/lib/src/narratives/templates/typescript/ClinicalImpressionTemplate.d.ts +15 -0
  12. package/lib/src/narratives/templates/typescript/ClinicalImpressionTemplate.js +111 -0
  13. package/lib/src/narratives/templates/typescript/DiagnosticResultsTemplate.d.ts +50 -0
  14. package/lib/src/narratives/templates/typescript/DiagnosticResultsTemplate.js +153 -0
  15. package/lib/src/narratives/templates/typescript/FamilyHistoryTemplate.d.ts +15 -0
  16. package/lib/src/narratives/templates/typescript/FamilyHistoryTemplate.js +103 -0
  17. package/lib/src/narratives/templates/typescript/FunctionalStatusTemplate.d.ts +22 -0
  18. package/lib/src/narratives/templates/typescript/FunctionalStatusTemplate.js +70 -0
  19. package/lib/src/narratives/templates/typescript/HistoryOfProceduresTemplate.d.ts +22 -0
  20. package/lib/src/narratives/templates/typescript/HistoryOfProceduresTemplate.js +66 -0
  21. package/lib/src/narratives/templates/typescript/ImmunizationsTemplate.d.ts +22 -0
  22. package/lib/src/narratives/templates/typescript/ImmunizationsTemplate.js +73 -0
  23. package/lib/src/narratives/templates/typescript/MedicalDevicesTemplate.d.ts +22 -0
  24. package/lib/src/narratives/templates/typescript/MedicalDevicesTemplate.js +67 -0
  25. package/lib/src/narratives/templates/typescript/MedicationSummaryTemplate.d.ts +50 -0
  26. package/lib/src/narratives/templates/typescript/MedicationSummaryTemplate.js +206 -0
  27. package/lib/src/narratives/templates/typescript/PastHistoryOfIllnessTemplate.d.ts +15 -0
  28. package/lib/src/narratives/templates/typescript/PastHistoryOfIllnessTemplate.js +59 -0
  29. package/lib/src/narratives/templates/typescript/PatientTemplate.d.ts +65 -0
  30. package/lib/src/narratives/templates/typescript/PatientTemplate.js +158 -0
  31. package/lib/src/narratives/templates/typescript/PlanOfCareTemplate.d.ts +15 -0
  32. package/lib/src/narratives/templates/typescript/PlanOfCareTemplate.js +63 -0
  33. package/lib/src/narratives/templates/typescript/PregnancyTemplate.d.ts +22 -0
  34. package/lib/src/narratives/templates/typescript/PregnancyTemplate.js +68 -0
  35. package/lib/src/narratives/templates/typescript/ProblemListTemplate.d.ts +22 -0
  36. package/lib/src/narratives/templates/typescript/ProblemListTemplate.js +119 -0
  37. package/lib/src/narratives/templates/typescript/SocialHistoryTemplate.d.ts +22 -0
  38. package/lib/src/narratives/templates/typescript/SocialHistoryTemplate.js +70 -0
  39. package/lib/src/narratives/templates/typescript/TemplateUtilities.d.ts +251 -0
  40. package/lib/src/narratives/templates/typescript/TemplateUtilities.js +696 -0
  41. package/lib/src/narratives/templates/typescript/TypeScriptTemplateMapper.d.ts +17 -0
  42. package/lib/src/narratives/templates/typescript/TypeScriptTemplateMapper.js +64 -0
  43. package/lib/src/narratives/templates/typescript/VitalSignsTemplate.d.ts +22 -0
  44. package/lib/src/narratives/templates/typescript/VitalSignsTemplate.js +74 -0
  45. package/lib/src/narratives/templates/typescript/interfaces/ITemplate.d.ts +13 -0
  46. package/lib/src/narratives/templates/typescript/interfaces/ITemplate.js +2 -0
  47. package/lib/src/profiles/ips_resource_profile_registry.d.ts +7 -0
  48. package/lib/src/profiles/ips_resource_profile_registry.js +143 -0
  49. package/lib/src/structures/ips_mandatory_sections.d.ts +7 -0
  50. package/lib/src/structures/ips_mandatory_sections.js +11 -0
  51. package/lib/src/structures/ips_recommended_sections.d.ts +8 -0
  52. package/lib/src/structures/ips_recommended_sections.js +12 -0
  53. package/lib/src/structures/ips_resource_profile.d.ts +7 -0
  54. package/lib/src/structures/ips_resource_profile.js +2 -0
  55. package/lib/src/structures/ips_section_loinc_codes.d.ts +4 -0
  56. package/lib/src/structures/ips_section_loinc_codes.js +48 -0
  57. package/lib/src/structures/ips_section_resource_map.d.ts +8 -0
  58. package/lib/src/structures/ips_section_resource_map.js +69 -0
  59. package/lib/src/structures/ips_sections.d.ts +19 -0
  60. package/lib/src/structures/ips_sections.js +27 -0
  61. package/lib/src/types/partials/Address.d.ts +16 -0
  62. package/lib/src/types/partials/Address.js +3 -0
  63. package/lib/src/types/partials/AllergyIntoleranceReaction.d.ts +16 -0
  64. package/lib/src/types/partials/AllergyIntoleranceReaction.js +3 -0
  65. package/lib/src/types/partials/Annotation.d.ts +12 -0
  66. package/lib/src/types/partials/Annotation.js +3 -0
  67. package/lib/src/types/partials/Attachment.d.ts +17 -0
  68. package/lib/src/types/partials/Attachment.js +3 -0
  69. package/lib/src/types/partials/BundleEntry.d.ts +18 -0
  70. package/lib/src/types/partials/BundleEntry.js +3 -0
  71. package/lib/src/types/partials/BundleLink.d.ts +9 -0
  72. package/lib/src/types/partials/BundleLink.js +3 -0
  73. package/lib/src/types/partials/BundleRequest.d.ts +14 -0
  74. package/lib/src/types/partials/BundleRequest.js +3 -0
  75. package/lib/src/types/partials/BundleResponse.d.ts +14 -0
  76. package/lib/src/types/partials/BundleResponse.js +3 -0
  77. package/lib/src/types/partials/BundleSearch.d.ts +9 -0
  78. package/lib/src/types/partials/BundleSearch.js +3 -0
  79. package/lib/src/types/partials/CarePlanActivity.d.ts +15 -0
  80. package/lib/src/types/partials/CarePlanActivity.js +3 -0
  81. package/lib/src/types/partials/CarePlanDetail.d.ts +33 -0
  82. package/lib/src/types/partials/CarePlanDetail.js +3 -0
  83. package/lib/src/types/partials/ClinicalImpressionFinding.d.ts +11 -0
  84. package/lib/src/types/partials/ClinicalImpressionFinding.js +3 -0
  85. package/lib/src/types/partials/ClinicalImpressionInvestigation.d.ts +10 -0
  86. package/lib/src/types/partials/ClinicalImpressionInvestigation.js +3 -0
  87. package/lib/src/types/partials/CodeableConcept.d.ts +8 -0
  88. package/lib/src/types/partials/CodeableConcept.js +3 -0
  89. package/lib/src/types/partials/CodeableReference.d.ts +9 -0
  90. package/lib/src/types/partials/CodeableReference.js +3 -0
  91. package/lib/src/types/partials/Coding.d.ts +11 -0
  92. package/lib/src/types/partials/Coding.js +3 -0
  93. package/lib/src/types/partials/CompositionAttester.d.ts +11 -0
  94. package/lib/src/types/partials/CompositionAttester.js +3 -0
  95. package/lib/src/types/partials/CompositionEvent.d.ts +12 -0
  96. package/lib/src/types/partials/CompositionEvent.js +3 -0
  97. package/lib/src/types/partials/CompositionRelatesTo.d.ts +11 -0
  98. package/lib/src/types/partials/CompositionRelatesTo.js +3 -0
  99. package/lib/src/types/partials/CompositionSection.d.ts +19 -0
  100. package/lib/src/types/partials/CompositionSection.js +3 -0
  101. package/lib/src/types/partials/ConditionEvidence.d.ts +10 -0
  102. package/lib/src/types/partials/ConditionEvidence.js +3 -0
  103. package/lib/src/types/partials/ConditionStage.d.ts +11 -0
  104. package/lib/src/types/partials/ConditionStage.js +3 -0
  105. package/lib/src/types/partials/ConsentActor.d.ts +10 -0
  106. package/lib/src/types/partials/ConsentActor.js +3 -0
  107. package/lib/src/types/partials/ConsentData.d.ts +9 -0
  108. package/lib/src/types/partials/ConsentData.js +3 -0
  109. package/lib/src/types/partials/ConsentPolicy.d.ts +9 -0
  110. package/lib/src/types/partials/ConsentPolicy.js +3 -0
  111. package/lib/src/types/partials/ConsentProvision.d.ts +22 -0
  112. package/lib/src/types/partials/ConsentProvision.js +3 -0
  113. package/lib/src/types/partials/ConsentVerification.d.ts +11 -0
  114. package/lib/src/types/partials/ConsentVerification.js +3 -0
  115. package/lib/src/types/partials/ContactDetail.d.ts +8 -0
  116. package/lib/src/types/partials/ContactDetail.js +3 -0
  117. package/lib/src/types/partials/ContactPoint.d.ts +12 -0
  118. package/lib/src/types/partials/ContactPoint.js +3 -0
  119. package/lib/src/types/partials/Contributor.d.ts +9 -0
  120. package/lib/src/types/partials/Contributor.js +3 -0
  121. package/lib/src/types/partials/DataRequirement.d.ts +21 -0
  122. package/lib/src/types/partials/DataRequirement.js +3 -0
  123. package/lib/src/types/partials/DataRequirementCodeFilter.d.ts +11 -0
  124. package/lib/src/types/partials/DataRequirementCodeFilter.js +3 -0
  125. package/lib/src/types/partials/DataRequirementDateFilter.d.ts +13 -0
  126. package/lib/src/types/partials/DataRequirementDateFilter.js +3 -0
  127. package/lib/src/types/partials/DataRequirementSort.d.ts +7 -0
  128. package/lib/src/types/partials/DataRequirementSort.js +3 -0
  129. package/lib/src/types/partials/DeviceDeviceName.d.ts +8 -0
  130. package/lib/src/types/partials/DeviceDeviceName.js +3 -0
  131. package/lib/src/types/partials/DeviceProperty.d.ts +11 -0
  132. package/lib/src/types/partials/DeviceProperty.js +3 -0
  133. package/lib/src/types/partials/DeviceSpecialization.d.ts +9 -0
  134. package/lib/src/types/partials/DeviceSpecialization.js +3 -0
  135. package/lib/src/types/partials/DeviceUdiCarrier.d.ts +14 -0
  136. package/lib/src/types/partials/DeviceUdiCarrier.js +3 -0
  137. package/lib/src/types/partials/DeviceVersion.d.ts +11 -0
  138. package/lib/src/types/partials/DeviceVersion.js +3 -0
  139. package/lib/src/types/partials/DiagnosticReportMedia.d.ts +9 -0
  140. package/lib/src/types/partials/DiagnosticReportMedia.js +3 -0
  141. package/lib/src/types/partials/Dosage.d.ts +26 -0
  142. package/lib/src/types/partials/Dosage.js +3 -0
  143. package/lib/src/types/partials/DosageDoseAndRate.d.ts +16 -0
  144. package/lib/src/types/partials/DosageDoseAndRate.js +3 -0
  145. package/lib/src/types/partials/Expression.d.ts +12 -0
  146. package/lib/src/types/partials/Expression.js +3 -0
  147. package/lib/src/types/partials/Extension.d.ts +99 -0
  148. package/lib/src/types/partials/Extension.js +3 -0
  149. package/lib/src/types/partials/FamilyMemberHistoryCondition.d.ts +19 -0
  150. package/lib/src/types/partials/FamilyMemberHistoryCondition.js +3 -0
  151. package/lib/src/types/partials/HumanName.d.ts +13 -0
  152. package/lib/src/types/partials/HumanName.js +3 -0
  153. package/lib/src/types/partials/Identifier.d.ts +15 -0
  154. package/lib/src/types/partials/Identifier.js +3 -0
  155. package/lib/src/types/partials/ImmunizationEducation.d.ts +12 -0
  156. package/lib/src/types/partials/ImmunizationEducation.js +3 -0
  157. package/lib/src/types/partials/ImmunizationPerformer.d.ts +10 -0
  158. package/lib/src/types/partials/ImmunizationPerformer.js +3 -0
  159. package/lib/src/types/partials/ImmunizationProtocolApplied.d.ts +16 -0
  160. package/lib/src/types/partials/ImmunizationProtocolApplied.js +3 -0
  161. package/lib/src/types/partials/ImmunizationReaction.d.ts +11 -0
  162. package/lib/src/types/partials/ImmunizationReaction.js +3 -0
  163. package/lib/src/types/partials/MedicationBatch.d.ts +9 -0
  164. package/lib/src/types/partials/MedicationBatch.js +3 -0
  165. package/lib/src/types/partials/MedicationIngredient.d.ts +13 -0
  166. package/lib/src/types/partials/MedicationIngredient.js +3 -0
  167. package/lib/src/types/partials/MedicationRequestDispenseRequest.d.ts +18 -0
  168. package/lib/src/types/partials/MedicationRequestDispenseRequest.js +3 -0
  169. package/lib/src/types/partials/MedicationRequestInitialFill.d.ts +9 -0
  170. package/lib/src/types/partials/MedicationRequestInitialFill.js +3 -0
  171. package/lib/src/types/partials/MedicationRequestSubstitution.d.ts +10 -0
  172. package/lib/src/types/partials/MedicationRequestSubstitution.js +3 -0
  173. package/lib/src/types/partials/Meta.d.ts +16 -0
  174. package/lib/src/types/partials/Meta.js +3 -0
  175. package/lib/src/types/partials/Money.d.ts +8 -0
  176. package/lib/src/types/partials/Money.js +3 -0
  177. package/lib/src/types/partials/Narrative.d.ts +8 -0
  178. package/lib/src/types/partials/Narrative.js +3 -0
  179. package/lib/src/types/partials/ObservationComponent.d.ts +31 -0
  180. package/lib/src/types/partials/ObservationComponent.js +3 -0
  181. package/lib/src/types/partials/ObservationReferenceRange.d.ts +15 -0
  182. package/lib/src/types/partials/ObservationReferenceRange.js +3 -0
  183. package/lib/src/types/partials/OrganizationContact.d.ts +14 -0
  184. package/lib/src/types/partials/OrganizationContact.js +3 -0
  185. package/lib/src/types/partials/ParameterDefinition.d.ts +14 -0
  186. package/lib/src/types/partials/ParameterDefinition.js +3 -0
  187. package/lib/src/types/partials/PatientCommunication.d.ts +9 -0
  188. package/lib/src/types/partials/PatientCommunication.js +3 -0
  189. package/lib/src/types/partials/PatientContact.d.ts +19 -0
  190. package/lib/src/types/partials/PatientContact.js +3 -0
  191. package/lib/src/types/partials/PatientLink.d.ts +9 -0
  192. package/lib/src/types/partials/PatientLink.js +3 -0
  193. package/lib/src/types/partials/Period.d.ts +8 -0
  194. package/lib/src/types/partials/Period.js +3 -0
  195. package/lib/src/types/partials/ProcedureFocalDevice.d.ts +10 -0
  196. package/lib/src/types/partials/ProcedureFocalDevice.js +3 -0
  197. package/lib/src/types/partials/ProcedurePerformer.d.ts +11 -0
  198. package/lib/src/types/partials/ProcedurePerformer.js +3 -0
  199. package/lib/src/types/partials/Quantity.d.ts +12 -0
  200. package/lib/src/types/partials/Quantity.js +3 -0
  201. package/lib/src/types/partials/Range.d.ts +8 -0
  202. package/lib/src/types/partials/Range.js +3 -0
  203. package/lib/src/types/partials/Ratio.d.ts +8 -0
  204. package/lib/src/types/partials/Ratio.js +3 -0
  205. package/lib/src/types/partials/RatioRange.d.ts +9 -0
  206. package/lib/src/types/partials/RatioRange.js +3 -0
  207. package/lib/src/types/partials/Reference.d.ts +14 -0
  208. package/lib/src/types/partials/Reference.js +3 -0
  209. package/lib/src/types/partials/RelatedArtifact.d.ts +16 -0
  210. package/lib/src/types/partials/RelatedArtifact.js +3 -0
  211. package/lib/src/types/partials/SampledData.d.ts +15 -0
  212. package/lib/src/types/partials/SampledData.js +3 -0
  213. package/lib/src/types/partials/Signature.d.ts +16 -0
  214. package/lib/src/types/partials/Signature.js +3 -0
  215. package/lib/src/types/partials/Timing.d.ts +12 -0
  216. package/lib/src/types/partials/Timing.js +3 -0
  217. package/lib/src/types/partials/TimingRepeat.d.ts +30 -0
  218. package/lib/src/types/partials/TimingRepeat.js +3 -0
  219. package/lib/src/types/partials/TriggerDefinition.d.ts +19 -0
  220. package/lib/src/types/partials/TriggerDefinition.js +3 -0
  221. package/lib/src/types/partials/UsageContext.d.ts +15 -0
  222. package/lib/src/types/partials/UsageContext.js +3 -0
  223. package/lib/src/types/resources/AllergyIntolerance.d.ts +45 -0
  224. package/lib/src/types/resources/AllergyIntolerance.js +3 -0
  225. package/lib/src/types/resources/Bundle.d.ts +22 -0
  226. package/lib/src/types/resources/Bundle.js +3 -0
  227. package/lib/src/types/resources/CarePlan.d.ts +47 -0
  228. package/lib/src/types/resources/CarePlan.js +3 -0
  229. package/lib/src/types/resources/ClinicalImpression.d.ts +45 -0
  230. package/lib/src/types/resources/ClinicalImpression.js +3 -0
  231. package/lib/src/types/resources/Composition.d.ts +39 -0
  232. package/lib/src/types/resources/Composition.js +3 -0
  233. package/lib/src/types/resources/Condition.d.ts +51 -0
  234. package/lib/src/types/resources/Condition.js +3 -0
  235. package/lib/src/types/resources/Consent.d.ts +38 -0
  236. package/lib/src/types/resources/Consent.js +3 -0
  237. package/lib/src/types/resources/Device.d.ts +53 -0
  238. package/lib/src/types/resources/Device.js +3 -0
  239. package/lib/src/types/resources/DeviceUseStatement.d.ts +38 -0
  240. package/lib/src/types/resources/DeviceUseStatement.js +3 -0
  241. package/lib/src/types/resources/DiagnosticReport.d.ts +43 -0
  242. package/lib/src/types/resources/DiagnosticReport.js +3 -0
  243. package/lib/src/types/resources/DomainResource.d.ts +16 -0
  244. package/lib/src/types/resources/DomainResource.js +3 -0
  245. package/lib/src/types/resources/FamilyMemberHistory.d.ts +53 -0
  246. package/lib/src/types/resources/FamilyMemberHistory.js +3 -0
  247. package/lib/src/types/resources/Immunization.d.ts +56 -0
  248. package/lib/src/types/resources/Immunization.js +3 -0
  249. package/lib/src/types/resources/Medication.d.ts +30 -0
  250. package/lib/src/types/resources/Medication.js +3 -0
  251. package/lib/src/types/resources/MedicationRequest.d.ts +59 -0
  252. package/lib/src/types/resources/MedicationRequest.js +3 -0
  253. package/lib/src/types/resources/MedicationStatement.d.ts +42 -0
  254. package/lib/src/types/resources/MedicationStatement.js +3 -0
  255. package/lib/src/types/resources/Observation.d.ts +69 -0
  256. package/lib/src/types/resources/Observation.js +3 -0
  257. package/lib/src/types/resources/Organization.d.ts +32 -0
  258. package/lib/src/types/resources/Organization.js +3 -0
  259. package/lib/src/types/resources/Patient.d.ts +47 -0
  260. package/lib/src/types/resources/Patient.js +3 -0
  261. package/lib/src/types/resources/Procedure.d.ts +59 -0
  262. package/lib/src/types/resources/Procedure.js +3 -0
  263. package/lib/src/types/simpleTypes/Base64Binary.d.ts +1 -0
  264. package/lib/src/types/simpleTypes/Base64Binary.js +2 -0
  265. package/lib/src/types/simpleTypes/Canonical.d.ts +1 -0
  266. package/lib/src/types/simpleTypes/Canonical.js +2 -0
  267. package/lib/src/types/simpleTypes/Date.d.ts +1 -0
  268. package/lib/src/types/simpleTypes/Date.js +2 -0
  269. package/lib/src/types/simpleTypes/DateTime.d.ts +1 -0
  270. package/lib/src/types/simpleTypes/DateTime.js +2 -0
  271. package/lib/src/types/simpleTypes/Decimal.d.ts +1 -0
  272. package/lib/src/types/simpleTypes/Decimal.js +2 -0
  273. package/lib/src/types/simpleTypes/Id.d.ts +1 -0
  274. package/lib/src/types/simpleTypes/Id.js +2 -0
  275. package/lib/src/types/simpleTypes/Instant.d.ts +1 -0
  276. package/lib/src/types/simpleTypes/Instant.js +2 -0
  277. package/lib/src/types/simpleTypes/Int.d.ts +1 -0
  278. package/lib/src/types/simpleTypes/Int.js +2 -0
  279. package/lib/src/types/simpleTypes/Markdown.d.ts +1 -0
  280. package/lib/src/types/simpleTypes/Markdown.js +2 -0
  281. package/lib/src/types/simpleTypes/Oid.d.ts +1 -0
  282. package/lib/src/types/simpleTypes/Oid.js +2 -0
  283. package/lib/src/types/simpleTypes/ResourceContainer.d.ts +1 -0
  284. package/lib/src/types/simpleTypes/ResourceContainer.js +2 -0
  285. package/lib/src/types/simpleTypes/Time.d.ts +1 -0
  286. package/lib/src/types/simpleTypes/Time.js +2 -0
  287. package/lib/src/types/simpleTypes/UnsignedInt.d.ts +1 -0
  288. package/lib/src/types/simpleTypes/UnsignedInt.js +2 -0
  289. package/lib/src/types/simpleTypes/Uri.d.ts +1 -0
  290. package/lib/src/types/simpleTypes/Uri.js +2 -0
  291. package/lib/src/types/simpleTypes/Url.d.ts +1 -0
  292. package/lib/src/types/simpleTypes/Url.js +2 -0
  293. package/lib/src/types/simpleTypes/Uuid.d.ts +1 -0
  294. package/lib/src/types/simpleTypes/Uuid.js +2 -0
  295. package/lib/src/types/simpleTypes/Xhtml.d.ts +1 -0
  296. package/lib/src/types/simpleTypes/Xhtml.js +2 -0
  297. package/lib/test/fhir-summary-bundle/fhir-summary-bundle.test.d.ts +1 -0
  298. package/lib/test/fhir-summary-bundle/fhir-summary-bundle.test.js +72 -0
  299. package/lib/test/ips-test/ips.test.d.ts +1 -0
  300. package/lib/test/ips-test/ips.test.js +389 -0
  301. package/lib/test/narrativeGenerator/narrativeGenerator.test.d.ts +1 -0
  302. package/lib/test/narrativeGenerator/narrativeGenerator.test.js +676 -0
  303. package/lib/test/summary.test.d.ts +1 -0
  304. package/lib/test/summary.test.js +452 -0
  305. package/lib/test/utilities/testHelpers.d.ts +21 -0
  306. package/lib/test/utilities/testHelpers.js +137 -0
  307. package/package.json +126 -0
@@ -0,0 +1,696 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TemplateUtilities = void 0;
4
+ const luxon_1 = require("luxon");
5
+ /**
6
+ * Utility class containing methods for formatting and rendering FHIR resources
7
+ * This replaces the Jinja2 utility-fragments.j2 macros
8
+ */
9
+ class TemplateUtilities {
10
+ /**
11
+ * Constructor to initialize the TemplateUtilities with a FHIR Bundle
12
+ * @param bundle - FHIR Bundle containing resources
13
+ */
14
+ constructor(bundle) {
15
+ this.bundle = bundle;
16
+ }
17
+ /**
18
+ * Formats a CodeableConcept object
19
+ * @param cc - The CodeableConcept object
20
+ * @param field - Optional specific field to return
21
+ * @returns Formatted string representation
22
+ */
23
+ codeableConcept(cc, field) {
24
+ if (!cc) {
25
+ return '';
26
+ }
27
+ // If a specific field is requested, use it if available
28
+ if (field) {
29
+ if (cc[field]) {
30
+ return cc[field];
31
+ }
32
+ else if (cc.coding && cc.coding[0] && cc.coding[0][field]) {
33
+ return cc.coding[0][field];
34
+ }
35
+ }
36
+ // Default order: text, display, code, coding[0].display, coding[0].code
37
+ if (cc.text) {
38
+ return cc.text;
39
+ }
40
+ else if ('display' in cc && cc.display) {
41
+ return cc.display;
42
+ }
43
+ else if (cc.coding && cc.coding[0]) {
44
+ if (cc.coding[0].display) {
45
+ return cc.coding[0].display;
46
+ }
47
+ else if (cc.coding[0].code) {
48
+ return cc.coding[0].code;
49
+ }
50
+ }
51
+ return '';
52
+ }
53
+ resolveReference(ref) {
54
+ var _a;
55
+ // find the resource in the bundle that matches the reference
56
+ if (!ref || !this.bundle || !this.bundle.entry) {
57
+ return null;
58
+ }
59
+ // split the reference into referenceResourceType and id on /
60
+ const referenceParts = (_a = ref.reference) === null || _a === void 0 ? void 0 : _a.split('/');
61
+ if (!referenceParts || referenceParts.length !== 2) {
62
+ return null;
63
+ }
64
+ const referenceResourceType = referenceParts[0];
65
+ const referenceResourceId = referenceParts[1];
66
+ const resource = this.bundle.entry.find(entry => {
67
+ return entry.resource && entry.resource.resourceType === referenceResourceType &&
68
+ entry.resource.id === referenceResourceId;
69
+ });
70
+ return resource ? resource.resource : null;
71
+ }
72
+ /**
73
+ * Renders a Device reference
74
+ * @param deviceRef - Reference to a Device resource
75
+ * @returns Formatted device description
76
+ */
77
+ renderDevice(deviceRef) {
78
+ const device = deviceRef && this.resolveReference(deviceRef);
79
+ if (device && device.resourceType === 'Device' && device.type) {
80
+ return this.codeableConcept(device.type, 'display');
81
+ }
82
+ return '';
83
+ }
84
+ /**
85
+ * Renders an Organization reference
86
+ * @param orgRef - Reference to an Organization resource
87
+ * @returns Organization name
88
+ */
89
+ renderOrganization(orgRef) {
90
+ const organization = orgRef && this.resolveReference(orgRef);
91
+ if (organization && organization.resourceType === 'Organization' && organization.name) {
92
+ return organization.name;
93
+ }
94
+ return '';
95
+ }
96
+ /**
97
+ * Renders a vaccine manufacturer
98
+ * @param immunization - Immunization resource
99
+ * @returns Manufacturer name
100
+ */
101
+ renderVaccineManufacturer(immunization) {
102
+ const organization = immunization.manufacturer && this.resolveReference(immunization.manufacturer);
103
+ if (organization && organization.resourceType === 'Organization' && organization.name) {
104
+ return organization.name;
105
+ }
106
+ return '';
107
+ }
108
+ /**
109
+ * Renders a medication
110
+ * @param medicationType - Resource containing medication information
111
+ * @returns Formatted medication description
112
+ */
113
+ renderMedicationStatement(medicationType) {
114
+ if (typeof medicationType !== 'object' || medicationType === null) {
115
+ return '';
116
+ }
117
+ if (medicationType.medicationCodeableConcept) {
118
+ return this.codeableConcept(medicationType.medicationCodeableConcept);
119
+ }
120
+ else if (medicationType.medicationReference) {
121
+ return this.renderMedicationRef(medicationType.medicationReference);
122
+ }
123
+ return '';
124
+ }
125
+ /**
126
+ * Renders a medication reference
127
+ * @param medicationRef - Reference to a Medication resource
128
+ * @returns Formatted medication description
129
+ */
130
+ renderMedicationRef(medicationRef) {
131
+ const medication = medicationRef && this.resolveReference(medicationRef);
132
+ if (medication) {
133
+ return this.renderMedicationCode(medication);
134
+ }
135
+ return '';
136
+ }
137
+ /**
138
+ * Renders a medication code
139
+ * @param medication - Medication resource
140
+ * @returns Formatted medication code
141
+ */
142
+ renderMedicationCode(medication) {
143
+ if (medication && medication.code) {
144
+ return this.codeableConcept(medication.code, 'display');
145
+ }
146
+ return '';
147
+ }
148
+ /**
149
+ * Renders a dose number
150
+ * @param doseNumber - Dose number object
151
+ * @returns Formatted dose number
152
+ */
153
+ renderDoseNumber(doseNumber) {
154
+ if (doseNumber && doseNumber.value !== undefined) {
155
+ return doseNumber.value.toString();
156
+ }
157
+ return '';
158
+ }
159
+ /**
160
+ * Renders the unit of a value
161
+ * @param value - Value object
162
+ * @returns Unit string
163
+ */
164
+ renderValueUnit(value) {
165
+ var _a;
166
+ if (value && ((_a = value.constructor) === null || _a === void 0 ? void 0 : _a.name) === 'Quantity' && value.unit) {
167
+ return value.unit;
168
+ }
169
+ return '';
170
+ }
171
+ /**
172
+ * Renders an effective date
173
+ * @param effective - Date value
174
+ * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
175
+ * @returns Formatted date string
176
+ */
177
+ renderEffective(effective, timezone) {
178
+ return this.formatDateTime(effective, timezone);
179
+ }
180
+ /**
181
+ * Renders a time value
182
+ * @param time - Time value
183
+ * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
184
+ * @returns Formatted time string
185
+ */
186
+ renderTime(time, timezone) {
187
+ return this.formatDateTime(time, timezone);
188
+ }
189
+ /**
190
+ * Renders a date value
191
+ * @param date - Date value
192
+ * @returns Formatted date string (date only, no time component)
193
+ */
194
+ renderDate(date) {
195
+ return this.formatDateTime(date, undefined, true);
196
+ }
197
+ /**
198
+ * Renders a recorded date
199
+ * @param recorded - Date value
200
+ * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
201
+ * @returns Formatted date string
202
+ */
203
+ renderRecorded(recorded, timezone) {
204
+ return this.formatDateTime(recorded, timezone);
205
+ }
206
+ /**
207
+ * Concatenates a list of items, optionally extracting a specific attribute
208
+ * @param list - Array of items
209
+ * @param attr - Optional attribute to extract from each item
210
+ * @returns Comma-separated string of items
211
+ */
212
+ concat(list, attr) {
213
+ if (!list || !Array.isArray(list)) {
214
+ return '';
215
+ }
216
+ const items = [];
217
+ for (const item of list) {
218
+ if (attr && item && typeof item === 'object' && attr in item) {
219
+ items.push(item[attr]);
220
+ }
221
+ else if (!attr && item !== undefined) {
222
+ items.push(item);
223
+ }
224
+ }
225
+ return items
226
+ .filter(item => typeof item === 'string' || typeof item === 'number')
227
+ .join(', ');
228
+ }
229
+ /**
230
+ * Safely concatenates a list of items, handling undefined/null lists
231
+ * @param list - Array of items (or undefined/null)
232
+ * @param attr - Optional attribute to extract from each item
233
+ * @returns Comma-separated string of items
234
+ */
235
+ safeConcat(list, attr) {
236
+ return this.concat(list || [], attr);
237
+ }
238
+ /**
239
+ * Concatenates text from a list of CodeableConcept objects
240
+ * @param list - Array of CodeableConcept objects
241
+ * @returns Comma-separated string of text values
242
+ */
243
+ concatCodeableConcept(list) {
244
+ if (!list || !Array.isArray(list)) {
245
+ return '';
246
+ }
247
+ const items = [];
248
+ for (const item of list) {
249
+ if (item && item.text) {
250
+ items.push(item.text);
251
+ }
252
+ }
253
+ return items.join(', ');
254
+ }
255
+ /**
256
+ * Concatenates reaction manifestations
257
+ * @param list - Array of reaction objects
258
+ * @returns Comma-separated string of manifestation texts
259
+ */
260
+ concatReactionManifestation(list) {
261
+ if (!list || !Array.isArray(list)) {
262
+ return '';
263
+ }
264
+ const texts = [];
265
+ for (const item of list) {
266
+ if (item && item.manifestation && item.manifestation[0] && item.manifestation[0].text) {
267
+ texts.push(item.manifestation[0].text);
268
+ }
269
+ }
270
+ return texts.join(', ');
271
+ }
272
+ /**
273
+ * Concatenates dose numbers
274
+ * @param list - Array of dose objects
275
+ * @returns Comma-separated string of dose numbers
276
+ */
277
+ concatDoseNumber(list) {
278
+ if (!list || !Array.isArray(list)) {
279
+ return '';
280
+ }
281
+ const doseNumbers = [];
282
+ for (const item of list) {
283
+ if (item && item.doseNumberPositiveInt) {
284
+ doseNumbers.push(item.doseNumberPositiveInt.toString());
285
+ }
286
+ }
287
+ return doseNumbers.join(', ');
288
+ }
289
+ /**
290
+ * Concatenates dosage routes
291
+ * @param list - Array of dosage objects
292
+ * @returns Comma-separated string of route texts
293
+ */
294
+ concatDosageRoute(list) {
295
+ if (!list || !Array.isArray(list)) {
296
+ return '';
297
+ }
298
+ const routes = [];
299
+ for (const item of list) {
300
+ if (item && item.route && item.route.text) {
301
+ routes.push(item.route.text);
302
+ }
303
+ }
304
+ return routes.join(', ');
305
+ }
306
+ /**
307
+ * Returns the first item from a list of CodeableConcept objects
308
+ * @param list - Array of CodeableConcept objects
309
+ * @returns Display text from the first item
310
+ */
311
+ firstFromCodeableConceptList(list) {
312
+ if (list && Array.isArray(list) && list[0]) {
313
+ return this.codeableConcept(list[0], 'display');
314
+ }
315
+ return '';
316
+ }
317
+ /**
318
+ * Concatenates reference range texts
319
+ * @param list - Array of reference range objects
320
+ * @returns Comma-separated string of texts
321
+ */
322
+ concatReferenceRange(list) {
323
+ if (!list || !Array.isArray(list)) {
324
+ return '';
325
+ }
326
+ const texts = [];
327
+ for (const item of list) {
328
+ if (item && item.text) {
329
+ texts.push(item.text);
330
+ }
331
+ }
332
+ return texts.join(', ');
333
+ }
334
+ /**
335
+ * Renders component codes
336
+ * @param list - Array of component objects
337
+ * @returns Comma-separated string of code texts
338
+ */
339
+ renderComponent(list) {
340
+ if (!list || !Array.isArray(list)) {
341
+ return '';
342
+ }
343
+ const texts = [];
344
+ for (const item of list) {
345
+ if (item && item.code && item.code.text) {
346
+ texts.push(item.code.text);
347
+ }
348
+ }
349
+ return texts.join(', ');
350
+ }
351
+ narrativeLinkExtension(source) {
352
+ // If source is undefined or null, return empty string
353
+ if (!source) {
354
+ return undefined;
355
+ }
356
+ // Case 1: Source is a resource with an extensions array
357
+ if (source.extension && Array.isArray(source.extension)) {
358
+ const extension = source.extension.find((ext) => ext.url === 'http://hl7.org/fhir/StructureDefinition/narrativeLink');
359
+ if (extension) {
360
+ return extension;
361
+ }
362
+ return undefined;
363
+ }
364
+ // Case 2: Source is the extension itself
365
+ return source;
366
+ }
367
+ /**
368
+ * Extracts narrative link ID from extension or resource
369
+ * @param source - Extension object or resource with extensions array
370
+ * @returns Extracted ID or empty string
371
+ */
372
+ narrativeLinkId(source) {
373
+ const extension = this.narrativeLinkExtension(source);
374
+ // If no extension found, return empty string
375
+ if (!extension) {
376
+ return '';
377
+ }
378
+ // Case 2: Source is the extension itself
379
+ return this.extractIdFromExtension(extension);
380
+ }
381
+ /**
382
+ * Helper method to extract ID from an extension object
383
+ * @param extension - Extension object
384
+ * @returns Extracted ID or empty string
385
+ */
386
+ extractIdFromExtension(extension) {
387
+ if (typeof extension === 'object' &&
388
+ extension.value &&
389
+ extension.value.value &&
390
+ typeof extension.value.value === 'string' &&
391
+ extension.value.value.includes('#')) {
392
+ return extension.value.value.split('#')[1];
393
+ }
394
+ return '';
395
+ }
396
+ extractObservationValue(observation) {
397
+ // Check all possible value fields in order
398
+ const valueFields = [
399
+ 'valueString',
400
+ 'valueInteger',
401
+ 'valueBoolean',
402
+ 'valueQuantity',
403
+ 'valueCodeableConcept',
404
+ 'valueDateTime',
405
+ 'valueTime',
406
+ 'valuePeriod'
407
+ ];
408
+ for (const field of valueFields) {
409
+ // @ts-expect-error accessing dynamic field
410
+ const observationElement = observation[`${field}`];
411
+ if (observationElement !== undefined) {
412
+ switch (field) {
413
+ case 'valueQuantity':
414
+ // For quantity, return a string representation
415
+ return this.formatQuantityValue(observationElement);
416
+ case 'valueCodeableConcept':
417
+ // For codeable concept, return code or text
418
+ return this.formatCodeableConceptValue(observationElement);
419
+ default:
420
+ return observationElement;
421
+ }
422
+ }
423
+ }
424
+ // Check component values if no direct value found
425
+ // @ts-expect-error accessing dynamic field
426
+ if ((observation === null || observation === void 0 ? void 0 : observation.component) && observation.component.length > 0) {
427
+ // @ts-expect-error accessing dynamic field
428
+ for (const component of observation.component) {
429
+ const componentValue = this.extractObservationValue(component);
430
+ if (componentValue !== null) {
431
+ return componentValue;
432
+ }
433
+ }
434
+ }
435
+ // Check for data absent reason if no value found
436
+ if (observation.dataAbsentReason) {
437
+ return this.formatCodeableConceptValue(observation.dataAbsentReason);
438
+ }
439
+ return null;
440
+ }
441
+ formatQuantityValue(quantity) {
442
+ if (!quantity)
443
+ return '';
444
+ const parts = [];
445
+ if (quantity.comparator)
446
+ parts.push(quantity.comparator);
447
+ if (quantity.value !== undefined)
448
+ parts.push(quantity.value.toString());
449
+ if (quantity.unit)
450
+ parts.push(quantity.unit);
451
+ return parts.join(' ').trim();
452
+ }
453
+ formatCodeableConceptValue(concept) {
454
+ if (!concept)
455
+ return '';
456
+ // Prefer text if available
457
+ if (concept.text)
458
+ return concept.text;
459
+ // Otherwise, use the first coding's display or code
460
+ if (concept.coding && concept.coding.length > 0) {
461
+ return concept.coding[0].display || concept.coding[0].code || '';
462
+ }
463
+ return '';
464
+ }
465
+ extractObservationValueUnit(observation) {
466
+ // Check if the observation has a valueQuantity field
467
+ if (observation.valueQuantity && observation.valueQuantity.unit) {
468
+ return observation.valueQuantity.unit;
469
+ }
470
+ // If no valueQuantity, check components
471
+ // @ts-expect-error accessing dynamic field
472
+ if (observation.component && observation.component.length > 0) {
473
+ // @ts-expect-error accessing dynamic field
474
+ for (const component of observation.component) {
475
+ const unit = this.extractObservationValueUnit(component);
476
+ if (unit) {
477
+ return unit;
478
+ }
479
+ }
480
+ }
481
+ // If no unit found, return empty string
482
+ return '';
483
+ }
484
+ /**
485
+ * Gets the medication name from various types of medication references or resources
486
+ * @param medicationSource - Can be a Reference to Medication, a CodeableConcept, or a Medication resource
487
+ * @returns The medication name as a string
488
+ */
489
+ getMedicationName(medicationSource) {
490
+ if (!medicationSource) {
491
+ return '';
492
+ }
493
+ // Case 1: It's a Medication resource
494
+ if (typeof medicationSource === 'object' && 'resourceType' in medicationSource && medicationSource.resourceType === 'Medication') {
495
+ return this.renderMedicationCode(medicationSource);
496
+ }
497
+ // Case 2: It's a CodeableConcept (medicationCodeableConcept)
498
+ if (typeof medicationSource === 'object' && ('coding' in medicationSource || 'text' in medicationSource)) {
499
+ return this.codeableConcept(medicationSource);
500
+ }
501
+ // Case 3: It's a Reference to a Medication resource (medicationReference)
502
+ if (typeof medicationSource === 'object' && 'reference' in medicationSource) {
503
+ const medication = this.resolveReference(medicationSource);
504
+ if (medication && medication.code) {
505
+ return this.codeableConcept(medication.code);
506
+ }
507
+ }
508
+ return '';
509
+ }
510
+ /**
511
+ * Renders text as HTML, escaping special characters and replacing newlines with <br />
512
+ * @param text - The text to render
513
+ * @private
514
+ */
515
+ renderTextAsHtml(text) {
516
+ // Check for empty string
517
+ if (!text || text.trim() === '') {
518
+ return '';
519
+ }
520
+ // Escape
521
+ const escapedText = text.replace(/</g, '&lt;').replace(/>/g, '&gt;');
522
+ // Replace newlines with <br />
523
+ return escapedText.replace(/\n/g, '<br />');
524
+ }
525
+ /**
526
+ * Renders note elements from a FHIR resource in a standardized format
527
+ * Can render as simple comma-separated text or as styled HTML with timestamps
528
+ *
529
+ * @param notes - Array of note objects (or undefined/null)
530
+ * @param timezone - Optional timezone to use for date formatting
531
+ * @param options - Rendering options
532
+ * @returns Formatted string representation of notes
533
+ */
534
+ renderNotes(notes, timezone, options = {}) {
535
+ if (!notes || !Array.isArray(notes) || notes.length === 0) {
536
+ return '';
537
+ }
538
+ // Simple text-only rendering (comma-separated)
539
+ if (!options.styled) {
540
+ return notes.map(n => this.renderTextAsHtml(n.text)).join('<br />');
541
+ }
542
+ // Styled HTML rendering with timestamps
543
+ let noteHtml = '<ul>';
544
+ for (const note of notes) {
545
+ if (note.text) {
546
+ const noteType = note.authorString || 'Overview';
547
+ noteHtml += `<li class="Note"><span class="NoteTitle">${noteType} (${this.renderTime(note.time, timezone)}):</span><br />`;
548
+ // Optional warning message about formatting
549
+ if (options.warning) {
550
+ noteHtml += `<span class="WarningMsg"><em>Formatting of this note might be different from the original.</em></span><br />`;
551
+ }
552
+ noteHtml += `<span class="NoteText">${this.renderTextAsHtml(note.text)}<br /></span></li>`;
553
+ }
554
+ }
555
+ noteHtml += '</ul>';
556
+ return noteHtml;
557
+ }
558
+ /**
559
+ * Helper method to format dates with Luxon
560
+ * @param dateValue - The date value to format
561
+ * @param timezone - Optional timezone
562
+ * @param dateOnly - Whether to format as date only (without time)
563
+ * @returns Formatted date string
564
+ * @private
565
+ */
566
+ formatDateTime(dateValue, timezone, dateOnly = false) {
567
+ if (!dateValue)
568
+ return '';
569
+ try {
570
+ let dateTime;
571
+ // Handle different input types
572
+ if (dateValue instanceof Date) {
573
+ dateTime = luxon_1.DateTime.fromJSDate(dateValue);
574
+ }
575
+ else if (typeof dateValue === 'string') {
576
+ // Luxon can handle ISO format dates correctly
577
+ dateTime = luxon_1.DateTime.fromISO(dateValue);
578
+ // For date-only strings (YYYY-MM-DD), use date-only formatting
579
+ if (!dateValue.includes('T')) {
580
+ dateOnly = true;
581
+ }
582
+ }
583
+ else {
584
+ dateTime = luxon_1.DateTime.fromISO(String(dateValue));
585
+ }
586
+ if (!dateTime.isValid) {
587
+ return String(dateValue);
588
+ }
589
+ // Set timezone if provided
590
+ if (timezone && !dateOnly) {
591
+ dateTime = dateTime.toUTC().setZone(timezone);
592
+ }
593
+ // Format options
594
+ const formatOptions = dateOnly ?
595
+ { year: 'numeric', month: '2-digit', day: '2-digit' } :
596
+ {
597
+ year: 'numeric',
598
+ month: 'numeric',
599
+ day: 'numeric',
600
+ hour: 'numeric',
601
+ minute: 'numeric',
602
+ hour12: true,
603
+ timeZoneName: 'short'
604
+ };
605
+ return dateTime.toLocaleString(formatOptions);
606
+ }
607
+ catch (_a) {
608
+ return String(dateValue);
609
+ }
610
+ }
611
+ /**
612
+ * Renders the onset age in a human-readable format
613
+ * @param onsetAge - The onset age value, which can be a string, number, or an object with value and unit
614
+ * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
615
+ */
616
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
617
+ renderOnset(onsetAge, timezone) {
618
+ if (!onsetAge) {
619
+ return '';
620
+ }
621
+ // Check if onsetAge is a valid object with value and unit
622
+ if (typeof onsetAge === 'object' && 'value' in onsetAge && 'unit' in onsetAge) {
623
+ // Format the value and unit
624
+ return `${onsetAge.value} ${onsetAge.unit}`;
625
+ }
626
+ return '';
627
+ }
628
+ /**
629
+ * Renders a period of time in a human-readable format
630
+ * @param effectivePeriod - The effective period object containing start and end dates
631
+ * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
632
+ */
633
+ renderPeriod(effectivePeriod, timezone) {
634
+ if (!effectivePeriod || !effectivePeriod.start || !effectivePeriod.end) {
635
+ return '';
636
+ }
637
+ // Format start and end dates using the renderTime method
638
+ const start = this.renderTime(effectivePeriod.start, timezone);
639
+ const end = this.renderTime(effectivePeriod.end, timezone);
640
+ // Return the formatted period string
641
+ return `${start} - ${end}`;
642
+ }
643
+ /**
644
+ * Renders a reference to a FHIR resource
645
+ * @param itemReference - The reference object containing the resource type and ID
646
+ */
647
+ renderReference(itemReference) {
648
+ var _a;
649
+ // check if the type of reference is Condition, Observation
650
+ if (itemReference && itemReference.reference) {
651
+ const parts = itemReference.reference.split('/');
652
+ if (parts.length === 2) {
653
+ const resourceType = parts[0];
654
+ const resourceId = parts[1];
655
+ // Find the resource in the bundle
656
+ const resource = (_a = this.bundle.entry) === null || _a === void 0 ? void 0 : _a.find(entry => { var _a, _b; return ((_a = entry.resource) === null || _a === void 0 ? void 0 : _a.resourceType) === resourceType && ((_b = entry.resource) === null || _b === void 0 ? void 0 : _b.id) === resourceId; });
657
+ if (resource) {
658
+ return `${resourceType}/${resourceId}`;
659
+ }
660
+ }
661
+ }
662
+ }
663
+ /**
664
+ * Formats a range of values in a human-readable format
665
+ * @param valueRange - The range object containing low and high values
666
+ */
667
+ formatRange(valueRange) {
668
+ if (!valueRange || !valueRange.low || !valueRange.high) {
669
+ return '';
670
+ }
671
+ // Format low and high values
672
+ const low = valueRange.low.value !== undefined ? valueRange.low.value.toString() : '';
673
+ const high = valueRange.high.value !== undefined ? valueRange.high.value.toString() : '';
674
+ // Include units if available
675
+ const lowUnit = valueRange.low.unit ? ` ${valueRange.low.unit}` : '';
676
+ const highUnit = valueRange.high.unit ? ` ${valueRange.high.unit}` : '';
677
+ return `${low}${lowUnit} - ${high}${highUnit}`;
678
+ }
679
+ /**
680
+ * Formats a ratio value in a human-readable format
681
+ * @param valueRatio - The ratio object containing numerator and denominator values
682
+ */
683
+ formatRatio(valueRatio) {
684
+ if (!valueRatio || !valueRatio.numerator || !valueRatio.denominator) {
685
+ return '';
686
+ }
687
+ // Format numerator and denominator values
688
+ const numerator = valueRatio.numerator.value !== undefined ? valueRatio.numerator.value.toString() : '';
689
+ const denominator = valueRatio.denominator.value !== undefined ? valueRatio.denominator.value.toString() : '';
690
+ // Include units if available
691
+ const numeratorUnit = valueRatio.numerator.unit ? ` ${valueRatio.numerator.unit}` : '';
692
+ const denominatorUnit = valueRatio.denominator.unit ? ` ${valueRatio.denominator.unit}` : '';
693
+ return `${numerator}${numeratorUnit} / ${denominator}${denominatorUnit}`;
694
+ }
695
+ }
696
+ exports.TemplateUtilities = TemplateUtilities;