gateway

package
v0.0.0-...-4eea697 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2023 License: Apache-2.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Ehr         *EhrHandler
	EhrStatus   *EhrStatusHandler
	Composition *CompositionHandler
	Directory   *DirectoryHandler
	Query       *QueryHandler
	Template    *TemplateHandler
	//GroupAccess *GroupAccessHandler
	DocAccess    *DocAccessHandler
	Request      *RequestHandler
	User         *UserHandler
	Contribution *ContributionHandler
}

func New

func New(cfg *config.Config, infra *infrastructure.Infra) *API

func (*API) Build

func (a *API) Build() *gin.Engine

type CompositionHandler

type CompositionHandler struct {
	// contains filtered or unexported fields
}

func NewCompositionHandler

func NewCompositionHandler(docService *service.DefaultDocumentService, compositionService *composition.Service, baseURL string) *CompositionHandler

func (*CompositionHandler) Create

func (h *CompositionHandler) Create(c *gin.Context)

Create

@Summary		Create COMPOSITION
@Description	Work in progress...
@Description	Creates the first version of a new COMPOSITION in the EHR identified by ehr_id.
@Description
@Tags		COMPOSITION
@Accept		json
@Produce	json
@Param		ehr_id			path		string				true	"EHR identifier. Example: 7d44b88c-4199-4bad-97dc-d78268e01398"
@Param		Authorization	header		string				true	"Bearer AccessToken"
@Param		AuthUserId		header		string				true	"UserId"
@Param		EhrSystemId		header		string				false	"The identifier of the system, typically a reverse domain identifier"
@Param		GroupAccessId	header		string				false	"GroupAccessId - UUID. If not specified, the default access group will be used."
@Param		Prefer			header		string				true	"The new EHR resource is returned in the body when the request’s `Prefer` header value is `return=representation`, otherwise only headers are returned."
@Param		Request			body		model.Composition	true	"COMPOSITION"
@Success	201				{object}	model.Composition
@Header		201				{string}	Location	"{baseUrl}/ehr/7d44b88c-4199-4bad-97dc-d78268e01398/composition/8849182c-82ad-4088-a07f-48ead4180515::openEHRSys.example.com::1"
@Header		201				{string}	ETag		"8849182c-82ad-4088-a07f-48ead4180515::openEHRSys.example.com::1"
@Header		201				{string}	RequestID	"Request identifier"
@Failure	400				"Is returned when the request has invalid ehr_id or invalid content (e.g. content could not be converted to a valid COMPOSITION object)"
@Failure	404				"Is returned when an EHR with ehr_id does not exist."
@Failure	422				"Is returned when the content could be converted to a COMPOSITION, but there are semantic validation errors, such as the underlying template is not known or is not validating the supplied COMPOSITION)."
@Failure	500				"Is returned when an unexpected error occurs while processing a request"
@Router		/ehr/{ehr_id}/composition [post]

func (*CompositionHandler) Delete

func (h *CompositionHandler) Delete(c *gin.Context)

Delete

@Summary		Deletes the COMPOSITION by version id
@Description	Deletes the COMPOSITION identified by `preceding_version_uid` and associated with the EHR identified by `ehr_id`.
@Description
@Tags		COMPOSITION
@Accept		json
@Produce	json
@Param		ehr_id					path	string	true	"EHR identifier taken from EHR.ehr_id.value. Example: 7d44b88c-4199-4bad-97dc-d78268e01398"
@Param		preceding_version_uid	path	string	true	"Identifier of the COMPOSITION to be deleted. This MUST be the last (most recent)  version.  Example:  `8849182c-82ad-4088-a07f-48ead4180515::openEHRSys.example.com::1`"
@Param		Authorization			header	string	true	"Bearer AccessToken"
@Param		AuthUserId				header	string	true	"UserId"
@Param		EhrSystemId				header	string	false	"The identifier of the system, typically a reverse domain identifier"
@Failure	204						"`No Content` is returned when COMPOSITION was deleted."
@Header		204						{string}	RequestID	"Request identifier"
@Failure	400						"`Bad Request` is returned when the composition with `preceding_version_uid` is already deleted."
@Failure	404						"`Not Found` is returned when an EHR with ehr_id does not exist or when a COMPOSITION with preceding_version_uid does not exist."
@Failure	409						"`Conflict` is returned when supplied `preceding_version_uid` doesn’t match the latest version. Returns latest version in the Location and ETag headers."
@Failure	500						"Is returned when an unexpected error occurs while processing a request"
@Router		/ehr/{ehr_id}/composition/{preceding_version_uid} [delete]

func (*CompositionHandler) GetByID

func (h *CompositionHandler) GetByID(c *gin.Context)

GetByID

@Summary		Get COMPOSITION by version id
@Description	Retrieves a particular version of the COMPOSITION identified by `version_uid` and associated with the EHR identified by `ehr_id`.
@Description
@Tags		COMPOSITION
@Accept		json
@Produce	json
@Param		ehr_id			path		string	true	"EHR identifier taken from EHR.ehr_id.value. Example: 7d44b88c-4199-4bad-97dc-d78268e01398"
@Param		version_uid		path		string	true	"VERSION identifier taken from VERSION.uid.value. Example: 8849182c-82ad-4088-a07f-48ead4180515::openEHRSys.example.com::1"
@Param		Authorization	header		string	true	"Bearer AccessToken"
@Param		AuthUserId		header		string	true	"UserId"
@Param		EhrSystemId		header		string	false	"The identifier of the system, typically a reverse domain identifier"
@Success	200				{object}	model.Composition
@Success	202				"Is returned when the request is still being processed"
@Failure	204				"Is returned when the COMPOSITION is deleted (logically)."
@Failure	400				"Is returned when AuthUserId is not specified"
@Failure	404				"is returned when an EHR with `ehr_id` does not exist or when an COMPOSITION with `version_uid` does not exist."
@Failure	500				"Is returned when an unexpected error occurs while processing a request"
@Router		/ehr/{ehr_id}/composition/{version_uid} [get]

func (CompositionHandler) GetList

func (h CompositionHandler) GetList(c *gin.Context)

List

@Summary		Get all COMPOSITIONs
@Description	Retrieves all versions of all COMPOSITIONs associated with the EHR identified by `ehr_id`.
@Description
@Tags		COMPOSITION
@Accept		json
@Produce	json
@Param		ehr_id			path		string	true	"EHR identifier taken from EHR.ehr_id.value. Example: 7d44b88c-4199-4bad-97dc-d78268e01398"
@Param		Authorization	header		string	true	"Bearer AccessToken"
@Param		AuthUserId		header		string	true	"UserId"
@Param		EhrSystemId		header		string	false	"The identifier of the system, typically a reverse domain identifier"
@Success	200				{object}	[]model.EhrDocumentItem
@Failure	400				"Is returned when AuthUserId or EhrSystemId is not specified"
@Failure	404				"is returned when an EHR with `ehr_id` does not exist."
@Failure	500				"Is returned when an unexpected error occurs while processing a request"
@Router		/ehr/{ehr_id}/composition [get]

func (CompositionHandler) Update

func (h CompositionHandler) Update(c *gin.Context)

Update

@Summary		Updates the COMPOSITION by version id
@Description	Updates COMPOSITION identified by `versioned_object_uid` and associated with the EHR
@Description	identified by `ehr_id`. If the request body already contains a COMPOSITION.uid.value,
@Description	it must match the `versioned_object_uid` in the URL. The existing latest `version_uid`
@Description	of COMPOSITION resource (i.e the `preceding_version_uid`) must be specified in the `If-Match` header.
@Description
@Tags		COMPOSITION
@Accept		json
@Produce	json
@Param		ehr_id					path		string				true	"EHR identifier taken from EHR.ehr_id.value. Example: 7d44b88c-4199-4bad-97dc-d78268e01398"
@Param		versioned_object_uid	path		string				true	"identifier of the COMPOSITION to be updated. Example: `8849182c-82ad-4088-a07f-48ead4180515`"
@Param		Authorization			header		string				true	"Bearer AccessToken"
@Param		AuthUserId				header		string				true	"UserId"
@Param		EhrSystemId				header		string				false	"The identifier of the system, typically a reverse domain identifier"
@Param		Prefer					header		string				true	"The updated COMPOSITION resource is returned to the body when the request’s `Prefer` header value is `return=representation`, otherwise only headers are returned."
@Param		If-Match				header		string				true	"The existing latest version_uid of COMPOSITION resource (i.e the preceding_version_uid).  Example:  `8849182c-82ad-4088-a07f-48ead4180515::openEHRSys.example.com::1`"
@Param		Request					body		model.Composition	true	"List of changes in COMPOSITION"
@Success	200						{object}	model.Composition	"Is returned when the COMPOSITION is successfully updated and the updated resource is returned in the body when Prefer header value is `return=representation.`"
@Header		200						{string}	Location			"{baseUrl}/ehr/7d44b88c-4199-4bad-97dc-d78268e01398/composition/8849182c-82ad-4088-a07f-48ead4180515::openEHRSys.example.com::2"
@Header		200						{string}	ETag				"8849182c-82ad-4088-a07f-48ead4180515::openEHRSys.example.com::2"
@Header		200						{string}	RequestID			"Request identifier"
@Failure	422						"`Unprocessable Entity` is returned when the content could be converted to a COMPOSITION, but there are semantic validation errors, such as the underlying template is not known or is not validating the supplied COMPOSITION)."
@Failure	400						"`Bad Request` is returned when the request has invalid `ehr_id` or invalid content (e.g. either the body of the request could not be read, or converted to a valid COMPOSITION object)"
@Failure	404						"`Not Found` is returned when an EHR with ehr_id does not exist or when a COMPOSITION with version_object_uid does not exist."
@Failure	412						"`Version conflict` is returned when `If-Match` request header doesn’t match the latest version (of this versioned object)  on  the  service  side.  Returns  also  latest  `version_uid`  in  the  `Location`  and  `ETag`  headers."
@Failure	500						"Is returned when an unexpected error occurs while processing a request"
@Router		/ehr/{ehr_id}/composition/{versioned_object_uid} [put]

