Skip to content

Commit cd4dcbe

Browse files
committed
Add summaries
Add README Name by packages
1 parent aa2140e commit cd4dcbe

File tree

166 files changed

+1718
-85
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+1718
-85
lines changed

.gitignore

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
2+
3+
# Logs
4+
5+
logs
6+
_.log
7+
npm-debug.log_
8+
yarn-debug.log*
9+
yarn-error.log*
10+
lerna-debug.log*
11+
.pnpm-debug.log*
12+
13+
# Caches
14+
15+
.cache
16+
17+
# Diagnostic reports (https://nodejs.org/api/report.html)
18+
19+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
20+
21+
# Runtime data
22+
23+
pids
24+
_.pid
25+
_.seed
26+
*.pid.lock
27+
28+
# Directory for instrumented libs generated by jscoverage/JSCover
29+
30+
lib-cov
31+
32+
# Coverage directory used by tools like istanbul
33+
34+
coverage
35+
*.lcov
36+
37+
# nyc test coverage
38+
39+
.nyc_output
40+
41+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
42+
43+
.grunt
44+
45+
# Bower dependency directory (https://bower.io/)
46+
47+
bower_components
48+
49+
# node-waf configuration
50+
51+
.lock-wscript
52+
53+
# Compiled binary addons (https://nodejs.org/api/addons.html)
54+
55+
build/Release
56+
57+
# Dependency directories
58+
59+
node_modules/
60+
jspm_packages/
61+
62+
# Snowpack dependency directory (https://snowpack.dev/)
63+
64+
web_modules/
65+
66+
# TypeScript cache
67+
68+
*.tsbuildinfo
69+
70+
# Optional npm cache directory
71+
72+
.npm
73+
74+
# Optional eslint cache
75+
76+
.eslintcache
77+
78+
# Optional stylelint cache
79+
80+
.stylelintcache
81+
82+
# Microbundle cache
83+
84+
.rpt2_cache/
85+
.rts2_cache_cjs/
86+
.rts2_cache_es/
87+
.rts2_cache_umd/
88+
89+
# Optional REPL history
90+
91+
.node_repl_history
92+
93+
# Output of 'npm pack'
94+
95+
*.tgz
96+
97+
# Yarn Integrity file
98+
99+
.yarn-integrity
100+
101+
# dotenv environment variable files
102+
103+
.env
104+
.env.development.local
105+
.env.test.local
106+
.env.production.local
107+
.env.local
108+
109+
# parcel-bundler cache (https://parceljs.org/)
110+
111+
.parcel-cache
112+
113+
# Next.js build output
114+
115+
.next
116+
out
117+
118+
# Nuxt.js build / generate output
119+
120+
.nuxt
121+
dist
122+
123+
# Gatsby files
124+
125+
# Comment in the public line in if your project uses Gatsby and not Next.js
126+
127+
# https://nextjs.org/blog/next-9-1#public-directory-support
128+
129+
# public
130+
131+
# vuepress build output
132+
133+
.vuepress/dist
134+
135+
# vuepress v2.x temp and cache directory
136+
137+
.temp
138+
139+
# Docusaurus cache and generated files
140+
141+
.docusaurus
142+
143+
# Serverless directories
144+
145+
.serverless/
146+
147+
# FuseBox cache
148+
149+
.fusebox/
150+
151+
# DynamoDB Local files
152+
153+
.dynamodb/
154+
155+
# TernJS port file
156+
157+
.tern-port
158+
159+
# Stores VSCode versions used for testing VSCode extensions
160+
161+
.vscode-test
162+
163+
# yarn v2
164+
165+
.yarn/cache
166+
.yarn/unplugged
167+
.yarn/build-state.yml
168+
.yarn/install-state.gz
169+
.pnp.*
170+
171+
# IntelliJ based IDEs
172+
.idea
173+
174+
# Finder (MacOS) folder config
175+
.DS_Store

