@iapps/ng-dhis2-ui 1.1.39 → 1.1.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4547,38 +4547,13 @@ class FormMetaData {
4547
4547
  #getSectionFromPrograms(programs) {
4548
4548
  const sections = flatten(programs.map((program) => {
4549
4549
  return [
4550
- this.#getRegisteringUnitSection(program),
4551
- this.#getReportingDateSection(program),
4552
- new FormMetadataSection({
4553
- section: {
4554
- id: 'registration',
4555
- name: 'Registration',
4556
- fieldGroups: (program.programSections || []).length > 0
4557
- ? program.programSections.map((programSection) => {
4558
- return {
4559
- id: programSection.id,
4560
- name: programSection.name,
4561
- sortOrder: programSection.sortOrder,
4562
- fields: programSection.trackedEntityAttributes,
4563
- };
4564
- })
4565
- : [
4566
- {
4567
- id: 'registration',
4568
- name: '',
4569
- sortOrder: 1,
4570
- fields: (program.programTrackedEntityAttributes || []).map((programTrackedEntityAttribute) => {
4571
- return {
4572
- id: programTrackedEntityAttribute
4573
- .trackedEntityAttribute?.id,
4574
- };
4575
- }),
4576
- },
4577
- ],
4578
- },
4579
- program,
4580
- locale: this.params.locale,
4581
- }).toJson(),
4550
+ ...(this.params.splitRegistrationSection
4551
+ ? [
4552
+ this.#getRegisteringUnitSection(program),
4553
+ this.#getReportingDateSection(program),
4554
+ this.#getRegistrationSection(program),
4555
+ ]
4556
+ : [this.#getMergedRegistrationSection(program)]),
4582
4557
  ...(program.programStages || []).map((programStage) => {
4583
4558
  return new FormMetadataSection({
4584
4559
  section: {
@@ -4685,6 +4660,112 @@ class FormMetaData {
4685
4660
  locale: this.params.locale,
4686
4661
  }).toJson();
4687
4662
  }
4663
+ #getRegistrationSection(program) {
4664
+ return new FormMetadataSection({
4665
+ section: {
4666
+ id: 'registration',
4667
+ name: 'Registration',
4668
+ fieldGroups: (program.programSections || []).length > 0
4669
+ ? program.programSections.map((programSection) => {
4670
+ return {
4671
+ id: programSection.id,
4672
+ name: programSection.name,
4673
+ sortOrder: programSection.sortOrder,
4674
+ fields: programSection.trackedEntityAttributes,
4675
+ };
4676
+ })
4677
+ : [
4678
+ {
4679
+ id: 'registration',
4680
+ name: '',
4681
+ sortOrder: 1,
4682
+ fields: (program.programTrackedEntityAttributes || []).map((programTrackedEntityAttribute) => {
4683
+ return {
4684
+ id: programTrackedEntityAttribute.trackedEntityAttribute
4685
+ ?.id,
4686
+ };
4687
+ }),
4688
+ },
4689
+ ],
4690
+ },
4691
+ program,
4692
+ locale: this.params.locale,
4693
+ }).toJson();
4694
+ }
4695
+ #getMergedRegistrationSection(program) {
4696
+ return new FormMetadataSection({
4697
+ section: {
4698
+ id: 'registration',
4699
+ name: 'Registration',
4700
+ fieldGroups: [
4701
+ {
4702
+ id: 'registering_unit_details',
4703
+ name: 'Registering unit details',
4704
+ sortOrder: 1,
4705
+ isFormHorizontal: false,
4706
+ fields: [
4707
+ new FormField({
4708
+ id: 'orgUnit',
4709
+ key: 'orgUnit',
4710
+ label: program.orgUnitLabel || 'Registering unit',
4711
+ code: 'orgUnit',
4712
+ required: true,
4713
+ controlType: 'org-unit',
4714
+ }),
4715
+ ],
4716
+ },
4717
+ {
4718
+ id: 'reporting_dates',
4719
+ name: 'Reporting dates',
4720
+ sortOrder: 1,
4721
+ isFormHorizontal: false,
4722
+ fields: [
4723
+ new DateField({
4724
+ id: 'enrollmentDate',
4725
+ label: program.enrollmentDateLabel || 'Enrollment date',
4726
+ code: 'enrollmentDate',
4727
+ key: 'enrollmentDate',
4728
+ required: true,
4729
+ }),
4730
+ program.displayIncidentDate
4731
+ ? new DateField({
4732
+ id: 'incidentDate',
4733
+ label: program.incidentDateLabel || 'Incident date',
4734
+ code: 'incidentDate',
4735
+ key: 'incidentDate',
4736
+ required: true,
4737
+ })
4738
+ : null,
4739
+ ].filter((field) => field),
4740
+ },
4741
+ ...((program.programSections || []).length > 0
4742
+ ? program.programSections.map((programSection) => {
4743
+ return {
4744
+ id: programSection.id,
4745
+ name: programSection.name,
4746
+ sortOrder: programSection.sortOrder,
4747
+ fields: programSection.trackedEntityAttributes,
4748
+ };
4749
+ })
4750
+ : [
4751
+ {
4752
+ id: 'registration',
4753
+ name: '',
4754
+ sortOrder: 1,
4755
+ fields: (program.programTrackedEntityAttributes || []).map((programTrackedEntityAttribute) => {
4756
+ return {
4757
+ id: programTrackedEntityAttribute.trackedEntityAttribute
4758
+ ?.id,
4759
+ };
4760
+ }),
4761
+ },
4762
+ ]),
4763
+ ],
4764
+ },
4765
+ program,
4766
+ locale: this.params.locale,
4767
+ }).toJson();
4768
+ }
4688
4769
  toJson() {
4689
4770
  return {
4690
4771
  id: this.params.customFormMetaData?.id,