type CompositionService

type CompositionService interface {
	helper.Finder
	DefaultGroupAccess() *uuid.UUID
	Create(ctx context.Context, userID, systemID string, ehrUUID, groupAccessUUID *uuid.UUID, composition *model.Composition, procRequest *proc.Request) (*model.Composition, error)
	Update(ctx context.Context, procRequest *proc.Request, userID, systemID string, ehrUUID, groupAccessUUID *uuid.UUID, composition *model.Composition) (*model.Composition, error)
	GetLastByBaseID(ctx context.Context, userID, systemID string, ehrUUID *uuid.UUID, versionUID string) (*model.Composition, error)
	GetByID(ctx context.Context, userID, systemID string, ehrUUID *uuid.UUID, versionUID string) (*model.Composition, error)
	DeleteByID(ctx context.Context, procRequest *proc.Request, ehrUUID *uuid.UUID, versionUID, userID, systemID string) (string, error)
	GetList(ctx context.Context, userID, systemID string) ([]*model.EhrDocumentItem, error)
}

type ContributionHandler

type ContributionHandler struct {
	// contains filtered or unexported fields
}

func (*ContributionHandler) Create

func (h *ContributionHandler) Create(ctx *gin.Context)

Create Summary Create CONTRIBUTION Description https://specifications.openehr.org/releases/ITS-REST/latest/ehr.html#tag/CONTRIBUTION/operation/contribution_create Tags CONTRIBUTION Param Authorization header string true "Bearer AccessToken" Param AuthUserId header string true "UserId UUID" Param Prefer header string true "Request header to indicate the preference over response details. The response will contain the entire resource when the Prefer header has a value of return=representation." Enums: ("return=representation", "return=minimal") default("return=minimal") Header 201 {string} Etag "The ETag (i.e. entity tag) response header is the contribution_uid identifier, enclosed by double quotes. Example: \"0826851c-c4c2-4d61-92b9-410fb8275ff0\"" Header 201 {string} Location "{baseUrl}/ehr/{ehr_id}/contribution/{contribution_uid}" Header 201 {string} RequestID "Request identifier" Accept json Produce json Success 201 {object} model.ContributionResponse "Is returned when the CONTRIBUTION was successfully created." Failure 400 {object} model.ErrorResponse "Is returned when the request URL or body could not be parsed or has invalid content (e.g. invalid {ehr_id}, or either the body of the request not be converted to a valid CONTRIBUTION object, or the modification type doesn’t match the operation - i.e. first version of a composition with MODIFICATION)." Failure 409 "Is returned when a resource with same identifier(s) already exists." Failure 500 "Is returned when an unexpected error occurs while processing a request" Router /ehr/{ehr_id}/contribution [post]

func (*ContributionHandler) GetByID

func (h *ContributionHandler) GetByID(c *gin.Context)

Get Summary Get CONTRIBUTION by id Description Retrieves a CONTRIBUTION identified by {contribution_uid} and associated with the EHR identified by {ehr_id}. Description https://specifications.openehr.org/releases/ITS-REST/latest/ehr.html#tag/CONTRIBUTION/operation/contribution_create Tags CONTRIBUTION Produce json Param contribution_uid path string false "The CONTRIBUTION uid" Param Authorization header string true "Bearer AccessToken" Param AuthUserId header string true "UserId UUID" Param EhrSystemId header string true "The identifier of the system, typically a reverse domain identifier" Success 200 {object} model.ContributionResponse Failure 400 "Is returned when the request has invalid content." Failure 404 "Is returned when an EHR with {ehr_id} does not exist, or when a CONTRIBUTION with {contribution_uid} does not exist" Failure 500 "Is returned when an unexpected error occurs while processing a request" Router /ehr/{ehr_id}/contribution/{contribution_uid} [get]

type ContributionService

type ContributionService interface {
	NewProcRequest(reqID, userID, ehrUUID string, kind processing.RequestKind) (processing.RequestInterface, error)
	GetByID(ctx context.Context, userID string, cID string) (*model.ContributionResponse, error)
	Store(ctx context.Context, req processing.RequestInterface, systemID string, user *userModel.UserInfo, c *model.Contribution) error
	Validate(ctx context.Context, c *model.Contribution, template helper.Searcher) (bool, error)
	Execute(ctx context.Context, req processing.RequestInterface, userID, ehrUUID string, c *model.Contribution, hComposition helper.Searcher) error
	PrepareResponse(ctx context.Context, systemID string, c *model.Contribution) (*model.ContributionResponse, error)
}

type DirectoryHandler

type DirectoryHandler struct {
	// contains filtered or unexported fields
}

func NewDirectoryHandler

func NewDirectoryHandler(cS DirectoryService, uS UserService, indexer Indexer, baseURL string) *DirectoryHandler

func (*DirectoryHandler) Create

func (h *DirectoryHandler) Create(ctx *gin.Context)

Create

@Summary		Create DIRECTORY
@Description	https://specifications.openehr.org/releases/ITS-REST/latest/ehr.html#tag/DIRECTORY/operation/directory_create
@Tags			DIRECTORY
@Param			Authorization	header		string		true	"Bearer AccessToken"
@Param			AuthUserId		header		string		true	"Doctor UserId"
@Param			Prefer			header		string		true	"Request header to indicate the preference over response details. The response will contain the entire resource when the Prefer header has a value of return=representation."	Enums:	("return=representation", "return=minimal")	default("return=minimal")
@Param			ehr_id			path		string		true	"EHR identifier taken from EHR.ehr_id.value. Example: 7d44b88c-4199-4bad-97dc-d78268e01398"
@Param			patient_id		query		string		true	"Patient UserId"
@Header			201				{string}	Etag		"The ETag (i.e. entity tag) response header is the version_uid identifier, enclosed by double quotes. Example: \"8849182c-82ad-4088-a07f-48ead4180515::openEHRSys.example.com::1\""
@Header			201				{string}	Location	"{baseUrl}/ehr/{ehr_id}/directory/{version_uid}"
@Header			201				{string}	RequestID	"Request identifier"
@Accept			json
@Produce		json
@Success		201	{object}	model.Directory	"Is returned when the DIRECTORY was successfully created."
@Failure		400	"Is returned when the request has invalid content"
@Failure		404	"Is returned when an EHR with {ehr_id}  does not exist"
@Failure		409	"Is returned when a resource with same identifier(s) already exists, or previous request still in progress"
@Failure		500	"Is returned when an unexpected error occurs while processing a request"
@Router			/ehr/{ehr_id}/directory [post]

func (*DirectoryHandler) Delete

func (h *DirectoryHandler) Delete(ctx *gin.Context)

Delete

@Summary		Delete DIRECTORY folder associated with the EHR identified by ehr_id.
@Description	https://specifications.openehr.org/releases/ITS-REST/latest/ehr.html#tag/DIRECTORY/operation/directory_delete
@Description	The existing latest {version_uid} of directory FOLDER resource (i.e. the {preceding_version_uid}) must be specified in the {If-Match} header.
@Tags			DIRECTORY
@Param			Authorization	header		string		true	"Bearer AccessToken"
@Param			AuthUserId		header		string		true	"UserId"
@Param			Prefer			header		string		true	"Request header to indicate the preference over response details. The response will contain the entire resource when the Prefer header has a value of return=representation."	Enums:	("return=representation", "return=minimal")	default("return=minimal")
@Param			ehr_id			path		string		true	"EHR identifier taken from EHR.ehr_id.value. Example: 7d44b88c-4199-4bad-97dc-d78268e01398"
@Param			patient_id		query		string		true	"Patient UserId"
@Header			204				{string}	RequestID	"Request identifier"
@Header			412				{string}	Etag		"The ETag (i.e. entity tag) response header is the version_uid identifier, enclosed by double quotes. Example: \"8849182c-82ad-4088-a07f-48ead4180515::openEHRSys.example.com::1\""
@Header			412				{string}	Location	"{baseUrl}/ehr/{ehr_id}/directory/{version_uid}"
@Success		204				"Is returned when the resource identified by the request parameters has been (logically) deleted"
@Failure		400				"Is returned when the request has invalid content"
@Failure		404				"Is returned when an EHR with {ehr_id} does not exist, or DIRECTORY with that version is not exist"
@Failure		409				"Is returned when a resource with same identifier(s) already exists, or previous request still in progress"
@Failure		412				"Is returned when 'If-Match' request header doesn't match the latest version on the service side. Returns also latest 'version_uid' in the 'Location' and 'ETag' headers"
@Failure		500				"Is returned when an unexpected error occurs while processing a request"
@Router			/ehr/{ehr_id}/directory [delete]

