Comments (5)
Thanks! This kind of works, in that the code runs, but the response model is incorrect and it doesn't play nice with FastAPI's OpenAPI documentation generation:
- The OpenAPI doc generators can't parse the response model, and gives the message
"Unknown Type: Practitioner"
- The response model contains a bunch of private fields:
{
"fhir_comments": null,
"id": null,
"_id": null,
"implicitRules": null,
"_implicitRules": null,
"language": null,
"_language": null,
"meta": null,
"contained": null,
"extension": null,
"modifierExtension": null,
"text": null,
"active": null,
"_active": null,
"address": null,
"birthDate": null,
"_birthDate": null,
"communication": null,
"gender": null,
"_gender": null,
"identifier": null,
"name": null,
"photo": null,
"qualification": null,
"telecom": null,
"resourceType": "Practitioner"
}
If improved FastAPI support is something you'd be open to adding to the library, I'm happy to work on a pull request to see if we can fix these issues.
from fhir.resources.
@garry-jeromson you are welcome to make your pull requests. we are fully open to add any new feature.
Just keep in mind that the new feature should not make any new mandatory package dependency as well as not violating FHIR Resource specification.
from fhir.resources.
I think we have support the FastAPI typing methodology.
try
from fastapi import APIRouter
from fhir.resources.practitioner import Practitioner
from fhir.resources.fhirtypes import PractitionerType
router = APIRouter()
@router.get(
"/practitioner",
response_model=PractitionerType,
)
def get_practitioner(
) -> Any:
return Practitioner()
Let us know if you face any problem.
from fhir.resources.
if we add this to here: https://github.com/nazrulworld/fhir.resources/blob/main/fhir/resources/fhirabstractmodel.py#L516
We can remove all the _ properties from showing up on the Schema for FastAPI Swagger.
@staticmethod
def schema_extra(schema: Dict[str, Any], model: Type['FHIRAbstractModel']) -> None:
current_schema = schema.get('properties', {})
for key in list(current_schema.keys()):
if "_" in key:
current_schema.pop(key)
My next question is.. how do we get the sub models to render in FastAPI? if we do something like this:
name: HumanName = Field( None, alias="name", title="A name associated with the patient", description="A name associated with the individual.", # if property is element of this resource. element_property=True, )
i.e. removing the typing.List[fhirtypes.HumanNameType] we are nearly there, you get both the HumanName added to the Schema, but it also plugs in the full contract into the name field as well. Which might be problematic for some of the larger resources.
I don't know if there is a way to keep HumanNameType and then like.. simply add the HumanName to the Schema somehow?
from fhir.resources.
What's the status on FastAPI? Is there any inherit functionality for fastAPI in this repository or is there a 3rd party tool now?
from fhir.resources.
Related Issues (20)
- Incorrect parsing of StructureDefinition element ids for polymorphic elements HOT 2
- BundleEntryRequest validation error HOT 2
- Transition to R5 HOT 2
- `pkg_resources.declare_namespace` deprecation HOT 1
- urn not supported in Url
- FHIR resource as pydantic request model in FastAPI
- Pydantic 2.0 Migration Plan HOT 17
- Restrict Pydantic to <2.0.0 HOT 3
- Sample code execution error HOT 3
- Use warnings.warn() instead of logging the warning about the ignored extra parameters passed to json() and dict()
- Improve documentation of orjson HOT 1
- Parsing XML byte string MESH acknowledgment response HOT 2
- Instant on DocumentReference not properly output on json HOT 1
- Resource / element to be json-serializable HOT 2
- How to override validation HOT 2
- Handling FHIR Versions
- Error in ID length on EPIC Sandbox data HOT 4
- A way to get list of all resources and their inner elements, help needed in getting sub elements of inner elements HOT 1
- Security vulnerability in orjson package: CVE-2024-27454
- AllergyIntolerance object gives "Extra fields not permitted" error for reaction object.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fhir.resources.