@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
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # FHIR Patient Summary Generator
2
+
3
+ This project provides utilities to generate patient summaries from FHIR Bundles, including narrative generation and section extraction, following the International Patient Summary (IPS) specification.
4
+
5
+ ## Installation
6
+
7
+ Clone the repository and install dependencies:
8
+
9
+ ```bash
10
+ git clone <repo-url>
11
+ cd fhir-patient-summary
12
+ npm install
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ You can use the `ComprehensiveIPSCompositionBuilder` in your TypeScript or JavaScript project to generate an IPS-compliant FHIR Bundle. The builder supports both fluent section addition and a convenient `read_bundle()` method to extract all supported sections from a FHIR Bundle.
18
+
19
+ ### Example: Using setPatient and addSection
20
+
21
+ ```typescript
22
+ import { ComprehensiveIPSCompositionBuilder } from './src/generators/fhir_summary_generator';
23
+ import { IPSSections } from './src/structures/ips_sections';
24
+
25
+ const builder = new ComprehensiveIPSCompositionBuilder()
26
+ .setPatient(patientResource)
27
+ .addSection(IPSSections.ALLERGIES, allergiesArray, 'America/New_York')
28
+ .addSection(IPSSections.MEDICATIONS, medicationsArray, 'America/New_York')
29
+ .addSection(IPSSections.PROBLEMS, problemsArray, 'America/New_York')
30
+ .addSection(IPSSections.IMMUNIZATIONS, immunizationsArray, 'America/New_York');
31
+
32
+ const bundle = builder.build_bundle(
33
+ 'example-organization',
34
+ 'Example Organization',
35
+ 'https://fhir.icanbwell.com/4_0_0/',
36
+ 'America/New_York'
37
+ );
38
+ console.log(JSON.stringify(bundle, null, 2));
39
+ ```
40
+
41
+ ### Example: Using read_bundle()
42
+
43
+ ```typescript
44
+ import { ComprehensiveIPSCompositionBuilder } from './src/generators/fhir_summary_generator';
45
+ import testBundle from './test/fhir-summary-bundle/fixtures/test-bundle.json';
46
+
47
+ const patientResource = testBundle.entry.find(e => e.resource.resourceType === 'Patient').resource;
48
+ const builder = new ComprehensiveIPSCompositionBuilder()
49
+ .setPatient(patientResource)
50
+ .read_bundle(testBundle, 'Europe/London');
51
+
52
+ const bundle = builder.build_bundle(
53
+ 'org-1',
54
+ 'Example Hospital',
55
+ 'https://example.com/fhir',
56
+ 'Europe/London'
57
+ );
58
+ console.log(JSON.stringify(bundle, null, 2));
59
+ ```
60
+
61
+ - Use `setPatient(patientResource)` to set the patient.
62
+ - Use `addSection(sectionType, resources, timezone)` to add each IPS section, or use `read_bundle(fhirBundle, timezone)` to extract all supported sections from a FHIR Bundle.
63
+ - Use `build_bundle` to generate the final FHIR Bundle.
64
+
65
+ ## Running Tests
66
+
67
+ To run the test suite:
68
+
69
+ ```bash
70
+ npm test
71
+ ```
72
+
73
+ ## Project Structure
74
+
75
+ - `src/generators/`: Main logic for summary and narrative generation
76
+ - `src/types/`: FHIR resource TypeScript types
77
+ - `test/`: Test suites and FHIR bundle fixtures
78
+
79
+ ## License
80
+
81
+ See [LICENSE](./LICENSE).
@@ -0,0 +1,46 @@
1
+ import { TPatient } from "../types/resources/Patient";
2
+ import { TCompositionSection } from "../types/partials/CompositionSection";
3
+ import { TDomainResource } from "../types/resources/DomainResource";
4
+ import { IPSSections } from "../structures/ips_sections";
5
+ import { TBundle } from "../types/resources/Bundle";
6
+ export declare class ComprehensiveIPSCompositionBuilder {
7
+ private patient;
8
+ private sections;
9
+ private mandatorySectionsAdded;
10
+ private resources;
11
+ /**
12
+ * sets the patient resource for the IPS Composition.
13
+ * This is not needed if you are calling read_bundle, but can be used to set the patient resource directly.
14
+ * @param patient - FHIR Patient resource to set
15
+ */
16
+ setPatient(patient: TPatient): this;
17
+ addSection<T extends TDomainResource>(sectionType: IPSSections, resources: T[], timezone: string | undefined, options?: {
18
+ isOptional?: boolean;
19
+ customLoincCode?: string;
20
+ }): this;
21
+ /**
22
+ * Reads a FHIR Bundle and extracts resources for each section defined in IPSSections.
23
+ * @param bundle - FHIR Bundle containing resources
24
+ * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
25
+ */
26
+ read_bundle(bundle: TBundle, timezone: string | undefined): this;
27
+ /**
28
+ * Builds the final Composition sections, ensuring all mandatory sections are present.
29
+ * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
30
+ */
31
+ build(timezone: string | undefined): TCompositionSection[];
32
+ /**
33
+ * Builds a complete FHIR Bundle containing the Composition and all resources.
34
+ * @param authorOrganizationId - ID of the authoring organization (e.g., hospital or clinic)
35
+ * @param authorOrganizationName - Name of the authoring organization
36
+ * @param baseUrl - Base URL for the FHIR server (e.g., 'https://example.com/fhir')
37
+ * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
38
+ */
39
+ build_bundle(authorOrganizationId: string, authorOrganizationName: string, baseUrl: string, timezone: string | undefined): TBundle;
40
+ /**
41
+ * Creates a narrative for the composition based on the patient and sections.
42
+ * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
43
+ * @private
44
+ */
45
+ private createCompositionNarrative;
46
+ }
@@ -0,0 +1,228 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ComprehensiveIPSCompositionBuilder = void 0;
4
+ const ips_sections_1 = require("../structures/ips_sections");
5
+ const ips_section_loinc_codes_1 = require("../structures/ips_section_loinc_codes");
6
+ const ips_section_resource_map_1 = require("../structures/ips_section_resource_map");
7
+ const narrative_generator_1 = require("./narrative_generator");
8
+ class ComprehensiveIPSCompositionBuilder {
9
+ constructor() {
10
+ this.sections = [];
11
+ this.mandatorySectionsAdded = new Set();
12
+ this.resources = new Set();
13
+ }
14
+ /**
15
+ * sets the patient resource for the IPS Composition.
16
+ * This is not needed if you are calling read_bundle, but can be used to set the patient resource directly.
17
+ * @param patient - FHIR Patient resource to set
18
+ */
19
+ setPatient(patient) {
20
+ if (!patient || patient.resourceType !== 'Patient') {
21
+ throw new Error('Invalid Patient resource');
22
+ }
23
+ this.patient = patient;
24
+ return this;
25
+ }
26
+ // Comprehensive method to add sections with validation
27
+ addSection(sectionType, resources, timezone, options) {
28
+ // Validate resources
29
+ const validResources = resources;
30
+ for (const resource of validResources) {
31
+ // Add resource to the internal set
32
+ this.resources.add(resource);
33
+ }
34
+ // Skip if no valid resources and not mandatory
35
+ if (validResources.length === 0) {
36
+ if (!(options === null || options === void 0 ? void 0 : options.isOptional)) {
37
+ throw new Error(`No valid resources for mandatory section: ${sectionType}`);
38
+ }
39
+ return this;
40
+ }
41
+ // Patient resource does not get a section, it is handled separately
42
+ if (sectionType !== ips_sections_1.IPSSections.PATIENT) {
43
+ // Create section entry
44
+ const narrative = narrative_generator_1.NarrativeGenerator.generateNarrative(sectionType, validResources, timezone);
45
+ const sectionEntry = {
46
+ title: ips_section_loinc_codes_1.IPS_SECTION_DISPLAY_NAMES[sectionType] || sectionType,
47
+ code: {
48
+ coding: [{
49
+ system: 'http://loinc.org',
50
+ code: (options === null || options === void 0 ? void 0 : options.customLoincCode) || ips_section_loinc_codes_1.IPS_SECTION_LOINC_CODES[sectionType],
51
+ display: ips_section_loinc_codes_1.IPS_SECTION_DISPLAY_NAMES[sectionType] || sectionType
52
+ }],
53
+ text: ips_section_loinc_codes_1.IPS_SECTION_DISPLAY_NAMES[sectionType] || sectionType
54
+ },
55
+ text: narrative,
56
+ entry: validResources.map(resource => ({
57
+ reference: `${resource.resourceType}/${resource.id}`,
58
+ display: resource.resourceType
59
+ }))
60
+ };
61
+ // Track mandatory sections
62
+ if (!(options === null || options === void 0 ? void 0 : options.isOptional)) {
63
+ this.mandatorySectionsAdded.add(sectionType);
64
+ }
65
+ this.sections.push(sectionEntry);
66
+ }
67
+ return this;
68
+ }
69
+ /**
70
+ * Reads a FHIR Bundle and extracts resources for each section defined in IPSSections.
71
+ * @param bundle - FHIR Bundle containing resources
72
+ * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
73
+ */
74
+ read_bundle(bundle, timezone) {
75
+ if (!bundle.entry) {
76
+ return this;
77
+ }
78
+ // find the patient resource in the bundle
79
+ const patientEntry = bundle.entry.find(e => { var _a; return ((_a = e.resource) === null || _a === void 0 ? void 0 : _a.resourceType) === 'Patient'; });
80
+ if (!patientEntry || !patientEntry.resource) {
81
+ throw new Error('Patient resource not found in the bundle');
82
+ }
83
+ this.patient = patientEntry.resource;
84
+ // find resources for each section in IPSSections and add the section
85
+ for (const sectionType of Object.values(ips_sections_1.IPSSections)) {
86
+ const resourceTypesForSection = ips_section_resource_map_1.IPSSectionResourceHelper.getResourceTypesForSection(sectionType);
87
+ const customFilter = ips_section_resource_map_1.IPSSectionResourceHelper.getResourceFilterForSection(sectionType);
88
+ let resources = bundle.entry
89
+ .map(e => e.resource)
90
+ .filter(r => typeof (r === null || r === void 0 ? void 0 : r.resourceType) === 'string' && resourceTypesForSection.includes(r.resourceType));
91
+ if (customFilter) {
92
+ resources = resources.filter(customFilter);
93
+ }
94
+ if (resources.length > 0) {
95
+ this.addSection(sectionType, resources, timezone, { isOptional: true });
96
+ }
97
+ }
98
+ return this;
99
+ }
100
+ /**
101
+ * Builds the final Composition sections, ensuring all mandatory sections are present.
102
+ * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
103
+ */
104
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
105
+ build(timezone) {
106
+ // Ensure all mandatory sections are present
107
+ const mandatorySections = [
108
+ ips_sections_1.IPSSections.ALLERGIES,
109
+ ips_sections_1.IPSSections.MEDICATIONS,
110
+ ips_sections_1.IPSSections.PROBLEMS,
111
+ ips_sections_1.IPSSections.IMMUNIZATIONS
112
+ ];
113
+ const missingMandatorySections = mandatorySections.filter(section => !this.mandatorySectionsAdded.has(section));
114
+ if (missingMandatorySections.length > 0) {
115
+ throw new Error(`Missing mandatory IPS sections: ${missingMandatorySections.join(', ')}`);
116
+ }
117
+ return this.sections;
118
+ }
119
+ /**
120
+ * Builds a complete FHIR Bundle containing the Composition and all resources.
121
+ * @param authorOrganizationId - ID of the authoring organization (e.g., hospital or clinic)
122
+ * @param authorOrganizationName - Name of the authoring organization
123
+ * @param baseUrl - Base URL for the FHIR server (e.g., 'https://example.com/fhir')
124
+ * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
125
+ */
126
+ build_bundle(authorOrganizationId, authorOrganizationName, baseUrl, timezone) {
127
+ var _a, _b, _c;
128
+ if (baseUrl.endsWith('/')) {
129
+ baseUrl = baseUrl.slice(0, -1); // Remove trailing slash if present
130
+ }
131
+ if (!this.patient) {
132
+ throw new Error('Patient resource must be set before building the bundle');
133
+ }
134
+ // Create the Composition resource
135
+ const composition = {
136
+ id: `Composition-${this.patient.id}`,
137
+ resourceType: 'Composition',
138
+ status: 'final',
139
+ type: {
140
+ coding: [{
141
+ system: 'http://loinc.org',
142
+ code: '60591-5',
143
+ display: 'Patient summary Document'
144
+ }]
145
+ },
146
+ subject: {
147
+ reference: `Patient/${this.patient.id}`
148
+ },
149
+ author: [{
150
+ reference: `Organization/${authorOrganizationId}`, // Assuming patient is also a practitioner for simplicity
151
+ display: authorOrganizationName
152
+ }],
153
+ date: new Date().toISOString(),
154
+ title: 'International Patient Summary',
155
+ section: this.sections,
156
+ text: this.createCompositionNarrative(timezone)
157
+ };
158
+ // Create the bundle with proper document type
159
+ const bundle = {
160
+ resourceType: 'Bundle',
161
+ type: 'document',
162
+ timestamp: new Date().toISOString(),
163
+ identifier: {
164
+ "system": "urn:ietf:rfc:3986",
165
+ "value": "urn:uuid:4dcfd353-49fd-4ab0-b521-c8d57ced74d6"
166
+ },
167
+ entry: []
168
+ };
169
+ // Add Composition as first entry
170
+ (_a = bundle.entry) === null || _a === void 0 ? void 0 : _a.push({
171
+ fullUrl: `${baseUrl}/Composition/${composition.id}`,
172
+ resource: composition
173
+ });
174
+ // Add patient as second entry
175
+ (_b = bundle.entry) === null || _b === void 0 ? void 0 : _b.push({
176
+ fullUrl: `${baseUrl}/Patient/${this.patient.id}`,
177
+ resource: this.patient
178
+ });
179
+ // Extract and add all resources referenced in sections
180
+ this.resources.forEach(resource => {
181
+ var _a;
182
+ if (resource.resourceType !== "Patient") {
183
+ (_a = bundle.entry) === null || _a === void 0 ? void 0 : _a.push({
184
+ fullUrl: `${baseUrl}/${resource.resourceType}/${resource.id}`,
185
+ resource: resource
186
+ });
187
+ }
188
+ });
189
+ // add a bundle entry for Organization
190
+ (_c = bundle.entry) === null || _c === void 0 ? void 0 : _c.push({
191
+ fullUrl: `${baseUrl}/Organization/${authorOrganizationId}`,
192
+ resource: {
193
+ resourceType: 'Organization',
194
+ id: authorOrganizationId,
195
+ name: authorOrganizationName
196
+ }
197
+ });
198
+ return bundle;
199
+ }
200
+ /**
201
+ * Creates a narrative for the composition based on the patient and sections.
202
+ * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
203
+ * @private
204
+ */
205
+ createCompositionNarrative(timezone) {
206
+ const patient = this.patient;
207
+ let fullNarrativeContent = "";
208
+ // generate narrative for the patient
209
+ const patientNarrative = narrative_generator_1.NarrativeGenerator.generateNarrativeContent(ips_sections_1.IPSSections.PATIENT, [patient], timezone);
210
+ fullNarrativeContent = fullNarrativeContent.concat(patientNarrative || '');
211
+ // now generate narrative for the sections and add to this narrative
212
+ for (const sectionType of Object.values(ips_sections_1.IPSSections)) {
213
+ const resourceTypesForSection = ips_section_resource_map_1.IPSSectionResourceHelper.getResourceTypesForSection(sectionType);
214
+ const allResources = Array.from(this.resources);
215
+ const resources = allResources
216
+ .filter(r => resourceTypesForSection.includes(r.resourceType));
217
+ if (resources.length > 0) {
218
+ const sectionNarrative = narrative_generator_1.NarrativeGenerator.generateNarrativeContent(sectionType, resources, timezone);
219
+ fullNarrativeContent = fullNarrativeContent.concat(sectionNarrative || '');
220
+ }
221
+ }
222
+ return {
223
+ status: 'generated',
224
+ div: narrative_generator_1.NarrativeGenerator.wrapInXhtml(fullNarrativeContent)
225
+ };
226
+ }
227
+ }
228
+ exports.ComprehensiveIPSCompositionBuilder = ComprehensiveIPSCompositionBuilder;
@@ -0,0 +1,40 @@
1
+ import { TDomainResource } from "../types/resources/DomainResource";
2
+ import { IPSSections } from "../structures/ips_sections";
3
+ export interface Narrative {
4
+ status: 'generated' | 'extensions' | 'additional' | 'empty';
5
+ div: string;
6
+ }
7
+ /**
8
+ * Generates narrative content for FHIR resources using TypeScript templates
9
+ * Replaces the Nunjucks-based narrative generator
10
+ */
11
+ export declare class NarrativeGenerator {
12
+ /**
13
+ * Generates narrative HTML content for a section
14
+ * @param section - IPS section type
15
+ * @param resources - Array of domain resources
16
+ * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
17
+ * @returns Generated HTML content or undefined if no resources
18
+ */
19
+ static generateNarrativeContent<T extends TDomainResource>(section: IPSSections, resources: T[], timezone: string | undefined): string | undefined;
20
+ /**
21
+ * Creates a complete FHIR Narrative object
22
+ * @param content - HTML content
23
+ * @returns FHIR Narrative object
24
+ */
25
+ static createNarrative(content: string): Narrative;
26
+ /**
27
+ * Generates a complete FHIR Narrative object for a section
28
+ * @param section - IPS section type
29
+ * @param resources - Array of domain resources
30
+ * @param timezone - Optional timezone to use for date formatting (e.g., 'America/New_York', 'Europe/London')
31
+ * @returns FHIR Narrative object or undefined if no resources
32
+ */
33
+ static generateNarrative<T extends TDomainResource>(section: IPSSections, resources: T[], timezone: string | undefined): Narrative | undefined;
34
+ /**
35
+ * Wrap content in XHTML div with FHIR namespace
36
+ * @param content - HTML content to wrap
37
+ * @returns XHTML div string
38
+ */
39
+ static wrapInXhtml(content: string): string;
40
+ }