func (*DirectoryHandler) GetByTime

func (h *DirectoryHandler) GetByTime(ctx *gin.Context)

Get folder in DIRECTORY

@Summary		Get folder in DIRECTORY version at time.
@Description	https://specifications.openehr.org/releases/ITS-REST/latest/ehr.html#tag/DIRECTORY/operation/directory_get_at_time
@Description	Retrieves the version of the directory FOLDER associated with the EHR identified by {ehr_id}. If {version_at_time} is supplied, retrieves the version extant at specified time, otherwise retrieves the latest directory FOLDER version. If path is supplied, retrieves from the directory only the sub-FOLDER that is associated with that path.
@Tags			DIRECTORY
@Param			Authorization	header	string	true	"Bearer AccessToken"
@Param			AuthUserId		header	string	true	"UserId"
@Param			Prefer			header	string	true	"Request header to indicate the preference over response details. The response will contain the entire resource when the Prefer header has a value of return=representation."	Enums:	("return=representation", "return=minimal")	default("return=minimal")
@Param			ehr_id			path	string	true	"EHR identifier taken from EHR.ehr_id.value. Example: 7d44b88c-4199-4bad-97dc-d78268e01398"
@Param			version_at_time	query	string	true	"Example: version_at_time=2015-01-20T19:30:22.765+01:00 A given time in the extended ISO 8601 format"
@Param			path			query	string	true	"Example: path=episodes/a/b/c A path to a sub-folder; consists of slash-separated values of the name attribute of FOLDERs in the directory"
@Param			patient_id		query	string	true	"Patient UserId"
@Produce		json
@Success		200	{object}	model.Directory	"Is returned when the FOLDER is successfully retrieved"
@Success		204	"Is returned when the resource identified by the request parameters (at specified {version_at_time}) time has been deleted"
@Failure		400	"Is returned when the request has invalid content"
@Failure		404	"Is returned when an EHR with {ehr_id} does not exist, or when a directory does not exist at the specified {version_at_time}, or when {path} does not exists within the directory"
@Failure		500	"Is returned when an unexpected error occurs while processing a request"
@Router			/ehr/{ehr_id}/directory [get]

func (*DirectoryHandler) GetByVersion

func (h *DirectoryHandler) GetByVersion(ctx *gin.Context)

Get folder in DIRECTORY version

@Summary		Get folder in DIRECTORY by version.
@Description	https://specifications.openehr.org/releases/ITS-REST/latest/ehr.html#tag/DIRECTORY/operation/directory_get_at_time
@Description	Retrieves a particular version of the directory FOLDER identified by {version_uid} and associated with the EHR identified by {ehr_id}. If {path} is supplied, retrieves from the directory only the sub-FOLDER that is associated with that path.
@Tags			DIRECTORY
@Param			Authorization	header	string	true	"Bearer AccessToken"
@Param			AuthUserId		header	string	true	"UserId"
@Param			Prefer			header	string	true	"Request header to indicate the preference over response details. The response will contain the entire resource when the Prefer header has a value of return=representation."	Enums:	("return=representation", "return=minimal")	default("return=minimal")
@Param			ehr_id			path	string	true	"EHR identifier taken from EHR.ehr_id.value. Example: 7d44b88c-4199-4bad-97dc-d78268e01398"
@Param			version_uid		query	string	true	"Example: 6cb19121-4307-4648-9da0-d62e4d51f19b::openEHRSys.example.com::2 VERSION identifier taken from VERSION.uid.value"
@Param			path			query	string	true	"Example: path=episodes/a/b/c A path to a sub-folder; consists of slash-separated values of the name attribute of FOLDERs in the directory"
@Param			patient_id		query	string	true	"Patient UserId"
@Produce		json
@Success		200	{object}	model.Directory	"Is returned when the FOLDER is successfully retrieved"
@Success		204	"Is returned when the resource identified by the request parameters (at specified {version_at_time}) time has been deleted"
@Failure		400	"Is returned when the request has invalid content"
@Failure		404	"Is returned when an EHR with {ehr_id} does not exist, or when a directory does not exist at the specified {version_at_time}, or when {path} does not exists within the directory"
@Failure		500	"Is returned when an unexpected error occurs while processing a request"
@Router			/ehr/{ehr_id}/directory/{version_uid} [get]

func (*DirectoryHandler) Update

func (h *DirectoryHandler) Update(ctx *gin.Context)

Update

@Summary		Update DIRECTORY
@Description	https://specifications.openehr.org/releases/ITS-REST/latest/ehr.html#tag/DIRECTORY/operation/directory_update
@Tags			DIRECTORY
@Param			Authorization	header		string		true	"Bearer AccessToken"
@Param			AuthUserId		header		string		true	"UserId"
@Param			Prefer			header		string		true	"Request header to indicate the preference over response details. The response will contain the entire resource when the Prefer header has a value of return=representation."	Enums:	("return=representation", "return=minimal")	default("return=minimal")
@Param			ehr_id			path		string		true	"EHR identifier taken from EHR.ehr_id.value. Example: 7d44b88c-4199-4bad-97dc-d78268e01398"
@Param			patient_id		query		string		true	"Patient UserId"
@Header			201				{string}	Etag		"The ETag (i.e. entity tag) response header is the version_uid identifier, enclosed by double quotes. Example: \"8849182c-82ad-4088-a07f-48ead4180515::openEHRSys.example.com::1\""
@Header			201				{string}	Location	"{baseUrl}/ehr/{ehr_id}/directory/{version_uid}"
@Header			201				{string}	RequestID	"Request identifier"
@Accept			json
@Produce		json
@Success		200	{object}	model.Directory	"Is returned when the DIRECTORY was successfully updated"
@Success		204	"Is returned when directory was updated and 'Prefer' header is missing or is set to 'return=minimal'"
@Failure		400	"Is returned when the request has invalid content"
@Failure		404	"Is returned when an EHR with {ehr_id} does not exist, or DIRECTORY with that version is not exist"
@Failure		409	"Is returned when a resource with same identifier(s) already exists, or previous request still in progress"
@Failure		412	"Is returned when 'If-Match' request header doesn't match the latest version on the service side. Returns also latest 'version_uid' in the 'Location' and 'ETag' headers"
@Failure		500	"Is returned when an unexpected error occurs while processing a request"
@Router			/ehr/{ehr_id}/directory [put]

type DirectoryService

type DirectoryService interface {
	NewProcRequest(reqID, userID, ehrUUID string, kind processing.RequestKind) (processing.RequestInterface, error)
	GetActiveProcRequest(userID string, kind processing.RequestKind) (string, error)
	Create(ctx context.Context, req processing.RequestInterface, patientID, systemID, dirUID string, d *model.Directory) error
	Update(ctx context.Context, req processing.RequestInterface, systemID string, userID string, d *model.Directory) error
	Delete(ctx context.Context, req processing.RequestInterface, systemID string, ehrUUID *uuid.UUID, versionUID, userID string) (string, error)
	GetByTimeOrLast(ctx context.Context, systemID string, ehrUUID *uuid.UUID, userID string, versionTime time.Time) (*model.Directory, error)
	GetByID(ctx context.Context, patientID string, systemID string, ehrUUID *uuid.UUID, versionID *base.ObjectVersionID) (*model.Directory, error)
	IncreaseVersion(d *model.Directory, systemID string) (string, error)
}

type DocAccessHandler

type DocAccessHandler struct {
	// contains filtered or unexported fields
}

func NewDocAccessHandler

func NewDocAccessHandler(docService *service.DefaultDocumentService) *DocAccessHandler

func (*DocAccessHandler) List

func (h *DocAccessHandler) List(c *gin.Context)

List @Summary Get a document access list @Description Returns the list of documents available to the user @Tags ACCESS @Accept json @Produce json @Param Authorization header string true "Bearer AccessToken" @Param AuthUserId header string true "UserId" @Param EhrSystemId header string false "The identifier of the system, typically a reverse domain identifier" @Success 200 {object} model.DocAccessListResponse "" @Failure 400 "Is returned when the request has invalid content." @Failure 500 "Is returned when an unexpected error occurs while processing a request" @Router /access/document/ [get]

