Skip to content

Commit

Permalink
saving system object in task instead of systemId (#5449)
Browse files Browse the repository at this point in the history
* saving system object in task instead of id

* add missing license

* add migration for upadate old clientId with system object in task integration

* fix null issue for record audit history

* add log for migration

* update migration with progress information

* update migration with mongo count instead of array

* add missing percentage

* update import for helper function

* Await the completion of setupSystemIdentifier

---------

Co-authored-by: euanmillar <euanmillar77@gmail.com>
  • Loading branch information
kayumuzzaman and euanmillar authored Aug 15, 2023
1 parent 377c92d commit 7c26e73
Show file tree
Hide file tree
Showing 10 changed files with 308 additions and 25 deletions.
49 changes: 48 additions & 1 deletion packages/client/graphql.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7523,7 +7523,7 @@
"args": [],
"type": {
"kind": "OBJECT",
"name": "System",
"name": "IntegratedSystem",
"ofType": null
},
"isDeprecated": false,
Expand Down Expand Up @@ -7916,6 +7916,53 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "IntegratedSystem",
"description": null,
"fields": [
{
"name": "name",
"description": null,
"args": [],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "type",
"description": null,
"args": [],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "username",
"description": null,
"args": [],
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "ENUM",
"name": "IntegratingSystemType",
Expand Down
45 changes: 38 additions & 7 deletions packages/client/src/utils/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ export type History = {
requester?: Maybe<Scalars['String']>
signature?: Maybe<Signature>
statusReason?: Maybe<StatusReason>
system?: Maybe<System>
system?: Maybe<IntegratedSystem>
user?: Maybe<User>
}

Expand Down Expand Up @@ -841,6 +841,13 @@ export type InputOutput = {
valueString?: Maybe<Scalars['String']>
}

export type IntegratedSystem = {
__typename?: 'IntegratedSystem'
name?: Maybe<Scalars['String']>
type?: Maybe<Scalars['String']>
username?: Maybe<Scalars['String']>
}

export enum IntegratingSystemType {
Mosip = 'MOSIP',
Osia = 'OSIA',
Expand Down Expand Up @@ -3555,7 +3562,11 @@ export type FetchBirthRegistrationForReviewQuery = {
district?: string | null
} | null
} | null
system?: { __typename?: 'System'; name: string; type: SystemType } | null
system?: {
__typename?: 'IntegratedSystem'
name?: string | null
type?: string | null
} | null
user?: {
__typename?: 'User'
id: string
Expand Down Expand Up @@ -3867,7 +3878,11 @@ export type FetchBirthRegistrationForCertificateQuery = {
district?: string | null
} | null
} | null
system?: { __typename?: 'System'; name: string; type: SystemType } | null
system?: {
__typename?: 'IntegratedSystem'
name?: string | null
type?: string | null
} | null
user?: {
__typename?: 'User'
id: string
Expand Down Expand Up @@ -4267,7 +4282,11 @@ export type FetchDeathRegistrationForReviewQuery = {
district?: string | null
} | null
} | null
system?: { __typename?: 'System'; name: string; type: SystemType } | null
system?: {
__typename?: 'IntegratedSystem'
name?: string | null
type?: string | null
} | null
user?: {
__typename?: 'User'
id: string
Expand Down Expand Up @@ -4562,7 +4581,11 @@ export type FetchDeathRegistrationForCertificationQuery = {
district?: string | null
} | null
} | null
system?: { __typename?: 'System'; name: string; type: SystemType } | null
system?: {
__typename?: 'IntegratedSystem'
name?: string | null
type?: string | null
} | null
user?: {
__typename?: 'User'
id: string
Expand Down Expand Up @@ -4991,7 +5014,11 @@ export type FetchMarriageRegistrationForReviewQuery = {
name?: string | null
alias?: Array<string> | null
} | null
system?: { __typename?: 'System'; name: string; type: SystemType } | null
system?: {
__typename?: 'IntegratedSystem'
name?: string | null
type?: string | null
} | null
user?: {
__typename?: 'User'
id: string
Expand Down Expand Up @@ -5323,7 +5350,11 @@ export type FetchMarriageRegistrationForCertificateQuery = {
name?: string | null
alias?: Array<string> | null
} | null
system?: { __typename?: 'System'; name: string; type: SystemType } | null
system?: {
__typename?: 'IntegratedSystem'
name?: string | null
type?: string | null
} | null
user?: {
__typename?: 'User'
id: string
Expand Down
6 changes: 3 additions & 3 deletions packages/client/src/views/RecordAudit/History.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,11 @@ export const GetHistory = ({
user: (
<>
{isFlaggedAsPotentialDuplicate(item) ? (
<SystemUser name={item.system?.name} />
<SystemUser name={item.system?.name || ''} />
) : isVerifiedAction(item) ? (
<div />
) : isSystemInitiated(item) ? (
<HealthSystemUser name={item.system?.name} />
<HealthSystemUser name={item.system?.name || ''} />
) : isFieldAgent ? (
<GetNameWithAvatar
id={item?.user?.id as string}
Expand Down Expand Up @@ -276,7 +276,7 @@ export const GetHistory = ({
) : isVerifiedAction(item) ? (
<div />
) : isSystemInitiated(item) || !item.user?.systemRole ? (
intl.formatMessage(getSystemType(item.system?.type))
intl.formatMessage(getSystemType(item.system?.type || ''))
) : (
getUserRole(currentLanguage, item.user?.role)
),
Expand Down
8 changes: 7 additions & 1 deletion packages/gateway/src/features/registration/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ type InputOutput {
valueString: String
}

type IntegratedSystem {
name: String
username: String
type: String
}

type History {
user: User
date: Date
Expand All @@ -143,7 +149,7 @@ type History {
otherReason: String
#This doesn't resolve to the System model properly rather
#uses the getSystem endpoint in user-mgnt
system: System # -> identitifier(system='http://opencrvs.org/specs/extension/system_identifier')
system: IntegratedSystem # -> identitifier(system='http://opencrvs.org/specs/extension/system_identifier')
location: Location # -> extension(url='http://opencrvs.org/specs/extension/regLastLocation').valueReference
office: Location # -> extension(url='http://opencrvs.org/specs/extension/regLastOffice').valueReference
dhis2Notification: Boolean # -> identitifier(system='http://opencrvs.org/specs/extension/dhis2_event_identifier')
Expand Down
4 changes: 2 additions & 2 deletions packages/gateway/src/features/registration/type-resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ import {
getSignatureExtension,
IUserModelData
} from '@gateway/features/user/type-resolvers'
import { getSystem, getUser } from '@gateway/features/user/utils'
import { getUser } from '@gateway/features/user/utils'
import {
getPatientResource,
getPresignedUrlFromUri
Expand Down Expand Up @@ -1321,7 +1321,7 @@ export const typeResolvers: GQLResolver = {
if (!systemIdentifier || !systemIdentifier.value) {
return null
}
return await getSystem({ systemId: systemIdentifier.value }, authHeader)
return JSON.parse(systemIdentifier.value)
},
location: async (task: fhir.Task, _: any, { dataSources }) => {
const taskLocation = findExtension(
Expand Down
45 changes: 44 additions & 1 deletion packages/gateway/src/graphql/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ export interface GQLHistory {
requester?: string
hasShowedVerifiedDocument?: boolean
otherReason?: string
system?: GQLSystem
system?: GQLIntegratedSystem
location?: GQLLocation
office?: GQLLocation
dhis2Notification?: boolean
Expand Down Expand Up @@ -1384,6 +1384,12 @@ export interface GQLStatusReason {
text?: string
}

export interface GQLIntegratedSystem {
name?: string
username?: string
type?: string
}

export interface GQLComment {
id: string
user?: GQLUser
Expand Down Expand Up @@ -1893,6 +1899,7 @@ export interface GQLResolver {
Certificate?: GQLCertificateTypeResolver
DuplicatesInfo?: GQLDuplicatesInfoTypeResolver
StatusReason?: GQLStatusReasonTypeResolver
IntegratedSystem?: GQLIntegratedSystemTypeResolver
Comment?: GQLCommentTypeResolver
InputOutput?: GQLInputOutputTypeResolver
RoleLabel?: GQLRoleLabelTypeResolver
Expand Down Expand Up @@ -9131,6 +9138,42 @@ export interface StatusReasonToTextResolver<TParent = any, TResult = any> {
): TResult
}

export interface GQLIntegratedSystemTypeResolver<TParent = any> {
name?: IntegratedSystemToNameResolver<TParent>
username?: IntegratedSystemToUsernameResolver<TParent>
type?: IntegratedSystemToTypeResolver<TParent>
}

export interface IntegratedSystemToNameResolver<TParent = any, TResult = any> {
(
parent: TParent,
args: {},
context: Context,
info: GraphQLResolveInfo
): TResult
}

export interface IntegratedSystemToUsernameResolver<
TParent = any,
TResult = any
> {
(
parent: TParent,
args: {},
context: Context,
info: GraphQLResolveInfo
): TResult
}

export interface IntegratedSystemToTypeResolver<TParent = any, TResult = any> {
(
parent: TParent,
args: {},
context: Context,
info: GraphQLResolveInfo
): TResult
}

export interface GQLCommentTypeResolver<TParent = any> {
id?: CommentToIdResolver<TParent>
user?: CommentToUserResolver<TParent>
Expand Down
8 changes: 7 additions & 1 deletion packages/gateway/src/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ type History {
requester: String
hasShowedVerifiedDocument: Boolean
otherReason: String
system: System
system: IntegratedSystem
location: Location
office: Location
dhis2Notification: Boolean
Expand Down Expand Up @@ -1492,6 +1492,12 @@ type StatusReason {
text: String
}

type IntegratedSystem {
name: String
username: String
type: String
}

type Comment {
id: ID!
user: User
Expand Down
Loading

0 comments on commit 7c26e73

Please sign in to comment.