Skip to content

Commit

Permalink
refactor: use defined rejection types
Browse files Browse the repository at this point in the history
  • Loading branch information
naftis committed Sep 30, 2024
1 parent d9a9646 commit c2db318
Show file tree
Hide file tree
Showing 11 changed files with 473 additions and 92 deletions.
404 changes: 373 additions & 31 deletions packages/client/graphql.schema.json

Large diffs are not rendered by default.

12 changes: 0 additions & 12 deletions packages/client/src/i18n/messages/views/reject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ interface IRejectMessages
rejectionForm: MessageDescriptor
rejectionReason: MessageDescriptor
rejectionReasonDuplicate: MessageDescriptor
rejectionReasonMisspelling: MessageDescriptor
rejectionReasonMissingSupportingDoc: MessageDescriptor
rejectionReasonOther: MessageDescriptor
rejectionCommentForHealthWorkerLabel: MessageDescriptor
rejectionFormInstruction: MessageDescriptor
Expand Down Expand Up @@ -63,16 +61,6 @@ const messagesToDefine: IRejectMessages = {
defaultMessage: 'Mark as a duplicate',
description: 'Label for rejection option duplicate'
},
rejectionReasonMisspelling: {
id: 'review.rejection.form.reasons.misspelling',
defaultMessage: 'Misspelling',
description: 'Label for rejection option misspelling'
},
rejectionReasonMissingSupportingDoc: {
id: 'review.rej.form.reasons.missSupDoc',
defaultMessage: 'Missing supporting documents',
description: 'Label for rejection option missing supporting doc'
},
rejectionReasonOther: {
id: 'review.rejection.form.reasons.other',
defaultMessage: 'Other',
Expand Down
4 changes: 0 additions & 4 deletions packages/client/src/tests/languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1020,8 +1020,6 @@
"review.rejection.form.commentLabel": "Comments or instructions for health worker to rectify declaration",
"review.rejection.form.reasons": "Reason(s) for rejection:",
"review.rejection.form.reasons.duplicate": "Duplicate declaration",
"review.rej.form.reasons.missSupDoc": "Missing supporting documents",
"review.rejection.form.reasons.misspelling": "Misspelling",
"review.rejection.form.reasons.other": "Other",
"review.rejection.form.submitButton": "Submit rejection",
"review.rejection.form.title": "What update does the declaration require?",
Expand Down Expand Up @@ -2169,8 +2167,6 @@
"review.rejection.form.commentLabel": "আবেদন সংশোধন করতে স্বাস্থ্য কর্মীর জন্য নির্দেশাবলী",
"review.rejection.form.reasons": "প্রত্যাখ্যানের কারণসমূহ:",
"review.rejection.form.reasons.duplicate": "নকল আবেদন",
"review.rej.form.reasons.missSupDoc": "প্রমাণক অনুপস্থিত",
"review.rejection.form.reasons.misspelling": "ভুল বানান",
"review.rejection.form.reasons.other": "অন্যান্য",
"review.rejection.form.submitButton": "প্রত্যাখ্যান জমা দিন",
"review.rejection.form.title": "আবেদনটির কী হালনাগাদ দরকার?",
Expand Down
79 changes: 63 additions & 16 deletions packages/client/src/utils/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,12 @@ export type ComparisonInput = {
nin?: InputMaybe<Array<Scalars['String']>>
}

export type ConfirmRegistrationInput = {
childIdentifiers?: InputMaybe<Array<IdentifierInput>>
registrationNumber?: InputMaybe<Scalars['String']>
trackingId?: InputMaybe<Scalars['String']>
}

export type ContactPoint = {
__typename?: 'ContactPoint'
system?: Maybe<Scalars['String']>
Expand Down Expand Up @@ -558,11 +564,6 @@ export type DeclarationsStartedMetrics = {
officeDeclarations: Scalars['Int']
}

export type Dummy = {
__typename?: 'Dummy'
dummy: Scalars['String']
}

export type DuplicatesInfo = {
__typename?: 'DuplicatesInfo'
compositionId?: Maybe<Scalars['ID']>
Expand Down Expand Up @@ -706,7 +707,7 @@ export type History = {
output?: Maybe<Array<Maybe<InputOutput>>>
payment?: Maybe<Payment>
potentialDuplicates?: Maybe<Array<Scalars['String']>>
reason?: Maybe<Scalars['String']>
reason?: Maybe<RejectionReason>
regStatus?: Maybe<RegStatus>
requester?: Maybe<Scalars['String']>
requesterOther?: Maybe<Scalars['String']>
Expand Down Expand Up @@ -739,6 +740,11 @@ export type Identifier = {
value?: Maybe<Scalars['String']>
}

export type IdentifierInput = {
type: SupportedPatientIdentifierCode
value: Scalars['String']
}

export type IdentityInput = {
fieldsModifiedByIdentity?: InputMaybe<Array<InputMaybe<Scalars['String']>>>
id?: InputMaybe<Scalars['ID']>
Expand Down Expand Up @@ -927,6 +933,7 @@ export type Mutation = {
changeEmail?: Maybe<Scalars['String']>
changePassword?: Maybe<Scalars['String']>
changePhone?: Maybe<Scalars['String']>
confirmRegistration: Scalars['ID']
createBirthRegistration: Scalars['Void']
createBirthRegistrationCorrection: Scalars['ID']
createDeathRegistration: Scalars['Void']
Expand Down Expand Up @@ -959,6 +966,7 @@ export type Mutation = {
reactivateSystem?: Maybe<System>
refreshSystemSecret?: Maybe<SystemSecret>
registerSystem?: Maybe<SystemSecret>
rejectRegistration: Scalars['ID']
rejectRegistrationCorrection: Scalars['ID']
removeBookmarkedAdvancedSearch?: Maybe<BookMarkedSearches>
requestRegistrationCorrection: Scalars['ID']
Expand Down Expand Up @@ -1027,6 +1035,11 @@ export type MutationChangePhoneArgs = {
verifyCode: Scalars['String']
}

export type MutationConfirmRegistrationArgs = {
details: ConfirmRegistrationInput
id: Scalars['ID']
}

export type MutationCreateBirthRegistrationArgs = {
details: BirthRegistrationInput
}
Expand Down Expand Up @@ -1145,7 +1158,7 @@ export type MutationMarkEventAsUnassignedArgs = {
export type MutationMarkEventAsVoidedArgs = {
comment: Scalars['String']
id: Scalars['String']
reason: Scalars['String']
reason: RejectionReason
}

export type MutationMarkMarriageAsCertifiedArgs = {
Expand Down Expand Up @@ -1180,6 +1193,11 @@ export type MutationRegisterSystemArgs = {
system?: InputMaybe<SystemInput>
}

export type MutationRejectRegistrationArgs = {
details: RejectRegistrationInput
id: Scalars['ID']
}

export type MutationRejectRegistrationCorrectionArgs = {
details: CorrectionRejectionInput
id: Scalars['ID']
Expand Down Expand Up @@ -1832,6 +1850,16 @@ export type Reinstated = {
taskEntryResourceID: Scalars['ID']
}

export type RejectRegistrationInput = {
comment: Scalars['String']
reason: RejectionReason
}

export enum RejectionReason {
Duplicate = 'duplicate',
Other = 'other'
}

export type RelatedPerson = {
__typename?: 'RelatedPerson'
_fhirID?: Maybe<Scalars['ID']>
Expand Down Expand Up @@ -1982,6 +2010,25 @@ export type StatusWiseRegistrationCount = {
status: Scalars['String']
}

export enum SupportedPatientIdentifierCode {
AlienNumber = 'ALIEN_NUMBER',
BirthConfigurableIdentifier_1 = 'BIRTH_CONFIGURABLE_IDENTIFIER_1',
BirthConfigurableIdentifier_2 = 'BIRTH_CONFIGURABLE_IDENTIFIER_2',
BirthConfigurableIdentifier_3 = 'BIRTH_CONFIGURABLE_IDENTIFIER_3',
BirthPatientEntry = 'BIRTH_PATIENT_ENTRY',
BirthRegistrationNumber = 'BIRTH_REGISTRATION_NUMBER',
DeathRegistrationNumber = 'DEATH_REGISTRATION_NUMBER',
DeceasedPatientEntry = 'DECEASED_PATIENT_ENTRY',
DrivingLicense = 'DRIVING_LICENSE',
MarriageRegistrationNumber = 'MARRIAGE_REGISTRATION_NUMBER',
MosipPsutTokenId = 'MOSIP_PSUT_TOKEN_ID',
NationalId = 'NATIONAL_ID',
Other = 'OTHER',
Passport = 'PASSPORT',
RefugeeNumber = 'REFUGEE_NUMBER',
SocialSecurityNo = 'SOCIAL_SECURITY_NO'
}

export type System = {
__typename?: 'System'
_id: Scalars['ID']
Expand Down Expand Up @@ -3077,7 +3124,7 @@ export type MarkBirthAsRegisteredMutation = {

export type MarkEventAsVoidedMutationVariables = Exact<{
id: Scalars['String']
reason: Scalars['String']
reason: RejectionReason
comment: Scalars['String']
}>

Expand Down Expand Up @@ -3373,7 +3420,7 @@ export type FetchBirthRegistrationForReviewQuery = {
regStatus?: RegStatus | null
dhis2Notification?: boolean | null
ipAddress?: string | null
reason?: string | null
reason?: RejectionReason | null
duplicateOf?: string | null
potentialDuplicates?: Array<string> | null
documents: Array<{
Expand Down Expand Up @@ -3707,7 +3754,7 @@ export type FetchBirthRegistrationForCertificateQuery = {
regStatus?: RegStatus | null
dhis2Notification?: boolean | null
ipAddress?: string | null
reason?: string | null
reason?: RejectionReason | null
otherReason?: string | null
duplicateOf?: string | null
potentialDuplicates?: Array<string> | null
Expand Down Expand Up @@ -4169,7 +4216,7 @@ export type FetchDeathRegistrationForReviewQuery = {
regStatus?: RegStatus | null
dhis2Notification?: boolean | null
ipAddress?: string | null
reason?: string | null
reason?: RejectionReason | null
duplicateOf?: string | null
potentialDuplicates?: Array<string> | null
documents: Array<{
Expand Down Expand Up @@ -4888,7 +4935,7 @@ export type FetchMarriageRegistrationForReviewQuery = {
action?: RegAction | null
regStatus?: RegStatus | null
dhis2Notification?: boolean | null
reason?: string | null
reason?: RejectionReason | null
documents: Array<{
__typename?: 'Attachment'
id: string
Expand Down Expand Up @@ -5242,7 +5289,7 @@ export type FetchMarriageRegistrationForCertificateQuery = {
action?: RegAction | null
regStatus?: RegStatus | null
dhis2Notification?: boolean | null
reason?: string | null
reason?: RejectionReason | null
statusReason?: {
__typename?: 'StatusReason'
text?: string | null
Expand Down Expand Up @@ -8001,7 +8048,7 @@ export type FetchViewRecordByCompositionQuery = {
regStatus?: RegStatus | null
dhis2Notification?: boolean | null
ipAddress?: string | null
reason?: string | null
reason?: RejectionReason | null
statusReason?: {
__typename?: 'StatusReason'
text?: string | null
Expand Down Expand Up @@ -8387,7 +8434,7 @@ export type FetchViewRecordByCompositionQuery = {
regStatus?: RegStatus | null
dhis2Notification?: boolean | null
ipAddress?: string | null
reason?: string | null
reason?: RejectionReason | null
statusReason?: {
__typename?: 'StatusReason'
text?: string | null
Expand Down Expand Up @@ -8705,7 +8752,7 @@ export type FetchViewRecordByCompositionQuery = {
regStatus?: RegStatus | null
dhis2Notification?: boolean | null
ipAddress?: string | null
reason?: string | null
reason?: RejectionReason | null
statusReason?: {
__typename?: 'StatusReason'
text?: string | null
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/views/DataProvider/birth/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const REGISTER_BIRTH_DECLARATION = gql`
const REJECT_BIRTH_DECLARATION = gql`
mutation markEventAsVoided(
$id: String!
$reason: String!
$reason: RejectionReason!
$comment: String!
) {
markEventAsVoided(id: $id, reason: $reason, comment: $comment)
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/views/DataProvider/death/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const REGISTER_DEATH_DECLARATION = gql`
const REJECT_DEATH_DECLARATION = gql`
mutation markEventAsVoided(
$id: String!
$reason: String!
$reason: RejectionReason!
$comment: String!
) {
markEventAsVoided(id: $id, reason: $reason, comment: $comment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const REGISTER_MARRIAGE_DECLARATION = gql`
const REJECT_MARRIAGE_DECLARATION = gql`
mutation markEventAsVoided(
$id: String!
$reason: String!
$reason: RejectionReason!
$comment: String!
) {
markEventAsVoided(id: $id, reason: $reason, comment: $comment)
Expand Down
20 changes: 10 additions & 10 deletions packages/client/src/views/SearchResult/SearchResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ import { ITheme } from '@opencrvs/components/lib/theme'
import { Scope } from '@client/utils/authUtils'
import { SEARCH_RESULT_SORT } from '@client/utils/constants'
import { getUserLocation, UserDetails } from '@client/utils/userUtils'
import { SearchEventsQuery, SystemRoleType } from '@client/utils/gateway'
import {
SearchEventsQuery,
SystemRoleType,
RejectionReason
} from '@client/utils/gateway'

import {
ColumnContentAlignment,
Expand Down Expand Up @@ -86,18 +90,14 @@ const ToolTipContainer = styled.span`
text-align: center;
`

export function getRejectionReasonDisplayValue(reason: string) {
switch (reason.toLowerCase()) {
case 'duplicate':
export function getRejectionReasonDisplayValue(reason: RejectionReason) {
switch (reason) {
case RejectionReason.Duplicate:
return rejectMessages.rejectionReasonDuplicate
case 'misspelling':
return rejectMessages.rejectionReasonMisspelling
case 'missing_supporting_doc':
return rejectMessages.rejectionReasonMissingSupportingDoc
case 'other':
case RejectionReason.Other:
return rejectMessages.rejectionReasonOther
default:
return rejectMessages.rejectionReasonOther
return reason satisfies never
}
}

Expand Down
8 changes: 6 additions & 2 deletions packages/gateway/src/features/registration/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ type History {
action: RegAction
note: String
statusReason: StatusReason
reason: String
reason: RejectionReason
requester: String
requesterOther: String
hasShowedVerifiedDocument: Boolean
Expand Down Expand Up @@ -645,7 +645,11 @@ type Mutation {
markBirthAsRegistered(id: ID!, details: BirthRegistrationInput!): ID! # updates status to 'registered' - registration clerk has accepted the declaration, it is now official - internally call update if details exists
markBirthAsCertified(id: ID!, details: BirthRegistrationInput!): ID! # updates status to 'certified' - a printed certificate has been produced - internally call update if details exists
markBirthAsIssued(id: ID!, details: BirthRegistrationInput!): ID! # updates status to 'certified' - a printed certificate has been produced - internally call update if details exists
markEventAsVoided(id: String!, reason: String!, comment: String!): ID! # updated status to 'voided' - the registration was captured in error
markEventAsVoided(
id: String!
reason: RejectionReason!
comment: String!
): ID! # updated status to 'voided' - the registration was captured in error
markEventAsReinstated(id: String!): Reinstated # updates status to 'reinstated'
markEventAsNotDuplicate(id: String!): ID! # removes duplicates from composition
markEventAsArchived(
Expand Down
14 changes: 7 additions & 7 deletions packages/gateway/src/graphql/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,11 @@ export interface GQLMarriageRegistrationInput {

export type GQLVoid = any

export const enum GQLRejectionReason {
other = 'other',
duplicate = 'duplicate'
}

export interface GQLReinstated {
taskEntryResourceID: string
registrationStatus?: GQLRegStatus
Expand Down Expand Up @@ -769,7 +774,7 @@ export interface GQLHistory {
action?: GQLRegAction
note?: string
statusReason?: GQLStatusReason
reason?: string
reason?: GQLRejectionReason
requester?: string
requesterOther?: string
hasShowedVerifiedDocument?: boolean
Expand Down Expand Up @@ -1235,11 +1240,6 @@ export interface GQLIdentifierInput {
value: string
}

export const enum GQLRejectionReason {
other = 'other',
duplicate = 'duplicate'
}

export interface GQLHumanNameInput {
use?: string
firstNames?: string
Expand Down Expand Up @@ -2836,7 +2836,7 @@ export interface MutationToMarkBirthAsIssuedResolver<

export interface MutationToMarkEventAsVoidedArgs {
id: string
reason: string
reason: GQLRejectionReason
comment: string
}
export interface MutationToMarkEventAsVoidedResolver<
Expand Down
Loading

0 comments on commit c2db318

Please sign in to comment.