func (*DocAccessHandler) Set

func (h *DocAccessHandler) Set(c *gin.Context)

Set @Summary Set user access to the document @Description Sets access to the document with the specified CID for the user with the userID. @Description Possible access levels: `owner`, `admin`, `read`, `noAccess` @Tags ACCESS @Accept json @Produce json @Param Authorization header string true "Bearer AccessToken" @Param AuthUserId header string true "UserId" @Param EhrSystemId header string false "The identifier of the system, typically a reverse domain identifier" @Param Request body model.DocAccessSetRequest true "DTO with data to create group access" @Success 200 "Indicates that the request to change the level of access to the document was successfully created" @Failure 400 "Is returned when the request has invalid content." @Failure 404 "Is returned when the userID for which access is set is not found " @Failure 500 "Is returned when an unexpected error occurs while processing a request" @Router /access/document [post]

type EhrHandler

type EhrHandler struct {
	// contains filtered or unexported fields
}

func NewEhrHandler

func NewEhrHandler(docSvc *service.DefaultDocumentService, userSvc *userService.Service, docGroupSvc *docGroupService.Service, gaSvc *groupAccess.Service, baseURL string) *EhrHandler

func (*EhrHandler) Create

func (h *EhrHandler) Create(c *gin.Context)

Create

@Summary		Create EHR
@Description	Create a new EHR with an auto-generated identifier.
@Description	An EHR_STATUS resource needs to be always created and committed in the new EHR. This resource MAY be also supplied by the client as the request body. If not supplied, a default EHR_STATUS will be used by the service with following attributes:
@Description	- `is_queryable`: true
@Description	- `is_modifiable`: true
@Description	- `subject`: a PARTY_SELF object
@Description
@Description	All other required EHR attributes and resources will be automatically created as needed by the [EHR creation semantics](https://specifications.openehr.org/releases/RM/latest/ehr.html#_ehr_creation_semantics).
@Tags			EHR
@Accept			json
@Produce		json
@Param			Authorization	header		string					true	"Bearer AccessToken"
@Param			AuthUserId		header		string					true	"UserId"
@Param			EhrSystemId		header		string					false	"The identifier of the system, typically a reverse domain identifier"
@Param			GroupAccessId	header		string					false	"GroupAccessId - UUID. If not specified, the default access group will be used."
@Param			Prefer			header		string					true	"The new EHR resource is returned in the body when the request’s `Prefer` header value is `return=representation`, otherwise only headers are returned."
@Param			Request			body		model.EhrCreateRequest	true	"Query Request"
@Success		201				{object}	model.EhrSummary
@Header			201				{string}	Location	"{baseUrl}/ehr/7d44b88c-4199-4bad-97dc-d78268e01398"
@Header			201				{string}	ETag		"ehr_id of created document. Example: 7d44b88c-4199-4bad-97dc-d78268e01398"
@Header			201				{string}	RequestID	"Request identifier"
@Failure		400				"Is returned when the request body (if provided)  could      not  be  parsed."
@Failure		409				"Unable to create a new EHR due to a conflict with an already existing EHR with the same subject id, namespace pair."
@Failure		500				"Is returned when an unexpected error occurs while processing a request"
@Router			/ehr [post]

func (*EhrHandler) CreateWithID

func (h *EhrHandler) CreateWithID(c *gin.Context)

CreateWithID

@Summary		Create EHR with id
@Description	Create a new EHR with the specified ehr_id identifier.
@Description	The value of the ehr_id unique identifier MUST be valid HIER_OBJECT_ID value. It is strongly RECOMMENDED that an UUID always be used for this.
@Description	An EHR_STATUS resource needs to be always created and committed in the new EHR. This resource MAY be also supplied by the client as the request body. If not supplied, a default EHR_STATUS will be used by the service with following attributes:
@Description	- `is_queryable`: true
@Description	- `is_modifiable`: true
@Description	- `subject`: a PARTY_SELF object
@Description
@Description	All other required EHR attributes and resources will be automatically created as needed by the [EHR creation semantics](https://specifications.openehr.org/releases/RM/latest/ehr.html#_ehr_creation_semantics).
@Tags			EHR
@Accept			json
@Produce		json
@Param			Authorization	header		string					true	"Bearer AccessToken"
@Param			AuthUserId		header		string					true	"UserId"
@Param			EhrSystemId		header		string					false	"The identifier of the system, typically a reverse domain identifier"
@Param			Prefer			header		string					true	"The new EHR resource is returned in the body when the request’s `Prefer` header value is `return=representation`, otherwise only headers are returned."
@Param			ehr_id			path		string					true	"An UUID as a user specified EHR identifier. Example: 7d44b88c-4199-4bad-97dc-d78268e01398"
@Param			Request			body		model.EhrCreateRequest	true	"Query Request"
@Success		201				{object}	model.EhrSummary
@Header			201				{string}	Location	"{baseUrl}/ehr/7d44b88c-4199-4bad-97dc-d78268e01398"
@Header			201				{string}	ETag		"ehr_id of created document. Example: 7d44b88c-4199-4bad-97dc-d78268e01398"
@Header			201				{string}	RequestID	"Request identifier"
@Failure		400				"Is returned when the request body (if provided)  could      not  be  parsed."
@Failure		409				"Unable to create a new EHR due to a conflict with an already existing EHR. Can happen when the supplied ehr_id is already used by an existing EHR."
@Failure		500				"Is returned when an unexpected error occurs while processing a request"
@Router			/ehr/{ehr_id} [put]

func (*EhrHandler) GetByID

func (h *EhrHandler) GetByID(c *gin.Context)

GetByID

@Summary		Get EHR summary by id
@Description	Retrieve the EHR with the specified ehr_id
@Tags			EHR
@Accept			json
@Produce		json
@Param			ehr_id			path		string	true	"EHR identifier taken from EHR.ehr_id.value. Example: 7d44b88c-4199-4bad-97dc-d78268e01398"
@Param			Authorization	header		string	true	"Bearer AccessToken"
@Param			AuthUserId		header		string	true	"UserId"
@Param			EhrSystemId		header		string	false	"The identifier of the system, typically a reverse domain identifier"
@Success		200				{object}	model.EhrSummary
@Success		202				"Is returned when the request is still being processed"
@Failure		400				"Is returned when userID is empty"
@Failure		404				"Is returned when an EHR with ehr_id does not exist."
@Failure		500				"Is returned when an unexpected error occurs while processing a request"
@Router			/ehr/{ehr_id} [get]

func (*EhrHandler) GetBySubjectIDAndNamespace

func (h *EhrHandler) GetBySubjectIDAndNamespace(c *gin.Context)

GetBySubjectIDAndNamespace

@Summary		Get EHR summary by subject id
@Description	Retrieve the EHR with the specified subject_id and subject_namespace.
@Description	These subject parameters will be matched against EHR’s
@Description	EHR_STATUS.subject.external_ref.id.value and EHR_STATUS.subject.external_ref.namespace values.
@Tags			EHR
@Accept			json
@Produce		json
@Param			subject_id			query		string	true	"subject id. Example: ins01"
@Param			subject_namespace	query		string	true	"id namespace. Example: examples"
@Param			Authorization		header		string	true	"Bearer AccessToken"
@Param			AuthUserId			header		string	true	"UserId"
@Param			EhrSystemId			header		string	false	"The identifier of the system, typically a reverse domain identifier"
@Success		200					{object}	model.EhrSummary
@Success		202					"Is returned when the request is still being processed"
@Failure		400					"Is returned when userID is empty"
@Failure		404					"Is returned when an EHR with ehr_id does not exist."
@Router			/ehr [get]

type EhrStatusHandler

type EhrStatusHandler struct {
	// contains filtered or unexported fields
}

func NewEhrStatusHandler

func NewEhrStatusHandler(docSvc *service.DefaultDocumentService, userSvc *userService.Service, docGroupSvc *docGroupService.Service, gaSvc *groupAccess.Service, baseURL string) *EhrStatusHandler

func (*EhrStatusHandler) GetByID

func (h *EhrStatusHandler) GetByID(c *gin.Context)

GetByID

@Summary		Get EHR_STATUS by version id
@Description	Retrieves a particular version of the EHR_STATUS identified by `version_uid` and associated with the EHR identified by `ehr_id`.
@Tags			EHR_STATUS
@Accept			json
@Produce		json
@Param			ehr_id			path		string	true	"EHR identifier taken from EHR.ehr_id.value. Example: 7d44b88c-4199-4bad-97dc-d78268e01398"
@Param			version_uid		path		string	true	"VERSION identifier taken from VERSION.uid.value. Example: 8849182c-82ad-4088-a07f-48ead4180515::openEHRSys.example.com::2"
@Param			Authorization	header		string	true	"Bearer AccessToken"
@Param			AuthUserId		header		string	true	"UserId"
@Param			EhrSystemId		header		string	false	"The identifier of the system, typically a reverse domain identifier"
@Success		200				{object}	model.EhrStatusUpdate
@Success		202				"Is returned when the request is still being processed"
@Failure		400				"Is returned when AuthUserId is not specified"
@Failure		404				"is returned when an EHR with `ehr_id` does not exist or when an EHR_STATUS with `version_uid` does not exist."
@Failure		500				"Is returned when an unexpected error occurs while processing a request"
@Router			/ehr/{ehr_id}/ehr_status/{version_uid} [get]

func (*EhrStatusHandler) GetStatusByTime

func (h *EhrStatusHandler) GetStatusByTime(c *gin.Context)

GetStatusByTime

@Summary		Get EHR_STATUS version by time
@Description	Retrieves a version of the EHR_STATUS associated with the EHR identified by `ehr_id`. If `version_at_time` is supplied, retrieves the version extant at specified time, otherwise retrieves the latest EHR_STATUS version.
@Tags			EHR_STATUS
@Accept			json
@Produce		json
@Param			ehr_id			path		string	true	"EHR identifier taken from EHR.ehr_id.value. Example: 7d44b88c-4199-4bad-97dc-d78268e01398"
@Param			version_at_time	query		string	true	"A given time in the extended ISO 8601 format. Example: 2015-01-20T19:30:22.765+01:00"
@Param			Authorization	header		string	true	"Bearer AccessToken"
@Param			AuthUserId		header		string	true	"UserId"
@Param			EhrSystemId		header		string	false	"The identifier of the system, typically a reverse domain identifier"
@Success		200				{object}	model.EhrStatusUpdate
@Success		202				"Is returned when the request is still being processed"
@Failure		400				"Is returned when the request has invalid content such as an invalid `version_at_time` format."
@Failure		404				"Is returned when EHR with `ehr_id` does not exist or a version of an EHR_STATUS resource does not exist at the specified `version_at_time`"
@Failure		500				"Is returned when an unexpected error occurs while processing a request"
@Router			/ehr/{ehr_id}/ehr_status [get]

func (*EhrStatusHandler) Update

func (h *EhrStatusHandler) Update(c *gin.Context)

Update

@Summary		Update EHR_STATUS
@Description	Updates EHR_STATUS associated with the EHR identified by `ehr_id`.
@Tags			EHR_STATUS
@Accept			json
@Produce		json
@Param			ehr_id			path		string					true	"EHR identifier. Example: 7d44b88c-4199-4bad-97dc-d78268e01398"
@Param			Authorization	header		string					true	"Bearer AccessToken"
@Param			AuthUserId		header		string					true	"UserId"
@Param			EhrSystemId		header		string					false	"The identifier of the system, typically a reverse domain identifier"
@Param			If-Match		header		string					true	"The existing latest `version_uid` of EHR_STATUS resource (i.e. the `preceding_version_uid`)  must  be  specified."
@Param			Prefer			header		string					true	"Updated resource is returned in the body when the request’s `Prefer` header value is `return=representation`, otherwise only headers are returned."
@Param			Request			body		model.EhrStatusUpdate	true	"EHR_STATUS"
@Success		200				{object}	model.EhrStatusUpdate
@Header			200				{string}	Location	"{baseUrl}/ehr/7d44b88c-4199-4bad-97dc-d78268e01398/ehr_status/8849182c-82ad-4088-a07f-48ead4180515::openEHRSys.example.com::2"
@Header			200				{string}	ETag		"uid of created document. Example: 8849182c-82ad-4088-a07f-48ead4180515::openEHRSys.example.com::2"
@Header			200				{string}	RequestID	"Request identifier"
@Success		204				"Is returned when `Prefer` header is missing or is set to `return=minimal`"
@Header			204				{string}	Location	"{baseUrl}/ehr/7d44b88c-4199-4bad-97dc-d78268e01398/ehr_status/8849182c-82ad-4088-a07f-48ead4180515::openEHRSys.example.com::2"
@Header			204				{string}	ETag		"uid of created document. Example: 8849182c-82ad-4088-a07f-48ead4180515::openEHRSys.example.com::2"
@Failure		400				"Is returned when the request has invalid content."
@Failure		404				"Is returned when an EHR with ehr_id does not exist."
@Failure		412				"Is returned when `If-Match` request header doesn’t match the latest version on the service side. Returns also latest `version_uid` in the `Location` and `ETag` headers."
@Failure		500				"Is returned when an unexpected error occurs while processing a request"
@Router			/ehr/{ehr_id}/ehr_status [put]

type Indexer

type Indexer interface {
	GetEhrUUIDByUserID(ctx context.Context, userID, systemID string) (*uuid.UUID, error)
}

type ProcessingService

type ProcessingService interface {
	NewRequest(reqID, userID, ehrUUID string, kind processing.RequestKind) (*processing.Request, error)
}

type QueryHandler

type QueryHandler struct {
	// contains filtered or unexported fields
}

func NewQueryHandler

func NewQueryHandler(queryService QueryService, baseURL string) *QueryHandler

func (QueryHandler) ExecGetQuery

func (h QueryHandler) ExecGetQuery(c *gin.Context)

ExecGetQuery

@Summary		Execute ad-hoc AQL query
@Description	Execute a given ad-hoc AQL query, supplied by {q} parameter, fetching {fetch} numbers of rows from {offset} and passing {query_parameters} to the underlying query engine.
@Description	See also details on usage of [query parameters](https://specifications.openehr.org/releases/ITS-REST/Release-1.0.2/query.html#requirements-common-headers-and-query-parameters).
@Description
@Tags		QUERY
@Accept		plain
@Produce	json
@Param		Authorization	 header		string				true	"Bearer AccessToken"
@Param		AuthUserId		 header		string				true	"UserId"
@Param		Request			 body		model.QueryRequest	true	"Query Request"
@Param		ehr_id			 query		string	false	"An optional parameter to execute the query within an EHR context."
@Param		q				 query		string	false	"AQL. Example: {q=SELECT e/ehr_id/value, c/context/start_time/value as startTime, obs/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/magnitude AS systolic, c/uid/value AS cid, c/name FROM EHR e CONTAINS COMPOSITION c[openEHR-EHR-COMPOSITION.encounter.v1] CONTAINS OBSERVATION obs[openEHR-EHR-OBSERVATION.blood_pressure.v1] WHERE obs/data[at0001]/events[at0006]/data[at0003]/items[at0004]/value/magnitude >= $systolic_bp} The AQL query to be executed."
@Param		offset			 query		string	false	"The row number in result-set to start result-set from (0-based), default is 0."
@Param		fetch			 query		string	false	"Number of rows to fetch (the default depends on the implementation)."
@Param		query_parameters query		any		false	"Query parameters (can appear multiple times). Example: {ehr_id=7d44b88c-4199-4bad-97dc-d78268e01398&systolic_bp=140}"
@Success	200				 {object}	model.QueryResponse
@Failure	400				 "Is returned when the server was unable to execute the query due to invalid input, e.g. a request with missing `q` parameter or an invalid query syntax."
@Failure	408				 "Is returned when there is a query execution timeout (i.e. maximum query execution time reached, therefore the server aborted the execution of the query)."
@Failure	500				 "Is returned when an unexpected error occurs while processing a request"
@Router		/query/aql [get]

func (QueryHandler) ExecPostQuery

func (h QueryHandler) ExecPostQuery(c *gin.Context)

ExecPostQuery

@Summary		Execute ad-hoc (non-stored) AQL query
@Description	Execute ad-hoc query, supplied by q attribute, fetching {fetch} numbers of rows from {offset} and passing {query_parameters} to the underlying query engine.
@Description	See also details on usage of [query parameters](https://specifications.openehr.org/releases/ITS-REST/Release-1.0.2/query.html#requirements-common-headers-and-query-parameters).
@Description
@Tags		QUERY
@Accept		json
@Produce	json
@Param		Authorization	header		string				true	"Bearer AccessToken"
@Param		AuthUserId		header		string				true	"UserId"
@Param		Request			body		model.QueryRequest	true	"Query Request"
@Success	200				{object}	model.QueryResponse
@Header		201				{string}	ETag	"A unique identifier of the resultSet. Example: cdbb5db1-e466-4429-a9e5-bf80a54e120b"
@Failure	400				"Is returned when the server was unable to execute the query due to invalid input, e.g. a request with missing `q` parameter or an invalid query syntax."
@Failure	408				"Is returned when there is a query execution timeout (i.e. maximum query execution time reached, therefore the server aborted the execution of the query)."
@Failure	500				"Is returned when an unexpected error occurs while processing a request"
@Router		/query/aql [post]

func (QueryHandler) ExecStoredQuery

func (h QueryHandler) ExecStoredQuery(c *gin.Context)

Get

@Summary		Execute stored AQL
@Description	Execute a stored query, identified by the supplied qualified_query_name (at latest version), fetching fetch numbers of rows from offset and passing query_parameters to the underlying query engine.
@Description	See also details on usage of [query parameters](https://specifications.openehr.org/releases/ITS-REST/latest/query.html#tag/Request/Common-Headers-and-Query-Parameters).
@Description	Queries can be stored or, once stored, their definition can be retrieved using the [definition endpoint](https://specifications.openehr.org/releases/ITS-REST/latest/definition.html#tag/Query).
@Description	https://specifications.openehr.org/releases/ITS-REST/latest/query.html#tag/Query/operation/query_execute_stored_query
@Tags			QUERY
@Accept			json
@Produce		json
@Param			Authorization			header		string	true	"Bearer AccessToken"
@Param			AuthUserId				header		string	true	"UserId"
@Param			qualified_query_name	path		string	true	"If pattern should given be in the format of [{namespace}::]{query-name},  and  when  is       empty,  it       will     be  treated  as    "wildcard"  in       the  search."
@Param			ehr_id					query		string	false	"An optional parameter to execute the query within an EHR context."
@Param			offset					query		string	false	"The row number in result-set to start result-set from (0-based), default is 0."
@Param			fetch					query		string	false	"Number of rows to fetch (the default depends on the implementation)."
@Param			query_parameters		query		any		false	"Query parameters (can appear multiple times)."
@Success		200						{object}	model.QueryResponse
@Header			200						{string}	ETag	"A unique identifier of the resultSet. Example: cdbb5db1-e466-4429-a9e5-bf80a54e120b"
@Failure		400						"Is returned when the server was unable to execute the query due to invalid input, e.g. a required parameter is missing, or at least one of the parameters has invalid syntax"
@Failure		404						"Is returned when a stored query with qualified_query_name does not exists."
@Failure		408						"Is returned when there is a query execution timeout"
@Router			/query/{qualified_query_name} [get]

func (*QueryHandler) GetStoredByVersion

func (h *QueryHandler) GetStoredByVersion(c *gin.Context)

Get

@Summary		Get stored query by version
@Description	Retrieves the definition of a particular stored query (at specified version) and its associated metadata.
@Description	https://specifications.openehr.org/releases/ITS-REST/latest/definition.html#tag/Query/operation/definition_query_list
@Tags			DEFINITION
@Produce		json
@Param			qualified_query_name	path		string	false	"If pattern should given be in the format of [{namespace}::]{query-name},  and  when  is       empty,  it       will     be  treated  as    "wildcard"  in       the  search."
@Param			version					path		string	false	"A SEMVER version number. This can be a an exact version (e.g. 1.7.1),     or   a     pattern  as      partial  prefix,  in  a        form  of          {major}  or   {major}.{minor}  (e.g. 1 or 1.0),  in  which  case  the  highest  (latest)  version  matching  the  prefix  will  be  considered."
@Param			Authorization			header		string	true	"Bearer AccessToken"
@Param			AuthUserId				header		string	true	"UserId"
@Param			EhrSystemId				header		string	true	"The identifier of the system, typically a reverse domain identifier"
@Success		200						{object}	model.StoredQuery
@Failure		400						"Is returned when the request has invalid content."
@Failure		404						"Is returned when a stored query with {qualified_query_name}  and  {version}  does  not  exist."
@Failure		500						"Is returned when an unexpected error occurs while processing a request"
@Router			/definition/query/{qualified_query_name}/{version} [get]

func (*QueryHandler) ListStored

func (h *QueryHandler) ListStored(c *gin.Context)

Get

@Summary		Get list stored queries
@Description	Retrieves list of all stored queries on the system matched by qualified_query_name as pattern.
@Description	https://specifications.openehr.org/releases/ITS-REST/latest/definition.html#tag/Query/operation/definition_query_list
@Tags			DEFINITION
@Accept			json
@Produce		json
@Param			qualified_query_name	path		string	false	"If pattern should given be in the format of [{namespace}::]{query-name},  and  when  is  empty,  it  will  be  treated  as  "wildcard"  in  the  search."
@Param			Authorization			header		string	true	"Bearer AccessToken"
@Param			AuthUserId				header		string	true	"UserId"
@Param			EhrSystemId				header		string	true	"The identifier of the system, typically a reverse domain identifier"
@Success		200						{object}	[]model.StoredQuery
@Failure		500						"Is returned when an unexpected error occurs while processing a request"
@Router			/definition/query/{qualified_query_name} [get]

func (QueryHandler) PostExecStoredQuery

func (h QueryHandler) PostExecStoredQuery(c *gin.Context)

Post

@Summary		Execute stored AQL (POST)
@Description	Execute a stored query, identified by the supplied {qualified_query_name} (at latest version).
@Description	See also details on usage of [query parameters](https://specifications.openehr.org/releases/ITS-REST/latest/query.html#tag/Request/Common-Headers-and-Query-Parameters).
@Description	Queries can be stored or, once stored, their definition can be retrieved using the [definition endpoint](https://specifications.openehr.org/releases/ITS-REST/latest/definition.html#tag/Query).
@Description	https://specifications.openehr.org/releases/ITS-REST/latest/query.html#tag/Query/operation/query_execute_stored_query
@Tags			QUERY
@Accept			json
@Produce		json
@Param			Authorization			header		string				true	"Bearer AccessToken"
@Param			AuthUserId				header		string				true	"UserId"
@Param			qualified_query_name	path		string				true	"If pattern should given be in the format of [{namespace}::]{query-name},  and  when  is       empty,  it       will     be  treated  as    "wildcard"  in       the  search."
@Param			Request					body		model.QueryRequest	true	"Query Request"
@Success		200						{object}	model.QueryResponse
@Header			200						{string}	ETag	"A unique identifier of the resultSet. Example: cdbb5db1-e466-4429-a9e5-bf80a54e120b"
@Failure		400						"Is returned when the server was unable to execute the query due to invalid input, e.g. a required parameter is missing, or at least one of the parameters has invalid syntax"
@Failure		404						"Is returned when a stored query with qualified_query_name does not exists."
@Failure		408						"Is returned when there is a query execution timeout"
@Router			/query/{qualified_query_name} [post]

func (*QueryHandler) Store

func (h *QueryHandler) Store(c *gin.Context)

Store a query

@Summary	Stores a new query, or updates an existing query on the system
@Description
@Description	https://specifications.openehr.org/releases/ITS-REST/latest/definition.html#tag/Query/operation/definition_query_store.yaml
@Tags			DEFINITION
@Accept			json
@Produce		json
@Param			qualified_query_name	path		string		true	"If pattern should given be in the format of [{namespace}::]{query-name}, and when is empty, it will be treated as "wildcard" in the search."
@Param			query_type				query		string		true	"Parameter indicating the query language/type"
@Param			Authorization			header		string		true	"Bearer AccessToken"
@Param			AuthUserId				header		string		true	"UserId"
@Param			EhrSystemId				header		string		true	"The identifier of the system, typically a reverse domain identifier"
@Header			200						{string}	Location	"{baseUrl}/definition/query/org.openehr::compositions/1.0.1"
@Success		200						"Is returned when the query was successfully stored."
@Failure		400						"Is returned when the server was unable to store the query. This could be due to incorrect request body (could not be parsed, etc), unknown query type, etc."
@Failure		500						"Is returned when an unexpected error occurs while processing a request"
@Router			/definition/query/{qualified_query_name} [put]

func (*QueryHandler) StoreVersion

func (h *QueryHandler) StoreVersion(c *gin.Context)

Store a query version

@Summary	Stores a query, at a specified version, on the system.
@Description
@Description	https://specifications.openehr.org/releases/ITS-REST/latest/definition.html#tag/Query/operation/definition_query_store.yaml
@Tags			DEFINITION
@Accept			json
@Produce		json
@Param			qualified_query_name	path		string		true	"If pattern should given be in the format of [{namespace}::]{query-name},  and  when  is       empty,  it       will     be  treated  as    "wildcard"  in       the  search"
@Param			version					path		string		true	"A SEMVER version number. This can be a an exact version (e.g. 1.7.1),     or   a     pattern  as      partial  prefix,  in  a        form  of          {major}  or   {major}.{minor}  (e.g. 1 or 1.0),  in  which  case  the  highest  (latest)  version  matching  the  prefix  will  be  considered"
@Param			query_type				query		string		true	"Parameter indicating the query language/type"
@Param			Authorization			header		string		true	"Bearer AccessToken"
@Param			AuthUserId				header		string		true	"UserId"
@Header			200						{string}	Location	"{baseUrl}/definition/query/org.openehr::compositions/1.0.1"
@Success		200						"Is returned when the query was successfully stored"
@Failure		400						"Is returned when the server was unable to store the query. This could be due to incorrect request body (could not be parsed, etc),  unknown  query  type,  etc"
@Failure		409						"Is returned when a query with the given 'qualified_query_name' and 'version' already exists on the server"
@Failure		500						"Is returned when an unexpected error occurs while processing a request"
@Router			/definition/query/{qualified_query_name}/{version} [put]

type QueryService

type QueryService interface {
	List(ctx context.Context, userID, systemID, qualifiedQueryName string) ([]*model.StoredQuery, error)
	GetByVersion(ctx context.Context, userID, systemID, name string, version *base.VersionTreeID) (*model.StoredQuery, error)
	Validate(data []byte) bool
	Store(ctx context.Context, userID, systemID, reqID, qType, name, q string) (*model.StoredQuery, error)
	StoreVersion(ctx context.Context, userID, systemID, reqID, qType, name string, version *base.VersionTreeID, q string) (*model.StoredQuery, error)

	ExecQuery(ctx context.Context, query *model.QueryRequest) (*model.QueryResponse, error)
	ExecStoredQuery(ctx context.Context, userID, systemID, qualifiedQueryName string, query *model.QueryRequest) (*model.QueryResponse, error)
}

type RequestHandler

type RequestHandler struct {
	// contains filtered or unexported fields
}

func NewRequestHandler

func NewRequestHandler(docService *service.DefaultDocumentService) *RequestHandler

func (RequestHandler) GetAll

func (h RequestHandler) GetAll(c *gin.Context)

GetAll

@Summary		Get list of transactions requests by authorized user
@Description	It is returning only transactions which in progress
@Description
@Tags		REQUEST
@Accept		json
@Produce	json
@Param		Authorization	header		string	true	"Bearer AccessToken"
@Param		AuthUserId		header		string	true	"UserId"
@Param		limit			query		string	true	"default: 10"
@Param		offset			query		string	true	"id namespace. Example: examples"
@Success	200				{object}	processing.RequestsResult
@Failure	400				"Is returned when userID is empty"
@Failure	404				"Is returned when requests not exist"
@Failure	500				"Is returned when an unexpected error occurs while processing a request"
@Router		/requests/ [get]

func (RequestHandler) GetByID

func (h RequestHandler) GetByID(c *gin.Context)

GetByID

@Summary		Get list of transactions by certain request id for authorized user
@Description	It's returning only transactions which in progress
@Description
@Tags		REQUEST
@Accept		json
@Produce	json
@Param		Authorization	header		string	true	"Bearer AccessToken"
@Param		AuthUserId		header		string	true	"UserId"
@Param		request_id		path		string	true	"Unique id of request"
@Success	200				{object}	processing.RequestResult
@Failure	400				"Is returned when userID or request_id is empty"
@Failure	404				"Is returned when requests not exist"
@Failure	500				"Is returned when an unexpected error occurs while processing a request"
@Router		/requests/{request_id} [get]

type TemplateHandler

type TemplateHandler struct {
	// contains filtered or unexported fields
}

func NewTemplateHandler

func NewTemplateHandler(templateService TemplateService, baseURL string) *TemplateHandler

func (*TemplateHandler) GetByID

func (h *TemplateHandler) GetByID(c *gin.Context)

Get

@Summary		Get a template
@Description	Retrieves the ADL 1.4 operational template (OPT) identified by {template_id} identifier.
@Description	https://specifications.openehr.org/releases/ITS-REST/latest/definition.html#tag/ADL1.4/operation/definition_template_adl1.4_list
@Tags			DEFINITION
@Produce		application/xml
@Produce		application/openehr.wt+json
@Param			template_id		path		string	false	"Template identifier. Example: Vital Signs"
@Param			Authorization	header		string	true	"Bearer AccessToken"
@Param			AuthUserId		header		string	true	"UserId"
@Param			EhrSystemId		header		string	false	"The identifier of the system, typically a reverse domain identifier"
@Success		200				{string}	[]byte
@Failure		400				"Is returned when the request has invalid content."
@Failure		404				"Is returned when a stored query with {qualified_query_name} and {version} does not exist."
@Failure		406				"Is returned when template with certain ID created with other accept header"
@Failure		500				"Is returned when an unexpected error occurs while processing a request"
@Router			/definition/template/adl1.4/{template_id} [get]

func (*TemplateHandler) ListStored

func (h *TemplateHandler) ListStored(c *gin.Context)

Get

@Summary		Get a list of templates
@Description	List the available ADL 1.4 operational templates (OPT) on the system.
@Description	https://specifications.openehr.org/releases/ITS-REST/latest/definition.html#tag/ADL1.4/operation/definition_template_adl1.4_list
@Tags			DEFINITION
@Produce		json
@Param			Authorization	header		string	true	"Bearer AccessToken"
@Param			AuthUserId		header		string	true	"UserId"
@Success		200				{object}	[]model.Template
@Failure		400				"Is returned because of invalid content."
@Failure		500				"Is returned when an unexpected error occurs while processing a request"
@Router			/definition/template/adl1.4 [get]

func (*TemplateHandler) Store

func (h *TemplateHandler) Store(c *gin.Context)

Store

@Summary		Store a template
@Description	Upload a new ADL 1.4 operational template (OPT).
@Description	https://specifications.openehr.org/releases/ITS-REST/latest/definition.html#tag/ADL1.4/operation/definition_template_adl1.4_upload
@Tags			DEFINITION
@Param			Authorization	header		string		true	"Bearer AccessToken"
@Param			AuthUserId		header		string		true	"UserId"
@Param			Prefer			header		string		true	"Request header to indicate the preference over response details. The response will contain the entire resource when the Prefer header has a value of return=representation."	Enums:	("return=representation", "return=minimal")	default("return=minimal")
@Header			201				{string}	Location	"{baseUrl}/definition/template/adl1.4/{template_id}"
@Header			201				{string}	RequestID	"Request identifier"
@Accept			application/xml
@Produce		text/plain
@Produce		application/xml
@Success		201	{object}	model.Template	"Is returned when the query was successfully uploaded."
@Failure		400	"Is returned when unable to upload a template, because of invalid content."
@Failure		409	"Is returned when a template with same {template_id} (at given version, if supplied) already exists."
@Failure		500	"Is returned when an unexpected error occurs while processing a request"
@Router			/definition/template/adl1.4 [post]

type TemplateService

type TemplateService interface {
	helper.Finder
	Parser(version model.ADLVer) (template.ADLParser, error)
	GetByID(ctx context.Context, userID, systemID, templateID string) (*model.Template, error)
	Store(ctx context.Context, userID, systemID, reqID string, m *model.Template) error
	GetList(ctx context.Context, userID, systemID string) ([]*model.Template, error)
}

type UserHandler

type UserHandler struct {
	// contains filtered or unexported fields
}

func NewUserHandler

func NewUserHandler(handlerService UserService) *UserHandler

func (*UserHandler) GroupAddUser

func (h *UserHandler) GroupAddUser(c *gin.Context)

Group add user

@Summary	Adding a user to a group
@Description
@Tags		USER_GROUP
@Accept		json
@Param		Authorization	header	string	true	"Bearer AccessToken"
@Param		AuthUserId		header	string	true	"UserId"
@Param		EhrSystemId		header	string	false	"The identifier of the system, typically a reverse domain identifier"
@Param		group_id		path	string	true	"The identifier of the user group"
@Param		user_id			path	string	true	"The identifier of the user to be added"
@Param		access_level	path	string	true	"Access Level. One of `admin` or `read`"
@Success	200				""
@Header		200				{string}	RequestID	"Request identifier"
@Failure	400				"The request could not be understood by the server due to incorrect syntax."
@Failure	403				"Authentication required or user does not have access to change the group"
@Failure	404				"Group or adding user is not exist"
@Failure	409				"The user is already a member of a group"
@Failure	500				"Is returned when an unexpected error occurs while processing a request"
@Router		/user/group/{group_id}/user_add/{user_id}/{access_level} [put]

func (*UserHandler) GroupCreate

func (h *UserHandler) GroupCreate(c *gin.Context)

Group create

@Summary	User group create
@Description
@Tags		USER_GROUP
@Accept		json
@Param		Authorization	header		string			true	"Bearer AccessToken"
@Param		AuthUserId		header		string			true	"UserId"
@Param		EhrSystemId		header		string			false	"The identifier of the system, typically a reverse domain identifier"
@Param		Request			body		model.UserGroup	true	"User group"
@Success	201				{object}	model.UserGroup	"Indicates that the request has succeeded and transaction about create new user group has been created"
@Header		201				{string}	RequestID		"Request identifier"
@Failure	400				"The request could not be understood by the server due to incorrect syntax. The client SHOULD NOT repeat the request without modifications."
@Failure	404				"User with ID not exist"
@Failure	409				"Group with that Name already exist"
@Failure	500				"Is returned when an unexpected error occurs while processing a request"
@Router		/user/group [post]

func (*UserHandler) GroupGetByID

func (h *UserHandler) GroupGetByID(c *gin.Context)

Group get by ID

@Summary	Get user group by ID
@Description
@Tags		USER_GROUP
@Produce	json
@Param		group_id		path		string	true	"User group identifier. Example: 7d44b88c-4199-4bad-97dc-d78268e01398"
@Param		Authorization	header		string	true	"Bearer AccessToken"
@Param		AuthUserId		header		string	true	"UserId"
@Param		EhrSystemId		header		string	false	"The identifier of the system, typically a reverse domain identifier"
@Success	200				{object}	model.UserGroup
@Failure	400				"The request could not be understood by the server due to incorrect syntax."
@Failure	403				"Is returned when userID does not have access to requested group"
@Failure	404				"Is returned when groupID does not exist"
@Failure	500				"Is returned when an unexpected error occurs while processing a request"
@Router		/user/group/{group_id} [get]

func (*UserHandler) GroupGetList

func (h *UserHandler) GroupGetList(c *gin.Context)

Group get list

@Summary	Get a list of user groups
@Description
@Tags		USER_GROUP
@Produce	json
@Param		Authorization	header		string	true	"Bearer AccessToken"
@Param		AuthUserId		header		string	true	"UserId"
@Param		EhrSystemId		header		string	false	"The identifier of the system, typically a reverse domain identifier"
@Success	200				{object}	[]model.UserGroup
@Failure	400				"The request could not be understood by the server due to incorrect syntax."
@Failure	404				"Is returned when groupID does not exist"
@Failure	500				"Is returned when an unexpected error occurs while processing a request"
@Router		/user/group [get]

func (*UserHandler) GroupRemoveUser

func (h *UserHandler) GroupRemoveUser(c *gin.Context)

Group remove user

@Summary	Removing a user from a group
@Description
@Tags		USER_GROUP
@Accept		json
@Param		Authorization	header	string	true	"Bearer AccessToken"
@Param		AuthUserId		header	string	true	"UserId"
@Param		EhrSystemId		header	string	false	"The identifier of the system, typically a reverse domain identifier"
@Param		group_id		path	string	true	"The identifier of the user group"
@Param		user_id			path	string	true	"The identifier of the user to be removed"
@Success	200				""
@Header		200				{string}	RequestID	"Request identifier"
@Failure	400				"The request could not be understood by the server due to incorrect syntax."
@Failure	403				"Authentication required or user does not have access to change the group"
@Failure	404				"Group or adding user is not exist or `user_id` is not the member of the group"
@Failure	500				"Is returned when an unexpected error occurs while processing a request"
@Router		/user/group/{group_id}/user_remove/{user_id} [post]

func (*UserHandler) Info

func (h *UserHandler) Info(c *gin.Context)

Info

@Summary		Get user info
@Description	Get information about the user by user_id
@Tags			USER
@Accept			json
@Produce		json
@Param			user_id			path		string	true	"The identifier of the requested user info"
@Param			Authorization	header		string	true	"Bearer AccessToken"
@Param			AuthUserId		header		string	true	"UserId"
@Param			EhrSystemId		header		string	false	"The identifier of the system, typically a reverse domain identifier"
@Success		200				{object}	model.UserInfo
@Failure		400				"`user_id` is incorrect or requested user is not a doctor"
@Failure		404				"User with ID not exist"
@Failure		500				"Is returned when an unexpected error occurs while processing a request"
@Router			/user/{user_id} [get]

func (*UserHandler) InfoByCode

func (h *UserHandler) InfoByCode(c *gin.Context)

Info by code

@Summary		Get doctor info by code
@Description	Get information about the doctor by code
@Tags			USER
@Accept			json
@Produce		json
@Param			code	path		string	true	"The pin code of the requested doctor"
@Success		200		{object}	model.UserInfo
@Failure		400		"`code` is incorrect or requested user is not a doctor"
@Failure		404		"User code is not exist"
@Failure		500		"Is returned when an unexpected error occurs while processing a request"
@Router			/user/code/{code} [get]

func (*UserHandler) Login

func (h *UserHandler) Login(c *gin.Context)

Login

@Summary	Login user
@Description
@Tags		USER
@Accept		json
@Produce	json
@Param		AuthUserId	header		string					true	"UserId"
@Param		EhrSystemId	header		string					false	"The identifier of the system, typically a reverse domain identifier"
@Param		Request		body		model.UserAuthRequest	true	"User authentication request"
@Success	200			{object}	model.JWT
@Failure	404			"User with ID not exist"
@Failure	422			"The request could not be understood by the server due to incorrect syntax. The client SHOULD NOT repeat the request without modifications."
@Failure	400			"Password, EhrSystemId or userID incorrect"
@Failure	401			"Password or userID incorrect"
@Failure	500			"Is returned when an unexpected error occurs while processing a request"
@Router		/user/login [post]

func (*UserHandler) Logout

func (h *UserHandler) Logout(c *gin.Context)

Logout

@Summary	Logout
@Description
@Tags		USER
@Accept		json
@Produce	json
@Param		Authorization	header	string		true	"Bearer AccessToken"
@Param		AuthUserId		header	string		true	"UserId"
@Param		Request			body	model.JWT	true	"JWT"
@Success	200				"Successfully logged out"
@Failure	401				"User unauthorized"
@Failure	422				"The request could not be understood by the server due to incorrect syntax. The client SHOULD NOT repeat the request without modifications."
@Failure	500				"Is returned when an unexpected error occurs while processing a request"
@Router		/user/logout [post]

func (*UserHandler) RefreshToken

func (h *UserHandler) RefreshToken(c *gin.Context)

RefreshToken

@Summary	Refresh JWT
@Description
@Tags		USER
@Accept		json
@Produce	json
@Param		Authorization	header		string	true	"Bearer RefreshToken"
@Param		AuthUserId		header		string	true	"UserId"
@Success	200				{object}	model.JWT
@Failure	401				"User unauthorized"
@Failure	404				"User with ID not exist"
@Failure	422				"The request could not be understood by the server due to incorrect syntax. The client SHOULD NOT repeat the request without modifications."
@Failure	500				"Is returned when an unexpected error occurs while processing a request"
@Router		/user/refresh/ [get]

func (*UserHandler) Register

func (h *UserHandler) Register(c *gin.Context)

Register

@Summary	Register user
@Description
@Tags		USER
@Accept		json
@Produce	json
@Param		EhrSystemId	header	string					false	"The identifier of the system, typically a reverse domain identifier"
@Param		Request		body	model.UserCreateRequest	true	"User creation request. `role`: 0 - Patient, 1 - Doctor. Fields `Name`, `Address`, `Description`, `PictureURL` are required for Doctor role"
@Success	201			"Indicates that the request has succeeded and transaction about register new user has been created"
@Header		201			{string}	RequestID	"Request identifier"
@Failure	400			"The request could not be understood by the server due to incorrect syntax. The client SHOULD NOT repeat the request without modifications."
@Failure	409			"User with that userID already exist"
@Failure	422			"Password, systemID or role incorrect"
@Failure	500			"Is returned when an unexpected error occurs while processing a request"
@Router		/user/register [post]

type UserService

type UserService interface {
	NewProcRequest(reqID, userID string, kind processing.RequestKind) (processing.RequestInterface, error)
	Register(ctx context.Context, user *model.UserCreateRequest, systemID, reqID string) (err error)
	Login(ctx context.Context, userID, systemID, password string) (err error)
	Info(ctx context.Context, userID, systemID string) (*model.UserInfo, error)
	InfoByCode(ctx context.Context, code int) (*model.UserInfo, error)
	CreateToken(userID string) (*userService.TokenDetails, error)
	ExtractToken(bearToken string) string
	VerifyAccess(userID, tokenString string) error
	VerifyToken(userID, tokenString string, tokenType userService.TokenType) (*jwt.Token, error)
	ExtractTokenMetadata(token *jwt.Token) (*userService.TokenClaims, error)
	IsTokenInBlackList(tokenRaw string) bool
	AddTokenInBlackList(tokenRaw string, expires int64)
	GetTokenHash(tokenRaw string) [32]byte
	VerifyAndGetTokenDetails(userID, accessToken, refreshToken string) (*userService.TokenDetails, error)
	GroupCreate(ctx context.Context, req proc.RequestInterface, userID, systemID, groupName, groupDescription string) (*model.UserGroup, error)
	GroupGetByID(ctx context.Context, userID, systemID string, groupID *uuid.UUID, groupKey *chachaPoly.Key) (*model.UserGroup, error)
	GroupAddUser(ctx context.Context, userID, systemID, addUserID, addSystemID, reqID string, level access.Level, groupID *uuid.UUID) error
	GroupRemoveUser(ctx context.Context, userID, systemID, removingUserID, removeSystemID, reqID string, groupID *uuid.UUID) error
	GroupGetList(ctx context.Context, userID, systemID string) ([]*model.UserGroup, error)
}

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL