How can I extend the structure definition in patient profile in node-fhir-server-core - node-fhir-server-core

This issue is migrated from a question on our Github account because we want the answer to be available to others. Here is the original question:
I need to add custom data field to patient FHIR object, There are any way to Extend structure definition in FHIR patient object in Asymmetrik/node-fhir-server-core

Original answer provided by Jon Lee:
You can definitely add an extension to the Patient resource. The Patient Object extends the DomainResource which should give you access to the Extension Object.

Related

How to add an element in a table that contains multiple instances of objects from another table in Spring Boot?

I'm sure there is a simple solution to my problem but I'm having trouble finding it online so I would be very grateful if someone could point me in the right direction.
So I have a Spring Boot application that uses an external database. I have a table and class called Ingredient that contains the various ingredients. That class has all the necessary methods (PUT, POST, DELETE, GET) and they work as intended.
Now I need to implement another class called Food and every object of type Food should be initiated with a name and a list of Ingredients.
I don't know how to implement it. I made the class Food and I defined a #ManyToMany relationship between the two classes/tables but I don't know how to implement the POST method for the Food.
I tried googling but I'm having trouble wording my problem.

What name should gRPC messages have to avoid conflicts with internal classes?

I have a class Book and its information needs to be passed on gRPC.
message Book {
...
}
But if I use this name there will be conflicts between one class and the other. Is there a convention on this? What name for I use for the gRPC equivalents?
Any meaningful and consistent name will be fine. This problem is not specific to protobuf/gRPC. Often times, we will have an entity class called Book and the corresponding DTO (data transfer object) BookDto with more or less same fields. We add the Dto to the entity class name to create BookDto.
This protobuf messages are basically these DTOs. You can follow the same.
You can use the Book name and access via the qualified path to avoid the conflict. You know this and I hope you do not like it.
Is it really a Book object? It might be a BookSearchRequest to query some books and you might expect BookSearchResponse from your gRPC service.

Student should have a class and get it by a method

I have temporary problem with my project. I am creating a School Management System in Laravel. I have also implemented “spatie/laravel-permission”.
I have some roles: Student, Teacher, Parent, Headmaster etc.
I have some permissions: Add Grade / Edit Grade / Add Absence etc.
Everything works, yep. But the problem is that every student should be assigned to a class (I mean a class in school). How can I edit “spatie/laravel-permission” to implement what I want: if authenticated user is a student he should have also a class, and then type something like:
$thirdClass = User::role('student')->withClass('thirdClass')->get();
to get all users of this class?
I hope you understand what I mean, because my english is not so good as I think propably. I will appreciate every advice how to do it. Have a nice day!
You can use a where method, but only in case where information about class is in the same table (of course You always can use a class_id as a first parameter if you have relation):
User::role('student')->where('class', 'thirdClass')->get();
If you have relation and also want to get information about class, simply use with method:
User::role('student')->where('class_id', $classId)->with('class')->get();

scopes should be in controller or model?

I am new to ruby and rails development and have this question in mind. If i have a concern with scope created say latest_records which gives me latest data for a customer
Now what is the best practice to use scope in this situation. should scopes be in model or in controller?
I read some online articles and it talks about fat model and skinny controller and since scopes are do database related work then i am guessing they should be in model.
Any suggestions or thoughts?
You guessed it right.
Scopes belong to model and needs active record classs object to work on.
Scopes are nothing but a activerecord query divided in parts and it helps look your query elegant and dry.
e.g.
If you want to get users with confirmed emails, you would:
User.where(confirmed: true)
But with scopes in your user model:
scope :confirmed, -> { where(confirmed: true) }
And you would simply:
User.confirmed
For more detailed please refer this answer here
A scope could only be defined in a model so it would have to be on a model.

Spring Data-Rest POST to sub-resource

Lets say I have the following structure:
#Entity
class Person extends AbstractPersistable<Long> {
String name
String surname
}
#Entity
class Task extends AbstractPersistable<Long> {
String description
#ManyToOne
Person person
}
If I follow proper HAL guidelines I'm not supposed to expose entity id's. Since I don't have a bi-directional relationship I cant PUT or PATCH to http://localhost:8080/persons.
Even if I did create the relation, I probably wouldn't want to first POST the Task to /tasks and then PUT to /persons, (mobile clients are going to kill me). But even then I don't have the Task ID even from the returned Entity so I can PUT to the Person entity. (I obviously can string parse but I don't think it's appropriate).
I probably wouldnt want to have a list of 1000 tasks in the Person entity either. So not exporting the Task entity is not really an option (and this means PATCH will not work)
So how am I supposed to associate the Person with the Task if I cannot get his id? What is the correct approach?
If you want to associate a Task with a Person you need the link to the person.
Lets say the person URI is http://localhost/persons/1
Then you could assign the person to a task by just passing that URI in the person attribute.
So a post to Task could look like this:
{
"description": "some text",
"person": "http://localhost/persons/1"
}
Spring-data-rest will lookup the person and take care of the rest.
In HAL Links are used to reference related resources not ids and a HAL entity should always return a Link to itself, which serves as its unique identifier.
If I'm not mistaken you can also annotate fields with DBRef and links should be generated for you.
If you want related resources to actually show up inline with data you'll have to draft a Projection. See more here:
Spring Boot REST Resource not showing linked objects (sets)
Last but not least - if you want Projections to also contain Links you'll have to make ResourceProcessor's for them, see here:
How to add links to Spring Data REST projections?

Resources