@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,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PregnancyTemplate = void 0;
4
+ // PregnancyTemplate.ts - TypeScript replacement for Jinja2 pregnancy.j2
5
+ const TemplateUtilities_1 = require("./TemplateUtilities");
6
+ /**
7
+ * Class to generate HTML narrative for Pregnancy (Observation resources)
8
+ * This replaces the Jinja2 pregnancy.j2 template
9
+ */
10
+ class PregnancyTemplate {
11
+ /**
12
+ * Generate HTML narrative for Pregnancy
13
+ * @param resource - FHIR Bundle containing Observation 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 PregnancyTemplate.generateStaticNarrative(resource, timezone);
19
+ }
20
+ /**
21
+ * Internal static implementation that actually generates the narrative
22
+ * @param resource - FHIR Bundle containing Observation 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
+ const templateUtilities = new TemplateUtilities_1.TemplateUtilities(resource);
28
+ // Start building the HTML table
29
+ let html = `
30
+ <h5>Pregnancy</h5>
31
+ <table class="hapiPropertyTable">
32
+ <thead>
33
+ <tr>
34
+ <th>Code</th>
35
+ <th>Result</th>
36
+ <th>Comments</th>
37
+ <th>Date</th>
38
+ </tr>
39
+ </thead>
40
+ <tbody>`;
41
+ // Check if we have entries in the bundle
42
+ if (resource.entry && Array.isArray(resource.entry)) {
43
+ // Loop through entries in the bundle
44
+ for (const entry of resource.entry) {
45
+ const obs = entry.resource;
46
+ // Skip Composition resources
47
+ if (obs.resourceType === 'Composition') {
48
+ continue;
49
+ }
50
+ // Use the enhanced narrativeLinkId utility function to extract the ID directly from the resource
51
+ // Add a table row for this observation
52
+ html += `
53
+ <tr id="${(templateUtilities.narrativeLinkId(obs))}">
54
+ <td>${templateUtilities.codeableConcept(obs.code, 'display')}</td>
55
+ <td>${templateUtilities.extractObservationValue(obs)}</td>
56
+ <td>${templateUtilities.renderNotes(obs.note, timezone)}</td>
57
+ <td>${templateUtilities.renderEffective(obs.effectiveDateTime, timezone)}</td>
58
+ </tr>`;
59
+ }
60
+ }
61
+ // Close the HTML table
62
+ html += `
63
+ </tbody>
64
+ </table>`;
65
+ return html;
66
+ }
67
+ }
68
+ exports.PregnancyTemplate = PregnancyTemplate;
@@ -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 Problem List (Condition resources)
5
+ * This replaces the Jinja2 problemlist.j2 template
6
+ */
7
+ export declare class ProblemListTemplate implements ITemplate {
8
+ /**
9
+ * Generate HTML narrative for Problem List
10
+ * @param resource - FHIR Bundle containing Condition 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 Condition 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,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProblemListTemplate = void 0;
4
+ // ProblemListTemplate.ts - TypeScript replacement for Jinja2 problemlist.j2
5
+ const TemplateUtilities_1 = require("./TemplateUtilities");
6
+ /**
7
+ * Class to generate HTML narrative for Problem List (Condition resources)
8
+ * This replaces the Jinja2 problemlist.j2 template
9
+ */
10
+ class ProblemListTemplate {
11
+ /**
12
+ * Generate HTML narrative for Problem List
13
+ * @param resource - FHIR Bundle containing Condition 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 ProblemListTemplate.generateStaticNarrative(resource, timezone);
19
+ }
20
+ /**
21
+ * Internal static implementation that actually generates the narrative
22
+ * @param resource - FHIR Bundle containing Condition 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;
28
+ const templateUtilities = new TemplateUtilities_1.TemplateUtilities(resource);
29
+ // Start building the HTML
30
+ let html = `<div xmlns="http://www.w3.org/1999/xhtml">`;
31
+ // Split conditions into active and resolved
32
+ const activeConditions = [];
33
+ const resolvedConditions = [];
34
+ if (resource.entry && Array.isArray(resource.entry)) {
35
+ // Loop through entries in the bundle
36
+ for (const entry of resource.entry) {
37
+ const cond = entry.resource;
38
+ // Skip composition resources
39
+ if (cond.resourceType === 'Composition') {
40
+ continue;
41
+ }
42
+ // Determine if condition is active or resolved
43
+ const isResolved = (_b = (_a = cond.clinicalStatus) === null || _a === void 0 ? void 0 : _a.coding) === null || _b === void 0 ? void 0 : _b.some(c => { var _a; return c.code === 'resolved' || c.code === 'inactive' || ((_a = c.display) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('resolved')); });
44
+ if (isResolved) {
45
+ resolvedConditions.push(cond);
46
+ }
47
+ else {
48
+ activeConditions.push(cond);
49
+ }
50
+ }
51
+ }
52
+ // Generate active problems section
53
+ if (activeConditions.length > 0) {
54
+ html += `<div class="ActiveProblems">
55
+ <h3>Active Problems</h3>
56
+ <table class="ActiveProblemTable">
57
+ <thead>
58
+ <tr>
59
+ <th>Problem</th>
60
+ <th>Priority</th>
61
+ <th>Noted Date</th>
62
+ <th>Diagnosed Date</th>
63
+ <th>Notes</th>
64
+ </tr>
65
+ </thead>
66
+ <tbody>`;
67
+ for (const cond of activeConditions) {
68
+ html += `<tr id="${(templateUtilities.narrativeLinkId(cond))}">
69
+ <td class="Name">${templateUtilities.codeableConcept(cond.code)}</td>
70
+ <td class="Priority">${(templateUtilities.codeableConcept(cond.severity))}</td>
71
+ <td class="NotedDate">${(templateUtilities.renderDate(cond.onsetDateTime))}</td>
72
+ <td class="DiagnosedDate">${(templateUtilities.renderDate(cond.recordedDate))}</td>
73
+ <td class="Notes">${templateUtilities.renderNotes(cond.note, timezone, { styled: true, warning: true })}</td>
74
+ </tr>`;
75
+ }
76
+ html += `</tbody>
77
+ </table>
78
+ </div>`;
79
+ }
80
+ // Add a break between sections
81
+ if (activeConditions.length > 0 && resolvedConditions.length > 0) {
82
+ html += `<br />`;
83
+ }
84
+ // Generate resolved problems section
85
+ if (resolvedConditions.length > 0) {
86
+ html += `<div class="ResolvedProblems">
87
+ <h3>Resolved Problems</h3>
88
+ <table class="ResolvedProblemTable">
89
+ <thead>
90
+ <tr>
91
+ <th>Problem</th>
92
+ <th>Priority</th>
93
+ <th>Noted Date</th>
94
+ <th>Diagnosed Date</th>
95
+ <th>Resolved Date</th>
96
+ <th>Notes</th>
97
+ </tr>
98
+ </thead>
99
+ <tbody>`;
100
+ for (const cond of resolvedConditions) {
101
+ html += `<tr id="${(templateUtilities.narrativeLinkId(cond))}">
102
+ <td class="Name">${templateUtilities.codeableConcept(cond.code)}</td>
103
+ <td class="Priority">${(templateUtilities.codeableConcept(cond.severity))}</td>
104
+ <td class="NotedDate">${(templateUtilities.renderDate(cond.onsetDateTime))}</td>
105
+ <td class="DiagnosedDate">${(templateUtilities.renderDate(cond.recordedDate))}</td>
106
+ <td class="ResolvedDate">${(templateUtilities.renderDate(cond.abatementDateTime))}</td>
107
+ <td class="Notes">${templateUtilities.renderNotes(cond.note, timezone, { styled: true, warning: true })}</td>
108
+ </tr>`;
109
+ }
110
+ html += `</tbody>
111
+ </table>
112
+ </div>`;
113
+ }
114
+ // Close the HTML
115
+ html += `</div>`;
116
+ return html;
117
+ }
118
+ }
119
+ exports.ProblemListTemplate = ProblemListTemplate;
@@ -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 Social History (Observation resources)
5
+ * This replaces the Jinja2 socialhistory.j2 template
6
+ */
7
+ export declare class SocialHistoryTemplate implements ITemplate {
8
+ /**
9
+ * Generate HTML narrative for Social History
10
+ * @param resource - FHIR Bundle containing Observation 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 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.SocialHistoryTemplate = void 0;
4
+ // SocialHistoryTemplate.ts - TypeScript replacement for Jinja2 socialhistory.j2
5
+ const TemplateUtilities_1 = require("./TemplateUtilities");
6
+ /**
7
+ * Class to generate HTML narrative for Social History (Observation resources)
8
+ * This replaces the Jinja2 socialhistory.j2 template
9
+ */
10
+ class SocialHistoryTemplate {
11
+ /**
12
+ * Generate HTML narrative for Social History
13
+ * @param resource - FHIR Bundle containing Observation 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 SocialHistoryTemplate.generateStaticNarrative(resource, timezone);
19
+ }
20
+ /**
21
+ * Internal static implementation that actually generates the narrative
22
+ * @param resource - FHIR Bundle containing Observation 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
+ const templateUtilities = new TemplateUtilities_1.TemplateUtilities(resource);
28
+ // Start building the HTML table
29
+ let html = `
30
+ <h5>Social History</h5>
31
+ <table class="hapiPropertyTable">
32
+ <thead>
33
+ <tr>
34
+ <th>Code</th>
35
+ <th>Result</th>
36
+ <th>Unit</th>
37
+ <th>Comments</th>
38
+ <th>Date</th>
39
+ </tr>
40
+ </thead>
41
+ <tbody>`;
42
+ // Check if we have entries in the bundle
43
+ if (resource.entry && Array.isArray(resource.entry)) {
44
+ // Loop through entries in the bundle
45
+ for (const entry of resource.entry) {
46
+ const obs = entry.resource;
47
+ // Skip Composition resources
48
+ if (obs.resourceType === 'Composition') {
49
+ continue;
50
+ }
51
+ // Find the narrative link ID if it exists
52
+ // Add a table row for this observation
53
+ html += `
54
+ <tr id="${(templateUtilities.narrativeLinkId(obs))}">
55
+ <td>${templateUtilities.codeableConcept(obs.code, 'display')}</td>
56
+ <td>${templateUtilities.extractObservationValue(obs)}</td>
57
+ <td>${templateUtilities.extractObservationValueUnit(obs)}</td>
58
+ <td>${templateUtilities.renderNotes(obs.note, timezone)}</td>
59
+ <td>${templateUtilities.renderTime(obs.effectiveDateTime, timezone)}</td>
60
+ </tr>`;
61
+ }
62
+ }
63
+ // Close the HTML table
64
+ html += `
65
+ </tbody>
66
+ </table>`;
67
+ return html;
68
+ }
69
+ }
70
+ exports.SocialHistoryTemplate = SocialHistoryTemplate;
@@ -0,0 +1,251 @@
1
+ import { TCodeableConcept } from '../../../types/partials/CodeableConcept';
2
+ import { TReference } from '../../../types/partials/Reference';
3
+ import { TMedication } from '../../../types/resources/Medication';
4
+ import { TImmunization } from "../../../types/resources/Immunization";
5
+ import { TMedicationStatement } from "../../../types/resources/MedicationStatement";
6
+ import { TQuantity } from "../../../types/partials/Quantity";
7
+ import { TObservation } from "../../../types/resources/Observation";
8
+ import { TObservationComponent } from "../../../types/partials/ObservationComponent";
9
+ import { TBundle } from "../../../types/resources/Bundle";
10
+ import { TDomainResource } from "../../../types/resources/DomainResource";
11
+ import { TExtension } from "../../../types/partials/Extension";
12
+ import { TResourceContainer } from "../../../types/simpleTypes/ResourceContainer";
13
+ import { TInstant } from "../../../types/simpleTypes/Instant";
14
+ import { TAnnotation } from "../../../types/partials/Annotation";
15
+ import { TPeriod } from "../../../types/partials/Period";
16
+ import { TRange } from "../../../types/partials/Range";
17
+ import { TRatio } from "../../../types/partials/Ratio";
18
+ type ObservationValueType = string | number | boolean | TQuantity | {
19
+ code?: string;
20
+ text?: string;
21
+ } | Date;
22
+ /**
23
+ * Utility class containing methods for formatting and rendering FHIR resources
24
+ * This replaces the Jinja2 utility-fragments.j2 macros
25
+ */
26
+ export declare class TemplateUtilities {
27
+ private readonly bundle;
28
+ /**
29
+ * Constructor to initialize the TemplateUtilities with a FHIR Bundle
30
+ * @param bundle - FHIR Bundle containing resources
31
+ */
32
+ constructor(bundle: TBundle);
33
+ /**
34
+ * Formats a CodeableConcept object
35
+ * @param cc - The CodeableConcept object
36
+ * @param field - Optional specific field to return
37
+ * @returns Formatted string representation
38
+ */
39
+ codeableConcept(cc?: TCodeableConcept | null, field?: string): string;
40
+ resolveReference<T extends TDomainResource>(ref: TReference): T | null;
41
+ /**
42
+ * Renders a Device reference
43
+ * @param deviceRef - Reference to a Device resource
44
+ * @returns Formatted device description
45
+ */
46
+ renderDevice(deviceRef: TReference): string;
47
+ /**
48
+ * Renders an Organization reference
49
+ * @param orgRef - Reference to an Organization resource
50
+ * @returns Organization name
51
+ */
52
+ renderOrganization(orgRef: TReference): string;
53
+ /**
54
+ * Renders a vaccine manufacturer
55
+ * @param immunization - Immunization resource
56
+ * @returns Manufacturer name
57
+ */
58
+ renderVaccineManufacturer(immunization: TImmunization): string;
59
+ /**
60
+ * Renders a medication
61
+ * @param medicationType - Resource containing medication information
62
+ * @returns Formatted medication description
63
+ */
64
+ renderMedicationStatement(medicationType: TMedicationStatement): string;
65
+ /**
66
+ * Renders a medication reference
67
+ * @param medicationRef - Reference to a Medication resource
68
+ * @returns Formatted medication description
69
+ */
70
+ renderMedicationRef(medicationRef: TReference): string;
71
+ /**
72
+ * Renders a medication code
73
+ * @param medication - Medication resource
74
+ * @returns Formatted medication code
75
+ */
76
+ renderMedicationCode(medication: TMedication): string;
77
+ /**
78
+ * Renders a dose number
79
+ * @param doseNumber - Dose number object
80
+ * @returns Formatted dose number
81
+ */
82
+ renderDoseNumber(doseNumber: any): string;
83
+ /**
84
+ * Renders the unit of a value
85
+ * @param value - Value object
86
+ * @returns Unit string
87
+ */
88
+ renderValueUnit(value: any): string;
89
+ /**
90
+ * Renders an effective date
91
+ * @param effective - Date value
92
+ * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
93
+ * @returns Formatted date string
94
+ */
95
+ renderEffective(effective: any, timezone: string | undefined): string;
96
+ /**
97
+ * Renders a time value
98
+ * @param time - Time value
99
+ * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
100
+ * @returns Formatted time string
101
+ */
102
+ renderTime(time: TInstant | string | undefined, timezone: string | undefined): string;
103
+ /**
104
+ * Renders a date value
105
+ * @param date - Date value
106
+ * @returns Formatted date string (date only, no time component)
107
+ */
108
+ renderDate(date: string | Date | undefined): string;
109
+ /**
110
+ * Renders a recorded date
111
+ * @param recorded - Date value
112
+ * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
113
+ * @returns Formatted date string
114
+ */
115
+ renderRecorded(recorded: any, timezone: string | undefined): string;
116
+ /**
117
+ * Concatenates a list of items, optionally extracting a specific attribute
118
+ * @param list - Array of items
119
+ * @param attr - Optional attribute to extract from each item
120
+ * @returns Comma-separated string of items
121
+ */
122
+ concat(list?: any[] | null, attr?: string): string;
123
+ /**
124
+ * Safely concatenates a list of items, handling undefined/null lists
125
+ * @param list - Array of items (or undefined/null)
126
+ * @param attr - Optional attribute to extract from each item
127
+ * @returns Comma-separated string of items
128
+ */
129
+ safeConcat(list?: any[] | null, attr?: string): string;
130
+ /**
131
+ * Concatenates text from a list of CodeableConcept objects
132
+ * @param list - Array of CodeableConcept objects
133
+ * @returns Comma-separated string of text values
134
+ */
135
+ concatCodeableConcept(list?: TCodeableConcept[] | null): string;
136
+ /**
137
+ * Concatenates reaction manifestations
138
+ * @param list - Array of reaction objects
139
+ * @returns Comma-separated string of manifestation texts
140
+ */
141
+ concatReactionManifestation(list?: any[] | null): string;
142
+ /**
143
+ * Concatenates dose numbers
144
+ * @param list - Array of dose objects
145
+ * @returns Comma-separated string of dose numbers
146
+ */
147
+ concatDoseNumber(list?: any[] | null): string;
148
+ /**
149
+ * Concatenates dosage routes
150
+ * @param list - Array of dosage objects
151
+ * @returns Comma-separated string of route texts
152
+ */
153
+ concatDosageRoute(list?: any[] | null): string;
154
+ /**
155
+ * Returns the first item from a list of CodeableConcept objects
156
+ * @param list - Array of CodeableConcept objects
157
+ * @returns Display text from the first item
158
+ */
159
+ firstFromCodeableConceptList(list?: TCodeableConcept[] | null): string;
160
+ /**
161
+ * Concatenates reference range texts
162
+ * @param list - Array of reference range objects
163
+ * @returns Comma-separated string of texts
164
+ */
165
+ concatReferenceRange(list?: any[] | null): string;
166
+ /**
167
+ * Renders component codes
168
+ * @param list - Array of component objects
169
+ * @returns Comma-separated string of code texts
170
+ */
171
+ renderComponent(list?: any[] | null): string;
172
+ narrativeLinkExtension(source: TResourceContainer | undefined): TExtension | undefined;
173
+ /**
174
+ * Extracts narrative link ID from extension or resource
175
+ * @param source - Extension object or resource with extensions array
176
+ * @returns Extracted ID or empty string
177
+ */
178
+ narrativeLinkId(source: any): string;
179
+ /**
180
+ * Helper method to extract ID from an extension object
181
+ * @param extension - Extension object
182
+ * @returns Extracted ID or empty string
183
+ */
184
+ private extractIdFromExtension;
185
+ extractObservationValue(observation: TObservation | TObservationComponent): ObservationValueType | null;
186
+ private formatQuantityValue;
187
+ private formatCodeableConceptValue;
188
+ extractObservationValueUnit(observation: TObservation | TObservationComponent): string;
189
+ /**
190
+ * Gets the medication name from various types of medication references or resources
191
+ * @param medicationSource - Can be a Reference to Medication, a CodeableConcept, or a Medication resource
192
+ * @returns The medication name as a string
193
+ */
194
+ getMedicationName(medicationSource: TReference | TCodeableConcept | TMedication | null | undefined): string;
195
+ /**
196
+ * Renders text as HTML, escaping special characters and replacing newlines with <br />
197
+ * @param text - The text to render
198
+ * @private
199
+ */
200
+ private renderTextAsHtml;
201
+ /**
202
+ * Renders note elements from a FHIR resource in a standardized format
203
+ * Can render as simple comma-separated text or as styled HTML with timestamps
204
+ *
205
+ * @param notes - Array of note objects (or undefined/null)
206
+ * @param timezone - Optional timezone to use for date formatting
207
+ * @param options - Rendering options
208
+ * @returns Formatted string representation of notes
209
+ */
210
+ renderNotes(notes: Array<TAnnotation> | null | undefined, timezone: string | undefined, options?: {
211
+ styled?: boolean;
212
+ warning?: boolean;
213
+ }): string;
214
+ /**
215
+ * Helper method to format dates with Luxon
216
+ * @param dateValue - The date value to format
217
+ * @param timezone - Optional timezone
218
+ * @param dateOnly - Whether to format as date only (without time)
219
+ * @returns Formatted date string
220
+ * @private
221
+ */
222
+ private formatDateTime;
223
+ /**
224
+ * Renders the onset age in a human-readable format
225
+ * @param onsetAge - The onset age value, which can be a string, number, or an object with value and unit
226
+ * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
227
+ */
228
+ renderOnset(onsetAge: TQuantity, timezone: string | undefined): string;
229
+ /**
230
+ * Renders a period of time in a human-readable format
231
+ * @param effectivePeriod - The effective period object containing start and end dates
232
+ * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
233
+ */
234
+ renderPeriod(effectivePeriod: TPeriod, timezone: string | undefined): string;
235
+ /**
236
+ * Renders a reference to a FHIR resource
237
+ * @param itemReference - The reference object containing the resource type and ID
238
+ */
239
+ renderReference(itemReference: TReference): string | undefined;
240
+ /**
241
+ * Formats a range of values in a human-readable format
242
+ * @param valueRange - The range object containing low and high values
243
+ */
244
+ formatRange(valueRange: TRange): string;
245
+ /**
246
+ * Formats a ratio value in a human-readable format
247
+ * @param valueRatio - The ratio object containing numerator and denominator values
248
+ */
249
+ formatRatio(valueRatio: TRatio): string;
250
+ }
251
+ export {};