README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# HL7 FHIR Implementation Guide Analyzer
2+
3+
This project contains scripts to fetch, analyze, and summarize HL7 FHIR Implementation Guides (IGs).
4+
5+
## Prerequisites
6+
7+
- [bun](https://bun.sh/) (latest version)
8+
- Git
9+
- Google Cloud SDK (for Vertex AI)
10+
- Anthropic API key (for Claude)
11+
12+
## Setup
13+
14+
1. Clone this repository:
15+
```
16+
git clone <repository-url>
17+
cd <repository-name>
18+
```
19+
20+
2. Install dependencies:
21+
```
22+
bun install
23+
```
24+
25+
3. Set up Google Cloud credentials:
26+
```
27+
gcloud auth application-default login
28+
```
29+
30+
4. Set your Anthropic API key as an environment variable:
31+
```
32+
export ANTHROPIC_API_KEY=your_api_key_here
33+
```
34+
35+
## Usage
36+
37+
### 1. Fetch HL7 Repositories
38+
39+
Run the `hl7repo.ts` script to fetch HL7 repositories:
40+
41+
```
42+
bun run hl7repo.ts
43+
```
44+
45+
This script will:
46+
- Fetch a list of HL7 repositories from https://build.fhir.org/ig/HL7/
47+
- Create a `repos` directory
48+
- Shallow clone each repository into the `repos` directory
49+
50+
### 2. Process Repositories
51+
52+
After fetching the repositories, you can process them using the `process_repo.ts` script:
53+
54+
```
55+
bun run process_repo.ts repos/<repository-name>
56+
```
57+
58+
Replace `<repository-name>` with the name of the repository you want to process.
59+
60+
This script will:
61+
- Concatenate relevant files from the repository's `input` directory
62+
- Generate an initial analysis using Google's Vertex AI
63+
- Refine the analysis using Anthropic's Claude AI
64+
- Save the results in the following directories:
65+
- `prompts`: Contains the prompts used for AI analysis
66+
- `analysis`: Contains the initial AI analysis
67+
- `summaries`: Contains the final refined summaries
68+
69+
## Output
70+
71+
- `repos/`: Contains the cloned HL7 repositories
72+
- `prompts/`: Contains the prompts used for AI analysis
73+
- `analysis/`: Contains the initial AI analysis for each IG
74+
- `summaries/`: Contains the final refined summaries for each IG
75+
76+
Each summary in the `summaries/` directory is a markdown file named after the IG, containing a concise, plain-language description of the IG's purpose, features, and relevance.
77+
78+
## Notes
79+
80+
- The scripts use AI models, so results will vary between runs.
81+
- Ensure you have sufficient permissions and API quota for Google Cloud and Anthropic services.
82+
- Processing large repositories may take some time and consume API resources.
83+
84+
## Contributing
85+
86+
Contributions are welcome! Please feel free to submit a Pull Request.
87+
88+
## License
89+
90+
This project is licensed under the MIT License.

bun.lockb

6.29 KB
Binary file not shown.

generate-repository-to-package.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { writeFile } from 'fs/promises';
2+
3+
interface IGInfo {
4+
repo: string;
5+
'package-id': string;
6+
}
7+
8+
async function fetchAndProcessIGs() {
9+
try {
10+
const response = await fetch('https://build.fhir.org/ig/qas.json');
11+
const data: IGInfo[] = await response.json();
12+
13+
const repoToPackage: Record<string, string> = {};
14+
15+
data.forEach((ig) => {
16+
const repoPath = ig.repo.split('/');
17+
if (repoPath[0] === 'HL7') {
18+
const repoName = repoPath[1];
19+
repoToPackage[repoName] = ig['package-id'];
20+
}
21+
});
22+
23+
await writeFile('repository_to_package.json', JSON.stringify(repoToPackage, null, 2));
24+
console.log('repository_to_package.json has been created successfully.');
25+
} catch (error) {
26+
console.error('Error fetching or processing data:', error);
27+
}
28+
}
29+
30+
fetchAndProcessIGs();

hl7repo.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { parse } from 'node-html-parser';
2+
import { exec } from 'child_process';
3+
import { promises as fs } from 'fs';
4+
import path from 'path';
5+
6+
const url = 'https://build.fhir.org/ig/HL7/';
7+
const reposDir = 'repos';
8+
9+
async function fetchHL7Repos() {
10+
try {
11+
const response = await fetch(url);
12+
const html = await response.text();
13+
const root = parse(html);
14+
15+
const repos = root.querySelectorAll('tr.file')
16+
.map(tr => tr.querySelector('.name'))
17+
.filter(nameEl => nameEl !== null)
18+
.map(nameEl => nameEl.textContent.trim())
19+
.filter(name => name.endsWith('/'))
20+
.map(name => name.slice(0, -1)) // Remove trailing slash
21+
.filter(name => !name.toLowerCase().includes('template')); // Filter out repos with 'template' in the name
22+
23+
const githubUrls = repos.map(repo => `https://github.com/HL7/${repo}`);
24+
25+
// Create repos directory if it doesn't exist
26+
await fs.mkdir(reposDir, { recursive: true });
27+
28+
for (const url of githubUrls) {
29+
const repoName = url.split('/').pop();
30+
const repoPath = path.join(reposDir, repoName);
31+
32+
console.log(`Shallow cloning ${url}...`);
33+
await new Promise((resolve, reject) => {
34+
exec(`git clone --depth 1 ${url} ${repoPath}`, (error, stdout, stderr) => {
35+
if (error) {
36+
console.error(`Error cloning ${url}:`, error);
37+
reject(error);
38+
} else {
39+
console.log(`Successfully shallow cloned ${url}`);
40+
resolve(stdout);
41+
}
42+
});
43+
});
44+
}
45+
} catch (error) {
46+
console.error('Error fetching or parsing the page:', error);
47+
}
48+
}
49+
50+
fetchHL7Repos();

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"typescript": "^5.0.0"
1010
},
1111
"dependencies": {
12+
"@anthropic-ai/sdk": "^0.27.3",
1213
"@google-cloud/vertexai": "^1.7.0",
1314
"node-html-parser": "^6.1.13"
1415
}

0 commit comments

Comments
 (0)