Giter Club home page Giter Club logo

Comments (5)

garry-jeromson avatar garry-jeromson commented on July 20, 2024 11

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.

nazrulworld avatar nazrulworld commented on July 20, 2024 2

@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.

nazrulworld avatar nazrulworld commented on July 20, 2024

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.

pcorazao avatar pcorazao commented on July 20, 2024

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.

gilmorera avatar gilmorera commented on July 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.