Skip to content

Commit

Permalink
test: Use local test server
Browse files Browse the repository at this point in the history
  • Loading branch information
Flix committed Sep 1, 2023
1 parent e143a98 commit cd5fea6
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 18 deletions.
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 33 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,20 @@ This is a [FHIR](https://www.hl7.org/fhir/) library in its early stages. The mod

## Features

- [x] Generation of FHIR codes, types and resources
- [x] Generated FHIR codes, types and resources
- [x] Serialization and deserialization to and from JSON
- [x] Linked code-fields to respective enums
- [x] Builders for types and resources
- [x] Allow to convert code enums to Coding and CodeableConcept
- [x] Optional builders for types and resources
- [x] Implementation of base traits
- [x] (Base)Resource
- [x] NamedResource
- [x] DomainResource
- [x] IdentifiableResource
- [x] (Base)Resource for accessing common fields
- [x] NamedResource for getting the resource type in const time
- [x] DomainResource for accessing common fields
- [x] IdentifiableResource for all resources with an identifier field
- [x] REST client implementation
- [x] Create, Read, Update, Delete
- [x] Search
- [x] Paging
- [ ] Batch operations / Transactions
- [ ] Operations
- [ ] Patch
- [ ] FHIRpath implementation
- [ ] Resource validation using FHIRpath and regular expressions
Expand All @@ -37,6 +36,32 @@ This is a [FHIR](https://www.hl7.org/fhir/) library in its early stages. The mod

- XML

## Example

```rust
use fhir_sdk::r5::resources::Patient;
use fhir_sdk::client::*;

#[tokio::main]
async fn main() -> Result<(), Error> {
// Set up the client using the local test server.
let client = Client::new("http://localhost:8090/fhir/".parse().unwrap())?;

// Create a Patient resource using a typed builder.
let mut patient = Patient::builder().active(false).build();
// Push it to the server.
patient.create(&client).await?;
// The id and versionId is updated automatically this way.
assert!(patient.id.is_some());

Ok(())
}
```

## Testing

Simply set up the FHIR test server using `docker compose up -d` and run `cargo test --workspace` in the workspace root.

## Known Problems

- Due to the big number of big types, the compile time and its memory usage is really high. The auto-generated builders also take a long time during the build time.
Expand Down
1 change: 0 additions & 1 deletion crates/fhir-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,5 @@ thiserror = {version = "1.0.40", optional = true}
tokio-retry = {version = "0.3.0", optional = true}

[dev-dependencies]
dotenvy = "0.15.7"
eyre = "0.6.8"
tokio = {version = "1.27.0", features = ["full"]}
4 changes: 2 additions & 2 deletions crates/fhir-sdk/tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use fhir_sdk::{
use futures::TryStreamExt;

fn client() -> Result<Client> {
dotenvy::dotenv()?;
let base_url = env::var("BASE_URL").expect("BASE_URL missing").parse()?;
let base_url =
env::var("FHIR_SERVER").unwrap_or("http://localhost:8090/fhir/".to_owned()).parse()?;
Ok(Client::new(base_url)?)
}

Expand Down
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3.7'

services:
fhir:
image: hapiproject/hapi:latest
ports:
- "8090:8080"
volumes:
- fhir-data:/data/hapi
environment:
hapi.fhir.fhir_version: "R5"
hapi.fhir.tester.home.fhir_version: "R5"
hapi.fhir.subscription.resthook_enabled: "true"
hapi.fhir.subscription.email.from: "[email protected]"
hapi.fhir.subscription.email.host: "test.test"

volumes:
fhir-data:

0 comments on commit cd5fea6

Please sign in to comment.