@@ -484,12 +484,22 @@ const getChildBirthLocation = (eventLocationId, type, id) =>
484484
485485 return {
486486 name : healthFacility ?. name ,
487- stateName : healthFacilityCommune ?. name ,
488- districtName : healthFacilityDistrict . name
487+ districtName : healthFacilityCommune ?. name ,
488+ stateName : healthFacilityDistrict ? .name ,
489489 }
490490 case 'OTHER' :
491491 const other = await fetchLocationById ( eventLocationId )
492- return other . address
492+ const otherCommune = await fetchLocationById (
493+ other ?. partOf ?. reference ?. split ?. ( '/' ) [ 1 ]
494+ )
495+ const otherDistrict = await fetchLocationById (
496+ otherCommune ?. partOf ?. reference ?. split ?. ( '/' ) [ 1 ]
497+ )
498+ return {
499+ country : other ?. address ?. country ,
500+ districtName : otherCommune ?. name ,
501+ stateName : otherDistrict ?. name ,
502+ }
493503 default :
494504 const home = await fetchOtherBirthLocation ( id )
495505 return home . data . fetchBirthRegistration . eventLocation . address
@@ -970,7 +980,7 @@ window.openPrintModal = async function openPrintModal(id) {
970980 q . fieldId ===
971981 'birth.father.father-view-group.fatherHasFormallyRecognisedChild'
972982 ) || { value : '' }
973- ) . value
983+ ) . value === 'true' // because the value is string 'false' or 'true'
974984
975985 const title = window . getIsWithAdpotion (
976986 event . mother . maritalStatus ,
@@ -1032,8 +1042,8 @@ window.openPrintModal = async function openPrintModal(id) {
10321042 'birth.child.child-view-group.otherPlaceOfBirthAddress'
10331043 ) ?. value
10341044 : undefined ,
1035- placeOfBirthDistrict : childBirthLocation ?. stateName ,
1036- placeOfBirthState : childBirthLocation ?. districtName ,
1045+ placeOfBirthDistrict : childBirthLocation ?. districtName , // in helper.js, it is already used like "District"="Commune" "state"="District" : should not permute it here
1046+ placeOfBirthState : childBirthLocation ?. stateName ,
10371047 childFamilyName : event . child . name [ 0 ] . familyName ,
10381048 childFirstName : [
10391049 event . child . name [ 0 ] . middleName ,
@@ -1051,6 +1061,10 @@ window.openPrintModal = async function openPrintModal(id) {
10511061 internationalPostalCodePlaceofbirth : childBirthLocation ?. postalCode
10521062 }
10531063
1064+ const fatherPrimaryAddress = event . father . address ?. find (
1065+ ( a ) => a . type === 'PRIMARY_ADDRESS'
1066+ )
1067+
10541068 const fatherDetailsContext = {
10551069 motherMaritalStatus : event . mother . maritalStatus ,
10561070 fatherReasonNotApplying : event . father . reasonNotApplying ,
@@ -1100,13 +1114,8 @@ window.openPrintModal = async function openPrintModal(id) {
11001114 ) . value == 'true'
11011115 ? true
11021116 : false ,
1103- countryPrimaryFather : event . father . address ?. find (
1104- ( a ) => a . type === 'PRIMARY_ADDRESS'
1105- ) ?. country
1106- ? countryData [
1107- event . father . address ?. find ( ( a ) => a . type === 'PRIMARY_ADDRESS' )
1108- ?. country
1109- ] [ defaultLang ]
1117+ countryPrimaryFather : fatherPrimaryAddress ?. country
1118+ ? countryData [ fatherPrimaryAddress ?. country ] [ defaultLang ]
11101119 : '' ,
11111120 birthFatherFokontanyCustomAddress : (
11121121 event ?. questionnaire ?. find (
@@ -1122,26 +1131,26 @@ window.openPrintModal = async function openPrintModal(id) {
11221131 'birth.mother.mother-view-group.fokontanyCustomAddress'
11231132 ) || { value : '' }
11241133 ) . value ,
1125- fatherPrimaryDistrict : event . father . address ?. find (
1126- ( a ) => a . type === 'PRIMARY_ADDRESS'
1127- ) ?. districtName ,
1134+ fatherPrimaryDistrict : fatherPrimaryAddress ?. districtName ,
11281135 fatherOccupation : event . father . occupation ,
11291136 birthFatherFatherHasFormallyRecognisedChild :
11301137 isFatherHasFormallyRecognisedChild ,
11311138 motherReasonNotApplying : event . mother . reasonNotApplying ,
1132- internationalStatePrimaryFather : event . father . address ?. state ,
1133- internationalDistrictPrimaryFather : event . father . address ?. district ,
1134- internationalCityPrimaryFather : event . father . address ?. city ,
1135- internationalAddressLine1PrimaryFather : event . father . address ?. line ?. [ 6 ] ,
1136- internationalAddressLine2PrimaryFather : event . father . address ?. line ?. [ 7 ] ,
1137- internationalAddressLine3PrimaryFather : event . father . address ?. line ?. [ 8 ] ,
1138- internationalPostalCodePrimaryFather : event . father . address ?. postalCode
1139+ internationalStatePrimaryFather :fatherPrimaryAddress ?. state ,
1140+ internationalDistrictPrimaryFather :fatherPrimaryAddress ?. district ,
1141+ internationalCityPrimaryFather :fatherPrimaryAddress ?. city ,
1142+ internationalAddressLine1PrimaryFather :fatherPrimaryAddress ?. line ?. [ 6 ] ,
1143+ internationalAddressLine2PrimaryFather :fatherPrimaryAddress ?. line ?. [ 7 ] ,
1144+ internationalAddressLine3PrimaryFather :fatherPrimaryAddress ?. line ?. [ 8 ] ,
1145+ internationalPostalCodePrimaryFather :fatherPrimaryAddress ?. postalCode
11391146 }
11401147
1148+ const motherPrimaryAddress = event . mother . address ?. find (
1149+ ( a ) => a . type === 'PRIMARY_ADDRESS'
1150+ )
1151+
11411152 const motherDetailsContext = {
1142- motherPrimaryDistrict : event . mother . address ?. find (
1143- ( a ) => a . type === 'PRIMARY_ADDRESS'
1144- ) ?. districtName ,
1153+ motherPrimaryDistrict : motherPrimaryAddress ?. districtName ,
11451154 motherReasonNotApplying : event . mother . reasonNotApplying ,
11461155 motherFamilyName :
11471156 event . mother . name && event . mother . name [ 0 ]
@@ -1158,7 +1167,15 @@ window.openPrintModal = async function openPrintModal(id) {
11581167 . join ( ' ' )
11591168 . trim ( ) ,
11601169 birthMotherCustomizedExactDateOfBirthUnknown :
1161- event . mother . exactDateOfBirthUnknown ,
1170+ (
1171+ event ?. questionnaire ?. find (
1172+ ( q ) =>
1173+ q . fieldId ===
1174+ 'birth.mother.mother-view-group.customizedExactDateOfBirthUnknown'
1175+ ) || { value : false }
1176+ ) . value == 'true'
1177+ ? true
1178+ : false ,
11621179 birthMotherYearOfBirth : (
11631180 event ?. questionnaire ?. find (
11641181 ( q ) => q . fieldId === 'birth.mother.mother-view-group.yearOfBirth'
@@ -1179,13 +1196,8 @@ window.openPrintModal = async function openPrintModal(id) {
11791196 ) . value == 'true'
11801197 ? true
11811198 : false ,
1182- countryPrimaryMother : event . mother . address ?. find (
1183- ( a ) => a . type === 'PRIMARY_ADDRESS'
1184- ) ?. country
1185- ? countryData [
1186- event . mother . address ?. find ( ( a ) => a . type === 'PRIMARY_ADDRESS' )
1187- ?. country
1188- ] [ defaultLang ]
1199+ countryPrimaryMother : motherPrimaryAddress ?. country
1200+ ? countryData [ motherPrimaryAddress ?. country ] [ defaultLang ]
11891201 : '' ,
11901202 birthMotherFokontanyCustomAddress : (
11911203 event ?. questionnaire ?. find (
@@ -1195,15 +1207,24 @@ window.openPrintModal = async function openPrintModal(id) {
11951207 ) || { value : '' }
11961208 ) . value ,
11971209 motherOccupation : event . mother . occupation ,
1198- internationalStatePrimaryMother : event . mother . address ?. state ,
1199- internationalDistrictPrimaryMother : event . mother . address ?. district ,
1200- internationalCityPrimaryMother : event . mother . address ?. city ,
1201- internationalAddressLine1PrimaryMother : event . mother . address ?. line ?. [ 6 ] ,
1202- internationalAddressLine2PrimaryMother : event . mother . address ?. line ?. [ 7 ] ,
1203- internationalAddressLine3PrimaryMother : event . mother . address ?. line ?. [ 8 ] ,
1204- internationalPostalCodePrimaryMother : event . mother . address ?. postalCode
1210+ internationalStatePrimaryMother : motherPrimaryAddress ?. state ,
1211+ internationalDistrictPrimaryMother : motherPrimaryAddress ?. district ,
1212+ internationalCityPrimaryMother : motherPrimaryAddress ?. city ,
1213+ internationalAddressLine1PrimaryMother : motherPrimaryAddress ?. line ?. [ 6 ] ,
1214+ internationalAddressLine2PrimaryMother : motherPrimaryAddress ?. line ?. [ 7 ] ,
1215+ internationalAddressLine3PrimaryMother : motherPrimaryAddress ?. line ?. [ 8 ] ,
1216+ internationalPostalCodePrimaryMother : motherPrimaryAddress ?. postalCode
12051217 }
12061218
1219+ /** @TODO CHANGE This if conditions of registration is changed */
1220+ const registrationItemInHistory = event . history ?. find (
1221+ ( i ) =>
1222+ i . action === null && i . regStatus === "REGISTERED"
1223+ )
1224+
1225+ const registrarRawFirstName = event . registration ?. assignment ?. firstName
1226+ const registrarFirstName = registrarRawFirstName ?. trim ( ) . toLowerCase ( ) === 'xyz261' ? '' : ` ${ registrarRawFirstName } `
1227+
12071228 const registrationStatementContext = {
12081229 motherMaritalStatus : event . mother . maritalStatus ,
12091230 birthFatherFatherHasFormallyRecognisedChild :
@@ -1222,7 +1243,7 @@ window.openPrintModal = async function openPrintModal(id) {
12221243 'birth.child.child-view-group.legacyBirthRegistrationTime'
12231244 ) || { value : '' }
12241245 ) . value ,
1225- registrarDate : event . createdAt ,
1246+ registrarDate : registrationItemInHistory ?. date ,
12261247 timezone : 'Africa/Nairobi' ,
12271248 informantType : event . informant . relationship ,
12281249
@@ -1274,8 +1295,8 @@ window.openPrintModal = async function openPrintModal(id) {
12741295 ) ?. districtName ,
12751296 informantOccupation : event . informant . occupation ,
12761297 registrarName : [
1277- event . registration . assignment . firstName ,
1278- event . registration . assignment . lastName
1298+ event . registration . assignment . lastName ,
1299+ registrarFirstName
12791300 ]
12801301 . join ( ' ' )
12811302 . trim ( ) ,
0 commit comments